- **OpenFOAM Running, Solving & CFD**
(*http://www.cfd-online.com/Forums/openfoam-solving/*)

- - **Solve a equationhelp me**
(*http://www.cfd-online.com/Forums/openfoam-solving/60434-solve-equationhelp-me.html*)

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) ); gammaEqn2.solve(); Here, gamma is defined in file 'createFields.H': volScalarField gamma ( IOobject ( "gamma", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); 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. |

Please give me some advice.
SPlease 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'? Thanks. |

All correct.
- add your grdAll 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. |

Thanks.
If I don't want to crThanks.
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); Then [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 ( fvm::laplacian(Im)==fvc::div(grdGam) ); Can the code given above be used to get the solution of Im? Many thanks. |

Why not try it and see, you wiWhy 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. |

Hi,
I resolve the momentum eqHi,
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) ); UEqn().relax(); solve(UEqn() == -fvc::grad(p)+F); volScalarField AU = UEqn().A(); U = UEqn().H()/AU; UEqn.clear(); phi = fvc::interpolate(U) & mesh.Sf(); adjustPhi(phi, U, p); ... fvm::laplacian(1/AU, p) == fvc::div(phi) ... if (nonOrth == nNonOrthCorr) { phi -= pEqn.flux(); } } p.relax(); U -= fvc::grad(p)/AU; U.correctBoundaryConditions(); for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix TEqn ( fvm::div(phi,T) == fvm::laplacian(DT,T) + S ); TEqn.solve(); } /************************************************** **********************/ what's the wrong in this implementation? thank you for your help |

All times are GMT -4. The time now is 17:54. |