faceLimitedGrad.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::fv::faceLimitedGrad
29 
30 Group
31  grpFvGradSchemes
32 
33 Description
34  faceLimitedGrad gradient scheme applied to a runTime selected base gradient
35  scheme.
36 
37  The scalar limiter based on limiting the extrapolated face values
38  between the face-neighbour cell values and is applied to all components
39  of the gradient.
40 
41 SourceFiles
42  faceLimitedGrad.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef faceLimitedGrad_H
47 #define faceLimitedGrad_H
48 
49 #include "gradScheme.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace fv
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class faceLimitedGrad Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class Type>
66 class faceLimitedGrad
67 :
68  public fv::gradScheme<Type>
69 {
70  // Private Data
71 
72  //- Gradient scheme
73  tmp<fv::gradScheme<Type>> basicGradScheme_;
74 
75  //- Limiter coefficient
76  const scalar k_;
77 
78 
79  // Private Member Functions
80 
81  inline void limitFace
82  (
83  scalar& limiter,
84  const scalar maxDelta,
85  const scalar minDelta,
86  const scalar extrapolate
87  ) const;
88 
89 
90  //- No copy construct
91  faceLimitedGrad(const faceLimitedGrad&) = delete;
92 
93  //- No copy assignment
94  void operator=(const faceLimitedGrad&) = delete;
95 
96 
97 public:
98 
99  //- RunTime type information
100  TypeName("faceLimited");
101 
102 
103  // Constructors
104 
105  //- Construct from mesh and schemeData
106  faceLimitedGrad(const fvMesh& mesh, Istream& schemeData)
107  :
108  gradScheme<Type>(mesh),
109  basicGradScheme_(fv::gradScheme<Type>::New(mesh, schemeData)),
110  k_(readScalar(schemeData))
111  {
112  if (k_ < 0 || k_ > 1)
113  {
114  FatalIOErrorInFunction(schemeData)
115  << "coefficient = " << k_
116  << " should be >= 0 and <= 1"
117  << exit(FatalIOError);
118  }
119  }
120 
121 
122  // Member Functions
123 
124  //- Return the gradient of the given field to the gradScheme::grad
125  //- for optional caching
126  virtual tmp
127  <
131  (
133  const word& name
134  ) const
135  {
136  return grad(vsf);
137  }
138 };
139 
140 
141 // * * * * * * * * * * * * Inline Member Function * * * * * * * * * * * * * //
142 
143 template<class Type>
144 inline void faceLimitedGrad<Type>::limitFace
145 (
146  scalar& limiter,
147  const scalar maxDelta,
148  const scalar minDelta,
149  const scalar extrapolate
150 ) const
151 {
152  if (extrapolate > maxDelta + VSMALL)
153  {
154  limiter = min(limiter, maxDelta/extrapolate);
155  }
156  else if (extrapolate < minDelta - VSMALL)
157  {
158  limiter = min(limiter, minDelta/extrapolate);
159  }
160 }
161 
162 
163 // * * * * * * * * Template Member Function Specialisations * * * * * * * * //
164 
165 template<>
166 tmp<volVectorField> faceLimitedGrad<scalar>::calcGrad
167 (
168  const volScalarField& vsf,
169  const word& name
170 ) const;
171 
172 
173 template<>
174 tmp<volTensorField> faceLimitedGrad<vector>::calcGrad
175 (
176  const volVectorField& vsf,
177  const word& name
178 ) const;
179 
180 
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
182 
183 } // End namespace fv
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 } // End namespace Foam
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 #endif
192 
193 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fv::faceLimitedGrad
faceLimitedGrad gradient scheme applied to a runTime selected base gradient scheme.
Definition: faceLimitedGrad.H:65
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:51
Foam::outerProduct::type
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:114
Foam::FatalIOError
IOerror FatalIOError
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::fv::gradScheme::New
static tmp< gradScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return a pointer to a new gradScheme created on freestore.
Definition: gradScheme.C:37
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::fv::gradScheme::mesh
const fvMesh & mesh() const
Return const reference to mesh.
Definition: gradScheme.H:126
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
gradScheme.H
Foam::fv::gradScheme
Abstract base class for gradient schemes.
Definition: gradScheme.H:63
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::volVectorField
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:62
fv
labelList fv(nPoints)
Foam::fv::faceLimitedGrad::faceLimitedGrad
faceLimitedGrad(const fvMesh &mesh, Istream &schemeData)
Construct from mesh and schemeData.
Definition: faceLimitedGrad.H:105
Foam::fv::faceLimitedGrad::TypeName
TypeName("faceLimited")
RunTime type information.
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::GeometricField
Generic GeometricField class.
Definition: areaFieldsFwd.H:53
Foam::limiter
tmp< areaScalarField > limiter(const areaScalarField &phi)
Definition: faNVDscheme.C:37
Foam::fv::gradScheme::grad
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > grad(const GeometricField< Type, fvPatchField, volMesh > &, const word &name) const
Foam::fv::faceLimitedGrad::calcGrad
virtual tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh > > calcGrad(const GeometricField< Type, fvPatchField, volMesh > &vsf, const word &name) const
Definition: faceLimitedGrad.H:130