codedFixedValueFvPatchField.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) 2011-2024 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::codedFixedValueFvPatchField
26 
27 Description
28  Constructs on-the-fly a new boundary condition (derived from
29  fixedValueFvPatchField) which is then used to evaluate.
30 
31 Usage
32  Example:
33  \verbatim
34  <patchName>
35  {
36  type codedFixedValue;
37  value uniform 0;
38  name rampedFixedValue; // name of generated BC
39 
40  code
41  #{
42  operator==(min(10, 0.1*this->db().time().value()));
43  #};
44 
45  // codeInclude
46  //#{
47  // #include ".H"
48  //#};
49 
50  // codeOptions
51  //#{
52  // -I$(LIB_SRC)/finiteVolume/lnInclude
53  //#};
54  }
55  \endverbatim
56 
57  A special form is if the 'code' section is not supplied. In this case
58  the code is read from a (runTimeModifiable!) dictionary system/codeDict
59  which would have a corresponding entry:
60 
61  \verbatim
62  <patchName>
63  {
64  code
65  #{
66  operator==(min(10, 0.1*this->db().time().value()));
67  #};
68  }
69  \endverbatim
70 
71 See also
72  Foam::dynamicCode
73  Foam::functionEntries::codeStream
74 
75 SourceFiles
76  codedFixedValueFvPatchField.C
77 
78 \*---------------------------------------------------------------------------*/
79 
80 #ifndef codedFixedValueFvPatchField_H
81 #define codedFixedValueFvPatchField_H
82 
84 #include "codedBase.H"
85 
86 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
87 
88 namespace Foam
89 {
90 
91 /*---------------------------------------------------------------------------*\
92  Class codedFixedValueFvPatchField Declaration
93 \*---------------------------------------------------------------------------*/
94 
95 template<class Type>
97 :
98  public fixedValueFvPatchField<Type>,
99  public codedBase
100 {
101  // Private Data
102 
103  mutable autoPtr<fvPatchField<Type>> redirectPatchFieldPtr_;
104 
105 
106  // Private Member Functions
107 
108  //- Get the keywords associated with source code
109  virtual wordList codeKeys() const;
110 
111  //- Get the name of the dictionary variables in the source code
112  virtual wordList codeDictVars() const;
113 
114  //- Adapt the context for the current object
115  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
116 
117  //- Clear the ptr to the redirected object
118  virtual void clearRedirect() const;
119 
120 
121 public:
122 
123  //- Runtime type information
124  TypeName("codedFixedValue");
125 
126 
127  // Constructors
128 
129  //- Construct from patch, internal field and dictionary
131  (
132  const fvPatch&,
134  const dictionary&
135  );
136 
137  //- Construct by mapping given codedFixedValueFvPatchField
138  // onto a new patch
140  (
142  const fvPatch&,
144  const fieldMapper&
145  );
146 
147 
148  //- Disallow copy without setting internal field reference
150  (
152  ) = delete;
153 
154  //- Copy constructor setting internal field reference
156  (
159  );
160 
161  //- Construct and return a clone setting internal field reference
163  (
165  ) const
166  {
167  return tmp<fvPatchField<Type>>
168  (
169  new codedFixedValueFvPatchField<Type>(*this, iF)
170  );
171  }
172 
173 
174  // Member Functions
175 
176  //- Get reference to the underlying patch
177  const fvPatchField<Type>& redirectPatchField() const;
178 
179  //- Update the coefficients associated with the patch field
180  virtual void updateCoeffs();
181 
182  //- Evaluate the patch field, sets Updated to false
183  virtual void evaluate
184  (
186  );
187 
188  //- Write
189  virtual void write(Ostream&) const;
190 };
191 
192 
193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 
195 } // End namespace Foam
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 #ifdef NoRepository
201 #endif
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #endif
206 
207 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Base class for function objects and boundary conditions using dynamic code.
Definition: codedBase.H:54
Constructs on-the-fly a new boundary condition (derived from fixedValueFvPatchField) which is then us...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
TypeName("codedFixedValue")
Runtime type information.
virtual void write(Ostream &) const
Write.
codedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const fvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patch.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Encapsulation of dynamic code dictionaries.
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:57
Abstract base class for field mapping.
Definition: fieldMapper.H:48
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:204
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.