Diffrence in results between varf and problem statment

I am tryin to solve PDE and need to use PETSc and need yo know if using it with problem statement or should I use varf statement.
the problem is when I use varf statement the results differs than using problem statement and I am sure that results obtained from problem statement is correct

hereunder is the code for defining the PDE in two different statements and the remain code is the same
1-
problem HydrodynamicNn(Nn, v3) = int2d(Th)(Nnv3
+(Dn
dt*(grad(Nn)'grad(v3)))
+((-Wnx * dx(Nn) + -Wny * dy(Nn))dtv3))
-int2d(Th)(Nnold
v3)
-int2d(Th)(Snv3dt)
+on (needle, Nn = 0)
//solve
HydrodynamicNn;

2-
varf HydrodynamicNn(Nn, v3) = int2d(Th)(Nnv3
+(Dn
dt*(grad(Nn)'grad(v3)))
+((-Wnx * dx(Nn) + -Wny * dy(Nn))dtv3))
-int2d(Th)(Nnold
v3)
+int2d(Th)(Snv3dt)
+on (needle, Nn = 0);
//constructing the matrices
matrix AN = HydrodynamicNn(Ve,Ve, solver = UMFPACK, factorize =0) ;
real [int] bN = HydrodynamicNn(0 ,Ve) ;

//Solve
Nn = AN^-1*bN ;

You have to be careful with signs of the rhs when passing from problem to varf. see discussion in this thread

Thank you very much for you attention and reply
but I thing the sings are correct in problem statement it is negative ( -int2d(Th)(Snv3 dt)
and in varf statement it is positive ( +int2d(Th)(Snv3 dt))

You cannot use problem. You must define a varf in order to build the Mat object for PETSc. See the examples.

1 Like

Thank you for your attention and reply
another question and forgive me if it so basic
the default solver used when write problem statement is the same as writing varf statement (wit out mentioning and solver like below)

problem HydrodynamicNn(Nn, v3)
varf HydrodynamicNn(Nn, v3)

what I am trying to say that the above two statements uses the same solver ?

Yes, but the way the serial FreeFEM solvers work is different from the way they work in PETSc. Please spend some time working through the examples and then follow up if you have additional questions.

1 Like

Hello Chris
Thank you again for your time
attached the code the problem now when I change problem to varf (and keep in mind the sign also of the right hand side change) I do not get a correct results

new 1.edp (6.7 KB)

I suggest that you start with a MWE (see the examples folder) and then gradually increase the complexity until you understand your problem.

What is MWE ?
I am sorry I am totally new with this program