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()
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
226 subMeshPtr_().interpolate
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;
277 ).interpolate(*volSubFieldPtr_).ptr();
287 storedVolSubFieldPtr_.reset
291 volSubFieldPtr_ = storedVolSubFieldPtr_.get();
297 << volSubFieldPtr_->
name()
298 <<
" min:" <<
min(*volSubFieldPtr_).value()
299 <<
" max:" <<
max(*volSubFieldPtr_).value() <<
nl
301 << pointSubFieldPtr_->
name()
308void Foam::sampledIsoSurface::combineSurfaces
310 PtrList<isoSurfaceBase>& isoSurfPtrs
313 isoSurfacePtr_.reset(
nullptr);
321 && isoSurfPtrs.size() == 1
325 isoSurfacePtr_.reset(isoSurfPtrs.release(0));
327 else if (isoSurfPtrs.size() == 1)
329 autoPtr<isoSurfaceBase> ptr(isoSurfPtrs.release(0));
333 meshCells_.transfer(surf.meshCells());
344 for (
const auto& surf : isoSurfPtrs)
347 nPoints += surf.points().size();
352 meshCells_.resize(
nFaces);
358 forAll(isoSurfPtrs, surfi)
360 autoPtr<isoSurfaceBase> ptr(isoSurfPtrs.release(surfi));
363 SubList<face> subFaces(newFaces, surf.size(),
nFaces);
364 SubList<point> subPoints(newPoints, surf.points().size(),
nPoints);
365 SubList<label> subCells(meshCells_, surf.size(),
nFaces);
367 newZones[surfi] = surfZone
375 subFaces = surf.surfFaces();
376 subPoints = surf.points();
377 subCells = surf.meshCells();
381 for (face&
f : subFaces)
383 for (label& pointi :
f)
396 std::move(newPoints),
401 surface_.transfer(combined);
405 if (subMeshPtr_ && meshCells_.size())
408 UIndirectList<label>(subMeshPtr_->cellMap(), meshCells_);
413bool Foam::sampledIsoSurface::updateGeometry()
const
415 const fvMesh& fvm =
static_cast<const fvMesh&
>(
mesh());
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);
452 bitSet
select(
mesh().cellZones().selection(zoneNames_));
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_),
505 refPtr<volScalarField> tvolFld(*volFieldPtr_);
506 refPtr<pointScalarField> tpointFld(*pointFieldPtr_);
510 tvolFld.cref(*volSubFieldPtr_);
511 tpointFld.cref(*pointSubFieldPtr_);
517 PtrList<isoSurfaceBase> isoSurfPtrs(isoValues_.size());
528 tpointFld().primitiveField(),
536 const_cast<sampledIsoSurface&
>(*this)
537 .combineSurfaces(isoSurfPtrs);
553 meshCells_ = UIndirectList<label>(meshCells_,
faceMap)();
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)
630 if (isoValues_.
empty())
633 <<
"No isoValue or isoValues specified." <<
nl
637 if (isoValues_.
size() > 1)
639 const label nOrig = isoValues_.
size();
643 if (nOrig != isoValues_.
size())
646 <<
"Removed non-unique isoValues" <<
nl;
653 simpleSubMesh_ =
false;
659 if (isoValues_.
size() > 1)
662 <<
"Multiple values on iso-surface (point) not supported"
663 <<
" since needs original interpolators." <<
nl
677 <<
"Cannot triangulate without a regularise filter" <<
nl
696 <<
"Restricting to cellZone(s) " <<
flatOutput(zoneNames_)
697 <<
" with exposed internal faces into patch "
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_
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:
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
const word & name() const noexcept
Return the object name.
void resize(const label len)
Adjust allocated size of list.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
label timeIndex() const noexcept
Return current time index.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
T & first()
Return the first element of the list.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
void size(const label n)
Older name for setAddressableSize.
bitSet selection(const labelUList &zoneIds) const
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
unsigned int count(const bool on=true) const
Count number of bits set.
static word defaultName
The default cloud name: defaultCloud.
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
Search for an entry (const access) with the given keyword.
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.
const Time & time() const
Return the top-level database.
Abstract base class for volume field interpolation.
Preferences for controlling iso-surface algorithms.
filterType filter() const noexcept
Get current filter type.
@ ALGO_DEFAULT
Use current 'standard' algorithm.
algorithmType algorithm() const noexcept
Get current algorithm.
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.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
A sampledSurface defined by a surface of iso value. It only recalculates the iso-surface if time chan...
virtual ~sampledIsoSurface()
Destructor.
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.
static tmp< VolumeField< Type > > pointAverage(const PointField< Type > &pfld)
Create cell values by averaging the point values.
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.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
#define DebugInfo
Report an information message using Foam::Info.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
#define DebugInFunction
Report an information message using Foam::Info.
List< bool > select(const label n, const labelUList &locations)
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
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
vectorField pointField
pointField is a vectorField.
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
void inplaceUniqueSort(ListType &input)
Inplace sorting and removal of duplicates.
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.
Type gMin(const FieldField< Field, Type > &f)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
List< surfZone > surfZoneList
List< face > faceList
A List of faces.
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.