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
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 
234 
235  // Interpolate
236 
237  //- Interpolate volume field onto surface points
239  (
240  const interpolation<scalar>& interpolator
241  ) const;
242 
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 // ************************************************************************* //
Foam::sampledInterface::points
virtual const pointField & points() const
Points of surface.
Definition: sampledInterface.H:175
Foam::List::null
static const List< T > & null()
Return a null List.
Definition: ListI.H:109
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
reconstructionSchemes.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::sampledInterface::surface
const reconstructionSchemes::interface & surface() const
Definition: sampledInterface.H:156
fvMeshSubset.H
Foam::sampledInterface::update
virtual bool update()
Update the surface as required.
Definition: sampledInterface.C:175
Foam::sampledInterface::faces
virtual const faceList & faces() const
Faces of surface.
Definition: sampledInterface.H:181
Foam::MeshedSurface::Sf
const vectorField & Sf() const
Face area vectors (normals)
Definition: MeshedSurface.H:435
Foam::MeshedSurface::surfFaces
const List< Face > & surfFaces() const
Return const access to the faces.
Definition: MeshedSurface.H:413
Foam::sampledInterface::sampledInterface
sampledInterface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
Definition: sampledInterface.C:114
ZoneIDs.H
Foam::sampledInterface::magSf
virtual const scalarField & magSf() const
Face area magnitudes.
Definition: sampledInterface.H:199
Foam::sampledInterface::Sf
virtual const vectorField & Sf() const
Face area magnitudes.
Definition: sampledInterface.H:193
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::MeshedSurface::magSf
const scalarField & magSf() const
Face area magnitudes.
Definition: MeshedSurface.H:441
Foam::sampledSurface::interpolate
bool interpolate() const noexcept
Same as isPointData()
Definition: sampledSurface.H:598
Foam::Field< vector >
Foam::sampledInterface::Cf
virtual const vectorField & Cf() const
Face centres.
Definition: sampledInterface.H:205
sampledSurface.H
Foam::sampledInterface::needsUpdate
virtual bool needsUpdate() const
Does the surface need an update?
Definition: sampledInterface.C:147
Foam::sampledSurface
An abstract class for surfaces with sampling.
Definition: sampledSurface.H:121
Foam::interpolation
Abstract base class for interpolation.
Definition: mappedPatchFieldBase.H:96
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::sampledInterface::expire
virtual bool expire()
Mark the surface as needing an update.
Definition: sampledInterface.C:155
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::sampledSurface::name
const word & name() const noexcept
Name of surface.
Definition: sampledSurface.H:322
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::sampledInterface::sample
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Definition: sampledInterface.C:182
Foam::sampledInterface::TypeName
TypeName("sampledInterface")
Runtime type information.
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::List< face >
sampledInterfaceTemplates.C
Foam::sampledSurface::mesh
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
Definition: sampledSurface.H:316
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::sampledInterface::print
virtual void print(Ostream &os, int level=0) const
Print information.
Definition: sampledInterface.C:270
Foam::sampledInterface::~sampledInterface
virtual ~sampledInterface()=default
Destructor.
Foam::sampledInterface
A sampledSurface that calculates the PLIC interface in VoF simulations Only works in combination with...
Definition: sampledInterface.H:88
Foam::MeshedSurface::Cf
const vectorField & Cf() const
Face centres.
Definition: MeshedSurface.H:447
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::reconstructionSchemes::interface
Definition: reconstructionSchemes.H:113
Foam::sampledInterface::zoneIds
virtual const labelList & zoneIds() const
Const access to per-face zone/region information.
Definition: sampledInterface.H:187