bcaval
(Bruno)
April 22, 2024, 8:42am
1
Hello FreeFem community,
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.
for (i=1;i<=3;i++) {
macro F…[i]…?(u,v) (c[i] (1,1) * S1(u)+c[i] (1,2) * S2(v)) // EOM
}
varf K(u,v) = int3d(Th3,1)(F…[1]…?(u,v)) + int3d(Th3,2)(F…[2]…?(u,v)) + int3d(Th3,3)(F…[3]…?(u,v))+ …
Thanks in advance,
The answer is no, but I do not understand what you want to do,
remark, you can defined macro in macro with the new syntax
you can see this exemple
// -Ddim=3 parametre or -D=2
int bar=4;
// valeur par defaut ..
IFMACRO(!dim)
macro dim 2//
ENDIFMACRO
IFMACRO(dim,2)
macro intO int2d//
macro intG int1d//
macro Mesh mesh//
macro Boite(n) square(n,n)//
macro grad(u) [dx(u),dy(u)]//
macro Grad(u) [ grad(u#1), grad(u#2)]//
macro div(u) (dx(u#1)+dy(u#2))//
macro cnd(u) u#1,u#2//
macro ccd(u) u,u//
macro Vd(u) [u#1,u#2]//
macro myON1(l,u,v) on(l,u#1=0.,u#2=v)//
ENDIFMACRO
This file has been truncated. show original
bcaval
(Bruno)
April 26, 2024, 6:10pm
3
Thanks for the answer.
In fact I imagine this for attributing physical property to each material, see below, is it correct ?
real [int, int][int] z(4)
for (i=1;i<=3;i++) {
z[i].resize(4,4); z[i] = 0.; // for instance 3 materials (I don’t use 0 index)
}
// Def for a physical property to whatever i material
macro Z(i) [[ z[i] (1,1), z[i] (1,2), z[i] (1,3) ],
[ z[i] (2,1), z[i] (2,2), z[i] (2,3) ],
[ z[i] (3,1), z[i] (3,2), z[i] (3,3) ]] // EOM
// and the varf for each material…1,2,3
varf VZ(u,v) = int3d(Th,1)( grad(v)’ *(Z(1)*grad(u)) )
+ int3d(Th,2)( grad(v)’ *(Z(2)*grad(u)) )
+ int3d(Th,3)( grad(v)’ *(Z(3)*grad(u)) );