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