sampledInterface.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2020 DLR
9  Copyright (C) 2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::sampledInterface
29 
30 Description
31  A sampledSurface that calculates the PLIC interface in VoF simulations
32  Only works in combination with isoAdvector and a reconstruction scheme
33 
34  This is often embedded as part of a sampled surfaces function object.
35 
36 Usage
37  Example of function object partial specification:
38  \verbatim
39  surfaces
40  {
41  freeSurf
42  {
43  type interface;
44  interpolate false;
45  }
46  }
47  \endverbatim
48 
49  Where the sub-entries comprise:
50  \table
51  Property | Description | Required | Default
52  type | interface | yes |
53  \endtable
54 
55  Original code supplied by Henning Scheufler, DLR (2019)
56 
57 SourceFiles
58  sampledInterface.C
59 
60 \*---------------------------------------------------------------------------*/
61 
62 #ifndef sampledInterface_H
63 #define sampledInterface_H
64 
65 #include "sampledSurface.H"
66 #include "ZoneIDs.H"
67 #include "fvMeshSubset.H"
68 #include "reconstructionSchemes.H"
69 
70 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
71 
72 namespace Foam
73 {
74 
75 /*---------------------------------------------------------------------------*\
76  Class sampledInterface Declaration
77 \*---------------------------------------------------------------------------*/
78 
79 class sampledInterface
80 :
81  public sampledSurface
82 {
83  // Private Data
84 
85  //- Restrict to given cell zones
86  wordRes zoneNames_;
87 
88  //- For zones: patch to put exposed faces into
89  mutable word exposedPatchName_;
90 
92 
93 
94  // Recreated for every interface
95 
96  //- Time at last call, also track if surface needs an update
97  mutable label prevTimeIndex_;
98 
99  //- Cached submesh
100  mutable autoPtr<fvMeshSubset> subMeshPtr_;
101 
102 
103  // Private Member Functions
104 
105  //- Create iso surface (if time has changed)
106  // Do nothing (and return false) if no update was needed
107  bool updateGeometry() const;
108 
109  //- Sample volume field onto surface faces
110  template<class Type>
111  tmp<Field<Type>> sampleOnFaces
112  (
113  const interpolation<Type>& sampler
114  ) const;
115 
116  //- Interpolate volume field onto surface points
117  template<class Type>
118  tmp<Field<Type>> sampleOnPoints
119  (
120  const interpolation<Type>& interpolator
121  ) const;
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("sampledInterface");
128 
129 
130  // Constructors
131 
132  //- Construct from dictionary
134  (
135  const word& name,
136  const polyMesh& mesh,
137  const dictionary& dict
138  );
139 
140 
141  //- Destructor
142  virtual ~sampledInterface() = default;
143 
144 
145  // Member Functions
146 
148  {
149  return surfPtr_();
150  }
151 
152  //- Does the surface need an update?
153  virtual bool needsUpdate() const;
154 
155  //- Mark the surface as needing an update.
156  // May also free up unneeded data.
157  // Return false if surface was already marked as expired.
158  virtual bool expire();
159 
160  //- Update the surface as required.
161  // Do nothing (and return false) if no update was needed
162  virtual bool update();
163 
164 
165  //- Points of surface
166  virtual const pointField& points() const
167  {
168  return surface().points();
169  }
170 
171  //- Faces of surface
172  virtual const faceList& faces() const
173  {
174  return surface().surfFaces();
175  }
176 
177  //- Const access to per-face zone/region information
178  virtual const labelList& zoneIds() const
179  {
180  return labelList::null();
181  }
182 
183  //- Face area magnitudes
184  virtual const vectorField& Sf() const
185  {
186  return surface().Sf();
187  }
188 
189  //- Face area magnitudes
190  virtual const scalarField& magSf() const
191  {
192  return surface().magSf();
193  }
194 
195  //- Face centres
196  virtual const vectorField& Cf() const
197  {
198  return surface().Cf();
199  }
200 
201 
202  // Sample
203 
204  //- Sample volume field onto surface faces
205  virtual tmp<scalarField> sample
206  (
207  const interpolation<scalar>& sampler
208  ) const;
209 
210  //- Sample volume field onto surface faces
211  virtual tmp<vectorField> sample
212  (
213  const interpolation<vector>& sampler
214  ) const;
215 
216  //- Sample volume field onto surface faces
218  (
219  const interpolation<sphericalTensor>& sampler
220  ) const;
221 
222  //- Sample volume field onto surface faces
224  (
225  const interpolation<symmTensor>& sampler
226  ) const;
227 
228  //- Sample volume field onto surface faces
229  virtual tmp<tensorField> sample
230  (
231  const interpolation<tensor>& sampler
232  ) const;
233 
235  // Interpolate
236 
237  //- Interpolate volume field onto surface points
239  (
240  const interpolation<scalar>& interpolator
241  ) const;
243  //- Interpolate volume field onto surface points
245  (
246  const interpolation<vector>& interpolator
247  ) const;
248 
249  //- Interpolate volume field onto surface points
251  (
252  const interpolation<sphericalTensor>& interpolator
253  ) const;
254 
255  //- Interpolate volume field onto surface points
257  (
258  const interpolation<symmTensor>& interpolator
259  ) const;
260 
261  //- Interpolate volume field onto surface points
263  (
264  const interpolation<tensor>& interpolator
265  ) const;
266 
267 
268  // Output
269 
270  //- Print information
271  virtual void print(Ostream& os, int level=0) const;
272 };
273 
274 
275 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 
277 } // End namespace Foam
278 
279 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
280 
281 #ifdef NoRepository
282  #include "sampledInterfaceTemplates.C"
283 #endif
284 
285 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
286 
287 #endif
288 
289 // ************************************************************************* //
dictionary dict
bool interpolate() const noexcept
Same as isPointData()
virtual const pointField & points() const
Points of surface.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
const vectorField & Sf() const
Face area vectors (normals)
virtual bool expire()
Mark the surface as needing an update.
static const List< label > & null()
Return a null List.
Definition: ListI.H:130
const word & name() const noexcept
Name of surface.
virtual const faceList & faces() const
Faces of surface.
List< face > faceList
List of faces.
Definition: faceListFwd.H:39
TypeName("sampledInterface")
Runtime type information.
A class for handling words, derived from Foam::string.
Definition: word.H:63
const scalarField & magSf() const
Face area magnitudes.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual const vectorField & Sf() const
Face area magnitudes.
virtual void print(Ostream &os, int level=0) const
Print information.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
const Field< point_type > & points() const noexcept
Return reference to global points.
virtual bool update()
Update the surface as required.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
const List< Face > & surfFaces() const
Return const access to the faces.
OBJstream os(runTime.globalPath()/outputName)
virtual const vectorField & Cf() const
Face centres.
virtual const scalarField & magSf() const
Face area magnitudes.
const vectorField & Cf() const
Face centres.
const reconstructionSchemes::interface & surface() const
Abstract base class for volume field interpolation.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
virtual ~sampledInterface()=default
Destructor.
virtual bool needsUpdate() const
Does the surface need an update?
A class for managing temporary objects.
Definition: HashPtrTable.H:50
sampledInterface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual const labelList & zoneIds() const
Const access to per-face zone/region information.
Namespace for OpenFOAM.