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-2015 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  \heading Patch usage
47 
48  \table
49  Property | Description | Required | Default value
50  gradient | gradient | yes |
51  \endtable
52 
53  Example of the boundary condition specification:
54  \verbatim
55  myPatch
56  {
57  type fixedGradient;
58  gradient uniform 0;
59  }
60  \endverbatim
61 
62 SourceFiles
63  fixedGradientFvPatchField.C
64 
65 \*---------------------------------------------------------------------------*/
66 
67 #ifndef fixedGradientFvPatchField_H
68 #define fixedGradientFvPatchField_H
69 
70 #include "fvPatchField.H"
71 
72 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
73 
74 namespace Foam
75 {
76 
77 /*---------------------------------------------------------------------------*\
78  Class fixedGradientFvPatchField Declaration
79 \*---------------------------------------------------------------------------*/
80 
81 template<class Type>
82 class fixedGradientFvPatchField
83 :
84  public fvPatchField<Type>
85 {
86  // Private data
87 
88  Field<Type> gradient_;
89 
90 
91 public:
92 
93  //- Runtime type information
94  TypeName("fixedGradient");
95 
96 
97  // Constructors
98 
99  //- Construct from patch and internal field
101  (
102  const fvPatch&,
103  const DimensionedField<Type, volMesh>&
104  );
105 
106  //- Construct from patch, internal field and dictionary
108  (
109  const fvPatch&,
111  const dictionary&
112  );
113 
114  //- Construct by mapping the given fixedGradientFvPatchField
115  // onto a new patch
117  (
119  const fvPatch&,
121  const fvPatchFieldMapper&
122  );
123 
124  //- Construct as copy
126  (
128  );
129 
130  //- Construct and return a clone
131  virtual tmp<fvPatchField<Type> > clone() const
132  {
133  return tmp<fvPatchField<Type> >
134  (
136  );
137  }
138 
139  //- Construct as copy setting internal field reference
141  (
144  );
145 
146  //- Construct and return a clone setting internal field reference
147  virtual tmp<fvPatchField<Type> > clone
148  (
150  ) const
151  {
152  return tmp<fvPatchField<Type> >
153  (
154  new fixedGradientFvPatchField<Type>(*this, iF)
155  );
156  }
157 
158 
159  // Member functions
160 
161  // Return defining fields
162 
163  //- Return gradient at boundary
164  virtual Field<Type>& gradient()
165  {
166  return gradient_;
167  }
168 
169  virtual const Field<Type>& gradient() const
170  {
171  return gradient_;
172  }
174 
175  // Mapping functions
176 
177  //- Map (and resize as needed) from self given a mapping object
178  virtual void autoMap
179  (
180  const fvPatchFieldMapper&
181  );
182 
183  //- Reverse map the given fvPatchField onto this fvPatchField
184  virtual void rmap
185  (
186  const fvPatchField<Type>&,
187  const labelList&
188  );
190 
191  // Evaluation functions
192 
193  //- Return gradient at boundary
194  virtual tmp<Field<Type> > snGrad() const
195  {
196  return gradient_;
197  }
198 
199  //- Evaluate the patch field
200  virtual void evaluate
201  (
202  const Pstream::commsTypes commsType=Pstream::blocking
203  );
204 
205  //- Return the matrix diagonal coefficients corresponding to the
206  // evaluation of the value of this patchField with given weights
208  (
209  const tmp<scalarField>&
210  ) const;
211 
212  //- Return the matrix source coefficients corresponding to the
213  // evaluation of the value of this patchField with given weights
215  (
216  const tmp<scalarField>&
217  ) const;
218 
219  //- Return the matrix diagonal coefficients corresponding to the
220  // evaluation of the gradient of this patchField
221  virtual tmp<Field<Type> > gradientInternalCoeffs() const;
222 
223  //- Return the matrix source coefficients corresponding to the
224  // evaluation of the gradient of this patchField
225  virtual tmp<Field<Type> > gradientBoundaryCoeffs() const;
226 
227 
228  //- Write
229  virtual void write(Ostream&) const;
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #ifdef NoRepository
240 # include "fixedGradientFvPatchField.C"
241 #endif
242 
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
244 
245 #endif
246 
247 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Foam::fvPatchFieldMapper.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Namespace for OpenFOAM.
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
commsTypes
Types of communications.
Definition: UPstream.H:64
virtual Field< Type > & gradient()
Return gradient at boundary.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Pre-declare SubField and related Field type.
Definition: Field.H:57
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void write(Ostream &) const
Write.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
TypeName("fixedGradient")
Runtime type information.
A class for managing temporary objects.
Definition: PtrList.H:118
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.