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-2023 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  }
162 
163 
164  // Mapping functions
165 
166  //- Map the given fvPatchField onto this fvPatchField
167  virtual void map
168  (
169  const fvPatchField<Type>&,
170  const fvPatchFieldMapper&
171  );
172 
173  //- Reset the fvPatchField to the given fvPatchField
174  // Used for mesh to mesh mapping
175  virtual void reset(const fvPatchField<Type>&);
176 
177 
178  // Evaluation functions
179 
180  //- Return gradient at boundary
181  virtual tmp<Field<Type>> snGrad() const
182  {
183  return gradient_;
184  }
185 
186  //- Evaluate the patch field
187  virtual void evaluate
188  (
189  const Pstream::commsTypes commsType =
191  );
192 
193  //- Return the matrix diagonal coefficients corresponding to the
194  // evaluation of the value of this patchField with given weights
196  (
197  const tmp<scalarField>&
198  ) const;
199 
200  //- Return the matrix source coefficients corresponding to the
201  // evaluation of the value of this patchField with given weights
203  (
204  const tmp<scalarField>&
205  ) const;
206 
207  //- Return the matrix diagonal coefficients corresponding to the
208  // evaluation of the gradient of this patchField
209  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
210 
211  //- Return the matrix source coefficients corresponding to the
212  // evaluation of the gradient of this patchField
213  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
214 
215 
216  //- Write
217  virtual void write(Ostream&) const;
218 };
219 
220 
221 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
222 
223 } // End namespace Foam
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 #ifdef NoRepository
228  #include "fixedGradientFvPatchField.C"
229 #endif
230 
231 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
232 
233 #endif
234 
235 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
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 write(Ostream &) const
Write.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
TypeName("fixedGradient")
Runtime type information.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
virtual void map(const fvPatchField< Type > &, const fvPatchFieldMapper &)
Map the given fvPatchField onto this fvPatchField.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual Field< Type > & gradient()
Return gradient at boundary.
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:203
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.