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-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::codedFixedValuePointPatchField
29
30Description
31 Constructs on-the-fly a new boundary condition (derived from
32 fixedValuePointPatchField) which is then used to evaluate.
33
34 The code entries:
35 \plaintable
36 codeInclude | include files
37 codeOptions | compiler line: added to EXE_INC (Make/options)
38 codeLibs | linker line: added to LIB_LIBS (Make/options)
39 localCode | c++; local static functions
40 code | c++; patch value assignment
41 codeContext | additional dictionary context for the code
42 \endplaintable
43
44 Example:
45 \verbatim
46 movingWall
47 {
48 type codedFixedValue;
49 value uniform 0;
50 name rampedFixedValue; // name of generated bc
51
52 code
53 #{
54 operator==
55 (
56 vector(0,0,1) * min(10, 0.1*this->db().time().value())
57 );
58 #};
59
60 codeContext
61 {
62 ...
63 }
64
65 //codeInclude
66 //#{
67 // #include "fvCFD.H"
68 //#};
69
70 //codeOptions
71 //#{
72 // -I$(LIB_SRC)/finiteVolume/lnInclude
73 //#};
74 }
75 \endverbatim
76
77 A special form is if the \c code section is not supplied. In this case
78 the code gets read from a (runTimeModifiable!) dictionary system/codeDict
79 which would have a corresponding entry
80
81 \verbatim
82 rampedFixedValue
83 {
84 code
85 #{
86 operator==(min(10, 0.1*this->db().time().value()));
87 #};
88 }
89 \endverbatim
90
91Note
92 The code context dictionary can be supplied separately as the
93 \c codeContext entry.
94
95See also
96 codedFixedValueFvPatchField
97
98SourceFiles
99 codedFixedValuePointPatchField.C
100
101\*---------------------------------------------------------------------------*/
102
103#ifndef codedFixedValuePointPatchField_H
104#define codedFixedValuePointPatchField_H
105
107#include "codedBase.H"
108
109// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110
111namespace Foam
112{
113
114/*---------------------------------------------------------------------------*\
115 Class codedFixedValuePointPatchField Declaration
116\*---------------------------------------------------------------------------*/
117
118template<class Type>
119class codedFixedValuePointPatchField
120:
121 public fixedValuePointPatchField<Type>,
122 protected codedBase
123{
124 //- The parent boundary condition type
125 typedef fixedValuePointPatchField<Type> parent_bctype;
126
127
128 // Private Data
129
130 //- Dictionary contents for the boundary condition
131 dictionary dict_;
132
133 const word name_;
134
135 mutable autoPtr<pointPatchField<Type>> redirectPatchFieldPtr_;
136
137
138 // Private Member Functions
139
140 //- Mutable access to the loaded dynamic libraries
141 virtual dlLibraryTable& libs() const;
143 //- Description (type + name) for the output
144 virtual string description() const;
145
146 //- Clear redirected object(s)
147 virtual void clearRedirect() const;
148
149 //- Additional 'codeContext' dictionary to pass through
150 virtual const dictionary& codeContext() const;
151
152 //- The code dictionary. Inline "code" or from system/codeDict
153 virtual const dictionary& codeDict() const;
154
155 //- Adapt the context for the current object
156 virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
157
158
159public:
160
161 // Static Data Members
162
163 //- Name of the C code template to be used
164 static constexpr const char* const codeTemplateC
165 = "fixedValuePointPatchFieldTemplate.C";
166
167 //- Name of the H code template to be used
168 static constexpr const char* const codeTemplateH
169 = "fixedValuePointPatchFieldTemplate.H";
170
171
172 //- Runtime type information
173 TypeName("codedFixedValue");
174
175
176 // Constructors
177
178 //- Construct from patch and internal field
180 (
181 const pointPatch&,
183 );
184
185 //- Construct from patch, internal field and dictionary
188 const pointPatch&,
190 const dictionary&,
191 const bool valueRequired=true
192 );
193
194 //- Construct by mapping given codedFixedValuePointPatchField
195 // onto a new patch
197 (
199 const pointPatch&,
202 );
203
204 //- Construct as copy
206 (
208 );
209
210 //- Construct and return a clone
211 virtual autoPtr<pointPatchField<Type>> clone() const
212 {
214 (
216 );
217 }
218
219 //- Construct as copy setting internal field reference
221 (
224 );
225
226 //- Construct and return a clone setting internal field reference
228 (
230 ) const
231 {
233 (
235 (
236 *this,
237 iF
238 )
239 );
240 }
241
242
243 // Member functions
244
245 //- Get reference to the underlying patch
247
248 //- Update the coefficients associated with the patch field
249 virtual void updateCoeffs();
251 //- Evaluate the patch field, sets Updated to false
252 virtual void evaluate
253 (
255 );
256
257 //- Write
258 virtual void write(Ostream&) const;
259};
260
261
262// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263
264} // End namespace Foam
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268#ifdef NoRepository
270#endif
271
272// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273
274#endif
275
276// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
commsTypes
Types of communications.
Definition: UPstream.H:67
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
Definition: codedBase.H:67
Constructs on-the-fly a new boundary condition (derived from fixedValuePointPatchField) which is then...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
TypeName("codedFixedValue")
Runtime type information.
const pointPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
virtual autoPtr< pointPatchField< Type > > clone(const DimensionedField< Type, pointMesh > &iF) const
Construct and return a clone setting internal field reference.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
virtual autoPtr< pointPatchField< Type > > clone() const
Construct and return a clone.
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A table of dynamically loaded libraries.
Encapsulation of dynamic code dictionaries.
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:60
A FixedValue boundary condition for pointField.
Foam::pointPatchFieldMapper.
Abstract base class for point-mesh patch fields.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
runTime write()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73