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-2026 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  Mixed boundary condition evaluated from the code provided
29 
30  which is compiled, linked and executed automatically at run-time.
31 
32  The optional \c name entry specifies the name of the code generated from the
33  template, if not provided the it constructed as
34  <field name>_<patch name> for single region cases or
35  <region name>_<field name>_<patch name> for multi-region cases.
36 
37 Usage
38  Example:
39  \verbatim
40  <patchName>
41  {
42  type codedMixed;
43 
44  refValue uniform (0 0 0);
45  refGradient uniform (0 0 0);
46  valueFraction uniform 1;
47 
48  name rampedFixedValue; // Optional name of generated code
49 
50  code
51  #{
52  this->refValue() =
53  vector(1, 0, 0)*min(10, 0.1*this->time().value());
54  this->refGrad() = Zero;
55  this->valueFraction() = 1.0;
56  #};
57 
58  // codeInclude
59  //#{
60  // #include ".H"
61  //#};
62 
63  // codeOptions
64  //#{
65  // -I$(LIB_SRC)/finiteVolume/lnInclude
66  //#};
67  }
68  \endverbatim
69 
70 See also
71  Foam::codedBase
72  Foam::dynamicCode
73 
74 SourceFiles
75  codedMixedFvPatchField.C
76 
77 \*---------------------------------------------------------------------------*/
78 
79 #ifndef codedMixedFvPatchField_H
80 #define codedMixedFvPatchField_H
81 
82 #include "mixedFvPatchFields.H"
83 #include "codedBase.H"
84 
85 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
86 
87 namespace Foam
88 {
89 
90 /*---------------------------------------------------------------------------*\
91  Class codedMixedFvPatchField Declaration
92 \*---------------------------------------------------------------------------*/
93 
94 template<class Type>
96 :
97  public mixedFvPatchField<Type>,
98  public codedBase
99 {
100  // Private Data
101 
102  //- Keywords associated with source code
103  static const wordList codeKeys;
104 
105  //- Name of the dictionary variables in the source code
106  static const wordList codeDictVars;
107 
108  // Name of the code options template file
109  static const word codeOptions;
110 
111  // Names of the source files to compile
112  static const wordList compileFiles;
113 
114  // Names of the source files to copy (header files)
115  static const wordList copyFiles;
116 
117  mutable autoPtr<mixedFvPatchField<Type>> redirectPatchFieldPtr_;
118 
119 
120 public:
121 
122  //- Runtime type information
123  TypeName("codedMixed");
124 
125 
126  // Constructors
127 
128  //- Construct from patch, internal field and dictionary
130  (
131  const fvPatch&,
133  const dictionary&
134  );
135 
136  //- Construct by mapping given codedMixedFvPatchField
137  // onto a new patch
139  (
141  const fvPatch&,
143  const fieldMapper&
144  );
145 
146 
147  //- Disallow copy without setting internal field reference
149 
150  //- Copy constructor setting internal field reference
152  (
155  );
156 
157  //- Construct and return a clone setting internal field reference
159  (
161  ) const
162  {
163  return tmp<fvPatchField<Type>>
164  (
165  new codedMixedFvPatchField<Type>(*this, iF)
166  );
167  }
168 
169 
170  // Member Functions
171 
172  //- Get reference to the underlying patchField
174 
175  //- Update the coefficients associated with the patch field
176  virtual void updateCoeffs();
177 
178  //- Evaluate the patch field
179  // This is only needed to set the updated() flag of the name
180  // to false.
181  virtual void evaluate
182  (
184  );
185 
186  //- Write
187  virtual void write(Ostream&) const;
188 
189 
190  // Member Operators
191 
192  //- Inherit assignment
194 };
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace Foam
200 
201 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
202 
203 #ifdef NoRepository
204  #include "codedMixedFvPatchField.C"
205 #endif
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 #endif
210 
211 // ************************************************************************* //
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 coded functionObjects, fvModels, Function1, Function2.
Definition: codedBase.H:53
Mixed boundary condition evaluated from the code provided.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
codedMixedFvPatchField(const fvPatch &, const DimensionedField< Type, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
virtual void write(Ostream &) const
Write.
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
tmp< fvPatchField< Type > > clone() const
Disallow clone without setting internal field reference.
Definition: fvPatchField.H:215
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
This boundary condition provides a base class for 'mixed' type boundary conditions,...
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.