codedFixedValuePointPatchField.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::codedFixedValuePointPatchField
26 
27 Description
28  Constructs on-the-fly a new boundary condition (derived from
29  fixedValuePointPatchField) which is then used to evaluate.
30 
31  Example:
32  \verbatim
33  movingWall
34  {
35  type codedFixedValue;
36  value uniform 0;
37  name rampedFixedValue; // name of generated bc
38 
39  code
40  #{
41  operator==
42  (
43  vector(0,0,1)
44  *min(10, 0.1*this->db().time().value())
45  );
46  #};
47 
48  // codeInclude
49  //#{
50  // #include "fvCFD.H"
51  //#};
52 
53  // codeOptions
54  //#{
55  // -I$(LIB_SRC)/finiteVolume/lnInclude
56  //#};
57  }
58  \endverbatim
59 
60  A special form is if the \c code section is not supplied. In this case
61  the code gets read from a (runTimeModifiable!) dictionary system/codeDict
62  which would have a corresponding entry
63 
64  \verbatim
65  rampedFixedValue
66  {
67  code
68  #{
69  operator==(min(10, 0.1*this->db().time().value()));
70  #};
71  }
72  \endverbatim
73 
74 See also
75  codedFixedValueFvPatchField
76 
77 SourceFiles
78  codedFixedValuePointPatchField.C
79 
80 \*---------------------------------------------------------------------------*/
81 
82 #ifndef codedFixedValuePointPatchField_H
83 #define codedFixedValuePointPatchField_H
84 
86 #include "CodedBase.H"
87 
88 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
89 
90 namespace Foam
91 {
92 
93 /*---------------------------------------------------------------------------*\
94  Class codedFixedValueFvPatchFieldBase Declaration
95 \*---------------------------------------------------------------------------*/
96 
98 {
99 public:
100 
101  ClassNameNoDebug("fixedValuePointPatchField");
102 };
103 
104 
105 /*---------------------------------------------------------------------------*\
106  Class codedFixedValuePointPatchField Declaration
107 \*---------------------------------------------------------------------------*/
108 
109 template<class Type>
111 :
112  public fixedValuePointPatchField<Type>,
113  public CodedBase<codedFixedValuePointPatchFieldBase>
114 {
115  // Private Data
116 
117  mutable autoPtr<pointPatchField<Type>> redirectPatchFieldPtr_;
118 
119 
120  // Private Member Functions
121 
122  //- Adapt the context for the current object
123  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
124 
125  //- Clear the ptr to the redirected object
126  virtual void clearRedirect() const;
127 
128 
129 public:
130 
131  //- Runtime type information
132  TypeName("codedFixedValue");
133 
134 
135  // Constructors
136 
137  //- Construct from patch and internal field
139  (
140  const pointPatch&,
142  );
143 
144  //- Construct from patch, internal field and dictionary
146  (
147  const pointPatch&,
149  const dictionary&
150  );
151 
152  //- Construct by mapping given codedFixedValuePointPatchField
153  // onto a new patch
155  (
157  const pointPatch&,
159  const pointPatchFieldMapper&
160  );
161 
162  //- Copy constructor
164  (
166  );
167 
168  //- Construct and return a clone
169  virtual autoPtr<pointPatchField<Type>> clone() const
170  {
172  (
174  );
175  }
176 
177  //- Copy constructor setting internal field reference
179  (
182  );
183 
184  //- Construct and return a clone setting internal field reference
186  (
188  ) const
189  {
191  (
193  (
194  *this,
195  iF
196  )
197  );
198  }
199 
200 
201  // Member Functions
202 
203  //- Get reference to the underlying patch
204  const pointPatchField<Type>& redirectPatchField() const;
205 
206  //- Update the coefficients associated with the patch field
207  virtual void updateCoeffs();
208 
209  //- Evaluate the patch field, sets Updated to false
210  virtual void evaluate
211  (
213  );
214 
215  //- Write
216  virtual void write(Ostream&) const;
217 };
218 
219 
220 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
221 
222 } // End namespace Foam
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #ifdef NoRepository
228 #endif
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
commsTypes
Types of communications.
Definition: UPstream.H:64
A FixedValue boundary condition for pointField.
Foam::pointPatchFieldMapper.
ClassNameNoDebug("fixedValuePointPatchField")
Abstract base class for point-mesh patch fields.
T clone(const T &t)
Definition: List.H:54
Constructs on-the-fly a new boundary condition (derived from fixedValuePointPatchField) which is then...
Templated wrapper class to reduce code duplication and simplify maintenance of coded classes...
Definition: CodedBase.H:49
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:70
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
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:56
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Namespace for OpenFOAM.