CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   laplacian (http://www.cfd-online.com/Forums/openfoam/87685-laplacian.html)

nimasam April 26, 2011 14:24

laplacian
 
hi foamer
i have a term like this in my equations

del(K del (T))

K is not constant!

which one of following openFOAM expression is correct for above term?

1) fvm :: laplacian ( K,T)

2)fvm::laplacian(K , T) + (fvc::grad(T) & fvc::grad(K))

Cyp April 27, 2011 06:07

Hi Nimasam !

It is the first expression which is correct otherwise it would be :
Code:

K*fvm::laplacian(T) + (fvc::grad(T) & fvc::grad(K))
because you have the following relationship:
Code:

fvm::laplacian(K,T) = K*fvm::laplacian(T) + (fvc::grad(T) & fvc::grad(K))
In the programmer guide P-38 you can notice that the laplacian term is coded with the diffusion term which allow you to use a variable diffusion.

Best,
Cyp

nimasam May 3, 2011 08:51

are you sure following equation sides are equal?
fvm::laplacian(K,T) = K*fvm::laplacian(T) + (fvc::grad(T) & fvc::grad(K))
i used both of them in code and i received different answers!

santiagomarquezd May 3, 2011 14:13

I think it depends on the kind of operation you want to, namely:

1. Implicit (fvm)
2. Explicit (fvc)
3. Mixed treatment

from Programmer's Guide Table 2.2 we have for laplacian:

Laplacian Implicit/Explicit \nabla^2\phi laplacian(phi) (1)
\nabla\cdot\Gamma\nabla\phi laplacian(Gamma, phi) (2)

then both in implicit and explicit treatment we have the operator with and without Gamma within the divergence. In the first case (1) constant gamma is assumed, in (2) laplacian(Gamma, phi) expands in the div-grad formulation intended for variable Gamma. So we have four cases,

a. Explicit, variable Gamma
b. Explicit, constant Gamma (no gamma within the operator)
c. Implicit, variable Gamma
d. Implicit, constant Gamma (no gamma within the operator)

a and b give geometricField as a result and c and d fvMatrix (implying an integration). Reading the code we have in gaussLaplacianScheme.C, for a, b, c

Code:

00186 template<class Type, class GType>
00187 tmp<GeometricField<Type, fvPatchField, volMesh> >
00188 gaussLaplacianScheme<Type, GType>::fvcLaplacian
00189 (
00190    const GeometricField<GType, fvsPatchField, surfaceMesh>& gamma,
00191    const GeometricField<Type, fvPatchField, volMesh>& vf
00192 )
00193 {
00194    const fvMesh& mesh = this->mesh();
00195
00196    surfaceVectorField Sn = mesh.Sf()/mesh.magSf();
00197
00198    surfaceVectorField SfGamma = mesh.Sf() & gamma;
00199    GeometricField<scalar, fvsPatchField, surfaceMesh> SfGammaSn = SfGamma & Sn;
00200    surfaceVectorField SfGammaCorr = SfGamma - SfGammaSn*Sn;
00201
00202    tmp<GeometricField<Type, fvPatchField, volMesh> > tLaplacian
00203    (
00204        fvc::div
00205        (
00206            SfGammaSn*this->tsnGradScheme_().snGrad(vf)
00207          + gammaSnGradCorr(SfGammaCorr, vf)
00208        )
00209    );
00210
00211    tLaplacian().rename("laplacian(" + gamma.name() + ',' + vf.name() + ')');
00212
00213    return tLaplacian;
00214 }

00127 template<class Type, class GType>
00128 tmp<GeometricField<Type, fvPatchField, volMesh> >
00129 gaussLaplacianScheme<Type, GType>::fvcLaplacian
00130 (
00131    const GeometricField<Type, fvPatchField, volMesh>& vf
00132 )
00133 {
00134    const fvMesh& mesh = this->mesh();
00135
00136    tmp<GeometricField<Type, fvPatchField, volMesh> > tLaplacian
00137    (
00138        fvc::div(this->tsnGradScheme_().snGrad(vf)*mesh.magSf())
00139    );
00140
00141    tLaplacian().rename("laplacian(" + vf.name() + ')');
00142
00143    return tLaplacian;
00144 }

00147 template<class Type, class GType>
00148 tmp<fvMatrix<Type> >
00149 gaussLaplacianScheme<Type, GType>::fvmLaplacian
00150 (
00151    const GeometricField<GType, fvsPatchField, surfaceMesh>& gamma,
00152    GeometricField<Type, fvPatchField, volMesh>& vf
00153 )
00154 {
00155    const fvMesh& mesh = this->mesh();
00156
00157    surfaceVectorField Sn = mesh.Sf()/mesh.magSf();
00158
00159    surfaceVectorField SfGamma = mesh.Sf() & gamma;
00160    GeometricField<scalar, fvsPatchField, surfaceMesh> SfGammaSn = SfGamma & Sn;
00161    surfaceVectorField SfGammaCorr = SfGamma - SfGammaSn*Sn;
00162
00163    tmp<fvMatrix<Type> > tfvm = fvmLaplacianUncorrected(SfGammaSn, vf);
00164    fvMatrix<Type>& fvm = tfvm();
00165
00166    tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tfaceFluxCorrection
00167        = gammaSnGradCorr(SfGammaCorr, vf);
00168
00169    if (this->tsnGradScheme_().corrected())
00170    {
00171        tfaceFluxCorrection() +=
00172            SfGammaSn*this->tsnGradScheme_().correction(vf);
00173    }
00174
00175    fvm.source() -= mesh.V()*fvc::div(tfaceFluxCorrection())().internalField();
00176
00177    if (mesh.fluxRequired(vf.name()))
00178    {
00179        fvm.faceFluxCorrectionPtr() = tfaceFluxCorrection.ptr();
00180    }
00181
00182    return tfvm;
00183 }

and for d, from fvmLaplacian.C

Code:

00069 template<class Type>
00070 tmp<fvMatrix<Type> >
00071 laplacian
00072 (
00073    GeometricField<Type, fvPatchField, volMesh>& vf
00074 )
00075 {
00076    surfaceScalarField Gamma
00077    (
00078        IOobject
00079        (
00080            "1",
00081            vf.time().constant(),
00082            vf.mesh(),
00083            IOobject::NO_READ
00084        ),
00085        vf.mesh(),
00086        dimensionedScalar("1", dimless, 1.0)
00087    );
00088
00089    return fvm::laplacian
00090    (
00091        Gamma,
00092        vf,
00093        "laplacian(" + vf.name() + ')'
00094    );
00095 }

from the last it is clear that d=c, with Gamma=1. Finally the correct implicit formulation in #1 is

1) fvm::laplacian ( K,T)

formulation given #3

fvm::laplacian(K,T) = K*fvm::laplacian(T) + (fvc::grad(T) & fvc::grad(K))

is a mixed one with the spatial variation of T treated implicitly and the spatial variation of K explicitly, the fvc part is put in the RHS, meanwhile fvm part contributes to the matrix, so that it is natural to hope different results (I think).

Regards.

nimasam May 9, 2011 14:45

hi Santiago
thank you, for detailed response , now i find why these expressions give different numerical result
now tell me which one of them i should choose for energy equation in two phase flow?
when implicit manner is suitable and when explicit manner is useful?

santiagomarquezd May 9, 2011 15:32

I think it is not very different to what is done in scalarTransportFoam solver. That includes variable scalar K (if it is tensorial things change a little bit).

Regards.

nimasam May 9, 2011 16:04

now i add the energy equation into interFoam i even consider evaporation, im just in doubt which one of the above expression is suitable for conduction term?

santiagomarquezd May 9, 2011 16:06

The first one.

Regards.


All times are GMT -4. The time now is 09:12.