Here is my sample code
real x0 = 0, x1 = 1.;
real y0 = 0, y1 = 0.5;
int n = 2, m = 1;
mesh Th = square(n, m, [x0 + (x1 - x0) * x, y0 + (y1 - y0) * y]);
mesh uTh = Th;
macro res [rx, ry] // EOM // Residuum.
macro resEl [rxEl, ryEl] // EOM // Residuum.
// *********************
// Finite element space.
// *********************
fespace Vh(Th, [P1, P1]);
// FEM variables.
Vh res, resEl;
rx[] = 1;
ry[] = 2;
rxEl[] = 1;
ryEl[] = 2;
for (int i = 0; i < rx.n; i++){
rx[](i) = rx[](i) - rx[](i);
ry[](i) = ry[](i) - ryEl[](i);
}
cout << rx[] << endl;
The final print should be all zeros. Instead it is all “-2”.
12
-2 -2 -2 -2 -2
-2 -2 -2 -2 -2
-2 -2
Anybody understands why the values in rx
were not updated?