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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::fixedGradientFvPatchField
28 
29 Group
30  grpGenericBoundaryConditions
31 
32 Description
33  This boundary condition supplies a fixed gradient condition, such that
34  the patch values are calculated using:
35 
36  \f[
37  x_p = x_c + \frac{\nabla(x)}{\Delta}
38  \f]
39 
40  where
41  \vartable
42  x_p | patch values
43  x_c | internal field values
44  \nabla(x)| gradient (user-specified)
45  \Delta | inverse distance from patch face centre to cell centre
46  \endvartable
47 
48 Usage
49  \table
50  Property | Description | Required | Default value
51  gradient | gradient | yes |
52  \endtable
53 
54  Example of the boundary condition specification:
55  \verbatim
56  <patchName>
57  {
58  type fixedGradient;
59  gradient uniform 0;
60  }
61  \endverbatim
62 
63 SourceFiles
64  fixedGradientFvPatchField.C
65 
66 \*---------------------------------------------------------------------------*/
67 
68 #ifndef fixedGradientFvPatchField_H
69 #define fixedGradientFvPatchField_H
70 
71 #include "fvPatchField.H"
72 
73 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
74 
75 namespace Foam
76 {
77 
78 /*---------------------------------------------------------------------------*\
79  Class fixedGradientFvPatchField Declaration
80 \*---------------------------------------------------------------------------*/
81 
82 template<class Type>
83 class fixedGradientFvPatchField
84 :
85  public fvPatchField<Type>
86 {
87  // Private data
88 
89  Field<Type> gradient_;
90 
91 
92 public:
93 
94  //- Runtime type information
95  TypeName("fixedGradient");
96 
97 
98  // Constructors
99 
100  //- Construct from patch and internal field
102  (
103  const fvPatch&,
104  const DimensionedField<Type, volMesh>&
105  );
106 
107  //- Construct from patch, internal field and dictionary
109  (
110  const fvPatch&,
112  const dictionary&
113  );
114 
115  //- Construct by mapping the given fixedGradientFvPatchField
116  // onto a new patch
118  (
120  const fvPatch&,
122  const fvPatchFieldMapper&
123  );
124 
125  //- Construct as copy
127  (
129  );
130 
131  //- Construct and return a clone
132  virtual tmp<fvPatchField<Type>> clone() const
133  {
134  return tmp<fvPatchField<Type>>
135  (
137  );
138  }
139 
140  //- Construct as copy setting internal field reference
142  (
145  );
146 
147  //- Construct and return a clone setting internal field reference
149  (
151  ) const
152  {
153  return tmp<fvPatchField<Type>>
154  (
155  new fixedGradientFvPatchField<Type>(*this, iF)
156  );
157  }
158 
159 
160  // Member functions
161 
162  // Return defining fields
163 
164  //- Return gradient at boundary
165  virtual Field<Type>& gradient()
166  {
167  return gradient_;
168  }
169 
170  virtual const Field<Type>& gradient() const
171  {
172  return gradient_;
173  }
174 
175 
176  // Mapping functions
177 
178  //- Map (and resize as needed) from self given a mapping object
179  virtual void autoMap
180  (
181  const fvPatchFieldMapper&
182  );
183 
184  //- Reverse map the given fvPatchField onto this fvPatchField
185  virtual void rmap
186  (
187  const fvPatchField<Type>&,
188  const labelList&
189  );
190 
191 
192  // Evaluation functions
193 
194  //- Return gradient at boundary
195  virtual tmp<Field<Type>> snGrad() const
196  {
197  return gradient_;
198  }
199 
200  //- Evaluate the patch field
201  virtual void evaluate
202  (
203  const Pstream::commsTypes commsType =
205  );
206 
207  //- Return the matrix diagonal coefficients corresponding to the
208  // evaluation of the value of this patchField with given weights
210  (
211  const tmp<scalarField>&
212  ) const;
213 
214  //- Return the matrix source coefficients corresponding to the
215  // evaluation of the value of this patchField with given weights
217  (
218  const tmp<scalarField>&
219  ) const;
220 
221  //- Return the matrix diagonal coefficients corresponding to the
222  // evaluation of the gradient of this patchField
223  virtual tmp<Field<Type>> gradientInternalCoeffs() const;
224 
225  //- Return the matrix source coefficients corresponding to the
226  // evaluation of the gradient of this patchField
227  virtual tmp<Field<Type>> gradientBoundaryCoeffs() const;
228 
229 
230  //- Write
231  virtual void write(Ostream&) const;
232 };
233 
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 } // End namespace Foam
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #ifdef NoRepository
242  #include "fixedGradientFvPatchField.C"
243 #endif
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #endif
248 
249 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::fixedGradientFvPatchField::TypeName
TypeName("fixedGradient")
Runtime type information.
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::fixedGradientFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fixedGradientFvPatchField.C:192
fixedGradientFvPatchField.C
Foam::fixedGradientFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: fixedGradientFvPatchField.H:157
Foam::fixedGradientFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: fixedGradientFvPatchField.C:137
Foam::fixedGradientFvPatchField::gradient
virtual const Field< Type > & gradient() const
Definition: fixedGradientFvPatchField.H:195
Foam::fixedGradientFvPatchField::gradient
virtual Field< Type > & gradient()
Return gradient at boundary.
Definition: fixedGradientFvPatchField.H:190
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fixedGradientFvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:167
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::fixedGradientFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fixedGradientFvPatchField.C:111
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fixedGradientFvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:156
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::fixedGradientFvPatchField::fixedGradientFvPatchField
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fixedGradientFvPatchField.C:35
Foam::List< label >
Foam::fixedGradientFvPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
Definition: fixedGradientFvPatchField.H:220
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::fixedGradientFvPatchField
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
Definition: fixedGradientFvPatchField.H:108
Foam::fixedGradientFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fixedGradientFvPatchField.C:122
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::UPstream::commsTypes::blocking
fvPatchField.H
Foam::fixedGradientFvPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:185
Foam::fixedGradientFvPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:177