Macro ThN2O for mixed vectorial and scalar finite element space

OK.
example.edp (3.0 KB)

Why are you removing the brackets?

Why are you commenting lines 95 and 96? Why are you still defining A and B inside the brackets?

It seems like that I need to uncomment lines 95 and 96.
example.edp (3.0 KB)
But I need to find a solution to avoid the duplicate definition of

macro def(i)[i, i#B, i#C]//
macro init(i)[i, i, i]//

to avoid errors

Compile error : The macro already exists, sorry

Again, why did you remove the brackets?

If I keep the brackets, A is invisible in the for loop.
example.edp (3.0 KB)

106 : u1=A The Identifier A does not exist
Error line number 106, in file example.edp, before token A

Yes, now, back to square one: Macro ThN2O for mixed vectorial and scalar finite element space - #12 by prj
Do not declare A and B inside the brackets, but leave all the rest the same.

Then I obtained The macro already exists error again.
example_new.edp (3.4 KB)

OK, I ask you to move A and B definitions outside of the brackets and leave the rest of the code the same, but you insist on modifying the rest of the code (by removing the brackets). Why?

Now it runs without errors with the following revision.

Mat A;
{
macro def(i)[i, i#B, i#C, i#D, i#E, i#F, i#G]//
macro init(i)[i, i, i, i, i, i, i]//
createMat(Th,A,Pk)
set(A, sparams = “-pc_type lu”);
A = vSt(Wh, Wh);
}
Mat B;
{
macro def(i)[i, i#B, i#C]//
macro init(i)[i, i, i]//
createMat(Th,B,Ps)
set(B, sparams = “-pc_type lu”);
}

Another question is that whether I include the A = vSt(Wh, Wh); in the brackets.

You can leave it in the brackets or not, it does not really matters. What matters is that you leave the macro definitions inside the brackets, and the Mat definitions outside the brackets.

I see. Thank you so much!