CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Nonorthogonal correction (

maka August 8, 2008 09:05

Where can I find the piece of
Where can I find the piece of code that describes how the non-orthogonal correction is implemented in a solver like icoFoam? Thanks.

olwi August 9, 2008 06:17

The code for icoFoam is in $
The code for icoFoam is in


maka August 9, 2008 14:33

yes, I have read the code but
yes, I have read the code but the implementation of how the non-orthogonal correction is implemented is internal and does not show on the icoFoam.C. I read that non-orthogonal grid will result when treating a laplacian term in some terms that will be treated explicitly. May be that is why there is a loop. But I'm looking for the details of how such terms are implemented in openfoam.
for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++)
fvScalarMatrix pEqn
fvm::laplacian(rUA, p) == fvc::div(phi)

pEqn.setReference(pRefCell, pRefValue);

if (nonOrth == nNonOrthCorr)
phi -= pEqn.flux();


nadine August 9, 2008 16:49


hjasak August 9, 2008 17:58

Try: - my Thesis for a refere
- my Thesis for a reference
- gaussLaplacianScheme.C, line 165
fvm.source() -=

where the correction comes from the snGradScheme, eg. correctedSnGrad.C, line 89:

& linear



maka August 12, 2008 05:17

Thanks Hrv for your help.
Thanks Hrv for your help.

waynezw0618 August 27, 2008 11:07

Hi Hrv do i need to checkme
Hi Hrv

do i need to checkmesh before calculation,and creat the nonorth information file in the constant dictionary? to let the Non-orthogonal correction affect.


hjasak August 27, 2008 11:33

No, just run it with a correct
No, just run it with a corrected snGrad scheme.


MichiB October 18, 2011 06:14

I've been struggling to fully understand the laplacian schemes, and I think this may be the right thread to get some enlightment.

I'm still stuck at two points...

I was able to follow the overrelaxed approach (as explained in Hrv's thesis) until this point:

00066 fvm.upper() = deltaCoeffs.internalField()*gammaMagSf.internalFie ld();
00067 fvm.negSumDiag();

Line 0066 fills the upper array of the fvMatrix with coefficients Gamma*[S^2/(d dot S)].

Tell me if I'm completely wrong, but I think this only holds true for scalar fields.

However, if you take the laplacian of a vector field (e.g. laplacian(nu,U)),
you should end up with a tensor dotted with the orthogonal part of the surface normal vector.

This should give off-diagonal contributions that should end up in the source term, right?

Where do they come into play? I couldn't figure it out yet.

The second question that I have concerns the non-orthogonol correction:

00156 const surfaceVectorField Sn(mesh.Sf()/mesh.magSf());
00158 const surfaceVectorField SfGamma(mesh.Sf() & gamma);
00159 const GeometricField<scalar, fvsPatchField, surfaceMesh> SfGammaSn
00160 (
00161 SfGamma & Sn
00162 );
00163 const surfaceVectorField SfGammaCorr(SfGamma - SfGammaSn*Sn);
00165 tmp<fvMatrix<Type> > tfvm = fvmLaplacianUncorrected(SfGammaSn, vf);
00166 fvMatrix<Type>& fvm = tfvm();
00168 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tfaceFluxCorrection
00169 = gammaSnGradCorr(SfGammaCorr, vf);
00171 if (this->tsnGradScheme_().corrected())
00172 {
00173 tfaceFluxCorrection() +=
00174 SfGammaSn*this->tsnGradScheme_().correction(vf);
00175 }
00177 fvm.source() -= mesh.V()*fvc::div(tfaceFluxCorrection())().internalField();

At line 00163 the non-orthogonal part of the surface vector is calculated.
It should be gamma&(S - (d*S^2)/(d dot S)) (following Hrv's thesis).
However this doesn't correspond to the equation in line 00163.

I guess the programming is correct, since nobody ever complained in the forums,
but maybe someone knows the answer to my (probably stupid) questions.

MichiB October 25, 2011 10:55

For those who have problems understanding the laplacians in OpenFOAM, I found the answers to my questions in Ferzinger & Perić (1997) -> Chapter 8, Diffusive Fluxes

Hrv's PhD is a good lecture for laplacians in OpenFOAM, and F&P rounds the missing details up.

All times are GMT -4. The time now is 18:38.