CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Solve a equationhelp me (

luckyluke May 6, 2005 19:48

I want to solve a equation in
I want to solve a equation in the original solver 'interFoam' as following:
fvScalarMatrix gammaEqn2
fvm::laplacian(gamma) == fvc::div(grdGam)

Here, gamma is defined in file 'createFields.H':
volScalarField gamma

While grdGam is my own variable, which is not one of the fluid property variables (U,Pd,Gamma) and can be computed directly from the geometry of fluid interface . Then how should I define grdGam in my code? I am not familiar with the construction of volScalarField object and the IOobject paprameters, e.g. MUST_READ,AUTO_WRITE.

I am urgely waiting for your help.

luckyluke May 7, 2005 09:39

Please give me some advice. S
Please give me some advice.
Should I define grdGam like gamma as a flow variable? Then I will create a file named 'grdGam' under \interFoam\damBreak\0\? And modify 'fvScheme'?


mattijs May 8, 2005 08:10

All correct. - add your grd
All correct.

- add your grdGam to createFields.H. Use the same constructor as e.g. gamma or p (if it is a scalar) or e.g. U(if vector).
- create a file for it with correct boundary conditions.
- edit fvSchemes to define discretisation schemes for your variable. Look at the error messages if you get stuck.

luckyluke May 8, 2005 09:43

Thanks. If I don't want to cr
If I don't want to create additional file for the new grdGam, I define it as a copy of U:

volVectorField grdGam("grdGam",U);

[i] Can the divergence of grdGam be obtained by this code "fvc::div(grdGam)"?? Because I don't edit fvSchemes to define discretisation schemes for grdGam, is there a default scheme for fvc::div? How to modify the discretisation scheme of grdGam under my situation.
<ii> I write:
fvScalarMatrix Im
Can the code given above be used to get the solution of Im?

Many thanks.

henry May 8, 2005 10:41

Why not try it and see, you wi
Why not try it and see, you will learn much more that way.

There are a large number of example codes supplied with OpenFOAM which will help you understand what is possible, there is also the Doxygen documentation, but the most important thing is that you try things out for yourself, that's by far the best way of learning anything.

olivier November 11, 2005 12:55

Hi, I resolve the momentum eq
I resolve the momentum equation with energy equation. the regime is laminar and steady state.
when I couple those equations I have the bad results.
the implementation is like that:
/************************************************** *************/
tmp<fvvectormatrix> UEqn
fvm::div(phi, U)
- fvm::laplacian(nu,U)


solve(UEqn() == -fvc::grad(p)+F);

volScalarField AU = UEqn().A();
U = UEqn().H()/AU;

phi = fvc::interpolate(U) & mesh.Sf();
adjustPhi(phi, U, p);

fvm::laplacian(1/AU, p) == fvc::div(phi)

if (nonOrth == nNonOrthCorr)
phi -= pEqn.flux();

U -= fvc::grad(p)/AU;
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
fvScalarMatrix TEqn


+ S



/************************************************** **********************/
what's the wrong in this implementation?
thank you for your help

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