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-2018 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  //- Construct as copy
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  //- Construct as copy 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  virtual void autoMap
175  (
176  const fvPatchFieldMapper&
177  );
178 
179  //- Reverse map the given fvPatchField onto this fvPatchField
180  virtual void rmap
181  (
182  const fvPatchField<Type>&,
183  const labelList&
184  );
186 
187  // Evaluation functions
188 
189  //- Return gradient at boundary
190  virtual tmp<Field<Type>> snGrad() const
191  {
192  return gradient_;
193  }
194 
195  //- Evaluate the patch field
196  virtual void evaluate
197  (
198  const Pstream::commsTypes commsType =
200  );
201 
202  //- Return the matrix diagonal coefficients corresponding to the
203  // evaluation of the value of this patchField with given weights
205  (
206  const tmp<scalarField>&
207  ) const;
208 
209  //- Return the matrix source coefficients corresponding to the
210  // evaluation of the value of this patchField with given weights
212  (
213  const tmp<scalarField>&
214  ) const;
216  //- Return the matrix diagonal coefficients corresponding to the
217  // evaluation of the gradient of this patchField
218  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
219 
220  //- Return the matrix source coefficients corresponding to the
221  // evaluation of the gradient of this patchField
222  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
223 
224 
225  //- Write
226  virtual void write(Ostream&) const;
227 };
228 
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 } // End namespace Foam
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #ifdef NoRepository
237  #include "fixedGradientFvPatchField.C"
238 #endif
239 
240 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 
242 #endif
243 
244 // ************************************************************************* //
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:137
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:57
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:53
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.