CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Running, Solving & CFD

Solve a equationhelp me

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 6, 2005, 19:48
Default I want to solve a equation in
  #1
Member
 
Luckyluke
Join Date: Mar 2009
Posts: 51
Rep Power: 17
luckyluke is on a distinguished road
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.
luckyluke is offline   Reply With Quote

Old   May 7, 2005, 09:39
Default Please give me some advice. S
  #2
Member
 
Luckyluke
Join Date: Mar 2009
Posts: 51
Rep Power: 17
luckyluke is on a distinguished road
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'?

Thanks.
luckyluke is offline   Reply With Quote

Old   May 8, 2005, 08:10
Default All correct. - add your grd
  #3
Senior Member
 
Mattijs Janssens
Join Date: Mar 2009
Posts: 1,419
Rep Power: 26
mattijs is on a distinguished road
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.
mattijs is offline   Reply With Quote

Old   May 8, 2005, 09:43
Default Thanks. If I don't want to cr
  #4
Member
 
Luckyluke
Join Date: Mar 2009
Posts: 51
Rep Power: 17
luckyluke is on a distinguished road
Thanks.
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.
luckyluke is offline   Reply With Quote

Old   May 8, 2005, 10:41
Default Why not try it and see, you wi
  #5
Senior Member
 
Join Date: Mar 2009
Posts: 854
Rep Power: 22
henry is on a distinguished road
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.
henry is offline   Reply With Quote

Old   November 11, 2005, 11:55
Default Hi, I resolve the momentum eq
  #6
Member
 
olivier Petit
Join Date: Mar 2009
Location: Göteborg, Sweden
Posts: 67
Rep Power: 17
olivier is on a distinguished road
Hi,
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
olivier is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another way to solve Stokes lam OpenFOAM Running, Solving & CFD 2 June 26, 2007 05:54
To solve my own equation lam OpenFOAM Running, Solving & CFD 7 March 30, 2007 03:37
Help:Two errors in the CFX-SOLVE James CFX 5 September 28, 2006 16:54
HOW TO Solve rambabu.s Main CFD Forum 4 April 20, 2002 21:30
Can i solve? Janice CFX 2 May 29, 2001 12:40


All times are GMT -4. The time now is 00:45.