1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
5 \\ / A nd | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Abstract base class for finite volume calculus gradient schemes.
27 \*---------------------------------------------------------------------------*/
30 #include "HashTable.H"
31 #include "primitiveFields.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
46 tmp<gradScheme<Type> > gradScheme<Type>::New
54 Info<< "gradScheme<Type>::New(Istream& schemeData) : "
55 "constructing gradScheme<Type>"
63 "gradScheme<Type>::New(Istream& schemeData)",
65 ) << "Grad scheme not specified" << endl << endl
66 << "Valid grad schemes are :" << endl
67 << IstreamConstructorTablePtr_->sortedToc()
68 << exit(FatalIOError);
71 word schemeName(schemeData);
73 typename IstreamConstructorTable::iterator cstrIter =
74 IstreamConstructorTablePtr_->find(schemeName);
76 if (cstrIter == IstreamConstructorTablePtr_->end())
80 "gradScheme<Type>::New(Istream& schemeData)",
82 ) << "unknown grad scheme " << schemeName << endl << endl
83 << "Valid grad schemes are :" << endl
84 << IstreamConstructorTablePtr_->sortedToc()
85 << exit(FatalIOError);
88 return cstrIter()(mesh, schemeData);
92 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 gradScheme<Type>::~gradScheme()
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 tmp<blockVectorMatrix> gradScheme<Type>::fvmGrad
104 const GeometricField<Type, fvPatchField, volMesh>& vf
109 "tmp<blockVectorMatrix> fvmGrad\n",
111 " GeometricField<Type, fvPatchField, volMesh>&"
113 ) << "Implicit gradient operator currently defined only for Gauss grad."
114 << abort(FatalIOError);
116 tmp<blockVectorMatrix> tbm
118 new blockVectorMatrix
129 void gradScheme<Type>::correctBoundaryConditions
131 const GeometricField<Type, fvPatchField, volMesh>& vsf,
134 typename outerProduct<vector, Type>::type, fvPatchField, volMesh
138 forAll (vsf.boundaryField(), patchi)
140 if (!vsf.boundaryField()[patchi].coupled())
142 vectorField n = vsf.mesh().boundary()[patchi].nf();
144 gGrad.boundaryField()[patchi] += n*
146 vsf.boundaryField()[patchi].snGrad()
147 - (n & gGrad.boundaryField()[patchi])
152 // Note: coupled boundaries provide patchNeighbourField, which is only
153 // updated on correct boundary conditions. Therefore, evaluateCoupled()
154 // should be called here. HJ, Apr/2013
155 gGrad.boundaryField().evaluateCoupled();
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 } // End namespace fv
163 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 } // End namespace Foam
167 // ************************************************************************* //