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.valid() && 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 482 setDistanceFields(plane_);
486 Pout<<
"Writing cell distance:" << cellDistance.objectPath() <<
endl;
487 cellDistance.
write();
504 Pout<<
"Writing point distance:" << pointDist.objectPath() <<
endl;
511 PtrList<isoSurfaceBase> isoSurfPtrs(offsets_.size());
530 combineSurfaces(isoSurfPtrs);
536 cellDistancePtr_.reset(
nullptr);
537 pointDistance_.clear();
553 const polyMesh&
mesh,
554 const dictionary&
dict 563 isoSurfaceParams::ALGO_TOPO,
564 isoSurfaceParams::filterType::DIAGCELL
566 average_(
dict.getOrDefault(
"average", false)),
567 simpleSubMesh_(
dict.getOrDefault(
"simpleSubMesh", false)),
574 isoSurfacePtr_(nullptr),
576 subMeshPtr_(nullptr),
577 ignoreCellsPtr_(nullptr),
578 cellDistancePtr_(nullptr),
581 dict.readIfPresent(
"offsets", offsets_);
583 if (offsets_.
empty())
589 if (offsets_.
size() > 1)
591 const label nOrig = offsets_.
size();
595 if (nOrig != offsets_.
size())
598 <<
"Removed non-unique offsets" <<
nl;
605 simpleSubMesh_ =
false;
608 if (offsets_.
size() > 1)
611 <<
"Multiple offsets with iso-surface (point) not supported" 612 <<
" since needs original interpolators." <<
nl 620 if (!
dict.readIfPresent(
"zones", zoneNames_) &&
dict.found(
"zone"))
623 dict.readEntry(
"zone", zoneNames_.
first());
628 dict.readIfPresent(
"exposedPatchName", exposedPatchName_);
631 <<
"Restricting to cellZone(s) " <<
flatOutput(zoneNames_)
632 <<
" with exposed internal faces into patch " 650 Pout<<
"sampledCuttingPlane::expire :" 651 <<
" needsUpdate:" << needsUpdate_ <<
endl;
656 isoSurfacePtr_.reset(
nullptr);
676 Pout<<
"sampledCuttingPlane::update :" 677 <<
" needsUpdate:" << needsUpdate_ <<
endl;
687 needsUpdate_ =
false;
698 return sampleOnFaces(sampler);
708 return sampleOnFaces(sampler);
718 return sampleOnFaces(sampler);
728 return sampleOnFaces(sampler);
738 return sampleOnFaces(sampler);
748 return sampleOnPoints(interpolator);
758 return sampleOnPoints(interpolator);
768 return sampleOnPoints(interpolator);
778 return sampleOnPoints(interpolator);
788 return sampleOnPoints(interpolator);
794 os <<
"sampledCuttingPlane: " <<
name() <<
" :" 795 <<
" plane:" << plane_
800 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 a new 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.
Ignore writing from objectRegistry::writeObject()
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
const Time & time() const
Return the top-level database.
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 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.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
const vectorField & cellCentres() const
#define DebugInfo
Report an information message using Foam::Info.
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...
static word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time formatted with the given precision.
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
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
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.
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)