Loading...
Searching...
No Matches
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 Foam_codedMixedFvPatchField_H
111#define Foam_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>
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
196 (
197 const fvPatch&,
199 const dictionary&
200 );
201
202 //- Construct by mapping given codedMixedFvPatchField
203 // onto a new patch
205 (
207 const fvPatch&,
209 const fvPatchFieldMapper&
210 );
211
212 //- Construct as copy
214 (
216 );
217
218 //- Construct as copy setting internal field reference
220 (
223 );
224
225 //- Return a clone
226 virtual tmp<fvPatchField<Type>> clone() const
227 {
228 return fvPatchField<Type>::Clone(*this);
229 }
230
231 //- Clone with an internal field reference
233 (
235 ) const
236 {
237 return fvPatchField<Type>::Clone(*this, iF);
238 }
239
240
241 // Member functions
242
243 //- Get reference to the underlying patchField
245
246 //- Update the coefficients associated with the patch field
247 virtual void updateCoeffs();
248
249 //- Evaluate the patch field
250 // This is only needed to set the updated() flag of the name
251 // 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
269 #include "codedMixedFvPatchField.C"
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:59
commsTypes
Communications types.
Definition UPstream.H:81
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
Definition UPstream.H:82
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
Definition codedBase.H:63
codedBase(const codedBase &)=delete
No copy construct.
Constructs on-the-fly a new boundary condition (derived from mixedFvPatchField) which is then used to...
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
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.
codedMixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
virtual tmp< fvPatchField< Type > > clone(const DimensionedField< Type, volMesh > &iF) const
Clone with an 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:133
A table of dynamically loaded libraries.
Encapsulation of dynamic code dictionaries.
Tools for handling dynamic code compilation.
Definition dynamicCode.H:57
A FieldMapper for finite-volume patch fields.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
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,...
mixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
Namespace for OpenFOAM.
runTime write()
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68