CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Incompatible fields for operation divphi Ub (

vvqf November 22, 2005 11:13

I am writing an adjoint solver
I am writing an adjoint solver based on simpleFoam.
I used 2 velocity fields, one is adjoint velocity- U, which needs to be calculated, the other is a read-in velocity - U'(constant, read in as initial value at the begining). phi is created by interpolating the adjoint velocity- U.

I also created a PhiU'.cfg file to define the fvSchemes, and did little corresponding modifications in the solver source and testcase fvScheme files.

But when I use the solver the solve the case, I have error message as follows:
FOAM FATAL ERROR : incompatible fields for operation
[U'] - [U]

From function checkMethod(const fvMatrix<type>&, const fvMatrix<type>&)
in file ~/OpenFOAM/OpenFOAM-1.2/src/OpenFOAM/lnInclude/fvMatrix.C at line 898.

in fvMatrix.C line 898, it went into a if block:
if (&fvm1.psi() != &fvm2.psi())

Does it mean that these two velocity fields have to be the same, or with different names but actually share the same address?


hjasak November 22, 2005 12:45

If you want to solve a single
If you want to solve a single equation in FOAM, it can only have one variable. In other words, when you do:

fvm::ddt(U) + fvm::div(phi, U)

the first and second U need to be the same field. In your case it looks as if they are not.

Please also have in mind that you are upsetting the database by the fact you've got two fields with the same name.


vvqf November 22, 2005 18:43

Thank you for the answer. I
Thank you for the answer.

I now just want to fvm::div(phi, U')
Where phi is defined as:
surfaceScalarField phi
linearInterpolate(U) & mesh.Sf()
I offered a U' file to be read in at the beginning, in the 0 time directory. So U' is known and is a constant field.

I want to express (U'•)U as fvm::div(phi, U'). Is that wrong?

hjasak November 22, 2005 18:55

phi does not matter - it only
phi does not matter - it only needs to fit dimensionally. If you do:

fvm::div(phi, U')

you will get the equation for U' - to be more precise an fvVectorMatrix where U' is the variable you will try to solve for. Are you sure you want fvm rather than fvc?


All times are GMT -4. The time now is 02:20.