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-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::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 "fvCFD.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 codedMixedFvPatchFieldBase Declaration
103 \*---------------------------------------------------------------------------*/
106 {
107 public:
108 
109  ClassNameNoDebug("mixedFvPatchField");
110 };
111 
112 
113 /*---------------------------------------------------------------------------*\
114  Class codedMixedFvPatchField Declaration
115 \*---------------------------------------------------------------------------*/
116 
117 template<class Type>
119 :
120  public mixedFvPatchField<Type>,
121  public CodedBase<codedMixedFvPatchFieldBase>
122 {
123  // Private Data
124 
125  mutable autoPtr<mixedFvPatchField<Type>> redirectPatchFieldPtr_;
126 
127 
128  // Private Member Functions
129 
130  //- Adapt the context for the current object
131  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
132 
133  //- Clear the ptr to the redirected object
134  virtual void clearRedirect() const;
135 
136 
137 public:
138 
139  //- Runtime type information
140  TypeName("codedMixed");
141 
142 
143  // Constructors
144 
145  //- Construct from patch and internal field
147  (
148  const fvPatch&,
150  );
151 
152  //- Construct from patch, internal field and dictionary
154  (
155  const fvPatch&,
157  const dictionary&
158  );
159 
160  //- Construct by mapping given codedMixedFvPatchField
161  // onto a new patch
163  (
165  const fvPatch&,
167  const fvPatchFieldMapper&
168  );
169 
170  //- Copy constructor
172  (
174  );
175 
176  //- Construct and return a clone
177  virtual tmp<fvPatchField<Type>> clone() const
178  {
179  return tmp<fvPatchField<Type>>
180  (
182  );
183  }
184 
185  //- Copy constructor setting internal field reference
187  (
190  );
191 
192  //- Construct and return a clone setting internal field reference
194  (
196  ) const
197  {
198  return tmp<fvPatchField<Type>>
199  (
200  new codedMixedFvPatchField<Type>(*this, iF)
201  );
202  }
203 
204 
205  // Member Functions
206 
207  //- Get reference to the underlying patchField
208  const mixedFvPatchField<Type>& redirectPatchField() const;
209 
210  //- Update the coefficients associated with the patch field
211  virtual void updateCoeffs();
212 
213  //- Evaluate the patch field
214  // This is only needed to set the updated() flag of the name
215  // to false.
216  virtual void evaluate
217  (
219  );
220 
221  //- Write
222  virtual void write(Ostream&) const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #ifdef NoRepository
233  #include "codedMixedFvPatchField.C"
234 #endif
235 
236 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
237 
238 #endif
239 
240 // ************************************************************************* //
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 finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
This boundary condition provides a base class for &#39;mixed&#39; type boundary conditions, i.e. conditions that mix fixed value and patch-normal gradient conditions.
T clone(const T &t)
Definition: List.H:54
Templated wrapper class to reduce code duplication and simplify maintenance of coded classes...
Definition: CodedBase.H:49
Foam::fvPatchFieldMapper.
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.
Constructs on-the-fly a new boundary condition (derived from mixedFvPatchField) which is then used to...
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
A class for managing temporary objects.
Definition: PtrList.H:53
ClassNameNoDebug("mixedFvPatchField")
Namespace for OpenFOAM.