fixedGradientFaPatchField.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::fixedGradientFaPatchField
29 
30 Description
31  This boundary condition supplies a fixed gradient condition, such that
32  the patch values are calculated using:
33 
34  \f[
35  x_p = x_c + \frac{\nabla(x)}{\Delta}
36  \f]
37 
38  where
39  \vartable
40  x_p | patch values
41  x_c | internal field values
42  \nabla(x)| gradient (user-specified)
43  \Delta | inverse distance from patch face centre to cell centre
44  \endvartable
45 
46 Usage
47  \table
48  Property | Description | Required | Default value
49  gradient | gradient | yes |
50  \endtable
51 
52  Example of the boundary condition specification:
53  \verbatim
54  <patchName>
55  {
56  type fixedGradient;
57  gradient uniform 0;
58  }
59  \endverbatim
60 
61 Author
62  Zeljko Tukovic, FMENA
63  Hrvoje Jasak, Wikki Ltd.
64 
65 SourceFiles
66  fixedGradientFaPatchField.C
67 
68 \*---------------------------------------------------------------------------*/
69 
70 #ifndef Foam_fixedGradientFaPatchField_H
71 #define Foam_fixedGradientFaPatchField_H
72 
73 #include "faPatchField.H"
74 
75 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
76 
77 namespace Foam
78 {
79 
80 /*---------------------------------------------------------------------------*\
81  Class fixedGradientFaPatch Declaration
82 \*---------------------------------------------------------------------------*/
83 
84 template<class Type>
85 class fixedGradientFaPatchField
86 :
87  public faPatchField<Type>
88 {
89  // Private Data
90 
91  Field<Type> gradient_;
92 
93 protected:
94 
95  // Protected Member Functions
96 
97  //- Read the "gradient" entry into corresponding member
98  // The reading can be optional (default), mandatory etc.
99  // \returns True on success
100  bool readGradientEntry
101  (
102  const dictionary& dict,
104  );
105 
106 public:
107 
108  //- Runtime type information
109  TypeName("fixedGradient");
110 
111 
112  // Constructors
113 
114  //- Construct from patch and internal field
116  (
117  const faPatch&,
119  );
120 
121  //- Construct from patch, internal field and dictionary.
123  (
124  const faPatch&,
126  const dictionary& dict,
129  );
130 
131  //- Construct by mapping the given fixedGradient patch field
132  //- onto a new patch
134  (
136  const faPatch&,
138  const faPatchFieldMapper&
139  );
140 
141  //- Construct as copy
143  (
145  );
146 
147  //- Construct and return a clone
148  virtual tmp<faPatchField<Type>> clone() const
149  {
150  return tmp<faPatchField<Type>>
151  (
153  );
154  }
155 
156  //- Construct as copy setting internal field reference
158  (
161  );
162 
163  //- Construct and return a clone setting internal field reference
165  (
167  ) const
168  {
169  return tmp<faPatchField<Type>>
170  (
171  new fixedGradientFaPatchField<Type>(*this, iF)
172  );
173  }
174 
175 
176  // Member Functions
177 
178  //- The reference gradient at boundary
179  virtual Field<Type>& gradient() noexcept
180  {
181  return gradient_;
182  }
183 
184  //- The reference gradient at boundary
185  virtual const Field<Type>& gradient() const noexcept
186  {
187  return gradient_;
188  }
189 
190 
191  // Mapping functions
192 
193  //- Map (and resize as needed) from self given a mapping object
194  virtual void autoMap
195  (
196  const faPatchFieldMapper&
197  );
198 
199  //- Reverse map the given faPatchField onto this faPatchField
200  virtual void rmap
201  (
202  const faPatchField<Type>&,
203  const labelList&
204  );
206 
207  // Evaluation functions
208 
209  //- Return gradient at boundary
210  virtual tmp<Field<Type>> snGrad() const
211  {
212  return gradient_;
213  }
214 
215  //- Evaluate the patch field
216  virtual void evaluate
217  (
218  const Pstream::commsTypes commsType =
220  );
222 
223  //- Return the matrix diagonal coefficients corresponding to the
224  // evaluation of the value of this patchField with given weights
226  (
227  const tmp<scalarField>&
228  ) const;
230  //- Return the matrix source coefficients corresponding to the
231  // evaluation of the value of this patchField with given weights
233  (
234  const tmp<scalarField>&
235  ) const;
236 
237  //- Return the matrix diagonal coefficients corresponding to the
238  // evaluation of the gradient of this patchField
239  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
240 
241  //- Return the matrix source coefficients corresponding to the
242  // evaluation of the gradient of this patchField
243  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
244 
245 
246  //- Write
247  virtual void write(Ostream&) const;
248 };
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace Foam
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #ifdef NoRepository
258  #include "fixedGradientFaPatchField.C"
259 #endif
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #endif
264 
265 // ************************************************************************* //
bool readGradientEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "gradient" entry into corresponding member.
dictionary dict
"blocking" : (MPI_Bsend, MPI_Recv)
commsTypes
Communications types.
Definition: UPstream.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: areaFieldsFwd.H:56
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Generic templated field type.
Definition: Field.H:62
fixedGradientFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual tmp< faPatchField< Type > > clone() const
Construct and return a clone.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const direction noexcept
Definition: Scalar.H:258
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual Field< Type > & gradient() noexcept
The reference gradient at boundary.
virtual void autoMap(const faPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
TypeName("fixedGradient")
Runtime type information.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
Reading is optional [identical to READ_IF_PRESENT].
A class for managing temporary objects.
Definition: HashPtrTable.H:50
A FieldMapper for finite-area patch fields.
Namespace for OpenFOAM.
virtual void rmap(const faPatchField< Type > &, const labelList &)
Reverse map the given faPatchField onto this faPatchField.
readOption
Enumeration defining read preferences.