Zonal_DimensionedFieldFunction.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) 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::DimensionedFieldFunctions::Zonal
26 
27 Description
28  Zonal internal and patch field initialisation function
29 
30  The field is initialised to the given \c defaultValue and then updated to
31  the \c value provided for each zone (cellZones for the internalField of
32  volFields or faceZones for patchFields).
33 
34 Usage
35  To set the water column in the \c alpha.water field for the damBreak cases
36  specifying a default value of 0 and a value of 1 in a \c box \c cellZone:
37  \verbatim
38  internalField
39  {
40  type zonal;
41 
42  defaultValue 0;
43 
44  zones
45  {
46  waterColumn
47  {
48  type box;
49 
50  box (0 0 -1) (0.1461 0.292 1);
51 
52  value 1;
53  }
54  }
55  }
56  \endverbatim
57 
58  The value of inlet and other fixed value patch fields can be specified using
59  DimensionedFieldFunctions::Zonal with the Foam::functionalFixedValue patch
60  field. It is also possible to use the same zone specification as used for
61  the internalField initialisation and filter it using the patch faceZone
62  for efficiency, e.g.
63  \verbatim
64  internalField
65  {
66  type zonal;
67 
68  defaultValue 0;
69 
70  zones
71  {
72  water
73  {
74  type box;
75  box (-999 -999 -999) (999 999 0.244);
76  value 1;
77  }
78  }
79  }
80 
81  boundaryField
82  {
83  inlet
84  {
85  type functionalFixedValue;
86 
87  value
88  {
89  $internalField;
90 
91  zones
92  {
93  water
94  {
95  zone
96  {
97  type patch;
98  patch inlet;
99  }
100  }
101  }
102  }
103  }
104  .
105  .
106  .
107  \endverbatim
108 
109 SourceFiles
110  Zonal_DimensionedFieldFunction.C
111 
112 \*---------------------------------------------------------------------------*/
113 
114 #ifndef Zonal_DimensionedFieldFunction_H
115 #define Zonal_DimensionedFieldFunction_H
116 
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 namespace Foam
122 {
123 namespace DimensionedFieldFunctions
124 {
125 
126 /*---------------------------------------------------------------------------*\
127  Class Zonal Declaration
128 \*---------------------------------------------------------------------------*/
129 
130 template<class DimensionedFieldType>
131 class Zonal
132 :
133  public DimensionedFieldFunction<DimensionedFieldType>
134 {
135  typedef typename DimensionedFieldType::Type_ Type;
136  typedef typename DimensionedFieldType::GeoMesh_::Zone Zone;
137 
138  // Private Data
139 
140  //- Default value
141  Type value_;
142 
143  //- Cached zone and value specification dictionary
144  dictionary zonesDict_;
145 
146 
147 public:
148 
149  //- Runtime type information
150  TypeName("zonal");
151 
152 
153  // Constructors
154 
155  //- Construct with dictionary to initialise given field
156  Zonal
157  (
158  const dictionary& dict,
159  DimensionedFieldType& field
160  );
161 
162  //- Construct a copy for the given field
163  Zonal
164  (
165  const Zonal& dff,
166  DimensionedFieldType& field
167  );
168 
169  //- Construct and return a clone for the specified field
171  clone(DimensionedFieldType& field) const;
172 
173 
174  //- Destructor
175  virtual ~Zonal()
176  {}
177 
178 
179  // Member Functions
180 
181  //- Evaluate the function and set the field
182  virtual void evaluate();
183 
184  //- Write data to dictionary stream
185  virtual void write(Ostream& os) const;
186 };
187 
188 
189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190 
191 } // End namespace DimensionedFieldFunctions
192 } // End namespace Foam
193 
194 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
195 
196 #ifdef NoRepository
198 #endif
199 
200 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
201 
202 #endif
203 
204 // ************************************************************************* //
Base class for run-time selectable internal and patch field initialisation evaluation and update with...
virtual autoPtr< DimensionedFieldFunction< DimensionedFieldType > > clone() const
Construct and return a clone for the specified field.
Zonal internal and patch field initialisation function.
Zonal(const dictionary &dict, DimensionedFieldType &field)
Construct with dictionary to initialise given field.
virtual void evaluate()
Evaluate the function and set the field.
virtual void write(Ostream &os) const
Write data to dictionary stream.
TypeName("zonal")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Namespace for OpenFOAM.
dictionary dict