All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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-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::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 "fvCFD.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 codedFixedValueFvPatchFieldBase Declaration
93 \*---------------------------------------------------------------------------*/
94 
96 {
97 public:
98 
99  ClassNameNoDebug("fixedValueFvPatchField");
100 };
101 
102 
103 /*---------------------------------------------------------------------------*\
104  Class codedFixedValueFvPatchField Declaration
105 \*---------------------------------------------------------------------------*/
106 
107 template<class Type>
109 :
110  public fixedValueFvPatchField<Type>,
111  public CodedBase<codedFixedValueFvPatchFieldBase>
112 {
113  // Private Data
114 
115  mutable autoPtr<fvPatchField<Type>> redirectPatchFieldPtr_;
116 
117 
118  // Private Member Functions
119 
120  //- Adapt the context for the current object
121  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
122 
123  //- Clear the ptr to the redirected object
124  virtual void clearRedirect() const;
125 
126 
127 public:
128 
129  //- Runtime type information
130  TypeName("codedFixedValue");
131 
132 
133  // Constructors
134 
135  //- Construct from patch and internal field
137  (
138  const fvPatch&,
140  );
141 
142  //- Construct from patch, internal field and dictionary
144  (
145  const fvPatch&,
147  const dictionary&
148  );
149 
150  //- Construct by mapping given codedFixedValueFvPatchField
151  // onto a new patch
153  (
155  const fvPatch&,
157  const fvPatchFieldMapper&
158  );
159 
160  //- Copy constructor
162  (
164  );
165 
166  //- Construct and return a clone
167  virtual tmp<fvPatchField<Type>> clone() const
168  {
169  return tmp<fvPatchField<Type>>
170  (
172  );
173  }
174 
175  //- Copy constructor setting internal field reference
177  (
180  );
181 
182  //- Construct and return a clone setting internal field reference
184  (
186  ) const
187  {
188  return tmp<fvPatchField<Type>>
189  (
190  new codedFixedValueFvPatchField<Type>(*this, iF)
191  );
192  }
193 
194 
195  // Member Functions
196 
197  //- Get reference to the underlying patch
198  const fvPatchField<Type>& redirectPatchField() const;
199 
200  //- Update the coefficients associated with the patch field
201  virtual void updateCoeffs();
202 
203  //- Evaluate the patch field, sets Updated to false
204  virtual void evaluate
205  (
207  );
208 
209  //- Write
210  virtual void write(Ostream&) const;
211 };
212 
213 
214 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 
216 } // End namespace Foam
217 
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
219 
220 #ifdef NoRepository
222 #endif
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 #endif
227 
228 // ************************************************************************* //
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
ClassNameNoDebug("fixedValueFvPatchField")
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
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
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
Constructs on-the-fly a new boundary condition (derived from fixedValueFvPatchField) which is then us...
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:56
Encapsulation of dynamic code dictionaries.
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
Namespace for OpenFOAM.