Dear all,
I have some issues involing complex functions in combination with gradients, i.e. dx() and dy(). I have a prepared a MWE (since I just registered, I can’t upload it as a file… sorry).
int numnode = 50;
mesh Th = square(numnode,numnode);
fespace Vh(Th,P1);
Vh<complex> uh,vh;
uh = sin(pi*sqrt(x))*sin(pi*y*y) + 1i*sin(pi*x*x)*sin(pi*sqrt(y));
cout << "--> Var assembly of uh'*C*uh: " << int2d(Th)( 1i*dx(uh)'*uh ) << endl;
varf c(uh,vh)= int2d(Th)( 1i*dx(uh)*vh );
matrix<complex> C = c(Vh,Vh); //# Assemble matrix C
complex[int] aux = C*uh[];
complex uCu = uh[]'*aux;
cout << "--> lin alg assembly of uh'*C*uh: " << uCu << endl;
and I get the following output:
→ Var assembly of uh’Cuh: (0.400063,-1.95872e-17)
→ lin alg assembly of uh’Cuh: (-0.400063,-9.02158e-17)
In my understanding, I should get the same value (which I do for example if I replace ‘dx(uh)’ by ‘uh’ in both expressions).
Does anyone understand what is going on?
Best regards,
Benjamin Stamm