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

laplacian

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

Like Tree1Likes
  • 1 Post By Cyp

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 26, 2011, 14:24
Default laplacian
  #1
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
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))
nimasam is offline   Reply With Quote

Old   April 27, 2011, 06:07
Default
  #2
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
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
tom_flint2012 likes this.
Cyp is offline   Reply With Quote

Old   May 3, 2011, 08:51
Default
  #3
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
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!
nimasam is offline   Reply With Quote

Old   May 3, 2011, 14:13
Default
  #4
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 23
santiagomarquezd will become famous soon enough
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.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   May 9, 2011, 14:45
Default
  #5
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
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?
nimasam is offline   Reply With Quote

Old   May 9, 2011, 15:32
Default
  #6
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 23
santiagomarquezd will become famous soon enough
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.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Old   May 9, 2011, 16:04
Default
  #7
Senior Member
 
Nima Samkhaniani
Join Date: Sep 2009
Location: Tehran, Iran
Posts: 1,266
Blog Entries: 1
Rep Power: 24
nimasam is on a distinguished road
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?
nimasam is offline   Reply With Quote

Old   May 9, 2011, 16:06
Default
  #8
Senior Member
 
santiagomarquezd's Avatar
 
Santiago Marquez Damian
Join Date: Aug 2009
Location: Santa Fe, Santa Fe, Argentina
Posts: 452
Rep Power: 23
santiagomarquezd will become famous soon enough
The first one.

Regards.
__________________
Santiago MÁRQUEZ DAMIÁN, Ph.D.
Research Scientist
Research Center for Computational Methods (CIMEC) - CONICET/UNL
Tel: 54-342-4511594 Int. 7032
Colectora Ruta Nac. 168 / Paraje El Pozo
(3000) Santa Fe - Argentina.
http://www.cimec.org.ar
santiagomarquezd is offline   Reply With Quote

Reply

Tags
laplacian

Thread Tools Search this Thread
Search this Thread:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Modifying the laplacian operator mlawson OpenFOAM Running, Solving & CFD 22 July 16, 2018 04:56
How to calculate laplacian of a scalar in cfx? Jun CFX 21 March 2, 2018 09:08
laplacian operatorin udf anon_c Fluent UDF and Scheme Programming 4 August 5, 2013 17:23
why laplacian() failed OFCrash OpenFOAM Running, Solving & CFD 1 February 1, 2010 07:32
Probable bug with laplacian steady state novyno OpenFOAM 1 November 23, 2009 19:31


All times are GMT -4. The time now is 19:04.