Hi, folks!
Suppose I have:
int n;
real[int] vi;
mesh Th;
fespace Vh(Th, P1);
Vh u;
I’d like to build a function in which one of its inputs is u, i.e., the variable of Vh-type. For example:
func int myfunction(int n, real[int] &vi, mesh &Th, [???] ){
return 0;
}
The question is: How should I pass u (the Vh-type variable) in [???] ?
1 Like
cmd
(Chris)
May 3, 2022, 9:19am
2
The line: Vh u;
defines a real array called u[]
that is defined on the fespace Vh
. Hence, you can pass u[]
just like any other real array, (e.g. vi
). Just be sure to include the square brackets so that FreeFEM interprets it as a real array.
Thanks for your reply. However, such a strategy does not work in my code. Could you provide a simple example?
cmd
(Chris)
May 3, 2022, 12:38pm
4
Define the function like:
func int myfunction(int n, real[int] &vi, mesh &Th, real[int] &u){
return 0;
}
Then call it like:
int k = myfunction(n,vi,Th, u[]);
1 Like
Thank you for your response. Indeed, this is the solution for the case when myfunction
is built within the file .edp.
1 Like