1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Cubic interpolation scheme class derived from linear and returns
29 linear weighting factors but also applies an explicit correction.
34 \*---------------------------------------------------------------------------*/
40 #include "gaussGrad.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 /*---------------------------------------------------------------------------*\
48 Class cubic Declaration
49 \*---------------------------------------------------------------------------*/
56 // Private Member Functions
58 //- Disallow default bitwise copy construct
61 //- Disallow default bitwise assignment
62 void operator=(const cubic&);
67 //- Runtime type information
73 //- Construct from mesh
74 cubic(const fvMesh& mesh)
79 //- Construct from mesh and Istream
89 //- Construct from mesh, faceFlux and Istream
93 const surfaceScalarField&,
103 //- Return true if this scheme uses an explicit correction
104 virtual bool corrected() const
109 //- Return the explicit correction to the face-interpolate
110 virtual tmp<GeometricField<Type, fvsPatchField, surfaceMesh> >
113 const GeometricField<Type, fvPatchField, volMesh>& vf
116 const fvMesh& mesh = this->mesh();
118 // calculate the appropriate interpolation factors
119 const surfaceScalarField& lambda = mesh.weights();
121 const surfaceScalarField kSc
123 lambda*(scalar(1) - lambda*(scalar(3) - scalar(2)*lambda))
126 const surfaceScalarField kVecP(sqr(scalar(1) - lambda)*lambda);
127 const surfaceScalarField kVecN(sqr(lambda)*(lambda - scalar(1)));
129 tmp<GeometricField<Type, fvsPatchField, surfaceMesh> > tsfCorr
131 new GeometricField<Type, fvsPatchField, surfaceMesh>
135 "cubic::correction(" + vf.name() +')',
136 mesh.time().timeName(),
142 surfaceInterpolationScheme<Type>::interpolate(vf, kSc, -kSc)
146 GeometricField<Type, fvsPatchField, surfaceMesh>& sfCorr =
149 for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; cmpt++)
154 sfCorr.component(cmpt)
156 surfaceInterpolationScheme
158 typename outerProduct
161 typename pTraits<Type>::cmptType
166 <typename pTraits<Type>::cmptType>(mesh)
167 .grad(vf.component(cmpt)),
171 )/mesh.magSf()/mesh.surfaceInterpolation::deltaCoeffs()
175 forAll(sfCorr.boundaryField(), pi)
177 if (!sfCorr.boundaryField()[pi].coupled())
179 sfCorr.boundaryField()[pi] = pTraits<Type>::zero;
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 } // End namespace Foam
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 // ************************************************************************* //