Is it possible to define a parameterized macro with a parameter inside in order to use it in varf.
In fact, this parameter could be the index of region. For example :
real [int, int][int] c(10)
for (i=1;i<=3;i++) {c[i].resize(7,7);c[i] = 0.;} and after c[i] (j,k) are filled.
I follow my previous post, and I would like to have your advices for the best implementation of anisotropic physical property for each material.
Is the proposal of my previous post correct ?
Or should I use definition with
Ph Phy = Phy1*(region==1)+Phy2*(region==2) + etc. But the latter definition is well documented only for scalar values even for elasticity in isotropic conditions with E, nu or lambda, mu.
In fact, I am searching for the best way to properly model these anisotropic properties, especially when some solution fields are dependent of such region property (for instance stress field).
Hello,
It seems like I didn’t get why and how to use the macros. The book “FreeFEM documentation, 4.13” didn’t help me. I have a very non-linear equation to solve and wanted to divide it in few parts as follows:
The program falls with error at the moment when it tries to start the macro, “error operator ( <7E_Array>”, and concludes with the compilation error: “before token )” for the line where the macro is called. What is my error in this part of code, maybe the syntax is wrong?
The problem is not in the macro, but in the fact that your expression is nonlinear in h. h is the unknown in your problem disturb (h,v). FF can only solve linear systems. For nonlinear problems you need to define an iterative scheme, each iteration containing only linear problems, as the Newton method for example.
Thank you for the answer, but the macros still do not work. I try to use it for simple calculation of a function value, just to prove (I received the result manually). Here is a piece of code:
Vh3 f,f1,f2,h = 0; // function f(h), first and second derivative, initial guess h0
Vh3 htil;
//…
macro finter(h)
dx(dx(h))+dy(dy(h))
-dx(F(h))*(dx(h)*dy(dy(h))-dy(h)dx(dy(h)))
-dy(F(h))(dy(h)*dx(dx(h))-dx(h)dx(dy(h)))
-F(h)(dx(dx(h))*dy(dy(h))-(dx(dy(h)))^2)
+dx(log(F(h)))*dx(h)+dy(log(F(h)))*dy(h)
+Ll2/F(h)
// //…
htil = finter(h);
and the compiler gives a very the same error: it goes to the called macro and cannot work with it, finding an extra bracket: “before token ‘(’” It seems like the macro is described in wrong way. There is one more thing which confuses me: in the macro, the operators ‘dx’ and ‘dy’ which, as I guess, are in-built operators of space derivatives, are in some lines black as variables, and in other places brown as functions|operators.
Sorry for the long message, I hope that it will help to someone who has the same issue
You have to know that the operators dx or dy work only on arguments that
are declared variables in a fespace.
In particular you cannot write dx(dx(h))
Instead you should write for example
Where Vh3, Wh, Zh are defined fespace.
Same remark for dx(F(h)): you have to define first F(h) as a variable in a fespace.
Notice anyway that computing a second derivative of a function h in a fespace is in general problematic because the first order derivatives of h are discontinuous.