Surfaces_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::Surfaces
26 
27 Description
28  Dimensioned field function which sets constant values inside a set of
29  surfaces, and a default value elsewhere. Cutting is used to set fractional
30  values in elements that intersect the surfaces. Foam::searchableSurface is
31  used to define the surface geometry, so triangulated surface files can be
32  used, as well as a list of simple predefined shapes (box, cylinder, ...).
33 
34  Example specification:
35  internalField
36  {
37  type surfaces;
38 
39  // Set a value of one everywhere, except ...
40  defaultValue 1;
41 
42  surfaces
43  {
44  // Set a value of zero in a sphere
45  bubble
46  {
47  type sphere;
48 
49  centre (0.5 0.5 0.5);
50  radius 0.1;
51 
52  value 0;
53  }
54 
55  // Set a value of zero where the y coordinate is greater than 1
56  air
57  {
58  type plane;
59 
60  point (0 1 0);
61  normal (0 -1 0);
62 
63  value 0;
64  }
65  }
66  }
67 
68 SourceFiles
69  Surfaces_DimensionedFieldFunction.C
70 
71 \*---------------------------------------------------------------------------*/
72 
73 #ifndef Surfaces_DimensionedFieldFunction_H
74 #define Surfaces_DimensionedFieldFunction_H
75 
77 #include "searchableSurfaceList.H"
78 
79 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
80 
81 namespace Foam
82 {
83 
84 class polyMesh;
85 class polyPatch;
86 class fvMesh;
87 class fvPatch;
88 
89 namespace DimensionedFieldFunctions
90 {
91 
92 /*---------------------------------------------------------------------------*\
93  Class Surfaces Declaration
94 \*---------------------------------------------------------------------------*/
95 
96 template<class DimensionedFieldType>
97 class Surfaces
98 :
99  public DimensionedFieldFunction<DimensionedFieldType>
100 {
101 private:
102 
103  // Private Type Definitions
104 
105  //- The primitive data type
106  typedef typename DimensionedFieldType::Type_ Type;
107 
108 
109  // Private Data
110 
111  //- Default (outside) value
112  dimensioned<Type> defaultValue_;
113 
114  //- Surfaces dictionary
115  dictionary surfacesDict_;
116 
117  //- Surfaces
118  autoPtr<searchableSurfaceList> surfacesPtr_;
119 
120  //- Inside values
121  PtrList<dimensioned<Type>> values_;
122 
123 
124  // Private Member Functions
125 
126  //- Return polyMesh given an fvMesh
127  static const polyMesh& poly(const fvMesh&);
128 
129  //- Return polyPatch given an fvPatch
130  static const polyPatch& poly(const fvPatch&);
131 
132  //- Read the surfaces and the values
133  void readSurfacesAndValues();
134 
135 
136 public:
137 
138  //- Runtime type information
139  TypeName("surfaces");
140 
141 
142  // Constructors
143 
144  //- Construct with dictionary to initialise given field
145  Surfaces
146  (
147  const dictionary& dict,
148  DimensionedFieldType& field
149  );
150 
151  //- Construct a copy for the given field
152  Surfaces
153  (
154  const Surfaces& dff,
155  DimensionedFieldType& field
156  );
157 
158  //- Construct and return a clone for the specified field
160  (
161  DimensionedFieldType& field
162  ) const;
163 
164 
165  //- Destructor
166  virtual ~Surfaces()
167  {}
168 
169 
170  // Member Functions
171 
172  //- Evaluate the function and set the field
173  virtual void evaluate();
174 
175  //- Write data to dictionary stream
176  virtual void write(Ostream& os) const;
177 };
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 } // End namespace DimensionedFieldFunctions
183 } // End namespace Foam
184 
185 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186 
187 #ifdef NoRepository
189 #endif
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 #endif
194 
195 // ************************************************************************* //
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.
Dimensioned field function which sets constant values inside a set of surfaces, and a default value e...
Surfaces(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("surfaces")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: PtrList.H:75
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
Generic dimensioned Type class.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:98
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:78
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
Namespace for OpenFOAM.
dictionary dict