fixedGradientFvPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fixedGradientFvPatchField
26 
27 Description
28  This boundary condition supplies a fixed gradient condition, such that
29  the patch values are calculated using:
30 
31  \f[
32  x_p = x_c + \frac{\nabla(x)}{\Delta}
33  \f]
34 
35  where
36  \vartable
37  x_p | patch values
38  x_c | internal field values
39  \nabla(x)| gradient (user-specified)
40  \Delta | inverse distance from patch face centre to cell centre
41  \endvartable
42 
43 Usage
44  \table
45  Property | Description | Required | Default value
46  gradient | gradient | yes |
47  \endtable
48 
49  Example of the boundary condition specification:
50  \verbatim
51  <patchName>
52  {
53  type fixedGradient;
54  gradient uniform 0;
55  }
56  \endverbatim
57 
58 SourceFiles
59  fixedGradientFvPatchField.C
60 
61 \*---------------------------------------------------------------------------*/
62 
63 #ifndef fixedGradientFvPatchField_H
64 #define fixedGradientFvPatchField_H
65 
66 #include "fvPatchField.H"
67 
68 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
69 
70 namespace Foam
71 {
72 
73 /*---------------------------------------------------------------------------*\
74  Class fixedGradientFvPatchField Declaration
75 \*---------------------------------------------------------------------------*/
76 
77 template<class Type>
78 class fixedGradientFvPatchField
79 :
80  public fvPatchField<Type>
81 {
82  // Private Data
83 
84  Field<Type> gradient_;
85 
86 
87 public:
88 
89  //- Runtime type information
90  TypeName("fixedGradient");
91 
92 
93  // Constructors
94 
95  //- Construct from patch and internal field
97  (
98  const fvPatch&,
99  const DimensionedField<Type, volMesh>&
100  );
101 
102  //- Construct from patch, internal field and dictionary
104  (
105  const fvPatch&,
107  const dictionary&,
108  const bool gradientRequired=true
109  );
110 
111  //- Construct by mapping the given fixedGradientFvPatchField
112  // onto a new patch
114  (
116  const fvPatch&,
118  const fvPatchFieldMapper&,
119  const bool mappingRequired=true
120  );
121 
122  //- Disallow copy without setting internal field reference
124  (
126  ) = delete;
127 
128  //- Copy constructor setting internal field reference
130  (
133  );
134 
135  //- Construct and return a clone setting internal field reference
137  (
139  ) const
140  {
141  return tmp<fvPatchField<Type>>
142  (
143  new fixedGradientFvPatchField<Type>(*this, iF)
144  );
145  }
146 
147 
148  // Member Functions
149 
150  // Return defining fields
151 
152  //- Return gradient at boundary
153  virtual Field<Type>& gradient()
154  {
155  return gradient_;
156  }
157 
158  virtual const Field<Type>& gradient() const
159  {
160  return gradient_;
161  }
163 
164  // Mapping functions
165 
166  //- Map (and resize as needed) from self given a mapping object
167  // Used to update fields following mesh topology change
168  virtual void autoMap(const fvPatchFieldMapper&);
169 
170  //- Reverse map the given fvPatchField onto this fvPatchField
171  // Used to reconstruct fields
172  virtual void rmap(const fvPatchField<Type>&, const labelList&);
173 
174 
175  // Evaluation functions
176 
177  //- Return gradient at boundary
178  virtual tmp<Field<Type>> snGrad() const
179  {
180  return gradient_;
181  }
182 
183  //- Evaluate the patch field
184  virtual void evaluate
185  (
186  const Pstream::commsTypes commsType =
188  );
189 
190  //- Return the matrix diagonal coefficients corresponding to the
191  // evaluation of the value of this patchField with given weights
193  (
194  const tmp<scalarField>&
195  ) const;
196 
197  //- Return the matrix source coefficients corresponding to the
198  // evaluation of the value of this patchField with given weights
200  (
201  const tmp<scalarField>&
202  ) const;
204  //- Return the matrix diagonal coefficients corresponding to the
205  // evaluation of the gradient of this patchField
206  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
207 
208  //- Return the matrix source coefficients corresponding to the
209  // evaluation of the gradient of this patchField
210  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
211 
212 
213  //- Write
214  virtual void write(Ostream&) const;
215 };
216 
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 } // End namespace Foam
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #ifdef NoRepository
225  #include "fixedGradientFvPatchField.C"
226 #endif
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #endif
231 
232 // ************************************************************************* //
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
commsTypes
Types of communications.
Definition: UPstream.H:64
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
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.
Pre-declare SubField and related Field type.
Definition: Field.H:56
Foam::fvPatchFieldMapper.
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.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
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...
A class for managing temporary objects.
Definition: PtrList.H:53
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:199
Namespace for OpenFOAM.