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