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 "gaussLaplacianScheme.H"
00028 #include "surfaceInterpolate.H"
00029 #include "fvcDiv.H"
00030 #include "fvcGrad.H"
00031 #include "fvMatrices.H"
00032
00033
00034
00035 namespace Foam
00036 {
00037
00038
00039
00040 namespace fv
00041 {
00042
00043
00044
00045 template<class Type, class GType>
00046 tmp<fvMatrix<Type> >
00047 gaussLaplacianScheme<Type, GType>::fvmLaplacianUncorrected
00048 (
00049 const surfaceScalarField& gammaMagSf,
00050 GeometricField<Type, fvPatchField, volMesh>& vf
00051 )
00052 {
00053 tmp<surfaceScalarField> tdeltaCoeffs =
00054 this->tsnGradScheme_().deltaCoeffs(vf);
00055 const surfaceScalarField& deltaCoeffs = tdeltaCoeffs();
00056
00057 tmp<fvMatrix<Type> > tfvm
00058 (
00059 new fvMatrix<Type>
00060 (
00061 vf,
00062 deltaCoeffs.dimensions()*gammaMagSf.dimensions()*vf.dimensions()
00063 )
00064 );
00065 fvMatrix<Type>& fvm = tfvm();
00066
00067 fvm.upper() = deltaCoeffs.internalField()*gammaMagSf.internalField();
00068 fvm.negSumDiag();
00069
00070 forAll(fvm.psi().boundaryField(), patchI)
00071 {
00072 const fvPatchField<Type>& psf = fvm.psi().boundaryField()[patchI];
00073 const fvsPatchScalarField& patchGamma =
00074 gammaMagSf.boundaryField()[patchI];
00075
00076 fvm.internalCoeffs()[patchI] = patchGamma*psf.gradientInternalCoeffs();
00077 fvm.boundaryCoeffs()[patchI] = -patchGamma*psf.gradientBoundaryCoeffs();
00078 }
00079
00080 return tfvm;
00081 }
00082
00083
00084 template<class Type, class GType>
00085 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
00086 gaussLaplacianScheme<Type, GType>::gammaSnGradCorr
00087 (
00088 const surfaceVectorField& SfGammaCorr,
00089 const GeometricField<Type, fvPatchField, volMesh>& vf
00090 )
00091 {
00092 const fvMesh& mesh = this->mesh();
00093
00094 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tgammaSnGradCorr
00095 (
00096 new GeometricField<Type, fvsPatchField, surfaceMesh>
00097 (
00098 IOobject
00099 (
00100 "gammaSnGradCorr("+vf.name()+')',
00101 vf.instance(),
00102 mesh,
00103 IOobject::NO_READ,
00104 IOobject::NO_WRITE
00105 ),
00106 mesh,
00107 SfGammaCorr.dimensions()
00108 *vf.dimensions()*mesh.deltaCoeffs().dimensions()
00109 )
00110 );
00111
00112 for (direction cmpt = 0; cmpt < pTraits<Type>::nComponents; cmpt++)
00113 {
00114 tgammaSnGradCorr().replace
00115 (
00116 cmpt,
00117 SfGammaCorr & fvc::interpolate(fvc::grad(vf.component(cmpt)))
00118 );
00119 }
00120
00121 return tgammaSnGradCorr;
00122 }
00123
00124
00125
00126
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 }
00145
00146
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 }
00184
00185
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 }
00215
00216
00217
00218
00219 }
00220
00221
00222
00223 }
00224
00225