Loading...
Searching...
No Matches
sampledInterface.C
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-------------------------------------------------------------------------------
10License
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\*---------------------------------------------------------------------------*/
27
28#include "sampledInterface.H"
29#include "dictionary.H"
30#include "volFields.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
40 (
43 word,
45 );
46}
47
48// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
49
50
51bool Foam::sampledInterface::updateGeometry() const
52{
53 const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
54
55 // No update needed
56 if (fvm.time().timeIndex() == prevTimeIndex_)
57 {
58 return false;
59 }
60
61 prevTimeIndex_ = fvm.time().timeIndex();
62
63 // Not really being used...
64
65 // Get sub-mesh if any
66 if
67 (
68 !subMeshPtr_
69 && (-1 != mesh().cellZones().findIndex(zoneNames_))
70 )
71 {
72 const label exposedPatchi =
73 mesh().boundaryMesh().findPatchID(exposedPatchName_);
74
75 bitSet cellsToSelect(mesh().cellZones().selection(zoneNames_));
76
78 << "Allocating subset of size "
79 << cellsToSelect.count()
80 << " with exposed faces into patch "
81 << exposedPatchi << endl;
82
83 subMeshPtr_.reset
84 (
85 new fvMeshSubset(fvm, cellsToSelect, exposedPatchi)
86 );
87 }
88
89
90 // Clear any stored topo
91 surfPtr_.clear();
92
93 // Clear derived data
94 clearGeom();
95
96 surfPtr_.reset
97 (
98 new reconstructionSchemes::interface
99 (
100 fvm.lookupObjectRef<reconstructionSchemes>
101 (
102 "reconstructionScheme"
103 ).surface()
104 )
105 );
107 return true;
108}
109
110
111// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
112
114(
115 const word& name,
116 const polyMesh& mesh,
117 const dictionary& dict
118)
119:
121 zoneNames_(),
122 exposedPatchName_(),
123 surfPtr_(nullptr),
124 prevTimeIndex_(-1),
125 subMeshPtr_(nullptr)
126{
127 if (!dict.readIfPresent("zones", zoneNames_) && dict.found("zone"))
128 {
129 zoneNames_.resize(1);
130 dict.readEntry("zone", zoneNames_.first());
131 }
132
133 if (-1 != mesh.cellZones().findIndex(zoneNames_))
134 {
135 dict.readIfPresent("exposedPatchName", exposedPatchName_);
136
137 DebugInfo
138 << "Restricting to cellZone " << flatOutput(zoneNames_)
139 << " with exposed internal faces into patch "
140 << mesh.boundaryMesh().findPatchID(exposedPatchName_) << endl;
141 }
142}
143
144
145// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
146
149 const fvMesh& fvm = static_cast<const fvMesh&>(mesh());
150
151 return fvm.time().timeIndex() != prevTimeIndex_;
152}
153
154
156{
157 surfPtr_.clear();
158 subMeshPtr_.clear();
159
160 // Clear derived data
161 clearGeom();
162
163 // Already marked as expired
164 if (prevTimeIndex_ == -1)
165 {
166 return false;
167 }
169 // Force update
170 prevTimeIndex_ = -1;
171 return true;
172}
173
176{
177 return updateGeometry();
178}
179
180
182(
184) const
185{
186 return sampleOnFaces(sampler);
187}
188
189
191(
193) const
194{
195 return sampleOnFaces(sampler);
196}
197
198
200(
202) const
203{
204 return sampleOnFaces(sampler);
205}
206
207
209(
211) const
212{
213 return sampleOnFaces(sampler);
214}
215
216
218(
220) const
221{
222 return sampleOnFaces(sampler);
223}
224
225
227(
228 const interpolation<scalar>& interpolator
229) const
230{
231 return sampleOnPoints(interpolator);
232}
233
234
237 const interpolation<vector>& interpolator
238) const
239{
240 return sampleOnPoints(interpolator);
241}
242
244(
246) const
247{
248 return sampleOnPoints(interpolator);
249}
250
251
253(
254 const interpolation<symmTensor>& interpolator
255) const
256{
257 return sampleOnPoints(interpolator);
258}
259
260
262(
263 const interpolation<tensor>& interpolator
264) const
265{
266 return sampleOnPoints(interpolator);
267}
268
269
270void Foam::sampledInterface::print(Ostream& os, int level) const
271{
272 os << "sampledInterface: " << name();
273}
274
275
276// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
if(patchID !=-1)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Abstract base class for volume field interpolation.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
A sampledSurface that calculates the PLIC interface in VoF simulations Only works in combination with...
sampledInterface(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual void print(Ostream &os, int level=0) const
Print information.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
virtual bool expire()
Mark the surface as needing an update.
virtual bool needsUpdate() const
Does the surface need an update?
virtual bool update()
Update the surface as required.
An abstract class for surfaces with sampling.
sampledSurface(const word &name, std::nullptr_t)
Construct null.
const word & name() const noexcept
Name of surface.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
bool interpolate() const noexcept
Same as isPointData().
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
auto & name
#define DebugInfo
Report an information message using Foam::Info.
Namespace of functions to calculate implicit derivatives returning a matrix.
Namespace for OpenFOAM.
label findIndex(const ListType &input, typename ListType::const_reference val, const label start=0)
Deprecated(2017-10) search for first occurrence of the given element.
Definition ListOps.H:517
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
dictionary dict
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())