codedMixedFvPatchField.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::codedMixedFvPatchField
29
30Group
31 grpGenericBoundaryConditions
32
33Description
34 Constructs on-the-fly a new boundary condition
35 (derived from mixedFvPatchField) 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 codedMixed;
53
54 refValue uniform (0 0 0);
55 refGradient uniform (0 0 0);
56 valueFraction uniform 1;
57
58 name rampedMixed; // name of generated BC
59
60 code
61 #{
62 this->refValue() =
63 vector(1, 0, 0)
64 *min(10, 0.1*this->db().time().value());
65 this->refGrad() = Zero;
66 this->valueFraction() = 1.0;
67 #};
68
69 //codeInclude
70 //#{
71 // #include "fvCFD.H"
72 //#};
73
74 //codeOptions
75 //#{
76 // -I$(LIB_SRC)/finiteVolume/lnInclude
77 //#};
78 }
79 \endverbatim
80
81 A special form is if the 'code' section is not supplied. In this case
82 the code gets read from a (runTimeModifiable!) dictionary system/codeDict
83 which would have a corresponding entry
84
85 \verbatim
86 <patchName>
87 {
88 code
89 #{
90 this->refValue() = min(10, 0.1*this->db().time().value());
91 this->refGrad() = Zero;
92 this->valueFraction() = 1.0;
93 #};
94 }
95 \endverbatim
96
97Note
98 The code context dictionary can be supplied separately as the
99 \c codeContext entry.
100
101See also
102 Foam::dynamicCode
103 Foam::functionEntries::codeStream
104
105SourceFiles
106 codedMixedFvPatchField.C
107
108\*---------------------------------------------------------------------------*/
109
110#ifndef codedMixedFvPatchField_H
111#define codedMixedFvPatchField_H
112
113#include "mixedFvPatchFields.H"
114#include "codedBase.H"
115
116// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117
118namespace Foam
119{
120
121/*---------------------------------------------------------------------------*\
122 Class codedMixedFvPatchField Declaration
123\*---------------------------------------------------------------------------*/
124
125template<class Type>
126class codedMixedFvPatchField
127:
128 public mixedFvPatchField<Type>,
129 public codedBase
130{
131 //- The parent boundary condition type
132 typedef mixedFvPatchField<Type> parent_bctype;
133
134
135 // Private Data
136
137 //- Dictionary contents for the boundary condition
138 dictionary dict_;
139
140 const word name_;
141
142 mutable autoPtr<mixedFvPatchField<Type>> redirectPatchFieldPtr_;
143
144
145protected:
146
147 // Protected Member Functions
148
149 //- Mutable access to the loaded dynamic libraries
150 virtual dlLibraryTable& libs() const;
151
152 //- Description (type + name) for the output
153 virtual string description() const;
154
155 //- Clear redirected object(s)
156 virtual void clearRedirect() const;
157
158 //- Additional 'codeContext' dictionary to pass through
159 virtual const dictionary& codeContext() const;
160
161 //- The code dictionary. Inline "code" or from system/codeDict
162 virtual const dictionary& codeDict() const;
163
164 //- Adapt the context for the current object
165 virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
166
167
168public:
169
170 // Static Data Members
171
172 //- Name of the C code template to be used
173 static constexpr const char* const codeTemplateC
174 = "mixedFvPatchFieldTemplate.C";
175
176 //- Name of the H code template to be used
177 static constexpr const char* const codeTemplateH
178 = "mixedFvPatchFieldTemplate.H";
179
180
181 //- Runtime type information
182 TypeName("codedMixed");
183
184
185 // Constructors
186
187 //- Construct from patch and internal field
189 (
190 const fvPatch&,
192 );
193
194 //- Construct from patch, internal field and dictionary
197 const fvPatch&,
199 const dictionary&
200 );
201
202 //- Construct by mapping given codedMixedFvPatchField
203 // onto a new patch
207 const fvPatch&,
209 const fvPatchFieldMapper&
210 );
211
212 //- Construct as copy
214 (
216 );
217
218 //- Construct and return a clone
219 virtual tmp<fvPatchField<Type>> clone() const
220 {
222 (
224 );
225 }
226
227 //- Construct as copy setting internal field reference
229 (
232 );
233
234 //- Construct and return a clone setting internal field reference
236 (
238 ) const
239 {
241 (
243 );
244 }
245
246
247 // Member functions
248
249 //- Get reference to the underlying patchField
251
252 //- Update the coefficients associated with the patch field
253 virtual void updateCoeffs();
254
255 //- Evaluate the patch field
256 // This is only needed to set the updated() flag of the name
257 // to false.
258 virtual void evaluate
259 (
261 );
262
263 //- Write
264 virtual void write(Ostream&) const;
265};
266
267
268// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269
270} // End namespace Foam
271
272// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273
274#ifdef NoRepository
275 #include "codedMixedFvPatchField.C"
276#endif
277
278// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279
280#endif
281
282// ************************************************************************* //
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 mixedFvPatchField) which is then used to...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual const dictionary & codeContext() const
Additional 'codeContext' dictionary to pass through.
virtual void prepare(dynamicCode &, const dynamicCodeContext &) const
Adapt the context for the current object.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
TypeName("codedMixed")
Runtime type information.
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
virtual const dictionary & codeDict() const
The code dictionary. Inline "code" or from system/codeDict.
const mixedFvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patchField.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
virtual void clearRedirect() const
Clear redirected object(s)
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
virtual tmp< fvPatchField< Type > > clone(const DimensionedField< Type, volMesh > &iF) const
Construct and return a clone setting internal field reference.
virtual string description() const
Description (type + name) for the output.
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 FieldMapper for finite-volume patch fields.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
This boundary condition provides a base class for 'mixed' type boundary conditions,...
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