fixedGradientFvPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2016 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 Group
28  grpGenericBoundaryConditions
29 
30 Description
31  This boundary condition supplies a fixed gradient condition, such that
32  the patch values are calculated using:
33 
34  \f[
35  x_p = x_c + \frac{\nabla(x)}{\Delta}
36  \f]
37 
38  where
39  \vartable
40  x_p | patch values
41  x_c | internal field values
42  \nabla(x)| gradient (user-specified)
43  \Delta | inverse distance from patch face centre to cell centre
44  \endvartable
45 
46 Usage
47  \table
48  Property | Description | Required | Default value
49  gradient | gradient | yes |
50  \endtable
51 
52  Example of the boundary condition specification:
53  \verbatim
54  <patchName>
55  {
56  type fixedGradient;
57  gradient uniform 0;
58  }
59  \endverbatim
60 
61 SourceFiles
62  fixedGradientFvPatchField.C
63 
64 \*---------------------------------------------------------------------------*/
65 
66 #ifndef fixedGradientFvPatchField_H
67 #define fixedGradientFvPatchField_H
68 
69 #include "fvPatchField.H"
70 
71 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
72 
73 namespace Foam
74 {
75 
76 /*---------------------------------------------------------------------------*\
77  Class fixedGradientFvPatchField Declaration
78 \*---------------------------------------------------------------------------*/
79 
80 template<class Type>
81 class fixedGradientFvPatchField
82 :
83  public fvPatchField<Type>
84 {
85  // Private data
86 
87  Field<Type> gradient_;
88 
89 
90 public:
91 
92  //- Runtime type information
93  TypeName("fixedGradient");
94 
95 
96  // Constructors
97 
98  //- Construct from patch and internal field
100  (
101  const fvPatch&,
102  const DimensionedField<Type, volMesh>&
103  );
104 
105  //- Construct from patch, internal field and dictionary
107  (
108  const fvPatch&,
110  const dictionary&
111  );
112 
113  //- Construct by mapping the given fixedGradientFvPatchField
114  // onto a new patch
116  (
118  const fvPatch&,
120  const fvPatchFieldMapper&
121  );
122 
123  //- Construct as copy
125  (
127  );
128 
129  //- Construct and return a clone
130  virtual tmp<fvPatchField<Type>> clone() const
131  {
132  return tmp<fvPatchField<Type>>
133  (
135  );
136  }
137 
138  //- Construct as copy setting internal field reference
140  (
143  );
144 
145  //- Construct and return a clone setting internal field reference
147  (
149  ) const
150  {
151  return tmp<fvPatchField<Type>>
152  (
153  new fixedGradientFvPatchField<Type>(*this, iF)
154  );
155  }
156 
157 
158  // Member functions
159 
160  // Return defining fields
161 
162  //- Return gradient at boundary
163  virtual Field<Type>& gradient()
164  {
165  return gradient_;
166  }
167 
168  virtual const Field<Type>& gradient() const
169  {
170  return gradient_;
171  }
173 
174  // Mapping functions
175 
176  //- Map (and resize as needed) from self given a mapping object
177  virtual void autoMap
178  (
179  const fvPatchFieldMapper&
180  );
181 
182  //- Reverse map the given fvPatchField onto this fvPatchField
183  virtual void rmap
184  (
185  const fvPatchField<Type>&,
186  const labelList&
187  );
189 
190  // Evaluation functions
191 
192  //- Return gradient at boundary
193  virtual tmp<Field<Type>> snGrad() const
194  {
195  return gradient_;
196  }
197 
198  //- Evaluate the patch field
199  virtual void evaluate
200  (
201  const Pstream::commsTypes commsType=Pstream::blocking
202  );
203 
204  //- Return the matrix diagonal coefficients corresponding to the
205  // evaluation of the value of this patchField with given weights
207  (
208  const tmp<scalarField>&
209  ) const;
210 
211  //- Return the matrix source coefficients corresponding to the
212  // evaluation of the value of this patchField with given weights
214  (
215  const tmp<scalarField>&
216  ) const;
217 
218  //- Return the matrix diagonal coefficients corresponding to the
219  // evaluation of the gradient of this patchField
220  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
221 
222  //- Return the matrix source coefficients corresponding to the
223  // evaluation of the gradient of this patchField
224  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
225 
226 
227  //- Write
228  virtual void write(Ostream&) const;
229 };
230 
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 } // End namespace Foam
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #ifdef NoRepository
239  #include "fixedGradientFvPatchField.C"
240 #endif
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #endif
245 
246 // ************************************************************************* //
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:65
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
virtual Field< Type > & gradient()
Return gradient at boundary.
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.
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 tmp< Field< Type > > snGrad() const
Return gradient at boundary.
TypeName("fixedGradient")
Runtime type information.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
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:54
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.
Namespace for OpenFOAM.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.