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