Variable formulation error

Hi FF Community,

I have attempted to convert a gas flow problem into a varf formulation, but there seems to be an error that’s resulting in incorrect solutions. I’ve attached a screenshot of the varf statement along with the code.

Could you please take a look and let me know what might be wrong?

Thank you!


porepcheckpll.edp (3.2 KB)

In your varf for the right-hand side varf gasflow2 the two last lines need to te removed (they correspond to nothing in problem gasflow, which is your working reference if I understand well).
You need also to put the boundary conditions in gasflow2. This gives

varf gasflow2(pr, q) =
    int1d(Msh)(prold * idt * phi * q / (T * R))
  +on(1,pr=200000)
  +on(2,pr=100000);

Thank you, it is working fine. What should we consider when applying Dirichlet and Neumann boundary conditions in varf statements?

The general rule is that you separate

  • the terms that depend linearly on the unknown (your gasflow1), it defines the matrix of the system,
  • the terms that do not depend on the unknown (your gasflow 2), it defines the right-hand side for the linear system.

The only special thing is for Dirichlet boundary conditions with on(), for example consider +on(1,pr=200000). You have to understand that it contains two parts:

  • one part for the matrix, it is the pr= (together with the info of label=1) that says which dof is concerned by the Dirichlet BC. It will modify the corresponding line of the matrix.
  • one part for the right-hand side, it is the =200000 (together with the info of label=1). It puts the value 200000 in the corresponding coordinate of the right-hand side (the index is the index of the line of the matrix in the previous coment).

Thus you have to put Dirichlet BC in both gasflow1 and gasflow2 in order to give all the data correctly.
But for example if you set +on(1,pr=0) in gasflow1, the result is still correct because it takes only the part pr=.

You can look at

p. 223-224