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-2019 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  );
109 
110  //- Construct by mapping the given fixedGradientFvPatchField
111  // onto a new patch
113  (
115  const fvPatch&,
117  const fvPatchFieldMapper&
118  );
119 
120  //- Copy constructor
122  (
124  );
125 
126  //- Construct and return a clone
127  virtual tmp<fvPatchField<Type>> clone() const
128  {
129  return tmp<fvPatchField<Type>>
130  (
132  );
133  }
134 
135  //- Copy constructor setting internal field reference
137  (
140  );
141 
142  //- Construct and return a clone setting internal field reference
144  (
146  ) const
147  {
148  return tmp<fvPatchField<Type>>
149  (
150  new fixedGradientFvPatchField<Type>(*this, iF)
151  );
152  }
153 
154 
155  // Member Functions
156 
157  // Return defining fields
158 
159  //- Return gradient at boundary
160  virtual Field<Type>& gradient()
161  {
162  return gradient_;
163  }
164 
165  virtual const Field<Type>& gradient() const
166  {
167  return gradient_;
168  }
170 
171  // Mapping functions
172 
173  //- Map (and resize as needed) from self given a mapping object
174  // Used to update fields following mesh topology change
175  virtual void autoMap(const fvPatchFieldMapper&);
176 
177  //- Reverse map the given fvPatchField onto this fvPatchField
178  // Used to reconstruct fields
179  virtual void rmap(const fvPatchField<Type>&, const labelList&);
180 
181 
182  // Evaluation functions
183 
184  //- Return gradient at boundary
185  virtual tmp<Field<Type>> snGrad() const
186  {
187  return gradient_;
188  }
189 
190  //- Evaluate the patch field
191  virtual void evaluate
192  (
193  const Pstream::commsTypes commsType =
195  );
196 
197  //- Return the matrix diagonal coefficients corresponding to the
198  // evaluation of the value of this patchField with given weights
200  (
201  const tmp<scalarField>&
202  ) const;
203 
204  //- Return the matrix source coefficients corresponding to the
205  // evaluation of the value of this patchField with given weights
207  (
208  const tmp<scalarField>&
209  ) const;
211  //- Return the matrix diagonal coefficients corresponding to the
212  // evaluation of the gradient of this patchField
213  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
214 
215  //- Return the matrix source coefficients corresponding to the
216  // evaluation of the gradient of this patchField
217  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
218 
219 
220  //- Write
221  virtual void write(Ostream&) const;
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #ifdef NoRepository
232  #include "fixedGradientFvPatchField.C"
233 #endif
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 #endif
238 
239 // ************************************************************************* //
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:158
commsTypes
Types of communications.
Definition: UPstream.H:64
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
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.
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: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
Namespace for OpenFOAM.