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 );
106
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
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
148{
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 }
168
169 // Force update
170 prevTimeIndex_ = -1;
171 return true;
172}
173
174
176{
177 return updateGeometry();
178}
179
180
182(
183 const interpolation<scalar>& sampler
184) const
185{
186 return sampleOnFaces(sampler);
187}
188
189
191(
192 const interpolation<vector>& sampler
193) const
194{
195 return sampleOnFaces(sampler);
196}
197
198
200(
201 const interpolation<sphericalTensor>& sampler
202) const
203{
204 return sampleOnFaces(sampler);
205}
206
207
209(
210 const interpolation<symmTensor>& sampler
211) const
212{
213 return sampleOnFaces(sampler);
214}
215
216
218(
219 const interpolation<tensor>& sampler
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
236(
237 const interpolation<vector>& interpolator
238) const
239{
240 return sampleOnPoints(interpolator);
241}
242
244(
245 const interpolation<sphericalTensor>& interpolator
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
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.
Minimal example by using system/controlDict.functions:
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
label timeIndex() const noexcept
Return current time index.
Definition: TimeStateI.H:37
T & first()
Return the first element of the list.
Definition: UListI.H:202
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
Definition: ZoneMesh.C:497
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Abstract base class for volume field interpolation.
Definition: interpolation.H:60
scalar print()
Print to screen.
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:81
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
Definition: polyMesh.H:504
A sampledSurface that calculates the PLIC interface in VoF simulations Only works in combination with...
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.
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:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
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:398
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Definition: FlatOutput.H:215
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
dictionary dict
interfaceProperties interface(alpha1, U, thermo->transportPropertiesDict())