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 as copy setting internal field reference
148  (
151  );
152 
153  //- Return a clone
154  virtual tmp<fvPatchField<Type>> clone() const
155  {
156  return fvPatchField<Type>::Clone(*this);
157  }
158 
159  //- Clone with an internal field reference
161  (
163  ) const
164  {
165  return fvPatchField<Type>::Clone(*this, iF);
166  }
167 
168 
169  // Member functions
170 
171  // Return defining fields
172 
173  //- Return gradient at boundary
174  virtual Field<Type>& gradient()
175  {
176  return gradient_;
177  }
178 
179  virtual const Field<Type>& gradient() const
180  {
181  return gradient_;
182  }
183 
184 
185  // Mapping functions
186 
187  //- Map (and resize as needed) from self given a mapping object
188  virtual void autoMap
189  (
190  const fvPatchFieldMapper&
191  );
192 
193  //- Reverse map the given fvPatchField onto this fvPatchField
194  virtual void rmap
195  (
196  const fvPatchField<Type>&,
197  const labelList&
198  );
199 
200 
201  // Evaluation functions
203  //- Return gradient at boundary
204  virtual tmp<Field<Type>> snGrad() const
205  {
206  return gradient_;
207  }
208 
209  //- Evaluate the patch field
210  virtual void evaluate
211  (
212  const Pstream::commsTypes commsType =
214  );
215 
216  //- Return the matrix diagonal coefficients corresponding to the
217  // evaluation of the value of this patchField with given weights
219  (
220  const tmp<scalarField>&
221  ) const;
223  //- Return the matrix source coefficients corresponding to the
224  // evaluation of the value of this patchField with given weights
226  (
227  const tmp<scalarField>&
228  ) const;
229 
230  //- Return the matrix diagonal coefficients corresponding to the
231  // evaluation of the gradient of this patchField
232  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
233 
234  //- Return the matrix source coefficients corresponding to the
235  // evaluation of the gradient of this patchField
236  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
237 
238 
239  //- Write
240  virtual void write(Ostream&) const;
241 };
242 
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 } // End namespace Foam
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #ifdef NoRepository
251  #include "fixedGradientFvPatchField.C"
252 #endif
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
bool readGradientEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "gradient" entry into corresponding member.
dictionary dict
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
commsTypes
Communications types.
Definition: UPstream.H:77
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
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.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
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
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...
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...
Reading is optional [identical to READ_IF_PRESENT].
A class for managing temporary objects.
Definition: HashPtrTable.H:50
"buffered" : (MPI_Bsend, MPI_Recv)
Namespace for OpenFOAM.
readOption
Enumeration defining read preferences.