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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-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::codedFixedValueFvPatchField
29
30Group
31 grpGenericBoundaryConditions
32
33Description
34 Constructs on-the-fly a new boundary condition (derived from
35 fixedValueFvPatchField) which is then used to evaluate.
36
37 The code entries:
38 \plaintable
39 codeInclude | include files
40 codeOptions | compiler line: added to EXE_INC (Make/options)
41 codeLibs | linker line: added to LIB_LIBS (Make/options)
42 localCode | c++; local static functions
43 code | c++; patch value assignment
44 codeContext | additional dictionary context for the code
45 \endplaintable
46
47Usage
48 Example:
49 \verbatim
50 <patchName>
51 {
52 type codedFixedValue;
53 value uniform 0;
54 name rampedFixedValue; // name of generated BC
55
56 codeContext
57 {
58 ...
59 }
60
61 code
62 #{
63 operator==(min(10, 0.1*this->db().time().value()));
64 #};
65
66 //codeInclude
67 //#{
68 // #include "fvCFD.H"
69 //#};
70
71 //codeOptions
72 //#{
73 // -I$(LIB_SRC)/finiteVolume/lnInclude
74 //#};
75 }
76 \endverbatim
77
78 A special form is if the 'code' section is not supplied. In this case
79 the code is read from a (runTimeModifiable!) dictionary system/codeDict
80 which would have a corresponding entry:
81
82 \verbatim
83 <patchName>
84 {
85 code
86 #{
87 operator==(min(10, 0.1*this->db().time().value()));
88 #};
89 }
90 \endverbatim
91
92Note
93 The code context dictionary can be supplied separately as the
94 \c codeContext entry.
95
96See also
97 Foam::dynamicCode
98 Foam::functionEntries::codeStream
99
100SourceFiles
101 codedFixedValueFvPatchField.C
102
103\*---------------------------------------------------------------------------*/
104
105#ifndef codedFixedValueFvPatchField_H
106#define codedFixedValueFvPatchField_H
107
109#include "codedBase.H"
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112
113namespace Foam
114{
115
116/*---------------------------------------------------------------------------*\
117 Class codedFixedValueFvPatchField Declaration
118\*---------------------------------------------------------------------------*/
119
120template<class Type>
121class codedFixedValueFvPatchField
122:
123 public fixedValueFvPatchField<Type>,
124 protected codedBase
125{
126 //- The parent boundary condition type
127 typedef fixedValueFvPatchField<Type> parent_bctype;
128
129
130 // Private Data
131
132 //- Dictionary contents for the boundary condition
133 dictionary dict_;
134
135 const word name_;
136
137 mutable autoPtr<fvPatchField<Type>> redirectPatchFieldPtr_;
138
139
140 // Private Member Functions
141
142 //- Mutable access to the loaded dynamic libraries
143 virtual dlLibraryTable& libs() const;
145 //- Description (type + name) for the output
146 virtual string description() const;
147
148 //- Clear redirected object(s)
149 virtual void clearRedirect() const;
150
151 //- Additional 'codeContext' dictionary to pass through
152 virtual const dictionary& codeContext() const;
153
154 //- The code dictionary. Inline "code" or from system/codeDict
155 virtual const dictionary& codeDict() const;
156
157 //- Adapt the context for the current object
158 virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
159
160
161public:
162
163 // Static data members
164
165 //- Name of the C code template to be used
166 static constexpr const char* const codeTemplateC
167 = "fixedValueFvPatchFieldTemplate.C";
168
169 //- Name of the H code template to be used
170 static constexpr const char* const codeTemplateH
171 = "fixedValueFvPatchFieldTemplate.H";
172
173
174 //- Runtime type information
175 TypeName("codedFixedValue");
176
177
178 // Constructors
179
180 //- Construct from patch and internal field
182 (
183 const fvPatch&,
185 );
186
187 //- Construct from patch, internal field and dictionary
190 const fvPatch&,
192 const dictionary&
193 );
194
195 //- Construct by mapping given codedFixedValueFvPatchField
196 // onto a new patch
200 const fvPatch&,
202 const fvPatchFieldMapper&
203 );
204
205 //- Construct as copy
207 (
209 );
210
211 //- Construct and return a clone
212 virtual tmp<fvPatchField<Type>> clone() const
213 {
215 (
217 );
218 }
219
220 //- Construct as copy setting internal field reference
222 (
225 );
226
227 //- Construct and return a clone setting internal field reference
229 (
231 ) const
232 {
234 (
236 );
237 }
238
239
240 // Member functions
241
242 //- Get reference to the underlying patch
244
245 //- Update the coefficients associated with the patch field
246 virtual void updateCoeffs();
247
248 //- Evaluate the patch field, sets Updated to false
249 virtual void evaluate
250 (
252 );
253
254 //- Write
255 virtual void write(Ostream&) const;
256};
257
258
259// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
260
261} // End namespace Foam
262
263// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
264
265#ifdef NoRepository
267#endif
268
269// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
270
271#endif
272
273// ************************************************************************* //
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 fixedValueFvPatchField) which is then us...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
TypeName("codedFixedValue")
Runtime type information.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const fvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
virtual tmp< fvPatchField< Type > > clone(const DimensionedField< Type, volMesh > &iF) const
Construct and return a clone setting internal field reference.
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
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
A FieldMapper for finite-volume patch fields.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:82
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
A class for managing temporary objects.
Definition: tmp.H:65
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