1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 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
26 Foam::fv::cellMDLimitedGrad
29 cellMDLimitedGrad gradient scheme applied to a runTime selected base
32 The scalar limiter based on limiting the extrapolated face values
33 between the maximum and minimum cell and cell neighbour values and is
34 applied to the gradient in each face direction separately.
39 \*---------------------------------------------------------------------------*/
41 #ifndef cellMDLimitedGrad_H
42 #define cellMDLimitedGrad_H
44 #include "gradScheme.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 /*---------------------------------------------------------------------------*\
57 Class cellMDLimitedGrad Declaration
58 \*---------------------------------------------------------------------------*/
61 class cellMDLimitedGrad
63 public fv::gradScheme<Type>
67 tmp<fv::gradScheme<Type> > basicGradScheme_;
69 //- Limiter coefficient
73 // Private Member Functions
75 //- Disallow default bitwise copy construct
76 cellMDLimitedGrad(const cellMDLimitedGrad&);
78 //- Disallow default bitwise assignment
79 void operator=(const cellMDLimitedGrad&);
84 //- RunTime type information
85 TypeName("cellMDLimited");
90 //- Construct from mesh and schemeData
91 cellMDLimitedGrad(const fvMesh& mesh, Istream& schemeData)
93 gradScheme<Type>(mesh),
94 basicGradScheme_(fv::gradScheme<Type>::New(mesh, schemeData)),
95 k_(readScalar(schemeData))
101 "cellMDLimitedGrad(const fvMesh&, Istream& schemeData)",
103 ) << "coefficient = " << k_
104 << " should be >= 0 and <= 1"
105 << exit(FatalIOError);
112 static inline void limitFace
114 typename outerProduct<vector, Type>::type& g,
115 const Type& maxDelta,
116 const Type& minDelta,
123 <typename outerProduct<vector, Type>::type, fvPatchField, volMesh>
126 const GeometricField<Type, fvPatchField, volMesh>&
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 inline void cellMDLimitedGrad<scalar>::limitFace
137 const scalar& maxDelta,
138 const scalar& minDelta,
142 scalar extrapolate = dcf & g;
144 if (extrapolate > maxDelta)
146 g = g + dcf*(maxDelta - extrapolate)/magSqr(dcf);
148 else if (extrapolate < minDelta)
150 g = g + dcf*(minDelta - extrapolate)/magSqr(dcf);
156 inline void cellMDLimitedGrad<Type>::limitFace
158 typename outerProduct<vector, Type>::type& g,
159 const Type& maxDelta,
160 const Type& minDelta,
164 for(direction cmpt=0; cmpt<Type::nComponents; cmpt++)
166 vector gi(g[cmpt], g[cmpt+3], g[cmpt+6]);
167 cellMDLimitedGrad<scalar>::limitFace
170 maxDelta.component(cmpt),
171 minDelta.component(cmpt),
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 } // End namespace fv
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 } // End namespace Foam
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 // ************************************************************************* //