1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "resErrorLaplacian.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 tmp<errorEstimate<Type> >
43 const GeometricField<Type, fvPatchField, volMesh>& vf
46 surfaceScalarField Gamma
56 dimensionedScalar("1", dimless, 1.0)
59 return resError::laplacian(Gamma, vf);
64 tmp<errorEstimate<Type> >
67 const dimensionedScalar& gamma,
68 const GeometricField<Type, fvPatchField, volMesh>& vf
71 surfaceScalarField Gamma
84 return resError::laplacian(Gamma, vf);
89 tmp<errorEstimate<Type> >
92 const volScalarField& gamma,
93 const GeometricField<Type, fvPatchField, volMesh>& vf
96 return resError::laplacian(fvc::interpolate(gamma), vf);
101 tmp<errorEstimate<Type> >
104 const tmp<volScalarField>& tgamma,
105 const GeometricField<Type, fvPatchField, volMesh>& vf
108 tmp<errorEstimate<Type> > Laplacian(resError::laplacian(tgamma(), vf));
115 tmp<errorEstimate<Type> >
118 const surfaceScalarField& gamma,
119 const GeometricField<Type, fvPatchField, volMesh>& vf
122 const fvMesh& mesh = vf.mesh();
124 const scalarField& vols = mesh.V();
125 const surfaceVectorField& Sf = mesh.Sf();
126 const surfaceScalarField magSf = mesh.magSf();
127 const fvPatchList& patches = mesh.boundary();
128 const unallocLabelList& owner = mesh.owner();
129 const unallocLabelList& neighbour = mesh.neighbour();
131 const surfaceScalarField& delta =
132 mesh.surfaceInterpolation::deltaCoeffs();
134 Field<Type> res(vols.size(), pTraits<Type>::zero);
135 scalarField aNorm(vols.size(), 0.0);
137 // Calculate gradient of the solution
140 typename outerProduct<vector, Type>::type, fvPatchField, volMesh
141 > gradVf = fvc::grad(vf);
144 forAll (owner, faceI)
148 // Subtract diffusion
150 gamma[faceI]*(Sf[faceI] & gradVf[owner[faceI]]);
152 aNorm[owner[faceI]] += delta[faceI]*gamma[faceI]*magSf[faceI];
156 // Subtract diffusion
157 res[neighbour[faceI]] +=
158 gamma[faceI]*(Sf[faceI] & gradVf[neighbour[faceI]]);
160 aNorm[neighbour[faceI]] += delta[faceI]*gamma[faceI]*magSf[faceI];
164 forAll (patches, patchI)
166 const vectorField& patchSf = Sf.boundaryField()[patchI];
167 const scalarField& patchMagSf = magSf.boundaryField()[patchI];
168 const scalarField& patchGamma = gamma.boundaryField()[patchI];
169 const scalarField& patchDelta = delta.boundaryField()[patchI];
171 const labelList& fCells = patches[patchI].faceCells();
173 forAll (fCells, faceI)
175 // Subtract diffusion
176 res[fCells[faceI]] -=
179 patchSf[faceI] & gradVf[fCells[faceI]]
182 aNorm[fCells[faceI]] +=
183 patchDelta[faceI]*patchGamma[faceI]*patchMagSf[faceI];
190 return tmp<errorEstimate<Type> >
192 new errorEstimate<Type>
195 delta.dimensions()*gamma.dimensions()*magSf.dimensions()
204 tmp<errorEstimate<Type> >
207 const tmp<surfaceScalarField>& tgamma,
208 const GeometricField<Type, fvPatchField, volMesh>& vf
211 tmp<errorEstimate<Type> > tresError(resError::laplacian(tgamma(), vf));
218 tmp<errorEstimate<Type> >
221 const volTensorField& gamma,
222 const GeometricField<Type, fvPatchField, volMesh>& vf
225 const fvMesh& mesh = vf.mesh();
227 return resError::laplacian
229 (mesh.Sf() & fvc::interpolate(gamma) & mesh.Sf())
236 tmp<errorEstimate<Type> >
239 const tmp<volTensorField>& tgamma,
240 const GeometricField<Type, fvPatchField, volMesh>& vf
243 tmp<errorEstimate<Type> > Laplacian = resError::laplacian(tgamma(), vf);
250 tmp<errorEstimate<Type> >
253 const surfaceTensorField& gamma,
254 const GeometricField<Type, fvPatchField, volMesh>& vf
257 const fvMesh& mesh = vf.mesh();
259 return resError::laplacian
261 (mesh.Sf() & gamma & mesh.Sf())/sqr(mesh.magSf()),
267 tmp<errorEstimate<Type> >
270 const tmp<surfaceTensorField>& tgamma,
271 const GeometricField<Type, fvPatchField, volMesh>& vf
274 tmp<errorEstimate<Type> > Laplacian = resError::laplacian(tgamma(), vf);
280 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
282 } // End namespace resError
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 } // End namespace Foam
288 // ************************************************************************* //
291 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //