CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

Question on the discretization of momentum equation in icoFoam

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   October 3, 2011, 02:25
Default Question on the discretization of momentum equation in icoFoam
  #1
MPJ
New Member
 
Oliver Pasqual
Join Date: May 2011
Posts: 12
Rep Power: 6
MPJ is on a distinguished road
Dear foamers,

I have a puzzle in the discretization of momentum equation in icoFoam.
As we know, the momentum equation was integrated over the control volume, and then discretized into linear equation.
When I dig into the code detail term by term of the UEqn, I found that the left hand part of the equation(fvm::ddt(U) + fvm::div(phi,U) - fvm::laplacian(nu,U)) was integrated and then the coefficient of unknow variables were added into the matrix A.
None of the terms is divided by the control volume.....


code detail of fvm::ddt using Euler scheme:
Code:
template<class Type>
tmp<fvMatrix<Type> >
EulerDdtScheme<Type>::fvmDdt
(
    const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
    tmp<fvMatrix<Type> > tfvm
    (
        new fvMatrix<Type>
        (
            vf,
            vf.dimensions()*dimVol/dimTime
        )
    );
 
    fvMatrix<Type>& fvm = tfvm();
 
    scalar rDeltaT = 1.0/mesh().time().deltaTValue();
 
    fvm.diag() = rDeltaT*mesh().V();
 
    if (mesh().moving())
    {
        fvm.source() = rDeltaT*vf.oldTime().internalField()*mesh().V0();
    }
    else
    {
        fvm.source() = rDeltaT*vf.oldTime().internalField()*mesh().V();
    }
 
    return tfvm;
}

To the right hand part of the momentum equation, first we integrate the term(fvc::div(p)) over the entire CV. then it was discretized using the Gauss law.
But the result was divided by the volume of the current grid.

code detail of fvc::grad(p) using GraussGrand:
Code:
Foam::fv::gaussGrad<Type>::gradf
(
    const GeometricField<Type, fvsPatchField, surfaceMesh>& ssf,
    const word& name
)
{
    typedef typename outerProduct<vector, Type>::type GradType;
 
    const fvMesh& mesh = ssf.mesh();
 
    tmp<GeometricField<GradType, fvPatchField, volMesh> > tgGrad
    (
        new GeometricField<GradType, fvPatchField, volMesh>
        (
            IOobject
            (
                name,
                ssf.instance(),
                mesh,
                IOobject::NO_READ,
                IOobject::NO_WRITE
            ),
            mesh,
            dimensioned<GradType>
            (
                "0",
                ssf.dimensions()/dimLength,
                pTraits<GradType>::zero
            ),
            zeroGradientFvPatchField<GradType>::typeName
        )
    );
    GeometricField<GradType, fvPatchField, volMesh>& gGrad = tgGrad();
 
    const labelUList& owner = mesh.owner();
    const labelUList& neighbour = mesh.neighbour();
    const vectorField& Sf = mesh.Sf();
 
    Field<GradType>& igGrad = gGrad;
    const Field<Type>& issf = ssf;
 
    forAll(owner, facei)
    {
        GradType Sfssf = Sf[facei]*issf[facei];
 
        igGrad[owner[facei]] += Sfssf;
        igGrad[neighbour[facei]] -= Sfssf;
    }
 
    forAll(mesh.boundary(), patchi)
    {
        const labelUList& pFaceCells =
            mesh.boundary()[patchi].faceCells();
 
        const vectorField& pSf = mesh.Sf().boundaryField()[patchi];
 
        const fvsPatchField<Type>& pssf = ssf.boundaryField()[patchi];
 
        forAll(mesh.boundary()[patchi], facei)
        {
            igGrad[pFaceCells[facei]] += pSf[facei]*pssf[facei];
        }
    }
 
    igGrad /= mesh.V();
    gGrad.correctBoundaryConditions();
 
    return tgGrad;
}
so my puzzle is that: the right hand part of U equation was divided by the volume, but the left part was not ...
the left hand part must be also divied by the volume in some place, but I can't figure it out...
any hint will be highly appreciated.
thanks

M.P J

Last edited by MPJ; October 3, 2011 at 09:26.
MPJ is offline   Reply With Quote

Old   October 3, 2011, 10:49
Default
  #2
MPJ
New Member
 
Oliver Pasqual
Join Date: May 2011
Posts: 12
Rep Power: 6
MPJ is on a distinguished road
perhaps the problem has not been discribed clearly.......

as we know, all the term of the momentum equation must be divided by the cell volumes,

when dig into the detail of the code implementation,
only the R.H.S of U equation was divided by the volume in the discretization process of fvc::grad(p).
How about the L.H.S of the equation?
From the discretization process of fvm::, all the term were integrated over the entire volume. I can't find the code on the division operation for them terms ....
can somebody give any suggestion?
thanks.
MPJ is offline   Reply With Quote

Old   October 4, 2011, 02:49
Default
  #3
Senior Member
 
Elvis
Join Date: Mar 2009
Location: Sindelfingen, Germany
Posts: 579
Blog Entries: 5
Rep Power: 13
elvis is on a distinguished road
Hello,

have you read http://openfoamwiki.net/index.php/IcoFoam ?
hope that gets you further
elvis is offline   Reply With Quote

Old   October 4, 2011, 09:44
Default
  #4
MPJ
New Member
 
Oliver Pasqual
Join Date: May 2011
Posts: 12
Rep Power: 6
MPJ is on a distinguished road
Quote:
Originally Posted by elvis View Post
Hello,

have you read http://openfoamwiki.net/index.php/IcoFoam ?
hope that gets you further

Thanks for your kindly reply,elvis

I am new to OF.
I have read the the detail discription of icoFoam several times.
A long time's debug found that the secret lies in the operation overloading of fvMatrix.
and now I am more clear about the discretization of equations using the language of OpenFOAM.

thanks
M.P J
MPJ is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56
Space and time discretization of Euler equation Hooman Main CFD Forum 2 June 6, 2010 08:30
Derivation of Momentum Equation in Integral Form Demonwolf Main CFD Forum 2 October 29, 2009 20:53
Derivation of Momentum Equation jbambery Main CFD Forum 1 June 9, 2006 13:27
Nonstaggered Grids and Momentum Interpolations S. Wang Main CFD Forum 3 March 2, 2001 14:44


All times are GMT -4. The time now is 15:50.