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 "resErrorLaplacian.H"
00028
00029
00030
00031 namespace Foam
00032 {
00033
00034
00035
00036 namespace resError
00037 {
00038
00039 template<class Type>
00040 tmp<errorEstimate<Type> >
00041 laplacian
00042 (
00043 const GeometricField<Type, fvPatchField, volMesh>& vf
00044 )
00045 {
00046 surfaceScalarField Gamma
00047 (
00048 IOobject
00049 (
00050 "gamma",
00051 vf.time().constant(),
00052 vf.db(),
00053 IOobject::NO_READ
00054 ),
00055 vf.mesh(),
00056 dimensionedScalar("1", dimless, 1.0)
00057 );
00058
00059 return resError::laplacian(Gamma, vf);
00060 }
00061
00062
00063 template<class Type>
00064 tmp<errorEstimate<Type> >
00065 laplacian
00066 (
00067 const dimensionedScalar& gamma,
00068 const GeometricField<Type, fvPatchField, volMesh>& vf
00069 )
00070 {
00071 surfaceScalarField Gamma
00072 (
00073 IOobject
00074 (
00075 gamma.name(),
00076 vf.time().timeName(),
00077 vf.db(),
00078 IOobject::NO_READ
00079 ),
00080 vf.mesh(),
00081 gamma
00082 );
00083
00084 return resError::laplacian(Gamma, vf);
00085 }
00086
00087
00088 template<class Type>
00089 tmp<errorEstimate<Type> >
00090 laplacian
00091 (
00092 const volScalarField& gamma,
00093 const GeometricField<Type, fvPatchField, volMesh>& vf
00094 )
00095 {
00096 return resError::laplacian(fvc::interpolate(gamma), vf);
00097 }
00098
00099
00100 template<class Type>
00101 tmp<errorEstimate<Type> >
00102 laplacian
00103 (
00104 const tmp<volScalarField>& tgamma,
00105 const GeometricField<Type, fvPatchField, volMesh>& vf
00106 )
00107 {
00108 tmp<errorEstimate<Type> > Laplacian(resError::laplacian(tgamma(), vf));
00109 tgamma.clear();
00110 return Laplacian;
00111 }
00112
00113
00114 template<class Type>
00115 tmp<errorEstimate<Type> >
00116 laplacian
00117 (
00118 const surfaceScalarField& gamma,
00119 const GeometricField<Type, fvPatchField, volMesh>& vf
00120 )
00121 {
00122 const fvMesh& mesh = vf.mesh();
00123
00124 const scalarField& vols = mesh.V();
00125 const surfaceVectorField& Sf = mesh.Sf();
00126 const surfaceScalarField magSf = mesh.magSf();
00127 const fvPatchList& patches = mesh.boundary();
00128 const unallocLabelList& owner = mesh.owner();
00129 const unallocLabelList& neighbour = mesh.neighbour();
00130
00131 const surfaceScalarField& delta =
00132 mesh.surfaceInterpolation::deltaCoeffs();
00133
00134 Field<Type> res(vols.size(), pTraits<Type>::zero);
00135 scalarField aNorm(vols.size(), 0.0);
00136
00137
00138 GeometricField
00139 <
00140 typename outerProduct<vector, Type>::type, fvPatchField, volMesh
00141 > gradVf = fvc::grad(vf);
00142
00143
00144 forAll (owner, faceI)
00145 {
00146
00147
00148
00149 res[owner[faceI]] -=
00150 gamma[faceI]*(Sf[faceI] & gradVf[owner[faceI]]);
00151
00152 aNorm[owner[faceI]] += delta[faceI]*gamma[faceI]*magSf[faceI];
00153
00154
00155
00156
00157 res[neighbour[faceI]] +=
00158 gamma[faceI]*(Sf[faceI] & gradVf[neighbour[faceI]]);
00159
00160 aNorm[neighbour[faceI]] += delta[faceI]*gamma[faceI]*magSf[faceI];
00161
00162 }
00163
00164 forAll (patches, patchI)
00165 {
00166 const vectorField& patchSf = Sf.boundaryField()[patchI];
00167 const scalarField& patchMagSf = magSf.boundaryField()[patchI];
00168 const scalarField& patchGamma = gamma.boundaryField()[patchI];
00169 const scalarField& patchDelta = delta.boundaryField()[patchI];
00170
00171 const labelList& fCells = patches[patchI].faceCells();
00172
00173 forAll (fCells, faceI)
00174 {
00175
00176 res[fCells[faceI]] -=
00177 patchGamma[faceI]*
00178 (
00179 patchSf[faceI] & gradVf[fCells[faceI]]
00180 );
00181
00182 aNorm[fCells[faceI]] +=
00183 patchDelta[faceI]*patchGamma[faceI]*patchMagSf[faceI];
00184 }
00185 }
00186
00187 res /= vols;
00188 aNorm /= vols;
00189
00190 return tmp<errorEstimate<Type> >
00191 (
00192 new errorEstimate<Type>
00193 (
00194 vf,
00195 delta.dimensions()*gamma.dimensions()*magSf.dimensions()
00196 *vf.dimensions(),
00197 res,
00198 aNorm
00199 )
00200 );
00201 }
00202
00203 template<class Type>
00204 tmp<errorEstimate<Type> >
00205 laplacian
00206 (
00207 const tmp<surfaceScalarField>& tgamma,
00208 const GeometricField<Type, fvPatchField, volMesh>& vf
00209 )
00210 {
00211 tmp<errorEstimate<Type> > tresError(resError::laplacian(tgamma(), vf));
00212 tgamma.clear();
00213 return tresError;
00214 }
00215
00216
00217 template<class Type>
00218 tmp<errorEstimate<Type> >
00219 laplacian
00220 (
00221 const volTensorField& gamma,
00222 const GeometricField<Type, fvPatchField, volMesh>& vf
00223 )
00224 {
00225 const fvMesh& mesh = vf.mesh();
00226
00227 return resError::laplacian
00228 (
00229 (mesh.Sf() & fvc::interpolate(gamma) & mesh.Sf())
00230 /sqr(mesh.magSf()),
00231 vf
00232 );
00233 }
00234
00235 template<class Type>
00236 tmp<errorEstimate<Type> >
00237 laplacian
00238 (
00239 const tmp<volTensorField>& tgamma,
00240 const GeometricField<Type, fvPatchField, volMesh>& vf
00241 )
00242 {
00243 tmp<errorEstimate<Type> > Laplacian = resError::laplacian(tgamma(), vf);
00244 tgamma.clear();
00245 return Laplacian;
00246 }
00247
00248
00249 template<class Type>
00250 tmp<errorEstimate<Type> >
00251 laplacian
00252 (
00253 const surfaceTensorField& gamma,
00254 const GeometricField<Type, fvPatchField, volMesh>& vf
00255 )
00256 {
00257 const fvMesh& mesh = vf.mesh();
00258
00259 return resError::laplacian
00260 (
00261 (mesh.Sf() & gamma & mesh.Sf())/sqr(mesh.magSf()),
00262 vf
00263 );
00264 }
00265
00266 template<class Type>
00267 tmp<errorEstimate<Type> >
00268 laplacian
00269 (
00270 const tmp<surfaceTensorField>& tgamma,
00271 const GeometricField<Type, fvPatchField, volMesh>& vf
00272 )
00273 {
00274 tmp<errorEstimate<Type> > Laplacian = resError::laplacian(tgamma(), vf);
00275 tgamma.clear();
00276 return Laplacian;
00277 }
00278
00279
00280
00281
00282 }
00283
00284
00285
00286 }
00287
00288
00289
00290
00291
00292