58 const dictionary&
dict 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);
97 void 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 " 144 void Foam::sampledCuttingPlane::setDistanceFields(
const plane& pln)
151 const fvMesh&
mesh = cellDistance.mesh();
163 fld[i] = pln.signedDistance(cc[i]);
170 cellDistance.boundaryFieldRef();
172 forAll(cellDistanceBf, patchi)
176 isA<emptyFvPatchScalarField>
178 cellDistanceBf[patchi]
185 new calculatedFvPatchScalarField
196 fld.setSize(
pp.size());
199 fld[i] = pln.signedDistance(cc[i]);
210 fld[i] = pln.signedDistance(cc[i]);
227 pointDistance_[i] = pln.signedDistance(
pts[i]);
233 void Foam::sampledCuttingPlane::combineSurfaces
235 PtrList<isoSurfaceBase>& isoSurfPtrs
238 isoSurfacePtr_.reset(
nullptr);
246 && isoSurfPtrs.size() == 1
250 isoSurfacePtr_.reset(isoSurfPtrs.release(0));
252 else if (isoSurfPtrs.size() == 1)
254 autoPtr<isoSurfaceBase> ptr(isoSurfPtrs.release(0));
257 surface_.transfer(static_cast<meshedSurface&>(surf));
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)
285 autoPtr<isoSurfaceBase> ptr(isoSurfPtrs.release(surfi));
288 SubList<face> subFaces(newFaces, surf.size(), nFaces);
289 SubList<point> subPoints(newPoints, surf.points().size(),
nPoints);
290 SubList<label> subCells(meshCells_, surf.size(), nFaces);
292 newZones[surfi] = surfZone
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())
333 UIndirectList<label>(subMeshPtr_->cellMap(), meshCells_);
338 void Foam::sampledCuttingPlane::createGeometry()
342 Pout<<
"sampledCuttingPlane::createGeometry :updating geometry." 349 isoSurfacePtr_.reset(
nullptr);
355 pointDistance_.clear();
356 cellDistancePtr_.clear();
358 const bool hasCellZones =
361 const fvMesh& fvm =
static_cast<const fvMesh&
>(this->
mesh());
370 subMeshPtr_.reset(
nullptr);
373 if (!ignoreCellsPtr_)
375 ignoreCellsPtr_.reset(
new bitSet);
379 bitSet
select(
mesh().cellZones().selection(zoneNames_));
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;
443 new fvMeshSubset(fvm, cellsToSelect, exposedPatchi)
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;
498 PtrList<isoSurfaceBase> isoSurfPtrs(offsets_.size());
517 combineSurfaces(isoSurfPtrs);
523 cellDistancePtr_.reset(
nullptr);
524 pointDistance_.clear();
540 const polyMesh&
mesh,
541 const dictionary&
dict 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())
576 if (offsets_.
size() > 1)
578 const label nOrig = offsets_.
size();
582 if (nOrig != offsets_.
size())
585 <<
"Removed non-unique offsets" <<
nl;
592 simpleSubMesh_ =
false;
595 if (offsets_.
size() > 1)
598 <<
"Multiple offsets with iso-surface (point) not supported" 599 <<
" since needs original interpolators." <<
nl 607 if (!
dict.readIfPresent(
"zones", zoneNames_) &&
dict.found(
"zone"))
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 " 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()
label findPatchID(const word &patchName, const bool allowNotFound=true) const
Find patch index given a name, return -1 if not found.
void size(const label n)
Older name for setAddressableSize.
bool interpolate() const noexcept
Same as isPointData()
errorManipArg< error, int > exit(error &err, const int errNo=1)
virtual bool expire()
Mark the surface as needing an update.
void resize(const label len)
Adjust allocated size of list.
const polyMesh & mesh() const noexcept
Access to the underlying mesh.
label nPoints() const noexcept
Number of mesh points.
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create MeshObject registered with typeName.
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
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].
Ostream & endl(Ostream &os)
Add newline and flush stream.
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
Type of boundary fields.
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
virtual tmp< scalarField > sample(const interpolation< scalar > &sampler) const
Sample volume field onto surface faces.
Macros for easy insertion into run-time selection tables.
addNamedToRunTimeSelectionTable(topoSetCellSource, badQualityToCell, word, badQuality)
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
GeometricField< scalar, fvPatchField, volMesh > volScalarField
List< face > faceList
List of faces.
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 expressions::valueTypeCode::INVALID.
fvPatchField< scalar > fvPatchScalarField
virtual bool needsUpdate() const
Does the surface need an update?
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
MeshedSurface< face > meshedSurface
static word defaultName(const label n=-1)
Default zone name: "zone" or "zoneN".
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
void inplaceUniqueSort(ListType &input)
Inplace sorting and removal of duplicates.
const vectorField & cellCentres() const
#define DebugInfo
Report an information message using Foam::Info.
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())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
algorithmType algorithm() const noexcept
Get current algorithm.
defineTypeNameAndDebug(combustionModel, 0)
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const vectorField & faceCentres() const
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
sampledCuttingPlane(const word &name, const polyMesh &mesh, const dictionary &dict)
Construct from dictionary.
List< surfZone > surfZoneList
List of surfZone.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
SubField< vector > subField
Declare type of subField.
const boundBox & bounds() const noexcept
Return mesh bounding box.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const volVectorField & C() const
Return cell centres as volVectorField.
A class for managing temporary objects.
IOobject newIOobject(const word &name, IOobjectOption ioOpt) const
Create an IOobject at the current time instance (timeName) with the specified options.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Do not request registration (bool: false)
virtual bool update()
Update the surface as required.
List< treeBoundBox > meshBb(1, treeBoundBox(coarseMesh.points()).extend(rndGen, 1e-3))
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
virtual void print(Ostream &os, int level=0) const
Print information.
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.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
static constexpr const zero Zero
Global zero (0)