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-2023 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 \c value entry (optional) is used for the initial values.
35  Otherwise the code is executed.
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  Example:
48  \verbatim
49  movingWall
50  {
51  type codedFixedValue;
52  value uniform 0;
53  name rampedFixedValue; // name of generated bc
54 
55  code
56  #{
57  operator==
58  (
59  vector(0,0,1) * min(10, 0.1*this->db().time().value())
60  );
61  #};
62 
63  codeContext
64  {
65  ...
66  }
67 
68  //codeInclude
69  //#{
70  // #include "fvCFD.H"
71  //#};
72 
73  //codeOptions
74  //#{
75  // -I$(LIB_SRC)/finiteVolume/lnInclude
76  //#};
77  }
78  \endverbatim
79 
80  A special form is if the \c code section is not supplied. In this case
81  the code gets read from a (runTimeModifiable!) dictionary system/codeDict
82  which would have a corresponding entry
83 
84  \verbatim
85  rampedFixedValue
86  {
87  code
88  #{
89  operator==(min(10, 0.1*this->db().time().value()));
90  #};
91  }
92  \endverbatim
93 
94 Note
95  The code context dictionary can be supplied separately as the
96  \c codeContext entry.
97 
98 See also
99  codedFixedValueFvPatchField
100 
101 SourceFiles
102  codedFixedValuePointPatchField.txx
103 
104 \*---------------------------------------------------------------------------*/
105 
106 #ifndef Foam_codedFixedValuePointPatchField_H
107 #define Foam_codedFixedValuePointPatchField_H
108 
110 #include "codedBase.H"
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 namespace Foam
115 {
116 
117 /*---------------------------------------------------------------------------*\
118  Class codedFixedValuePointPatchField Declaration
119 \*---------------------------------------------------------------------------*/
120 
121 template<class Type>
122 class codedFixedValuePointPatchField
123 :
124  public fixedValuePointPatchField<Type>,
125  protected codedBase
126 {
127  typedef codedFixedValuePointPatchField<Type> this_bctype;
128  typedef fixedValuePointPatchField<Type> parent_bctype;
129 
130 
131  // Private Data
132 
133  //- Dictionary contents for the boundary condition
134  dictionary dict_;
135 
136  const word name_;
137 
138  mutable autoPtr<pointPatchField<Type>> redirectPatchFieldPtr_;
139 
140 
141  // Private Member Functions
142 
143  //- Mutable access to the loaded dynamic libraries
144  virtual dlLibraryTable& libs() const;
145 
146  //- Description (type + name) for the output
147  virtual string description() const;
148 
149  //- Clear redirected object(s)
150  virtual void clearRedirect() const;
151 
152  //- Additional 'codeContext' dictionary to pass through
153  virtual const dictionary& codeContext() const;
154 
155  //- The code dictionary. Inline "code" or from system/codeDict
156  virtual const dictionary& codeDict() const;
157 
158  //- Adapt the context for the current object
159  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
160 
161 
162 public:
163 
164  // Static Data Members
165 
166  //- Name of the C code template to be used
167  static constexpr const char* const codeTemplateC
168  = "fixedValuePointPatchFieldTemplate.C";
169 
170  //- Name of the H code template to be used
171  static constexpr const char* const codeTemplateH
172  = "fixedValuePointPatchFieldTemplate.H";
173 
174 
175  //- Runtime type information
176  TypeName("codedFixedValue");
177 
178 
179  // Constructors
180 
181  //- Construct from patch and internal field
183  (
184  const pointPatch&,
186  );
187 
188  //- Construct from patch, internal field and dictionary
190  (
191  const pointPatch&,
193  const dictionary&
194  );
195 
196  //- Construct by mapping onto a new patch
198  (
199  const this_bctype&,
200  const pointPatch&,
202  const pointPatchFieldMapper&
203  );
204 
205  //- Construct as copy setting internal field reference
207  (
208  const this_bctype&,
210  );
211 
212  //- No copy without an internal field
214 
215  //- Clone with an internal field reference
217  (
219  ) const
220  {
221  return pointPatchField<Type>::Clone(*this, iF);
222  }
223 
224 
225  // Member functions
226 
227  //- Get reference to the underlying patch
229 
230  //- Update the coefficients associated with the patch field
231  virtual void updateCoeffs();
232 
233  //- Evaluate the patch field, sets updated() to false
234  virtual void evaluate
235  (
237  );
238 
239  //- Write
240  virtual void write(Ostream&) const;
241 
242 
243  // Member Operators
244 
245  //- Inherit assignment
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #ifdef NoRepository
257  #include "codedFixedValuePointPatchField.txx"
258 #endif
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
commsTypes
Communications types.
Definition: UPstream.H:81
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:130
codedFixedValuePointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
A FixedValue boundary condition for pointField.
const pointPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
Foam::pointPatchFieldMapper.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
Abstract base class for point-mesh patch fields.
friend Ostream & operator(Ostream &, const Field< Type > &)
TypeName("codedFixedValue")
Runtime type information.
tmp< Field< Type > > clone() const
Clone.
Definition: FieldI.H:140
virtual void write(Ostream &) const
Write.
static autoPtr< pointPatchField< Type > > Clone(const DerivedPatchField &pf, Args &&... args)
Clone a patch field, optionally with internal field reference etc.
A table of dynamically loaded libraries.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:56
Encapsulation of dynamic code dictionaries.
Basic pointPatch represents a set of points from the mesh.
Definition: pointPatch.H:64
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
"buffered" : (MPI_Bsend, MPI_Recv)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
Namespace for OpenFOAM.