codedFixedValuePointPatchField.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) 2012-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::codedFixedValuePointPatchField
26 
27 Description
28  Constructs on-the-fly a new boundary condition (derived from
29  fixedValuePointPatchField) which is then used to evaluate.
30 
31  Example:
32  \verbatim
33  movingWall
34  {
35  type codedFixedValue;
36  value uniform 0;
37  redirectType rampedFixedValue; // name of generated bc
38 
39  code
40  #{
41  operator==
42  (
43  vector(0,0,1)
44  *min(10, 0.1*this->db().time().value())
45  );
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 gets read from a (runTimeModifiable!) dictionary system/codeDict
62  which would have a corresponding entry
63 
64  \verbatim
65  rampedFixedValue
66  {
67  code
68  #{
69  operator==(min(10, 0.1*this->db().time().value()));
70  #};
71  }
72  \endverbatim
73 
74 SeeAlso
75  codedFixedValueFvPatchField
76 
77 SourceFiles
78  codedFixedValuePointPatchField.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef codedFixedValuePointPatchField_H
83 #define codedFixedValuePointPatchField_H
84 
86 #include "codedBase.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 // Forward declaration of classes
94 class dynamicCode;
95 class dynamicCodeContext;
96 class IOdictionary;
97 
98 /*---------------------------------------------------------------------------*\
99  Class codedFixedValuePointPatchField Declaration
100 \*---------------------------------------------------------------------------*/
101 
102 template<class Type>
104 :
105  public fixedValuePointPatchField<Type>,
106  public codedBase
107 {
108  // Private data
109 
110  //- Dictionary contents for the boundary condition
111  mutable dictionary dict_;
112 
113  const word redirectType_;
114 
115  mutable autoPtr<pointPatchField<Type> > redirectPatchFieldPtr_;
116 
117  // Private Member Functions
118 
119  const IOdictionary& dict() const;
120 
121  //- Set the rewrite vars controlling the Type
122  static void setFieldTemplates(dynamicCode& dynCode);
123 
124  //- Get the loaded dynamic libraries
125  virtual dlLibraryTable& libs() const;
126 
127  //- Adapt the context for the current object
128  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
129 
130  // Return a description (type + name) for the output
131  virtual string description() const;
132 
133  // Clear the ptr to the redirected object
134  virtual void clearRedirect() const;
135 
136  // Get the dictionary to initialize the codeContext
137  virtual const dictionary& codeDict() const;
138 
139 public:
140 
141  // Static data members
142 
143  //- Name of the C code template to be used
144  static const word codeTemplateC;
145 
146  //- Name of the H code template to be used
147  static const word codeTemplateH;
148 
149 
150  //- Runtime type information
151  TypeName("codedFixedValue");
152 
153 
154  // Constructors
155 
156  //- Construct from patch and internal field
158  (
159  const pointPatch&,
161  );
162 
163  //- Construct from patch, internal field and dictionary
165  (
166  const pointPatch&,
168  const dictionary&,
169  const bool valueRequired=true
170  );
171 
172  //- Construct by mapping given codedFixedValuePointPatchField
173  // onto a new patch
175  (
177  const pointPatch&,
179  const pointPatchFieldMapper&
180  );
181 
182  //- Construct as copy
184  (
186  );
187 
188  //- Construct and return a clone
189  virtual autoPtr<pointPatchField<Type> > clone() const
190  {
192  (
194  );
195  }
196 
197  //- Construct as copy setting internal field reference
199  (
202  );
203 
204  //- Construct and return a clone setting internal field reference
206  (
208  ) const
209  {
211  (
213  (
214  *this,
215  iF
216  )
217  );
218  }
219 
220 
221 
222  // Member functions
223 
224  //- Get reference to the underlying patch
226 
227  //- Update the coefficients associated with the patch field
228  virtual void updateCoeffs();
229 
230  //- Evaluate the patch field, sets Updated to false
231  virtual void evaluate
232  (
233  const Pstream::commsTypes commsType=Pstream::blocking
234  );
235 
236  //- Write
237  virtual void write(Ostream&) const;
238 };
239 
240 
241 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 
243 } // End namespace Foam
244 
245 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 
247 #ifdef NoRepository
249 #endif
250 
251 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 
253 #endif
254 
255 // ************************************************************************* //
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:56
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
virtual autoPtr< pointPatchField< Type > > clone() const
Construct and return a clone.
Constructs on-the-fly a new boundary condition (derived from fixedValuePointPatchField) which is then...
virtual void write(Ostream &) const
Write.
Base class for function objects and boundary conditions using dynamic code.
Definition: codedBase.H:53
A class for handling words, derived from string.
Definition: word.H:59
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field, sets Updated to false.
const pointPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
codedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Encapsulation of dynamic code dictionaries.
Abstract base class for point-mesh patch fields.
commsTypes
Types of communications.
Definition: UPstream.H:64
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:53
Foam::pointPatchFieldMapper.
TypeName("codedFixedValue")
Runtime type information.
A FixedValue boundary condition for pointField.
static const word codeTemplateH
Name of the H code template to be used.
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
A table of dynamically loaded libraries.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
static const word codeTemplateC
Name of the C code template to be used.