LimitedScheme.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "volFields.H"
00028 #include "surfaceFields.H"
00029 #include "fvcGrad.H"
00030 #include "coupledFvPatchFields.H"
00031
00032
00033
00034 namespace Foam
00035 {
00036
00037
00038
00039 template<class Type, class Limiter, template<class> class LimitFunc>
00040 tmp<surfaceScalarField> LimitedScheme<Type, Limiter, LimitFunc>::limiter
00041 (
00042 const GeometricField<Type, fvPatchField, volMesh>& phi
00043 ) const
00044 {
00045 const fvMesh& mesh = this->mesh();
00046
00047 tmp<surfaceScalarField> tLimiter
00048 (
00049 new surfaceScalarField
00050 (
00051 IOobject
00052 (
00053 type() + "Limiter(" + phi.name() + ')',
00054 mesh.time().timeName(),
00055 mesh
00056 ),
00057 mesh,
00058 dimless
00059 )
00060 );
00061 surfaceScalarField& lim = tLimiter();
00062
00063 tmp<GeometricField<typename Limiter::phiType, fvPatchField, volMesh> >
00064 tlPhi = LimitFunc<Type>()(phi);
00065
00066 const GeometricField<typename Limiter::phiType, fvPatchField, volMesh>&
00067 lPhi = tlPhi();
00068
00069 GeometricField<typename Limiter::gradPhiType, fvPatchField, volMesh>
00070 gradc(fvc::grad(lPhi));
00071
00072 const surfaceScalarField& CDweights = mesh.surfaceInterpolation::weights();
00073
00074 const unallocLabelList& owner = mesh.owner();
00075 const unallocLabelList& neighbour = mesh.neighbour();
00076
00077 const vectorField& C = mesh.C();
00078
00079 scalarField& pLim = lim.internalField();
00080
00081 forAll(pLim, face)
00082 {
00083 label own = owner[face];
00084 label nei = neighbour[face];
00085
00086 pLim[face] = Limiter::limiter
00087 (
00088 CDweights[face],
00089 this->faceFlux_[face],
00090 lPhi[own],
00091 lPhi[nei],
00092 gradc[own],
00093 gradc[nei],
00094 C[nei] - C[own]
00095 );
00096 }
00097
00098 surfaceScalarField::GeometricBoundaryField& bLim = lim.boundaryField();
00099
00100 forAll(bLim, patchi)
00101 {
00102 scalarField& pLim = bLim[patchi];
00103
00104 if (bLim[patchi].coupled())
00105 {
00106 const scalarField& pCDweights = CDweights.boundaryField()[patchi];
00107 const scalarField& pFaceFlux =
00108 this->faceFlux_.boundaryField()[patchi];
00109 Field<typename Limiter::phiType> plPhiP =
00110 lPhi.boundaryField()[patchi].patchInternalField();
00111 Field<typename Limiter::phiType> plPhiN =
00112 lPhi.boundaryField()[patchi].patchNeighbourField();
00113 Field<typename Limiter::gradPhiType> pGradcP =
00114 gradc.boundaryField()[patchi].patchInternalField();
00115 Field<typename Limiter::gradPhiType> pGradcN =
00116 gradc.boundaryField()[patchi].patchNeighbourField();
00117
00118
00119 vectorField pd =
00120 mesh.Sf().boundaryField()[patchi]
00121 /(
00122 mesh.magSf().boundaryField()[patchi]
00123 *mesh.deltaCoeffs().boundaryField()[patchi]
00124 );
00125
00126 if (!mesh.orthogonal())
00127 {
00128 pd -= mesh.correctionVectors().boundaryField()[patchi]
00129 /mesh.deltaCoeffs().boundaryField()[patchi];
00130 }
00131
00132 forAll(pLim, face)
00133 {
00134 pLim[face] = Limiter::limiter
00135 (
00136 pCDweights[face],
00137 pFaceFlux[face],
00138 plPhiP[face],
00139 plPhiN[face],
00140 pGradcP[face],
00141 pGradcN[face],
00142 pd[face]
00143 );
00144 }
00145 }
00146 else
00147 {
00148 pLim = 1.0;
00149 }
00150 }
00151
00152 return tLimiter;
00153 }
00154
00155
00156
00157
00158 }
00159
00160
Copyright © 2000-2009 OpenCFD Ltd