codedMixedFvPatchField.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::codedMixedFvPatchField
26 
27 Group
28  grpGenericBoundaryConditions
29 
30 Description
31  Constructs on-the-fly a new boundary condition (derived from
32  mixedFvPatchField) which is then used to evaluate.
33 
34  \heading Patch usage
35 
36  Example:
37  \verbatim
38  myPatch
39  {
40  type codedMixed;
41 
42  refValue uniform (0 0 0);
43  refGradient uniform (0 0 0);
44  valueFraction uniform 1;
45 
46  redirectType rampedMixed; // name of generated BC
47 
48  code
49  #{
50  this->refValue() =
51  vector(1, 0, 0)
52  *min(10, 0.1*this->db().time().value());
53  this->refGrad() = vector::zero;
54  this->valueFraction() = 1.0;
55  #};
56 
57  //codeInclude
58  //#{
59  // #include "fvCFD.H"
60  //#};
61 
62  //codeOptions
63  //#{
64  // -I$(LIB_SRC)/finiteVolume/lnInclude
65  //#};
66  }
67  \endverbatim
68 
69  A special form is if the 'code' section is not supplied. In this case
70  the code gets read from a (runTimeModifiable!) dictionary system/codeDict
71  which would have a corresponding entry
72 
73  \verbatim
74  myPatch
75  {
76  code
77  #{
78  this->refValue() = min(10, 0.1*this->db().time().value());
79  this->refGrad() = vector::zero;
80  this->valueFraction() = 1.0;
81  #};
82  }
83  \endverbatim
84 
85 SeeAlso
86  Foam::dynamicCode
87  Foam::functionEntries::codeStream
88 
89 SourceFiles
90  codedMixedFvPatchField.C
91 
92 \*---------------------------------------------------------------------------*/
93 
94 #ifndef codedMixedFvPatchField_H
95 #define codedMixedFvPatchField_H
96 
97 #include "mixedFvPatchFields.H"
98 #include "codedBase.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 namespace Foam
103 {
104 
105 // Forward declaration of classes
106 class dynamicCode;
107 class dynamicCodeContext;
108 class IOdictionary;
109 
110 /*---------------------------------------------------------------------------*\
111  Class codedMixedFvPatchField Declaration
112 \*---------------------------------------------------------------------------*/
113 
114 template<class Type>
116 :
117  public mixedFvPatchField<Type>,
118  public codedBase
119 {
120  // Private data
121 
122  //- Dictionary contents for the boundary condition
123  mutable dictionary dict_;
124 
125  const word redirectType_;
126 
127  mutable autoPtr<mixedFvPatchField<Type> > redirectPatchFieldPtr_;
128 
129 
130  // Private Member Functions
131 
132  const IOdictionary& dict() const;
133 
134  //- Set the rewrite vars controlling the Type
135  static void setFieldTemplates(dynamicCode& dynCode);
136 
137  //- Get the loaded dynamic libraries
138  virtual dlLibraryTable& libs() const;
139 
140  //- Adapt the context for the current object
141  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
142 
143  // Return a description (type + name) for the output
144  virtual string description() const;
145 
146  // Clear the ptr to the redirected object
147  virtual void clearRedirect() const;
148 
149  // Get the dictionary to initialize the codeContext
150  virtual const dictionary& codeDict() const;
151 
152 
153 public:
154 
155  // Static data members
156 
157  //- Name of the C code template to be used
158  static const word codeTemplateC;
159 
160  //- Name of the H code template to be used
161  static const word codeTemplateH;
162 
163 
164  //- Runtime type information
165  TypeName("codedMixed");
166 
167 
168  // Constructors
169 
170  //- Construct from patch and internal field
172  (
173  const fvPatch&,
175  );
176 
177  //- Construct from patch, internal field and dictionary
179  (
180  const fvPatch&,
182  const dictionary&
183  );
184 
185  //- Construct by mapping given codedMixedFvPatchField
186  // onto a new patch
188  (
190  const fvPatch&,
192  const fvPatchFieldMapper&
193  );
194 
195  //- Construct as copy
197  (
199  );
200 
201  //- Construct and return a clone
202  virtual tmp<fvPatchField<Type> > clone() const
203  {
204  return tmp<fvPatchField<Type> >
205  (
207  );
208  }
209 
210  //- Construct as copy setting internal field reference
212  (
215  );
216 
217  //- Construct and return a clone setting internal field reference
219  (
221  ) const
222  {
223  return tmp<fvPatchField<Type> >
224  (
225  new codedMixedFvPatchField<Type>(*this, iF)
226  );
227  }
228 
229 
230  // Member functions
231 
232  //- Get reference to the underlying patchField
234 
235  //- Update the coefficients associated with the patch field
236  virtual void updateCoeffs();
237 
238  //- Evaluate the patch field
239  // This is only needed to set the updated() flag of the redirectType
240  // to false.
241  virtual void evaluate
242  (
243  const Pstream::commsTypes commsType=Pstream::blocking
244  );
245 
246  //- Write
247  virtual void write(Ostream&) const;
248 };
249 
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 } // End namespace Foam
254 
255 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
256 
257 #ifdef NoRepository
258 # include "codedMixedFvPatchField.C"
259 #endif
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 #endif
264 
265 // ************************************************************************* //
This boundary condition provides a base class for &#39;mixed&#39; type boundary conditions, i.e. conditions that mix fixed value and patch-normal gradient conditions.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Base class for function objects and boundary conditions using dynamic code.
Definition: codedBase.H:53
static const word codeTemplateC
Name of the C code template to be used.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
Encapsulation of dynamic code dictionaries.
commsTypes
Types of communications.
Definition: UPstream.H:64
codedMixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Constructs on-the-fly a new boundary condition (derived from mixedFvPatchField) which is then used to...
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
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:56
TypeName("codedMixed")
Runtime type information.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
A table of dynamically loaded libraries.
const mixedFvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patchField.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
A class for managing temporary objects.
Definition: PtrList.H:118
virtual void write(Ostream &) const
Write.
static const word codeTemplateH
Name of the H code template to be used.