Hi all,
I am working on a code to solve the Cahn-Hilliard equation, and I am having trouble trying to split the solution function u into its phi and mu components for updating the Newton loop.
I have the mesh and functions declared as this:
// Mesh and function space
int h = 64;
mesh Th = square(h, h);
fespace Vh(Th, P1);
fespace ME = Vh*Vh;
// Define functions
Vh c, c0, dc, dmu;
Vh psi, v;
And the inside of the Newton loop as this:
// Assemble
matrix A = Lhs(ME, ME); real[int] b = Rhs(0, ME); real[int] sol = A^-1 * b; dc[] = sol(0:Vh.ndof - 1); dmu[] = sol(Vh.ndof:2*Vh.ndof - 1); c[] -= dc[]; mu[] -= dmu[];
I have also tried:
//Extract solution blocks: ucur = [dmu; dc]
int nd = Vh.ndof;
for (int i=0; i<nd; ++i) dmu[i] = ucur[i];
for (int i=0; i<nd; ++i) dc[i] = ucur[nd+i];
c = c - dc;
mu = mu - dmu;
However, something seems to go wrong with the updates in subsequent Newton Iterations. Particularly, c (phi) does not appear to be updating at all. Thanks in advance.