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 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::codedFixedValueFvPatchField
29 
30 Group
31  grpGenericBoundaryConditions
32 
33 Description
34  Constructs on-the-fly a new boundary condition (derived from
35  fixedValueFvPatchField) which is then used to evaluate.
36 
37 Usage
38  Example:
39  \verbatim
40  <patchName>
41  {
42  type codedFixedValue;
43  value uniform 0;
44  name rampedFixedValue; // name of generated BC
45 
46  code
47  #{
48  operator==(min(10, 0.1*this->db().time().value()));
49  #};
50 
51  //codeInclude
52  //#{
53  // #include "fvCFD.H"
54  //#};
55 
56  //codeOptions
57  //#{
58  // -I$(LIB_SRC)/finiteVolume/lnInclude
59  //#};
60  }
61  \endverbatim
62 
63  A special form is if the 'code' section is not supplied. In this case
64  the code is read from a (runTimeModifiable!) dictionary system/codeDict
65  which would have a corresponding entry:
66 
67  \verbatim
68  <patchName>
69  {
70  code
71  #{
72  operator==(min(10, 0.1*this->db().time().value()));
73  #};
74  }
75  \endverbatim
76 
77 See also
78  Foam::dynamicCode
79  Foam::functionEntries::codeStream
80 
81 SourceFiles
82  codedFixedValueFvPatchField.C
83 
84 \*---------------------------------------------------------------------------*/
85 
86 #ifndef codedFixedValueFvPatchField_H
87 #define codedFixedValueFvPatchField_H
88 
90 #include "codedBase.H"
91 
92 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
93 
94 namespace Foam
95 {
96 
97 // Forward Declarations
98 class IOdictionary;
99 
100 /*---------------------------------------------------------------------------*\
101  Class codedFixedValueFvPatchField Declaration
102 \*---------------------------------------------------------------------------*/
103 
104 template<class Type>
106 :
107  public fixedValueFvPatchField<Type>,
108  protected codedBase
109 {
110  // Private Data
111 
112  //- Dictionary contents for the boundary condition
113  const dictionary dict_;
114 
115  const word name_;
116 
117  mutable autoPtr<fvPatchField<Type>> redirectPatchFieldPtr_;
118 
119 
120  // Private Member Functions
121 
122  const IOdictionary& dict() const;
123 
124  //- Mutable access to the loaded dynamic libraries
125  virtual dlLibraryTable& libs() const;
126 
127  //- Adapt the context for the current object
128  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
129 
130  // Return a description (type + name) for the output
131  virtual string description() const;
132 
133  // Clear the ptr to the redirected object
134  virtual void clearRedirect() const;
135 
136  // Get the dictionary to initialize the codeContext
137  virtual const dictionary& codeDict() const;
138 
139 
140 public:
141 
142  // Static data members
143 
144  //- Name of the C code template to be used
145  static constexpr const char* const codeTemplateC
146  = "fixedValueFvPatchFieldTemplate.C";
147 
148  //- Name of the H code template to be used
149  static constexpr const char* const codeTemplateH
150  = "fixedValueFvPatchFieldTemplate.H";
151 
152 
153  //- Runtime type information
154  TypeName("codedFixedValue");
155 
156 
157  // Constructors
158 
159  //- Construct from patch and internal field
161  (
162  const fvPatch&,
164  );
165 
166  //- Construct from patch, internal field and dictionary
168  (
169  const fvPatch&,
171  const dictionary&
172  );
173 
174  //- Construct by mapping given codedFixedValueFvPatchField
175  // onto a new patch
177  (
179  const fvPatch&,
181  const fvPatchFieldMapper&
182  );
183 
184  //- Construct as copy
186  (
188  );
189 
190  //- Construct and return a clone
191  virtual tmp<fvPatchField<Type>> clone() const
192  {
193  return tmp<fvPatchField<Type>>
194  (
196  );
197  }
198 
199  //- Construct as copy setting internal field reference
201  (
204  );
205 
206  //- Construct and return a clone setting internal field reference
208  (
210  ) const
211  {
212  return tmp<fvPatchField<Type>>
213  (
214  new codedFixedValueFvPatchField<Type>(*this, iF)
215  );
216  }
217 
218 
219  // Member functions
220 
221  //- Get reference to the underlying patch
222  const fvPatchField<Type>& redirectPatchField() const;
223 
224  //- Update the coefficients associated with the patch field
225  virtual void updateCoeffs();
226 
227  //- Evaluate the patch field, sets Updated to false
228  virtual void evaluate
229  (
231  );
232 
233  //- Write
234  virtual void write(Ostream&) const;
235 };
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #ifdef NoRepository
246 #endif
247 
248 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
249 
250 #endif
251 
252 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
Foam::codedFixedValueFvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: codedFixedValueFvPatchField.H:190
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::codedFixedValueFvPatchField::codeTemplateH
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
Definition: codedFixedValueFvPatchField.H:149
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:62
Foam::codedFixedValueFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: codedFixedValueFvPatchField.C:295
Foam::codedFixedValueFvPatchField::codeTemplateC
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
Definition: codedFixedValueFvPatchField.H:145
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:67
Foam::codedFixedValueFvPatchField::TypeName
TypeName("codedFixedValue")
Runtime type information.
Foam::codedFixedValueFvPatchField::redirectPatchField
const fvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
Definition: codedFixedValueFvPatchField.C:228
Foam::codedFixedValueFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: codedFixedValueFvPatchField.C:279
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:80
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
codedFixedValueFvPatchField.C
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::codedFixedValueFvPatchField::codedFixedValueFvPatchField
codedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: codedFixedValueFvPatchField.C:149
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:69
fixedValueFvPatchFields.H
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::codedFixedValueFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: codedFixedValueFvPatchField.C:256
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::codedFixedValueFvPatchField
Constructs on-the-fly a new boundary condition (derived from fixedValueFvPatchField) which is then us...
Definition: codedFixedValueFvPatchField.H:104