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 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
244  const mixedFvPatchField<Type>& redirectPatchField() const;
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 // ************************************************************************* //
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
commsTypes
Communications types.
Definition: UPstream.H:77
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.
static tmp< fvPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
Definition: fvPatchField.H:597
A FieldMapper for finite-volume patch fields.
virtual void clearRedirect() const
Clear redirected object(s)
A table of dynamically loaded libraries.
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...
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
"buffered" : (MPI_Bsend, MPI_Recv)
virtual const dictionary & codeDict() const
The code dictionary. Inline "code" or from system/codeDict.
virtual tmp< fvPatchField< Type > > clone() const
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.