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 -------------------------------------------------------------------------------
11 License
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 
27 Class
28  Foam::codedMixedFvPatchField
29 
30 Group
31  grpGenericBoundaryConditions
32 
33 Description
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 
47 Usage
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 
97 Note
98  The code context dictionary can be supplied separately as the
99  \c codeContext entry.
100 
101 See also
102  Foam::dynamicCode
103  Foam::functionEntries::codeStream
104 
105 SourceFiles
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 
118 namespace Foam
119 {
120 
121 /*---------------------------------------------------------------------------*\
122  Class codedMixedFvPatchField Declaration
123 \*---------------------------------------------------------------------------*/
124 
125 template<class Type>
126 class 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 
145 protected:
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 
168 public:
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  );
212  //- Construct as copy
214  (
216  );
218  //- Construct and return a clone
219  virtual tmp<fvPatchField<Type>> clone() const
220  {
221  return tmp<fvPatchField<Type>>
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  {
240  return tmp<fvPatchField<Type>>
241  (
242  new codedMixedFvPatchField<Type>(*this, iF)
243  );
244  }
245 
246 
247  // Member functions
248 
249  //- Get reference to the underlying patchField
250  const mixedFvPatchField<Type>& redirectPatchField() const;
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
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 #ifdef NoRepository
275  #include "codedMixedFvPatchField.C"
276 #endif
277 
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
279 
280 #endif
281 
282 // ************************************************************************* //
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
"blocking" : (MPI_Bsend, MPI_Recv)
commsTypes
Communications types.
Definition: UPstream.H:72
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual const dictionary & codeContext() const
Additional &#39;codeContext&#39; dictionary to pass through.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
const mixedFvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patchField.
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
A FieldMapper for finite-volume patch fields.
virtual void clearRedirect() const
Clear redirected object(s)
A table of dynamically loaded libraries.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
codedMixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &) const
Write.
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:56
Encapsulation of dynamic code dictionaries.
Constructs on-the-fly a new boundary condition (derived from mixedFvPatchField) which is then used to...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
virtual string description() const
Description (type + name) for the output.
TypeName("codedMixed")
Runtime type information.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
virtual const dictionary & codeDict() const
The code dictionary. Inline "code" or from system/codeDict.
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
virtual void prepare(dynamicCode &, const dynamicCodeContext &) const
Adapt the context for the current object.
Namespace for OpenFOAM.
static constexpr const char *const codeTemplateC
Name of the C code template to be used.