Help with preconditionner

could someone help to use a preconditionner LU and solver GMRES on this three problems:

problem Larva(L,v) = int2d(Th2D)(Lv/dt)
- int2d(Th2D)(Lant
v/dt)
+ int2d(Th2D)((velx
dx(L) + vely
dy(L))v)
//metodo de difusao artificial classica
+ int2d(Th2D)(1e-3
- int2d(Th2D)( (r1
Mant*(1.0 - Lant/Klar))v - (b1+lambdaL)Lantv )
+ on(inflow, L = 0.08
1e6);

problem Mexilhao(M,w) = int2d(Th2D)(Mw/dt)
- int2d(Th2D)(Mant
w/dt)
- int2d(Th2D)(lambdaM
Lant
(Aant^2/(c1^2 + Aant^2))(1.0 - Mant/Kmex)w - b2Mantw)
+ on(inflow, M = 0.0) + on(outflow, M = 0.0) + on(intRig, M = 0.0) + on(intLef, M = 0.0) + on(intFluid, M = 0.0);

problem Alga(A,v) = int2d(Th2D)(Av/dt)
- int2d(Th2D)(Aant
v/dt)
+ int2d(Th2D)((velx
dx(A) + vely
dy(A))v)
//metodo de difusao artificial classica
+ int2d(Th2D)(1e-3
- int2d(Th2D)( (r2
Aant*(1.0 - Aant/Kalg))v - b3(Aant^2/(c2^2 + Aant^2))Mantv )
+ on(inflow, A = 0.006*1e6);

When i try to use the PETSc command:

``````   set(L, sparams="-ksp_type gmres -pc_type lu -ksp_rtol 1e-5");
set(M, sparams="-ksp_type gmres -pc_type lu -ksp_rtol 1e-5");
set(A, sparams="-ksp_type gmres -pc_type lu -ksp_rtol 1e-5");
``````

this happens:

List of choices
( <12SetMatrix_OpIdE> : <14Matrice_CreuseIdE> )
( <12SetMatrix_OpISt7complexIdEE> : <14Matrice_CreuseISt7complexIdEE> )

Error line number 328, in file CodigoMexilhaoIC2.edp, before token )

We cannot copy/paste your code to run it, and there is no definition of variable `L`, `M`, and `A`, so we can’t help you. Most likely, you a trying to set PETSc options on plain `matrix` instead of `Mat`, so you first need to call something like `Mat LPETSc(L)` and then call `set(LPETSc, ...);`.

So can not i use the PETSc options in problems and only in Matrix? L, M and A are variables from a fespace Vh(i.e “fespace Vh(Th2D, P2);”).

I tried to use this:

Mat mLarva(Vh.ndof), mMexilhao(Vh.ndof), mAlga(Vh.ndof);
real [int] bLarva(Vh.ndof),bMexilhao(Vh.ndof),bAlga(Vh.ndof);

mLarva = Larva(Vh, Vh);
mMexilhao = Mexilhao(Vh, Vh);
mAlga = Alga(Vh, Vh);

bLarva = Larva(0, Vh);
bMexilhao = Mexilhao(0, Vh);
bAlga = Alga(0, Vh);

set(mLarva, sparams=“-ksp_type gmres -pc_type lu -ksp_rtol 1e-5”);
set(mMexilhao, sparams=“-ksp_type gmres -pc_type lu -ksp_rtol 1e-5”);
set(mAlga, sparams=“-ksp_type gmres -pc_type lu -ksp_rtol 1e-5”);

and in a temporal Loop:

Loop of 1 year:
Mant = M;
Aant = A;
Lant = L;

``````   L[] = (mLarva^-1)*(bLarva);
M[] = (mMexilhao^-1)*(bMemMexilhao);
A[] = (mAlga^-1)*(bAlga);
``````

end;

But, unfortunally it not worked, even though the code could compile and run.

I have this pseudo-algorith, where i could put this changes to add the PETSc options?

Data: Initial and boundary conditions of the variables L, M , and A in the
domain.
Result: Approximate values of L, M , and A in the discretized domain.
1 Definition of the domain geometry.
2 Generation of the triangular mesh.
3 Calculation of the velocity field V using the Navier-Stokes equations.
4 Definition of the model’s physical parameters.
5 Initialization of the variables L, M , and A based on the initial conditions.
6 Application of the boundary conditions on the variables L, M , and A.
7 Solution of the Larva-Mussel-Algae system:
8 for ti - tf do
9 for each nonlinear iteration k do
10 Given Li,k, M i,k, and Ai,k, find Li,k+1, M i,k+1, and Ai,k+1 considering
the variational formulation of Eqs.Larva, Mussel, and Algae.
11 end
12 Update Li+1, M i+1, and Ai+1
13 end
14 Save the values of L, M , and A for visualization in Paraview.

You need to convert your `matrix` to `Mat` as I said initially.