53 void 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;
157 const_cast<pointScalarField&>(*pointFieldPtr_)
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
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;
262 const_cast<pointScalarField&>(*pointFieldPtr_)
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()
308 void 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));
332 surface_.transfer(static_cast<meshedSurface&>(surf));
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)
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)
390 nFaces += subFaces.size();
396 std::move(newPoints),
401 surface_.transfer(combined);
405 if (subMeshPtr_ && meshCells_.size())
408 UIndirectList<label>(subMeshPtr_->cellMap(), meshCells_);
413 bool 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()
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)
624 if (!
dict.readIfPresent(
"isoValues", isoValues_))
627 dict.readEntry(
"isoValue", isoValues_.
first());
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 685 if (!
dict.readIfPresent(
"zones", zoneNames_) &&
dict.found(
"zone"))
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 " 706 const polyMesh&
mesh,
707 const dictionary&
dict 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_
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
tmp< GeometricField< Type, pointPatchField, pointMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &) const
Interpolate volField using inverse distance weighting.
bool upToDate(const regIOobject &) const
Return true if up-to-date with respect to given object.
void size(const label n)
Older name for setAddressableSize.
bool interpolate() const noexcept
Same as isPointData()
unsigned int count(const bool on=true) const
Count number of bits set.
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void resize(const label len)
Adjust allocated size of list.
static tmp< VolumeField< Type > > pointAverage(const PointField< Type > &pfld)
Create cell values by averaging the point values.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
An abstract class for surfaces with sampling.
Type gMin(const FieldField< Field, Type > &f)
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
const word & name() const noexcept
Return the object name.
static const volPointInterpolation & New(const fvMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
Preferences for controlling iso-surface algorithms.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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...
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
T & first()
Access first element of the list, position [0].
virtual ~sampledIsoSurface()
Destructor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ignore writing from objectRegistry::writeObject()
const Time & time() const
Return the top-level database.
Macros for easy insertion into run-time selection tables.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
#define forAll(list, i)
Loop across all elements in list.
virtual bool update()
Update the surface as required.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< face > faceList
List of faces.
virtual bool needsUpdate() const
Does the surface need an update?
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
vectorField pointField
pointField is a vectorField.
virtual void clearGeom() const
Additional cleanup when clearing the geometry.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
Use current 'standard' algorithm.
MeshedSurface< face > meshedSurface
static word defaultName(const label n=-1)
Default zone name: "zone" or "zoneN".
#define DebugInFunction
Report an information message using Foam::Info.
label timeIndex() const noexcept
Return current time index.
void inplaceUniqueSort(ListType &input)
Inplace sorting and removal of duplicates.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
#define DebugInfo
Report an information message using Foam::Info.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
OBJstream os(runTime.globalPath()/outputName)
algorithmType algorithm() const noexcept
Get current algorithm.
defineTypeNameAndDebug(combustionModel, 0)
virtual void print(Ostream &os, int level=0) const
Print information.
sampledIsoSurface(const isoSurfaceParams ¶ms, const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Mesh data needed to do the Finite Volume discretisation.
List< surfZone > surfZoneList
List of surfZone.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
bitSet selection(const labelUList &zoneIds) const
Return all elements (cells, faces, points) contained in the listed zones.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
virtual bool expire()
Mark the surface as needing an update.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
A class for managing temporary objects.
filterType filter() const noexcept
Get current filter type.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
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.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
A sampledSurface defined by a surface of iso value. It only recalculates the iso-surface if time chan...
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...