Loading...
Searching...
No Matches
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 \c value entry (optional) is used for the initial values.
38 Otherwise the code is executed.
39
40 The code entries:
41 \plaintable
42 codeInclude | include files
43 codeOptions | compiler line: added to EXE_INC (Make/options)
44 codeLibs | linker line: added to LIB_LIBS (Make/options)
45 localCode | c++; local static functions
46 code | c++; patch value assignment
47 codeContext | additional dictionary context for the code
48 \endplaintable
49
50Usage
51 Example:
52 \verbatim
53 <patchName>
54 {
55 type codedFixedValue;
56 value uniform 0;
57 name rampedFixedValue; // name of generated BC
58
59 codeContext
60 {
61 ...
62 }
63
64 code
65 #{
66 operator==(min(10, 0.1*this->db().time().value()));
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 is read from a (runTimeModifiable!) dictionary system/codeDict
83 which would have a corresponding entry:
84
85 \verbatim
86 <patchName>
87 {
88 code
89 #{
90 operator==(min(10, 0.1*this->db().time().value()));
91 #};
92 }
93 \endverbatim
94
95Note
96 The code context dictionary can be supplied separately as the
97 \c codeContext entry.
98
99See also
100 Foam::dynamicCode
101 Foam::functionEntries::codeStream
102
103SourceFiles
104 codedFixedValueFvPatchField.C
105
106\*---------------------------------------------------------------------------*/
107
108#ifndef Foam_codedFixedValueFvPatchField_H
109#define Foam_codedFixedValueFvPatchField_H
110
112#include "codedBase.H"
113
114// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
115
116namespace Foam
117{
118
119/*---------------------------------------------------------------------------*\
120 Class codedFixedValueFvPatchField Declaration
121\*---------------------------------------------------------------------------*/
122
123template<class Type>
125:
126 public fixedValueFvPatchField<Type>,
127 protected codedBase
128{
129 //- The parent boundary condition type
130 typedef fixedValueFvPatchField<Type> parent_bctype;
131
132
133 // Private Data
134
135 //- Dictionary contents for the boundary condition
136 dictionary dict_;
137
138 const word name_;
139
140 mutable autoPtr<fvPatchField<Type>> redirectPatchFieldPtr_;
141
142
143 // Private Member Functions
144
145 //- Mutable access to the loaded dynamic libraries
146 virtual dlLibraryTable& libs() const;
147
148 //- Description (type + name) for the output
149 virtual string description() const;
150
151 //- Clear redirected object(s)
152 virtual void clearRedirect() const;
153
154 //- Additional 'codeContext' dictionary to pass through
155 virtual const dictionary& codeContext() const;
156
157 //- The code dictionary. Inline "code" or from system/codeDict
158 virtual const dictionary& codeDict() const;
159
160 //- Adapt the context for the current object
161 virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
162
163
164public:
165
166 // Static data members
167
168 //- Name of the C code template to be used
169 static constexpr const char* const codeTemplateC
170 = "fixedValueFvPatchFieldTemplate.C";
171
172 //- Name of the H code template to be used
173 static constexpr const char* const codeTemplateH
174 = "fixedValueFvPatchFieldTemplate.H";
175
176
177 //- Runtime type information
178 TypeName("codedFixedValue");
179
180
181 // Constructors
182
183 //- Construct from patch and internal field
185 (
186 const fvPatch&,
188 );
189
190 //- Construct from patch, internal field and dictionary
192 (
193 const fvPatch&,
195 const dictionary&
196 );
197
198 //- Construct by mapping given codedFixedValueFvPatchField
199 // onto a new patch
201 (
203 const fvPatch&,
205 const fvPatchFieldMapper&
206 );
207
208 //- Construct as copy
210 (
212 );
213
214 //- Construct as copy setting internal field reference
216 (
219 );
220
221 //- Return a clone
222 virtual tmp<fvPatchField<Type>> clone() const
223 {
224 return fvPatchField<Type>::Clone(*this);
225 }
226
227 //- Clone with an internal field reference
229 (
231 ) const
232 {
233 return fvPatchField<Type>::Clone(*this, iF);
234 }
235
236
237 // Member functions
238
239 //- Get reference to the underlying patch
241
242 //- Update the coefficients associated with the patch field
243 virtual void updateCoeffs();
244
245 //- Evaluate the patch field, sets updated() to false
246 virtual void evaluate
247 (
249 );
250
251 //- Write
252 virtual void write(Ostream&) const;
253};
254
255
256// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257
258} // End namespace Foam
259
260// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261
262#ifdef NoRepository
264#endif
265
266// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267
268#endif
269
270// ************************************************************************* //
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
virtual void clearRedirect() const =0
codedBase(const codedBase &)=delete
No copy construct.
virtual dlLibraryTable & libs() const =0
Mutable access to the loaded dynamic libraries.
virtual string description() const =0
virtual const dictionary & codeDict() const =0
dynamicCodeContext & codeContext()
Access to the dynamic code context.
Definition codedBase.H:131
Constructs on-the-fly a new boundary condition (derived from fixedValueFvPatchField) which is then us...
TypeName("codedFixedValue")
Runtime type information.
codedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
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
Return a clone.
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
virtual tmp< fvPatchField< Type > > clone(const DimensionedField< Type, volMesh > &iF) const
Clone with an internal field reference.
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
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
fixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
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...
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
fvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
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