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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::fv::faceLimitedGrad
28 
29 Group
30  grpFvGradSchemes
31 
32 Description
33  faceLimitedGrad gradient scheme applied to a runTime selected base gradient
34  scheme.
35 
36  The scalar limiter based on limiting the extrapolated face values
37  between the face-neighbour cell values and is applied to all components
38  of the gradient.
39 
40 SourceFiles
41  faceLimitedGrad.C
42 
43 \*---------------------------------------------------------------------------*/
44 
45 #ifndef faceLimitedGrad_H
46 #define faceLimitedGrad_H
47 
48 #include "gradScheme.H"
49 
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
51 
52 namespace Foam
53 {
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace fv
58 {
59 
60 /*---------------------------------------------------------------------------*\
61  Class faceLimitedGrad Declaration
62 \*---------------------------------------------------------------------------*/
63 
64 template<class Type>
65 class faceLimitedGrad
66 :
67  public fv::gradScheme<Type>
68 {
69  // Private Data
70 
71  tmp<fv::gradScheme<Type>> basicGradScheme_;
72 
73  //- Limiter coefficient
74  const scalar k_;
75 
76 
77  // Private Member Functions
78 
79  inline void limitFace
80  (
81  scalar& limiter,
82  const scalar maxDelta,
83  const scalar minDelta,
84  const scalar extrapolate
85  ) const;
86 
87 
88  //- No copy construct
89  faceLimitedGrad(const faceLimitedGrad&) = delete;
90 
91  //- No copy assignment
92  void operator=(const faceLimitedGrad&) = delete;
93 
94 
95 public:
96 
97  //- RunTime type information
98  TypeName("faceLimited");
99 
100 
101  // Constructors
102 
103  //- Construct from mesh and schemeData
104  faceLimitedGrad(const fvMesh& mesh, Istream& schemeData)
105  :
106  gradScheme<Type>(mesh),
107  basicGradScheme_(fv::gradScheme<Type>::New(mesh, schemeData)),
108  k_(readScalar(schemeData))
109  {
110  if (k_ < 0 || k_ > 1)
111  {
112  FatalIOErrorInFunction(schemeData)
113  << "coefficient = " << k_
114  << " should be >= 0 and <= 1"
115  << exit(FatalIOError);
116  }
117  }
118 
119 
120  // Member Functions
121 
122  //- Return the gradient of the given field to the gradScheme::grad
123  // for optional caching
124  virtual tmp
125  <
129  (
131  const word& name
132  ) const
133  {
134  return grad(vsf);
135  }
136 };
137 
138 
139 // * * * * * * * * * * * * Inline Member Function * * * * * * * * * * * * * //
140 
141 template<class Type>
142 inline void faceLimitedGrad<Type>::limitFace
143 (
144  scalar& limiter,
145  const scalar maxDelta,
146  const scalar minDelta,
147  const scalar extrapolate
148 ) const
149 {
150  if (extrapolate > maxDelta + VSMALL)
151  {
152  limiter = min(limiter, maxDelta/extrapolate);
153  }
154  else if (extrapolate < minDelta - VSMALL)
155  {
156  limiter = min(limiter, minDelta/extrapolate);
157  }
158 }
159 
160 
161 // * * * * * * * * Template Member Function Specialisations * * * * * * * * //
162 
163 template<>
164 tmp<volVectorField> faceLimitedGrad<scalar>::calcGrad
165 (
166  const volScalarField& vsf,
167  const word& name
168 ) const;
169 
170 
171 template<>
172 tmp<volTensorField> faceLimitedGrad<vector>::calcGrad
173 (
174  const volVectorField& vsf,
175  const word& name
176 ) const;
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace fv
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 } // End namespace Foam
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 #endif
190 
191 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
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:64
Foam::volMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: volMesh.H:50
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::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::fv::gradScheme::mesh
const fvMesh & mesh() const
Return mesh reference.
Definition: gradScheme.H:124
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:62
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
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:103
Foam::fv::faceLimitedGrad::TypeName
TypeName("faceLimited")
RunTime type information.
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:401
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
Calculate and return the grad of the given field.
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
Return the gradient of the given field to the gradScheme::grad.
Definition: faceLimitedGrad.H:128