66 auto csysPtr = coordinateSystem::NewIfPresent(
mesh,
dict);
70 csysPtr = coordinateSystem::NewIfPresent(
dict,
"transform");
76 coordSystem::cartesian cs(csysPtr());
78 const point orig = cs.globalPosition(pln.origin());
79 const vector norm = cs.globalVector(pln.normal());
83 <<
" origin:" << pln.origin()
84 <<
" normal:" << pln.normal()
86 <<
" origin:" << orig <<
" normal:" << norm
90 pln = plane(orig, norm);
97void Foam::sampledCuttingPlane::checkBoundsIntersection
104 const boundBox& clipBb = isoParams_.getClipBounds();
109 if (!clipBb.overlaps(
meshBb))
114 <<
"Bounds " << clipBb
115 <<
" do not overlap the mesh bounding box " <<
meshBb
120 if (!clipBb.intersects(pln))
125 <<
"Plane "<< pln <<
" does not intersect the bounds "
132 if (!
meshBb.intersects(pln))
137 <<
"Plane "<< pln <<
" does not intersect the mesh bounds "
144void Foam::sampledCuttingPlane::setDistanceFields(
const plane& pln)
163 fld[i] = pln.signedDistance(cc[i]);
170 cellDistance.boundaryFieldRef();
172 forAll(cellDistanceBf, patchi)
178 cellDistanceBf[patchi]
185 new calculatedFvPatchScalarField
199 fld[i] = pln.signedDistance(cc[i]);
210 fld[i] = pln.signedDistance(cc[i]);
227 pointDistance_[i] = pln.signedDistance(
pts[i]);
233void Foam::sampledCuttingPlane::combineSurfaces
238 isoSurfacePtr_.reset(
nullptr);
246 && isoSurfPtrs.size() == 1
250 isoSurfacePtr_.reset(isoSurfPtrs.release(0));
252 else if (isoSurfPtrs.size() == 1)
258 meshCells_.transfer(surf.meshCells());
269 for (
const auto& surf : isoSurfPtrs)
271 nFaces += surf.size();
272 nPoints += surf.points().size();
277 meshCells_.resize(nFaces);
283 forAll(isoSurfPtrs, surfi)
300 subFaces = surf.surfFaces();
301 subPoints = surf.points();
302 subCells = surf.meshCells();
306 for (
face&
f : subFaces)
308 for (label& pointi :
f)
315 nFaces += subFaces.size();
321 std::move(newPoints),
326 surface_.transfer(combined);
330 if (subMeshPtr_ && meshCells_.size())
338void Foam::sampledCuttingPlane::createGeometry()
342 Pout<<
"sampledCuttingPlane::createGeometry :updating geometry."
349 isoSurfacePtr_.reset(
nullptr);
355 pointDistance_.clear();
356 cellDistancePtr_.clear();
358 const bool hasCellZones =
370 subMeshPtr_.reset(
nullptr);
373 if (!ignoreCellsPtr_)
375 ignoreCellsPtr_.reset(
new bitSet);
386 *ignoreCellsPtr_ = std::move(select);
397 ignoreCellsPtr_->clearStorage();
401 ignoreCellsPtr_.reset(
new bitSet);
405 if (!subMeshPtr_ && hasCellZones)
407 const label exposedPatchi =
410 bitSet cellsToSelect(
mesh().cellZones().selection(zoneNames_));
413 <<
"Allocating subset of size "
414 << cellsToSelect.count() <<
" with exposed faces into patch "
415 << exposedPatchi <<
endl;
421 const boundBox& clipBb = isoParams_.getClipBounds();
422 if (clipBb.good() && cellsToSelect.any())
424 const auto& cellCentres =
fvm.C();
426 for (
const label celli : cellsToSelect)
428 const point& cc = cellCentres[celli];
430 if (!clipBb.contains(cc))
432 cellsToSelect.unset(celli);
437 <<
"Bounded subset of size "
438 << cellsToSelect.count() <<
endl;
453 ? subMeshPtr_->subMesh()
457 checkBoundsIntersection(plane_,
mesh.
bounds());
463 cellDistancePtr_.reset
472 const auto& cellDistance = *cellDistancePtr_;
474 setDistanceFields(plane_);
478 Pout<<
"Writing cell distance:" << cellDistance.objectPath() <<
endl;
479 cellDistance.write();
487 auto& pointDist = tpointDist.ref();
489 pointDist.primitiveFieldRef() = pointDistance_;
491 Pout<<
"Writing point distance:" << pointDist.objectPath() <<
endl;
517 combineSurfaces(isoSurfPtrs);
523 cellDistancePtr_.reset(
nullptr);
524 pointDistance_.clear();
540 const polyMesh&
mesh,
550 isoSurfaceParams::ALGO_TOPO,
551 isoSurfaceParams::filterType::DIAGCELL
553 average_(
dict.getOrDefault(
"average", false)),
554 simpleSubMesh_(
dict.getOrDefault(
"simpleSubMesh", false)),
561 isoSurfacePtr_(nullptr),
563 subMeshPtr_(nullptr),
564 ignoreCellsPtr_(nullptr),
565 cellDistancePtr_(nullptr),
568 dict.readIfPresent(
"offsets", offsets_);
570 if (offsets_.
empty())
573 offsets_.first() = Zero;
578 const label nOrig = offsets_.size();
580 inplaceUniqueSort(offsets_);
582 if (nOrig != offsets_.size())
584 IOWarningInFunction(dict)
585 <<
"Removed non-unique offsets" << nl;
592 simpleSubMesh_ = false;
595 if (offsets_.size() > 1)
597 FatalIOErrorInFunction(dict)
598 <<
"Multiple offsets with iso-surface (point) not supported"
599 <<
" since needs original interpolators." << nl
600 << exit(FatalIOError);
609 zoneNames_.resize(1);
610 dict.readEntry(
"zone", zoneNames_.first());
615 dict.readIfPresent(
"exposedPatchName", exposedPatchName_);
618 <<
"Restricting to cellZone(s) " << flatOutput(zoneNames_)
619 <<
" with exposed internal faces into patch "
620 << mesh.boundaryMesh().findPatchID(exposedPatchName_) << endl;
637 Pout<<
"sampledCuttingPlane::expire :"
638 <<
" needsUpdate:" << needsUpdate_ <<
endl;
643 isoSurfacePtr_.reset(
nullptr);
663 Pout<<
"sampledCuttingPlane::update :"
664 <<
" needsUpdate:" << needsUpdate_ <<
endl;
674 needsUpdate_ =
false;
685 return sampleOnFaces(sampler);
695 return sampleOnFaces(sampler);
705 return sampleOnFaces(sampler);
715 return sampleOnFaces(sampler);
725 return sampleOnFaces(sampler);
735 return sampleOnPoints(interpolator);
745 return sampleOnPoints(interpolator);
755 return sampleOnPoints(interpolator);
765 return sampleOnPoints(interpolator);
775 return sampleOnPoints(interpolator);
781 os <<
"sampledCuttingPlane: " <<
name() <<
" :"
782 <<
" plane:" << plane_
787 os <<
" faces:" << faces().size()
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.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
SubField< vector > subField
static tmp< GeometricField< scalar, pointPatchField, pointMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=pointPatchField< scalar >::calculatedType())
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
void resize(label newCapacity)
Rehash the hash table with new number of buckets. Currently identical to setCapacity().
@ NO_REGISTER
Do not request registration (bool: false).
label size() const noexcept
The number of elements in the list.
static FOAM_NO_DANGLING_REFERENCE const pointMesh & New(const polyMesh &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 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.
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...
A bounding box defined in terms of min/max extrema points.
void reset()
Reset to an inverted box.
Constructs cutting plane through a mesh.
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.
const volVectorField & C() const
Return cell centres as volVectorField.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
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.
IOobject newIOobject(const word &name, IOobjectOption ioOpt) const
Create an IOobject at the current time instance (timeName) with the specified options.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
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.
const boundBox & bounds() const noexcept
Return mesh bounding box.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
const vectorField & faceCentres() const
const vectorField & cellCentres() const
label nPoints() const noexcept
Number of mesh points.
A sampledSurface defined by a plane using an iso-surface algorithm to cut the mesh.
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 const faceList & faces() const
Faces of surface.
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.
sampledCuttingPlane(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
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().
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.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
OBJstream os(runTime.globalPath()/outputName)
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
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...
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
Namespace for handling debugging switches.
Namespace of functions to calculate implicit derivatives returning a matrix.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< surfZone > surfZoneList
List of surfZone.
List< face > faceList
List of faces.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
MeshedSurface< face > meshedSurface
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
vector point
Point is a vector.
static constexpr const zero Zero
Global zero (0).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
fvPatchField< scalar > fvPatchScalarField
constexpr char nl
The newline '\n' character (0x0a).
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
#define forAll(list, i)
Loop across all elements in list.