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