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 codedMixedFvPatchField_H
111 #define 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  );
211 
212  //- Construct as copy
214  (
216  );
217 
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  (
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 // ************************************************************************* //
Foam::codedMixedFvPatchField::codeDict
virtual const dictionary & codeDict() const
The code dictionary. Inline "code" or from system/codeDict.
Definition: codedMixedFvPatchField.C:74
Foam::dlLibraryTable
A table of dynamically loaded libraries.
Definition: dlLibraryTable.H:63
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::dynamicCode
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:59
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::dynamicCodeContext
Encapsulation of dynamic code dictionaries.
Definition: dynamicCodeContext.H:53
Foam::codedBase
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
Definition: codedBase.H:66
Foam::codedMixedFvPatchField::prepare
virtual void prepare(dynamicCode &, const dynamicCodeContext &) const
Adapt the context for the current object.
Definition: codedMixedFvPatchField.C:88
Foam::codedMixedFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: codedMixedFvPatchField.C:273
Foam::codedMixedFvPatchField::TypeName
TypeName("codedMixed")
Runtime type information.
Foam::codedMixedFvPatchField::libs
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
Definition: codedMixedFvPatchField.C:39
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::codedMixedFvPatchField::description
virtual string description() const
Description (type + name) for the output.
Definition: codedMixedFvPatchField.C:46
Foam::codedMixedFvPatchField::redirectPatchField
const mixedFvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patchField.
Definition: codedMixedFvPatchField.C:223
codedMixedFvPatchField.C
Foam::codedMixedFvPatchField::codeContext
virtual const dictionary & codeContext() const
Additional 'codeContext' dictionary to pass through.
Definition: codedMixedFvPatchField.C:65
Foam::codedMixedFvPatchField::codedMixedFvPatchField
codedMixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: codedMixedFvPatchField.C:131
Foam::codedMixedFvPatchField::clearRedirect
virtual void clearRedirect() const
Clear redirected object(s)
Definition: codedMixedFvPatchField.C:57
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::codedMixedFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: codedMixedFvPatchField.H:242
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::mixedFvPatchField
This boundary condition provides a base class for 'mixed' type boundary conditions,...
Definition: mixedFvPatchField.H:123
mixedFvPatchFields.H
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::codedMixedFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: codedMixedFvPatchField.C:297
Foam::codedMixedFvPatchField::codeTemplateH
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
Definition: codedMixedFvPatchField.H:201
codedBase.H
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::codedMixedFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: codedMixedFvPatchField.C:316
Foam::codedMixedFvPatchField
Constructs on-the-fly a new boundary condition (derived from mixedFvPatchField) which is then used to...
Definition: codedMixedFvPatchField.H:149
Foam::codedMixedFvPatchField::codeTemplateC
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
Definition: codedMixedFvPatchField.H:197
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::UPstream::commsTypes::blocking