codedFixedValuePointPatchField.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) 2012-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::codedFixedValuePointPatchField
29 
30 Description
31  Constructs on-the-fly a new boundary condition (derived from
32  fixedValuePointPatchField) which is then used to evaluate.
33 
34  The code entries:
35  \plaintable
36  codeInclude | include files
37  codeOptions | compiler line: added to EXE_INC (Make/options)
38  codeLibs | linker line: added to LIB_LIBS (Make/options)
39  localCode | c++; local static functions
40  code | c++; patch value assignment
41  codeContext | additional dictionary context for the code
42  \endplaintable
43 
44  Example:
45  \verbatim
46  movingWall
47  {
48  type codedFixedValue;
49  value uniform 0;
50  name rampedFixedValue; // name of generated bc
51 
52  code
53  #{
54  operator==
55  (
56  vector(0,0,1) * min(10, 0.1*this->db().time().value())
57  );
58  #};
59 
60  codeContext
61  {
62  ...
63  }
64 
65  //codeInclude
66  //#{
67  // #include "fvCFD.H"
68  //#};
69 
70  //codeOptions
71  //#{
72  // -I$(LIB_SRC)/finiteVolume/lnInclude
73  //#};
74  }
75  \endverbatim
76 
77  A special form is if the \c code section is not supplied. In this case
78  the code gets read from a (runTimeModifiable!) dictionary system/codeDict
79  which would have a corresponding entry
80 
81  \verbatim
82  rampedFixedValue
83  {
84  code
85  #{
86  operator==(min(10, 0.1*this->db().time().value()));
87  #};
88  }
89  \endverbatim
90 
91 Note
92  The code context dictionary can be supplied separately as the
93  \c codeContext entry.
94 
95 See also
96  codedFixedValueFvPatchField
97 
98 SourceFiles
99  codedFixedValuePointPatchField.C
100 
101 \*---------------------------------------------------------------------------*/
102 
103 #ifndef codedFixedValuePointPatchField_H
104 #define codedFixedValuePointPatchField_H
105 
107 #include "codedBase.H"
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 namespace Foam
112 {
113 
114 /*---------------------------------------------------------------------------*\
115  Class codedFixedValuePointPatchField Declaration
116 \*---------------------------------------------------------------------------*/
117 
118 template<class Type>
119 class codedFixedValuePointPatchField
120 :
121  public fixedValuePointPatchField<Type>,
122  protected codedBase
123 {
124  //- The parent boundary condition type
125  typedef fixedValuePointPatchField<Type> parent_bctype;
126 
127 
128  // Private Data
129 
130  //- Dictionary contents for the boundary condition
131  dictionary dict_;
132 
133  const word name_;
134 
135  mutable autoPtr<pointPatchField<Type>> redirectPatchFieldPtr_;
136 
137 
138  // Private Member Functions
139 
140  //- Mutable access to the loaded dynamic libraries
141  virtual dlLibraryTable& libs() const;
142 
143  //- Description (type + name) for the output
144  virtual string description() const;
145 
146  //- Clear redirected object(s)
147  virtual void clearRedirect() const;
148 
149  //- Additional 'codeContext' dictionary to pass through
150  virtual const dictionary& codeContext() const;
151 
152  //- The code dictionary. Inline "code" or from system/codeDict
153  virtual const dictionary& codeDict() const;
154 
155  //- Adapt the context for the current object
156  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
157 
158 
159 public:
160 
161  // Static Data Members
162 
163  //- Name of the C code template to be used
164  static constexpr const char* const codeTemplateC
165  = "fixedValuePointPatchFieldTemplate.C";
166 
167  //- Name of the H code template to be used
168  static constexpr const char* const codeTemplateH
169  = "fixedValuePointPatchFieldTemplate.H";
170 
171 
172  //- Runtime type information
173  TypeName("codedFixedValue");
174 
175 
176  // Constructors
177 
178  //- Construct from patch and internal field
180  (
181  const pointPatch&,
183  );
184 
185  //- Construct from patch, internal field and dictionary
187  (
188  const pointPatch&,
190  const dictionary&,
191  const bool valueRequired=true
192  );
193 
194  //- Construct by mapping given codedFixedValuePointPatchField
195  // onto a new patch
197  (
199  const pointPatch&,
201  const pointPatchFieldMapper&
202  );
203 
204  //- Construct as copy
206  (
208  );
209 
210  //- Construct and return a clone
211  virtual autoPtr<pointPatchField<Type>> clone() const
212  {
214  (
216  );
217  }
218 
219  //- Construct as copy setting internal field reference
221  (
224  );
225 
226  //- Construct and return a clone setting internal field reference
228  (
230  ) const
231  {
233  (
235  (
236  *this,
237  iF
238  )
239  );
240  }
241 
242 
243  // Member functions
244 
245  //- Get reference to the underlying patch
247 
248  //- Update the coefficients associated with the patch field
249  virtual void updateCoeffs();
250 
251  //- Evaluate the patch field, sets Updated 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
270 #endif
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 #endif
275 
276 // ************************************************************************* //
Foam::dlLibraryTable
A table of dynamically loaded libraries.
Definition: dlLibraryTable.H:63
codedFixedValuePointPatchField.C
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::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::codedFixedValuePointPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: codedFixedValuePointPatchField.C:292
Foam::codedFixedValuePointPatchField::codeTemplateC
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
Definition: codedFixedValuePointPatchField.H:188
Foam::pointPatch
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:58
Foam::codedFixedValuePointPatchField
Constructs on-the-fly a new boundary condition (derived from fixedValuePointPatchField) which is then...
Definition: codedFixedValuePointPatchField.H:142
Foam::codedFixedValuePointPatchField::clone
virtual autoPtr< pointPatchField< Type > > clone() const
Construct and return a clone.
Definition: codedFixedValuePointPatchField.H:234
Foam::pointPatchField
Abstract base class for point-mesh patch fields.
Definition: pointMVCWeight.H:60
Foam::pointPatchFieldMapper
Foam::pointPatchFieldMapper.
Definition: pointPatchFieldMapper.H:48
Foam::fixedValuePointPatchField
A FixedValue boundary condition for pointField.
Definition: fixedValuePointPatchField.H:51
Foam::codedFixedValuePointPatchField::write
virtual void write(Ostream &) const
Write.
Definition: codedFixedValuePointPatchField.C:308
Foam::codedFixedValuePointPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: codedFixedValuePointPatchField.C:269
Foam::codedFixedValuePointPatchField::codedFixedValuePointPatchField
codedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Definition: codedFixedValuePointPatchField.C:131
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::codedFixedValuePointPatchField::redirectPatchField
const pointPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
Definition: codedFixedValuePointPatchField.C:224
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
fixedValuePointPatchFields.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
codedBase.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::codedFixedValuePointPatchField::codeTemplateH
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
Definition: codedFixedValuePointPatchField.H:192
Foam::codedFixedValuePointPatchField::TypeName
TypeName("codedFixedValue")
Runtime type information.
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