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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2012-2017 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::codedFixedValuePointPatchField
29 
30 Description
31  Constructs on-the-fly a new boundary condition (derived from
32  fixedValuePointPatchField) which is then used to evaluate.
33 
34  Example:
35  \verbatim
36  movingWall
37  {
38  type codedFixedValue;
39  value uniform 0;
40  name rampedFixedValue; // name of generated bc
41 
42  code
43  #{
44  operator==
45  (
46  vector(0,0,1)
47  *min(10, 0.1*this->db().time().value())
48  );
49  #};
50 
51  //codeInclude
52  //#{
53  // #include "fvCFD.H"
54  //#};
55 
56  //codeOptions
57  //#{
58  // -I$(LIB_SRC)/finiteVolume/lnInclude
59  //#};
60  }
61  \endverbatim
62 
63  A special form is if the \c code section is not supplied. In this case
64  the code gets read from a (runTimeModifiable!) dictionary system/codeDict
65  which would have a corresponding entry
66 
67  \verbatim
68  rampedFixedValue
69  {
70  code
71  #{
72  operator==(min(10, 0.1*this->db().time().value()));
73  #};
74  }
75  \endverbatim
76 
77 See also
78  codedFixedValueFvPatchField
79 
80 SourceFiles
81  codedFixedValuePointPatchField.C
82 
83 \*---------------------------------------------------------------------------*/
84 
85 #ifndef codedFixedValuePointPatchField_H
86 #define codedFixedValuePointPatchField_H
87 
89 #include "codedBase.H"
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 namespace Foam
94 {
95 
96 // Forward Declarations
97 class IOdictionary;
98 
99 /*---------------------------------------------------------------------------*\
100  Class codedFixedValuePointPatchField Declaration
101 \*---------------------------------------------------------------------------*/
102 
103 template<class Type>
105 :
106  public fixedValuePointPatchField<Type>,
107  protected codedBase
108 {
109  // Private Data
110 
111  //- Dictionary contents for the boundary condition
112  mutable dictionary dict_;
113 
114  const word name_;
115 
116  mutable autoPtr<pointPatchField<Type>> redirectPatchFieldPtr_;
117 
118 
119  // Private Member Functions
120 
121  const IOdictionary& dict() const;
122 
123  //- Mutable access to the loaded dynamic libraries
124  virtual dlLibraryTable& libs() const;
125 
126  //- Adapt the context for the current object
127  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
128 
129  // Return a description (type + name) for the output
130  virtual string description() const;
131 
132  // Clear the ptr to the redirected object
133  virtual void clearRedirect() const;
134 
135  // Get the dictionary to initialize the codeContext
136  virtual const dictionary& codeDict() const;
137 
138 
139 public:
140 
141  // Static Data Members
142 
143  //- Name of the C code template to be used
144  static constexpr const char* const codeTemplateC
145  = "fixedValuePointPatchFieldTemplate.C";
146 
147  //- Name of the H code template to be used
148  static constexpr const char* const codeTemplateH
149  = "fixedValuePointPatchFieldTemplate.H";
150 
151 
152  //- Runtime type information
153  TypeName("codedFixedValue");
154 
155 
156  // Constructors
157 
158  //- Construct from patch and internal field
160  (
161  const pointPatch&,
163  );
164 
165  //- Construct from patch, internal field and dictionary
167  (
168  const pointPatch&,
170  const dictionary&,
171  const bool valueRequired=true
172  );
173 
174  //- Construct by mapping given codedFixedValuePointPatchField
175  // onto a new patch
177  (
179  const pointPatch&,
181  const pointPatchFieldMapper&
182  );
183 
184  //- Construct as copy
186  (
188  );
189 
190  //- Construct and return a clone
191  virtual autoPtr<pointPatchField<Type>> clone() const
192  {
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  {
213  (
215  (
216  *this,
217  iF
218  )
219  );
220  }
221 
222 
223  // Member functions
224 
225  //- Get reference to the underlying patch
227 
228  //- Update the coefficients associated with the patch field
229  virtual void updateCoeffs();
230 
231  //- Evaluate the patch field, sets Updated to false
232  virtual void evaluate
233  (
235  );
236 
237  //- Write
238  virtual void write(Ostream&) const;
239 };
240 
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 } // End namespace Foam
245 
246 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
247 
248 #ifdef NoRepository
250 #endif
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 #endif
255 
256 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::UPstream::commsTypes::blocking
Foam::dlLibraryTable
A table of dynamically loaded libraries.
Definition: dlLibraryTable.H:63
codedFixedValuePointPatchField.C
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::dynamicCode
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:59
Foam::dynamicCodeContext
Encapsulation of dynamic code dictionaries.
Definition: dynamicCodeContext.H:53
Foam::codedBase
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
Definition: codedBase.H:67
Foam::codedFixedValuePointPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: codedFixedValuePointPatchField.C:280
Foam::codedFixedValuePointPatchField::codeTemplateC
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
Definition: codedFixedValuePointPatchField.H:144
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::codedFixedValuePointPatchField
Constructs on-the-fly a new boundary condition (derived from fixedValuePointPatchField) which is then...
Definition: codedFixedValuePointPatchField.H:103
Foam::codedFixedValuePointPatchField::clone
virtual autoPtr< pointPatchField< Type > > clone() const
Construct and return a clone.
Definition: codedFixedValuePointPatchField.H:190
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:60
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::fixedValuePointPatchField
A FixedValue boundary condition for pointField.
Definition: fixedValuePointPatchField.H:51
Foam::codedFixedValuePointPatchField::write
virtual void write(Ostream &) const
Write.
Definition: codedFixedValuePointPatchField.C:296
Foam::codedFixedValuePointPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: codedFixedValuePointPatchField.C:257
Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField
codedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Definition: codedFixedValuePointPatchField.C:149
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::codedFixedValuePointPatchField::redirectPatchField
const pointPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
Definition: codedFixedValuePointPatchField.C:229
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fixedValuePointPatchFields.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
codedBase.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::codedFixedValuePointPatchField::codeTemplateH
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
Definition: codedFixedValuePointPatchField.H:148
Foam::codedFixedValuePointPatchField::TypeName
TypeName("codedFixedValue")
Runtime type information.
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54