53void Foam::sampledIsoSurface::getIsoFields()
const
55 const fvMesh& fvm =
static_cast<const fvMesh&
>(
mesh());
65 <<
"Lookup volField " << isoField_ <<
endl;
67 storedVolFieldPtr_.clear();
74 <<
"Checking " << isoField_
75 <<
" for same time " << fvm.time().timeName() <<
endl;
80 || (fvm.time().timeName() != storedVolFieldPtr_().instance())
84 <<
"Reading volField " << isoField_
85 <<
" from time " << fvm.time().timeName() <<
endl;
90 fvm.time().timeName(),
99 storedVolFieldPtr_.reset
107 volFieldPtr_ = storedVolFieldPtr_.get();
112 <<
"Cannot find isosurface field " << isoField_
113 <<
" in database or directory " << vfHeader.path()
133 const word pointFldName =
134 "volPointInterpolate_"
146 <<
"lookup pointField " << pointFldName <<
endl;
148 if (!pointFieldPtr_->upToDate(*volFieldPtr_))
151 <<
"updating pointField " << pointFldName <<
endl;
166 <<
"creating pointField " << pointFldName <<
endl;
187 storedVolFieldPtr_.reset
191 volFieldPtr_ = storedVolFieldPtr_.get();
196 <<
"volField " << volFieldPtr_->
name()
197 <<
" min:" <<
min(*volFieldPtr_).value()
198 <<
" max:" <<
max(*volFieldPtr_).value() <<
nl
199 <<
"pointField " << pointFieldPtr_->name()
200 <<
" min:" <<
gMin(pointFieldPtr_->primitiveField())
201 <<
" max:" <<
gMax(pointFieldPtr_->primitiveField()) <<
endl;
206 const fvMesh& subFvm = subMeshPtr_().subMesh();
215 <<
"Sub-mesh lookup volField " << isoField_ <<
endl;
217 storedVolSubFieldPtr_.clear();
222 <<
"Sub-setting volField " << isoField_ <<
endl;
224 storedVolSubFieldPtr_.reset
231 storedVolSubFieldPtr_->checkOut();
232 volSubFieldPtr_ = storedVolSubFieldPtr_.get();
238 const word pointFldName =
239 "volPointInterpolate_"
242 + volSubFieldPtr_->
name()
251 <<
"Sub-mesh lookup pointField " << pointFldName <<
endl;
253 if (!pointFieldPtr_->upToDate(*volSubFieldPtr_))
256 <<
"Updating submesh pointField " << pointFldName <<
endl;
269 <<
"Interpolating submesh volField "
270 << volSubFieldPtr_->name()
271 <<
" to get submesh pointField " << pointFldName <<
endl;
287 storedVolSubFieldPtr_.reset
291 volSubFieldPtr_ = storedVolSubFieldPtr_.get();
297 << volSubFieldPtr_->
name()
298 <<
" min:" <<
min(*volSubFieldPtr_).value()
299 <<
" max:" <<
max(*volSubFieldPtr_).value() <<
nl
301 << pointSubFieldPtr_->name()
302 <<
" min:" <<
gMin(pointSubFieldPtr_->primitiveField())
303 <<
" max:" <<
gMax(pointSubFieldPtr_->primitiveField()) <<
endl;
308void Foam::sampledIsoSurface::combineSurfaces
313 isoSurfacePtr_.reset(
nullptr);
321 && isoSurfPtrs.size() == 1
325 isoSurfacePtr_.reset(isoSurfPtrs.release(0));
327 else if (isoSurfPtrs.size() == 1)
333 meshCells_.transfer(surf.meshCells());
344 for (
const auto& surf : isoSurfPtrs)
346 nFaces += surf.size();
347 nPoints += surf.points().size();
352 meshCells_.resize(nFaces);
358 forAll(isoSurfPtrs, surfi)
375 subFaces = surf.surfFaces();
376 subPoints = surf.points();
377 subCells = surf.meshCells();
381 for (
face&
f : subFaces)
383 for (label& pointi :
f)
390 nFaces += subFaces.size();
396 std::move(newPoints),
401 surface_.transfer(combined);
405 if (subMeshPtr_ && meshCells_.size())
413bool Foam::sampledIsoSurface::updateGeometry()
const
418 if (
fvm.time().timeIndex() == prevTimeIndex_)
423 prevTimeIndex_ =
fvm.time().timeIndex();
428 isoSurfacePtr_.reset(
nullptr);
433 const bool hasCellZones =
443 subMeshPtr_.reset(
nullptr);
446 if (!ignoreCellsPtr_)
448 ignoreCellsPtr_.reset(
new bitSet);
459 *ignoreCellsPtr_ = std::move(select);
470 ignoreCellsPtr_->clearStorage();
474 ignoreCellsPtr_.reset(
new bitSet);
478 if (!subMeshPtr_ && hasCellZones)
480 const label exposedPatchi =
484 <<
"Allocating subset of size "
486 <<
" with exposed faces into patch "
487 << exposedPatchi <<
endl;
494 mesh().cellZones().selection(zoneNames_),
510 tvolFld.cref(*volSubFieldPtr_);
511 tpointFld.cref(*pointSubFieldPtr_);
528 tpointFld().primitiveField(),
537 .combineSurfaces(isoSurfPtrs);
558 Pout<<
"isoSurface::updateGeometry() : constructed iso:" <<
nl
559 <<
" field : " << isoField_ <<
nl
561 <<
" average : " <<
Switch(average_) <<
nl
563 <<
Switch(
bool(isoParams_.filter())) <<
nl
564 <<
" bounds : " << isoParams_.getClipBounds() <<
nl;
567 Pout<<
" zone size : "
568 << subMeshPtr_->subMesh().nCells() <<
nl;
572 <<
" cut cells : " << meshCells().size()
591 isoField_(
dict.get<
word>(
"isoField")),
593 isoParams_(
dict, params),
594 average_(
dict.getOrDefault(
"average", false)),
595 triangulate_(
dict.getOrDefault(
"triangulate", false)),
596 simpleSubMesh_(
dict.getOrDefault(
"simpleSubMesh", false)),
603 isoSurfacePtr_(nullptr),
605 subMeshPtr_(nullptr),
606 ignoreCellsPtr_(nullptr),
608 storedVolFieldPtr_(nullptr),
609 volFieldPtr_(nullptr),
610 pointFieldPtr_(nullptr),
612 storedVolSubFieldPtr_(nullptr),
613 volSubFieldPtr_(nullptr),
614 pointSubFieldPtr_(nullptr)
619 isoParams_.algorithm(params.algorithm());
624 if (!
dict.readIfPresent(
"isoValues", isoValues_))
626 isoValues_.resize(1);
627 dict.readEntry(
"isoValue", isoValues_.first());
632 FatalIOErrorInFunction(dict)
633 <<
"No isoValue or isoValues specified." << nl
634 << exit(FatalIOError);
637 if (isoValues_.
size() > 1)
639 const label nOrig = isoValues_.size();
641 inplaceUniqueSort(isoValues_);
643 if (nOrig != isoValues_.size())
645 IOWarningInFunction(dict)
646 <<
"Removed non-unique isoValues" << nl;
653 simpleSubMesh_ = false;
659 if (isoValues_.size() > 1)
661 FatalIOErrorInFunction(dict)
662 <<
"Multiple values on iso-surface (point) not supported"
663 <<
" since needs original interpolators." << nl
664 << exit(FatalIOError);
673 && (isoParams_.filter() == isoSurfaceParams::filterType::NONE)
676 FatalIOErrorInFunction(dict)
677 <<
"Cannot triangulate without a regularise filter" << nl
678 << exit(FatalIOError);
687 zoneNames_.resize(1);
688 dict.readEntry(
"zone", zoneNames_.first());
693 dict.readIfPresent(
"exposedPatchName", exposedPatchName_);
696 <<
"Restricting to cellZone(s) " << flatOutput(zoneNames_)
697 <<
" with exposed internal faces into patch "
698 << mesh.boundaryMesh().findPatchID(exposedPatchName_) << endl;
726 return fvm.time().timeIndex() != prevTimeIndex_;
734 isoSurfacePtr_.reset(
nullptr);
735 subMeshPtr_.reset(
nullptr);
741 if (prevTimeIndex_ == -1)
754 return updateGeometry();
764 return sampleOnFaces(sampler);
774 return sampleOnFaces(sampler);
784 return sampleOnFaces(sampler);
794 return sampleOnFaces(sampler);
804 return sampleOnFaces(sampler);
814 return sampleOnPoints(interpolator);
824 return sampleOnPoints(interpolator);
833 return sampleOnPoints(interpolator);
843 return sampleOnPoints(interpolator);
853 return sampleOnPoints(interpolator);
859 os <<
"isoSurface: " <<
name() <<
" :";
860 isoParams_.print(
os);
861 os <<
" field:" << isoField_
if(maxValue - minValue< SMALL)
Macros for easy insertion into run-time selection tables.
#define addNamedToRunTimeSelectionTable(baseType, thisType, argNames, lookupName)
Add to construction table with 'lookupName' as the key.
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
const word & name() const noexcept
Return the object name.
static FOAM_NO_DANGLING_REFERENCE const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
A non-owning sub-view of a List (allocated or unallocated storage).
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
A List with indirect addressing. Like IndirectList but does not store addressing.
bool any() const
True if any entries are 'true'.
bool empty() const noexcept
True if List is empty (ie, size() is zero).
bool all() const
True if all entries are 'true' or if the list is empty.
void size(const label n)
Older name for setAddressableSize.
bitSet selection(const labelUList &zoneIds) const
Return all elements (cells, faces, points) contained in the listed zones.
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
unsigned int count(const bool on=true) const
Count number of bits set.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
A face is a list of labels corresponding to mesh vertices.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
Mesh data needed to do the Finite Volume discretisation.
Abstract base class for volume field interpolation.
static autoPtr< isoSurfaceBase > New(const isoSurfaceParams ¶ms, const volScalarField &cellValues, const scalarField &pointValues, const scalar iso, const bitSet &ignoreCells=bitSet())
Create for specified algorithm type.
Preferences for controlling iso-surface algorithms.
@ ALGO_DEFAULT
Use current 'standard' algorithm.
algorithmType algorithm() const noexcept
Get current algorithm.
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.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
A class for managing references or pointers (no reference counting).
A sampledSurface defined by a surface of iso value. It only recalculates the iso-surface if time chan...
virtual tmp< scalarField > interpolate(const interpolation< scalar > &interpolator) const
Interpolate volume field onto surface points.
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 ~sampledIsoSurface()
Destructor.
virtual bool expire()
Mark the surface as needing an update.
virtual bool needsUpdate() const
Does the surface need an update?
sampledIsoSurface(const isoSurfaceParams ¶ms, const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
virtual bool update()
Update the surface as required.
An abstract class for surfaces with sampling.
static tmp< VolumeField< Type > > pointAverage(const PointField< Type > &pfld)
Create cell values by averaging the point values.
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().
static word defaultName(const label n=-1)
Default zone name: "zone" or "zoneN".
A surface zone on a MeshedSurface.
A class for managing temporary objects.
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
#define DebugInFunction
Report an information message using Foam::Info.
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
Namespace for handling debugging switches.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc).
Namespace of functions to calculate implicit derivatives returning a matrix.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
List< label > labelList
A List of labels.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< surfZone > surfZoneList
List of surfZone.
List< face > faceList
List of faces.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & endl(Ostream &os)
Add newline and flush stream.
MeshedSurface< face > meshedSurface
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Type gMin(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Type gMax(const FieldField< Field, Type > &f)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.