Just one more question: the following code produces a PETSc erro at the last line:
load "PETSc"
macro dimension()2// EOM
include "macro_ddm.idp"
macro grad(u)[dx(u), dy(u)]// EOM
func Pk = P1;
mesh Th = square(getARGV("-global", 40), getARGV("-global", 40));
Mat A00;
createMat(Th, A00, Pk)
fespace Wh(Th, Pk);
varf vPb(u, v) = int2d(Th)(grad(u)' * grad(v)) + int2d(Th)(v) + on(1, u = 0.0);
varf vPb2(u, v) = int2d(Th)(grad(u)' * grad(v) + 1e-8*dx(u)*dx(v)) + int2d(Th)(v) + on(1, u = 0.0);
real[int] rhs = vPb(0, Wh);
A00 = vPb(Wh, Wh);
Mat<real> A11(A00);
matrix I = eye(Wh.ndof);
A11 = I;
Mat<real> Sblock = [[A00, 0], [0, A11]];
real[int] rhsPETScTotal, usolPETScTotal;
changeNumbering([A00,A11],[rhs,rhs],rhsPETScTotal);
Wh<real> u1=1;
Wh<real> u2=2;
real[int] fieldIndices;
changeNumbering([A00,A11],[u1[], u2[]],fieldIndices);
string PETScPar = " -ksp_type preonly -ksp_monitor_true_residual -ksp_initial_guess_nonzero false -pc_type fieldsplit -pc_fieldsplit_type additive -options_left ";
set(Sblock, sparams=PETScPar, fields=fieldIndices);
set(A00, parent = Sblock, sparams=" -fieldsplit_0_ksp_type preonly -fieldsplit_0_pc_type lu -fieldsplit_0_ksp_reuse_preconditioner true ");
set(A11, parent = Sblock, sparams=" -fieldsplit_1_ksp_type preonly -fieldsplit_1_pc_type lu -fieldsplit_1_ksp_reuse_preconditioner true ");
KSPSolve(Sblock, rhsPETScTotal, usolPETScTotal);
matrix<real> A11new = vPb2(Wh, Wh);
ChangeOperator(A11,A11new);
They key difference between the previous code I sent and this one is the following. Previously. a block of the matrix was changed from the Laplacian to the identity, which seemed to be fine. However, doing it in reverse does not seem to be OK ( I did not check the results precisely, but the mile long PETSc error tells me something is seriously wrong). My question is: is this a bug, or does the sparsity pattern of the matrix cause this (I have no other idea what would cause the error). I think I can circumvent this error on my application I think; nevertheless, I would be happy to know whether this is a bug, or there is some reason for this behavior.