CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   different methods in hooking source terms (http://www.cfd-online.com/Forums/openfoam/90992-different-methods-hooking-source-terms.html)

Amir July 27, 2011 10:17

different methods in hooking source terms
 
Hi FOMERs,

I have a question about different method of hooking source terms which cause different solutions.
Would you please explain these methods:

Code:

1)    tmp<fvVectorMatrix> UEqn
    (
                        fvm::ddt(U)
                + fvm::div(phi, U)
                - fvm::laplacian(nu, U)
                == -source
    );

    solve
    (
        UEqn() == -fvc::grad(p)
    )

2)    tmp<fvVectorMatrix> UEqn
    (
                        fvm::ddt(U)
                + fvm::div(phi, U)
                - fvm::laplacian(nu, U)
                +source
    );

    solve
    (
        UEqn() == -fvc::grad(p)
    )

3)    tmp<fvVectorMatrix> UEqn
    (
                        fvm::ddt(U)
                + fvm::div(phi, U)
                - fvm::laplacian(nu, U)
    );

    solve
    (
        UEqn() == -fvc::grad(p) - source
    )


marupio July 27, 2011 16:18

They all should be equivalent. Are you getting different solutions?

Wait... the solve function should always be receiving the same fvVectorMatrix... but it's what happens afterwards that may be different. In 1 and 2, the object UEqn already includes source, but in 3, it doesn't. So if you are later using UEqn, keep this in mind. In all examples above, UEqn doesn't include the pressure gradient. But solve is always seeing the same thing, so what you have written there should not show any difference.

Amir July 28, 2011 01:07

Quote:

Originally Posted by marupio (Post 317772)
They all should be equivalent. Are you getting different solutions?

Wait... the solve function should always be receiving the same fvVectorMatrix... but it's what happens afterwards that may be different. In 1 and 2, the object UEqn already includes source, but in 3, it doesn't. So if you are later using UEqn, keep this in mind. In all examples above, UEqn doesn't include the pressure gradient. But solve is always seeing the same thing, so what you have written there should not show any difference.

Thanks David,

I checked that in many cases, and it can be shown that in method 3 different solution is achieved, but methods 1 & 2 seems to be equivalent!
As you said,the only difference is that in methods 1 & 2, source term is included in UEqn., but in the 3rd one, it's included in pEqn.! :confused:

marupio July 28, 2011 09:27

The differences would take place later in the code. Is the UEqn object ever used again below the point you've quoted? #3 differs from the rest of the options above because the UEqn object it produces is different.

Amir July 28, 2011 09:37

Quote:

Originally Posted by marupio (Post 317870)
The differences would take place later in the code. Is the UEqn object ever used again below the point you've quoted? #3 differs from the rest of the options above because the UEqn object it produces is different.

No, UEqn. is used once in each of them. I'm not sure but may be manipulating source terms in UEqn and pEqn. is totally different.


All times are GMT -4. The time now is 06:19.