faceLimitedFaGrad.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) 2016-2017 Wikki Ltd
9  Copyright (C) 2023 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::fa::faceLimitedGrad
29 
30 Description
31  faceLimitedGrad gradient scheme applied to a runTime selected base gradient
32  scheme.
33 
34  The scalar limiter based on limiting the extrapolated face values
35  between the maximum and minimum cell and cell neighbour values and is
36  applied to all components of the gradient.
37 
38 Author
39  Hrvoje Jasak, Wikki Ltd.
40 
41 SourceFiles
42  faceLimitedFaGrads.C
43 
44 \*---------------------------------------------------------------------------*/
45 
46 #ifndef faceLimitedFaGrad_H
47 #define faceLimitedFaGrad_H
48 
49 #include "faGradScheme.H"
50 
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 
53 namespace Foam
54 {
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace fa
59 {
60 
61 /*---------------------------------------------------------------------------*\
62  Class faceLimitedGrad Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 template<class Type>
66 class faceLimitedGrad
67 :
68  public fa::gradScheme<Type>
69 {
70  // Private Data
71 
72  //- Basic gradient scheme
73  tmp<fa::gradScheme<Type>> basicGradScheme_;
74 
75  //- Limiter coefficient
76  scalar k_;
77 
78 
79 public:
80 
81  //- RunTime type information
82  TypeName("faceLimited");
83 
84 
85  // Generated Methods
86 
87  //- No copy construct
88  faceLimitedGrad(const faceLimitedGrad&) = delete;
89 
90  //- No copy assignment
91  void operator=(const faceLimitedGrad&) = delete;
92 
93 
94  // Constructors
95 
96  //- Construct from mesh and schemeData
97  faceLimitedGrad(const faMesh& mesh, Istream& schemeData)
98  :
100  basicGradScheme_(fa::gradScheme<Type>::New(mesh, schemeData)),
101  k_(readScalar(schemeData))
102  {
103  if (k_ < 0 || k_ > 1)
104  {
105  FatalIOErrorInFunction(schemeData)
106  << "coefficient = " << k_
107  << " should be >= 0 and <= 1"
108  << exit(FatalIOError);
109  }
110  }
111 
112 
113  // Member Functions
114 
115  static inline void limitEdge
116  (
117  Type& limiter,
118  const Type& maxDelta,
119  const Type& minDelta,
120  const Type& extrapolate
121  );
122 
123  //- Return the gradient of the given field to the
124  //- gradScheme::grad for optional caching
125  virtual tmp
126  <
129  > calcGrad
130  (
132  const word& name
133  ) const;
134 };
135 
136 
137 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
138 
139 } // End namespace fa
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
142 
143 } // End namespace Foam
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 
147 #endif
148 
149 // ************************************************************************* //
faceLimitedGrad gradient scheme applied to a runTime selected base gradient scheme.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:133
TypeName("faceLimited")
RunTime type information.
virtual tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > calcGrad(const GeometricField< Type, faPatchField, areaMesh > &vsf, const word &name) const
Return the gradient of the given field to the gradScheme::grad for optional caching.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
void operator=(const faceLimitedGrad &)=delete
No copy assignment.
faceLimitedGrad(const faceLimitedGrad &)=delete
No copy construct.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
typeOfRank< typename pTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank) >::type type
Definition: products.H:118
Generic GeometricField class.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:46
tmp< areaScalarField > limiter(const areaScalarField &phi)
Definition: faNVDscheme.C:31
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
Abstract base class for finite area calculus gradient schemes.
Definition: faGradScheme.H:58
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:637
Mesh data needed to do the Finite Area discretisation.
Definition: areaFaMesh.H:47
const faMesh & mesh() const noexcept
Return mesh reference.
Definition: faGradScheme.H:131
A class for managing temporary objects.
Definition: HashPtrTable.H:50
static void limitEdge(Type &limiter, const Type &maxDelta, const Type &minDelta, const Type &extrapolate)
Namespace for OpenFOAM.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...