fixedGradientFvPatchField.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-2017 OpenFOAM Foundation
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::fixedGradientFvPatchField
29 
30 Group
31  grpGenericBoundaryConditions
32 
33 Description
34  This boundary condition supplies a fixed gradient condition, such that
35  the patch values are calculated using:
36 
37  \f[
38  x_p = x_c + \frac{\nabla(x)}{\Delta}
39  \f]
40 
41  where
42  \vartable
43  x_p | patch values
44  x_c | internal field values
45  \nabla(x)| gradient (user-specified)
46  \Delta | inverse distance from patch face centre to cell centre
47  \endvartable
48 
49 Usage
50  \table
51  Property | Description | Required | Default value
52  gradient | gradient | yes |
53  \endtable
54 
55  Example of the boundary condition specification:
56  \verbatim
57  <patchName>
58  {
59  type fixedGradient;
60  gradient uniform 0;
61  }
62  \endverbatim
63 
64 SourceFiles
65  fixedGradientFvPatchField.C
66 
67 \*---------------------------------------------------------------------------*/
68 
69 #ifndef Foam_fixedGradientFvPatchField_H
70 #define Foam_fixedGradientFvPatchField_H
71 
72 #include "fvPatchField.H"
73 
74 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
75 
76 namespace Foam
77 {
78 
79 /*---------------------------------------------------------------------------*\
80  Class fixedGradientFvPatchField Declaration
81 \*---------------------------------------------------------------------------*/
82 
83 template<class Type>
84 class fixedGradientFvPatchField
85 :
86  public fvPatchField<Type>
87 {
88  // Private Data
89 
90  Field<Type> gradient_;
91 
92 protected:
93 
94  // Protected Member Functions
95 
96  //- Read the "gradient" entry into corresponding member
97  // The reading can be optional (default), mandatory etc.
98  // \returns True on success
100  (
101  const dictionary& dict,
103  );
104 
105 public:
106 
107  //- Runtime type information
108  TypeName("fixedGradient");
109 
110 
111  // Constructors
112 
113  //- Construct from patch and internal field
115  (
116  const fvPatch&,
118  );
119 
120  //- Construct from patch, internal field and dictionary.
122  (
123  const fvPatch&,
125  const dictionary& dict,
128  );
129 
130  //- Construct by mapping the given fixedGradientFvPatchField
131  // onto a new patch
133  (
135  const fvPatch&,
137  const fvPatchFieldMapper&
138  );
139 
140  //- Construct as copy
142  (
144  );
145 
146  //- Construct and return a clone
147  virtual tmp<fvPatchField<Type>> clone() const
148  {
149  return tmp<fvPatchField<Type>>
150  (
152  );
153  }
154 
155  //- Construct as copy setting internal field reference
157  (
160  );
161 
162  //- Construct and return a clone setting internal field reference
164  (
166  ) const
167  {
168  return tmp<fvPatchField<Type>>
169  (
170  new fixedGradientFvPatchField<Type>(*this, iF)
171  );
172  }
173 
174 
175  // Member functions
176 
177  // Return defining fields
178 
179  //- Return gradient at boundary
180  virtual Field<Type>& gradient()
181  {
182  return gradient_;
183  }
185  virtual const Field<Type>& gradient() const
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 fvPatchFieldMapper&
197  );
198 
199  //- Reverse map the given fvPatchField onto this fvPatchField
200  virtual void rmap
201  (
202  const fvPatchField<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  );
221 
222  //- Return the matrix diagonal coefficients corresponding to the
223  // evaluation of the value of this patchField with given weights
225  (
226  const tmp<scalarField>&
227  ) const;
229  //- Return the matrix source coefficients corresponding to the
230  // evaluation of the value of this patchField with given weights
232  (
233  const tmp<scalarField>&
234  ) const;
235 
236  //- Return the matrix diagonal coefficients corresponding to the
237  // evaluation of the gradient of this patchField
238  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
239 
240  //- Return the matrix source coefficients corresponding to the
241  // evaluation of the gradient of this patchField
242  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
243 
244 
245  //- Write
246  virtual void write(Ostream&) const;
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #ifdef NoRepository
257  #include "fixedGradientFvPatchField.C"
258 #endif
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
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)
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
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
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual Field< Type > & gradient()
Return gradient at boundary.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Generic templated field type.
Definition: Field.H:62
A FieldMapper for finite-volume patch fields.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
TypeName("fixedGradient")
Runtime type information.
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
Reading is optional [identical to READ_IF_PRESENT].
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Namespace for OpenFOAM.
readOption
Enumeration defining read preferences.