codedMixedFvPatchField.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-2023 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::codedMixedFvPatchField
26 
27 Description
28  Constructs on-the-fly a new boundary condition (derived from
29  mixedFvPatchField) which is then used to evaluate.
30 
31 Usage
32  Example:
33  \verbatim
34  <patchName>
35  {
36  type codedMixed;
37 
38  refValue uniform (0 0 0);
39  refGradient uniform (0 0 0);
40  valueFraction uniform 1;
41 
42  name rampedMixed; // name of generated BC
43 
44  code
45  #{
46  this->refValue() =
47  vector(1, 0, 0)
48  *min(10, 0.1*this->db().time().value());
49  this->refGrad() = Zero;
50  this->valueFraction() = 1.0;
51  #};
52 
53  // codeInclude
54  //#{
55  // #include ".H"
56  //#};
57 
58  // codeOptions
59  //#{
60  // -I$(LIB_SRC)/finiteVolume/lnInclude
61  //#};
62  }
63  \endverbatim
64 
65  A special form is if the 'code' section is not supplied. In this case
66  the code gets read from a (runTimeModifiable!) dictionary system/codeDict
67  which would have a corresponding entry
68 
69  \verbatim
70  <patchName>
71  {
72  code
73  #{
74  this->refValue() = min(10, 0.1*this->db().time().value());
75  this->refGrad() = Zero;
76  this->valueFraction() = 1.0;
77  #};
78  }
79  \endverbatim
80 
81 See also
82  Foam::dynamicCode
83  Foam::functionEntries::codeStream
84 
85 SourceFiles
86  codedMixedFvPatchField.C
87 
88 \*---------------------------------------------------------------------------*/
89 
90 #ifndef codedMixedFvPatchField_H
91 #define codedMixedFvPatchField_H
92 
93 #include "mixedFvPatchFields.H"
94 #include "codedBase.H"
95 
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 
98 namespace Foam
99 {
100 
101 /*---------------------------------------------------------------------------*\
102  Class codedMixedFvPatchField Declaration
103 \*---------------------------------------------------------------------------*/
104 
105 template<class Type>
107 :
108  public mixedFvPatchField<Type>,
109  public codedBase
110 {
111  // Private Data
112 
113  mutable autoPtr<mixedFvPatchField<Type>> redirectPatchFieldPtr_;
114 
115 
116  // Private Member Functions
117 
118  //- Get the keywords associated with source code
119  virtual wordList codeKeys() const;
120 
121  //- Adapt the context for the current object
122  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
123 
124  //- Clear the ptr to the redirected object
125  virtual void clearRedirect() const;
126 
127 
128 public:
129 
130  //- Runtime type information
131  TypeName("codedMixed");
132 
133 
134  // Constructors
135 
136  //- Construct from patch, internal field and dictionary
138  (
139  const fvPatch&,
141  const dictionary&
142  );
143 
144  //- Construct by mapping given codedMixedFvPatchField
145  // onto a new patch
147  (
149  const fvPatch&,
151  const fvPatchFieldMapper&
152  );
153 
154 
155  //- Disallow copy without setting internal field reference
157 
158  //- Copy constructor setting internal field reference
160  (
163  );
164 
165  //- Construct and return a clone setting internal field reference
167  (
169  ) const
170  {
171  return tmp<fvPatchField<Type>>
172  (
173  new codedMixedFvPatchField<Type>(*this, iF)
174  );
175  }
176 
177 
178  // Member Functions
179 
180  //- Get reference to the underlying patchField
182 
183  //- Update the coefficients associated with the patch field
184  virtual void updateCoeffs();
185 
186  //- Evaluate the patch field
187  // This is only needed to set the updated() flag of the name
188  // to false.
189  virtual void evaluate
190  (
192  );
193 
194  //- Write
195  virtual void write(Ostream&) const;
196 };
197 
198 
199 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200 
201 } // End namespace Foam
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 #ifdef NoRepository
206  #include "codedMixedFvPatchField.C"
207 #endif
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 #endif
212 
213 // ************************************************************************* //
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 mixedFvPatchField) which is then used to...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual void write(Ostream &) const
Write.
codedMixedFvPatchField(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.
TypeName("codedMixed")
Runtime type information.
const mixedFvPatchField< Type > & redirectPatchField() const
Get reference to the underlying patchField.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
Encapsulation of dynamic code dictionaries.
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:57
Foam::fvPatchFieldMapper.
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:203
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
This boundary condition provides a base class for 'mixed' type boundary conditions,...
A class for managing temporary objects.
Definition: tmp.H:55
Namespace for OpenFOAM.