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 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 (derived from
35  mixedFvPatchField) which is then used to evaluate.
36 
37 Usage
38  Example:
39  \verbatim
40  <patchName>
41  {
42  type codedMixed;
43 
44  refValue uniform (0 0 0);
45  refGradient uniform (0 0 0);
46  valueFraction uniform 1;
47 
48  name rampedMixed; // name of generated BC
49 
50  code
51  #{
52  this->refValue() =
53  vector(1, 0, 0)
54  *min(10, 0.1*this->db().time().value());
55  this->refGrad() = Zero;
56  this->valueFraction() = 1.0;
57  #};
58 
59  //codeInclude
60  //#{
61  // #include "fvCFD.H"
62  //#};
63 
64  //codeOptions
65  //#{
66  // -I$(LIB_SRC)/finiteVolume/lnInclude
67  //#};
68  }
69  \endverbatim
70 
71  A special form is if the 'code' section is not supplied. In this case
72  the code gets read from a (runTimeModifiable!) dictionary system/codeDict
73  which would have a corresponding entry
74 
75  \verbatim
76  <patchName>
77  {
78  code
79  #{
80  this->refValue() = min(10, 0.1*this->db().time().value());
81  this->refGrad() = Zero;
82  this->valueFraction() = 1.0;
83  #};
84  }
85  \endverbatim
86 
87 See also
88  Foam::dynamicCode
89  Foam::functionEntries::codeStream
90 
91 SourceFiles
92  codedMixedFvPatchField.C
93 
94 \*---------------------------------------------------------------------------*/
95 
96 #ifndef codedMixedFvPatchField_H
97 #define codedMixedFvPatchField_H
98 
99 #include "mixedFvPatchFields.H"
100 #include "codedBase.H"
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 namespace Foam
105 {
106 
107 // Forward declaration of classes
108 class dynamicCode;
109 class dynamicCodeContext;
110 class IOdictionary;
111 
112 /*---------------------------------------------------------------------------*\
113  Class codedMixedFvPatchField Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 template<class Type>
118 :
119  public mixedFvPatchField<Type>,
120  public codedBase
121 {
122  // Private data
123 
124  //- Dictionary contents for the boundary condition
125  mutable dictionary dict_;
126 
127  const word name_;
128 
129  mutable autoPtr<mixedFvPatchField<Type>> redirectPatchFieldPtr_;
130 
131 
132  // Private Member Functions
133 
134  const IOdictionary& dict() const;
135 
136  //- Get the loaded dynamic libraries
137  virtual dlLibraryTable& libs() const;
138 
139  //- Adapt the context for the current object
140  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
141 
142  // Return a description (type + name) for the output
143  virtual string description() const;
144 
145  // Clear the ptr to the redirected object
146  virtual void clearRedirect() const;
147 
148  // Get the dictionary to initialize the codeContext
149  virtual const dictionary& codeDict() const;
150 
151 
152 public:
153 
154  // Static Data Members
155 
156  //- Name of the C code template to be used
157  static constexpr const char* const codeTemplateC
158  = "mixedFvPatchFieldTemplate.C";
159 
160  //- Name of the H code template to be used
161  static constexpr const char* const codeTemplateH
162  = "mixedFvPatchFieldTemplate.H";
163 
164 
165  //- Runtime type information
166  TypeName("codedMixed");
167 
168 
169  // Constructors
170 
171  //- Construct from patch and internal field
173  (
174  const fvPatch&,
176  );
177 
178  //- Construct from patch, internal field and dictionary
180  (
181  const fvPatch&,
183  const dictionary&
184  );
185 
186  //- Construct by mapping given codedMixedFvPatchField
187  // onto a new patch
189  (
191  const fvPatch&,
193  const fvPatchFieldMapper&
194  );
195 
196  //- Construct as copy
198  (
200  );
201 
202  //- Construct and return a clone
203  virtual tmp<fvPatchField<Type>> clone() const
204  {
205  return tmp<fvPatchField<Type>>
206  (
208  );
209  }
210 
211  //- Construct as copy setting internal field reference
213  (
216  );
217 
218  //- Construct and return a clone setting internal field reference
220  (
222  ) const
223  {
224  return tmp<fvPatchField<Type>>
225  (
226  new codedMixedFvPatchField<Type>(*this, iF)
227  );
228  }
229 
230 
231  // Member functions
232 
233  //- Get reference to the underlying patchField
235 
236  //- Update the coefficients associated with the patch field
237  virtual void updateCoeffs();
238 
239  //- Evaluate the patch field
240  // This is only needed to set the updated() flag of the name
241  // to false.
242  virtual void evaluate
243  (
245  );
246 
247  //- Write
248  virtual void write(Ostream&) const;
249 };
250 
251 
252 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
253 
254 } // End namespace Foam
255 
256 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 
258 #ifdef NoRepository
259  #include "codedMixedFvPatchField.C"
260 #endif
261 
262 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
263 
264 #endif
265 
266 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::UPstream::commsTypes::blocking
Foam::dlLibraryTable
A table of dynamically loaded libraries.
Definition: dlLibraryTable.H:51
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::dynamicCode
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:59
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
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::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: codedMixedFvPatchField.C:263
Foam::codedMixedFvPatchField::TypeName
TypeName("codedMixed")
Runtime type information.
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Foam::codedMixedFvPatchField::redirectPatchField
const mixedFvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patchField.
Definition: codedMixedFvPatchField.C:227
codedMixedFvPatchField.C
Foam::codedMixedFvPatchField::codedMixedFvPatchField
codedMixedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: codedMixedFvPatchField.C:148
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::codedMixedFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: codedMixedFvPatchField.H:202
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::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:66
Foam::codedMixedFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: codedMixedFvPatchField.C:288
Foam::codedMixedFvPatchField::codeTemplateH
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
Definition: codedMixedFvPatchField.H:161
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:307
Foam::codedMixedFvPatchField
Constructs on-the-fly a new boundary condition (derived from mixedFvPatchField) which is then used to...
Definition: codedMixedFvPatchField.H:116
Foam::codedMixedFvPatchField::codeTemplateC
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
Definition: codedMixedFvPatchField.H:157
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54