codedFixedValueFvPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 Description
28  Constructs on-the-fly a new boundary condition (derived from
29  fixedValueFvPatchField) which is then used to evaluate.
30 
31 Usage
32  Example:
33  \verbatim
34  <patchName>
35  {
36  type codedFixedValue;
37  value uniform 0;
38  name rampedFixedValue; // name of generated BC
39 
40  code
41  #{
42  operator==(min(10, 0.1*this->db().time().value()));
43  #};
44 
45  // codeInclude
46  //#{
47  // #include "fvCFD.H"
48  //#};
49 
50  // codeOptions
51  //#{
52  // -I$(LIB_SRC)/finiteVolume/lnInclude
53  //#};
54  }
55  \endverbatim
56 
57  A special form is if the 'code' section is not supplied. In this case
58  the code is read from a (runTimeModifiable!) dictionary system/codeDict
59  which would have a corresponding entry:
60 
61  \verbatim
62  <patchName>
63  {
64  code
65  #{
66  operator==(min(10, 0.1*this->db().time().value()));
67  #};
68  }
69  \endverbatim
70 
71 See also
72  Foam::dynamicCode
73  Foam::functionEntries::codeStream
74 
75 SourceFiles
76  codedFixedValueFvPatchField.C
77 
78 \*---------------------------------------------------------------------------*/
79 
80 #ifndef codedFixedValueFvPatchField_H
81 #define codedFixedValueFvPatchField_H
82 
84 #include "codedBase.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 
91 // Forward declaration of classes
92 class dynamicCode;
93 class dynamicCodeContext;
94 class IOdictionary;
95 
96 /*---------------------------------------------------------------------------*\
97  Class codedFixedValueFvPatchField Declaration
98 \*---------------------------------------------------------------------------*/
99 
100 template<class Type>
102 :
103  public fixedValueFvPatchField<Type>,
104  public codedBase
105 {
106  // Private static data
107 
108  //- The keywords associated with source code
109  static const wordList codeKeys_;
110 
111 
112  // Private Data
113 
114  //- Dictionary contents for the boundary condition
115  const dictionary dict_;
116 
117  const word name_;
118 
119  mutable autoPtr<fvPatchField<Type>> redirectPatchFieldPtr_;
120 
121 
122  // Private Member Functions
123 
124  const IOdictionary& dict() const;
125 
126  //- Set the rewrite vars controlling the Type
127  static void setFieldTemplates(dynamicCode& dynCode);
128 
129  //- Get the loaded dynamic libraries
130  virtual dlLibraryTable& libs() const;
131 
132  //- Adapt the context for the current object
133  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
134 
135  //- Return a description (type + name) for the output
136  virtual string description() const;
137 
138  //- Clear the ptr to the redirected object
139  virtual void clearRedirect() const;
140 
141  //- Get the dictionary to initialize the codeContext
142  virtual const dictionary& codeDict() const;
143 
144  //- Get the keywords associated with source code
145  virtual const wordList& codeKeys() const;
146 
147 
148 public:
149 
150  // Static Data Members
151 
152  //- Name of the C code template to be used
153  static const word codeTemplateC;
154 
155  //- Name of the H code template to be used
156  static const word codeTemplateH;
157 
158 
159  //- Runtime type information
160  TypeName("codedFixedValue");
161 
162 
163  // Constructors
164 
165  //- Construct from patch and internal field
167  (
168  const fvPatch&,
170  );
171 
172  //- Construct from patch, internal field and dictionary
174  (
175  const fvPatch&,
177  const dictionary&
178  );
179 
180  //- Construct by mapping given codedFixedValueFvPatchField
181  // onto a new patch
183  (
185  const fvPatch&,
187  const fvPatchFieldMapper&
188  );
189 
190  //- Copy constructor
192  (
194  );
195 
196  //- Construct and return a clone
197  virtual tmp<fvPatchField<Type>> clone() const
198  {
199  return tmp<fvPatchField<Type>>
200  (
202  );
203  }
204 
205  //- Copy constructor setting internal field reference
207  (
210  );
211 
212  //- Construct and return a clone setting internal field reference
214  (
216  ) const
217  {
218  return tmp<fvPatchField<Type>>
219  (
220  new codedFixedValueFvPatchField<Type>(*this, iF)
221  );
222  }
223 
224 
225  // Member Functions
226 
227  //- Get reference to the underlying patch
228  const fvPatchField<Type>& redirectPatchField() const;
229 
230  //- Update the coefficients associated with the patch field
231  virtual void updateCoeffs();
232 
233  //- Evaluate the patch field, sets Updated to false
234  virtual void evaluate
235  (
237  );
238 
239  //- Write
240  virtual void write(Ostream&) const;
241 };
242 
243 
244 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 
246 } // End namespace Foam
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #ifdef NoRepository
252 #endif
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #endif
257 
258 // ************************************************************************* //
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:158
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:66
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:52
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
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
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:52
virtual void write(Ostream &) const
Write.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
const fvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.