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-2022 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  //- Reset the fvPatchField to the given fvPatchField
175  // Used for mesh to mesh mapping
176  virtual void reset(const fvPatchField<Type>&);
177 
179  // Evaluation functions
180 
181  //- Return gradient at boundary
182  virtual tmp<Field<Type>> snGrad() const
183  {
184  return gradient_;
185  }
186 
187  //- Evaluate the patch field
188  virtual void evaluate
189  (
190  const Pstream::commsTypes commsType =
192  );
193 
194  //- Return the matrix diagonal coefficients corresponding to the
195  // evaluation of the value of this patchField with given weights
197  (
198  const tmp<scalarField>&
199  ) const;
200 
201  //- Return the matrix source coefficients corresponding to the
202  // evaluation of the value of this patchField with given weights
204  (
205  const tmp<scalarField>&
206  ) const;
208  //- Return the matrix diagonal coefficients corresponding to the
209  // evaluation of the gradient of this patchField
210  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
211 
212  //- Return the matrix source coefficients corresponding to the
213  // evaluation of the gradient of this patchField
214  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
215 
216 
217  //- Write
218  virtual void write(Ostream&) const;
219 };
220 
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 } // End namespace Foam
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 #ifdef NoRepository
229  #include "fixedGradientFvPatchField.C"
230 #endif
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #endif
235 
236 // ************************************************************************* //
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:63
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.
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
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.