58 const dictionary&
dict
64 const dictionary* dictptr =
nullptr;
65 coordSystem::cartesian cs;
87 cs = coordSystem::cartesian(*dictptr);
94 const point orig = cs.globalPosition(pln.origin());
95 const vector norm = cs.globalVector(pln.normal());
99 <<
" origin:" << pln.origin()
100 <<
" normal:" << pln.normal()
102 <<
" origin:" << orig <<
" normal:" << norm
106 pln = plane(orig, norm);
113void Foam::sampledCuttingPlane::checkBoundsIntersection
120 const boundBox& clipBb = isoParams_.getClipBounds();
125 if (!clipBb.overlaps(
meshBb))
130 <<
"Bounds " << clipBb
131 <<
" do not overlap the mesh bounding box " <<
meshBb
136 if (!clipBb.intersects(pln))
141 <<
"Plane "<< pln <<
" does not intersect the bounds "
148 if (!
meshBb.intersects(pln))
153 <<
"Plane "<< pln <<
" does not intersect the mesh bounds "
160void Foam::sampledCuttingPlane::setDistanceFields(
const plane& pln)
167 const fvMesh&
mesh = cellDistance.mesh();
179 fld[i] = pln.signedDistance(cc[i]);
186 cellDistance.boundaryFieldRef();
188 forAll(cellDistanceBf, patchi)
192 isA<emptyFvPatchScalarField>
194 cellDistanceBf[patchi]
201 new calculatedFvPatchScalarField
212 fld.setSize(pp.size());
215 fld[i] = pln.signedDistance(cc[i]);
226 fld[i] = pln.signedDistance(cc[i]);
243 pointDistance_[i] = pln.signedDistance(pts[i]);
249void Foam::sampledCuttingPlane::combineSurfaces
251 PtrList<isoSurfaceBase>& isoSurfPtrs
254 isoSurfacePtr_.reset(
nullptr);
262 && isoSurfPtrs.size() == 1
266 isoSurfacePtr_.reset(isoSurfPtrs.release(0));
268 else if (isoSurfPtrs.size() == 1)
270 autoPtr<isoSurfaceBase> ptr(isoSurfPtrs.release(0));
274 meshCells_.transfer(surf.meshCells());
285 for (
const auto& surf : isoSurfPtrs)
288 nPoints += surf.points().size();
293 meshCells_.resize(
nFaces);
299 forAll(isoSurfPtrs, surfi)
301 autoPtr<isoSurfaceBase> ptr(isoSurfPtrs.release(surfi));
304 SubList<face> subFaces(newFaces, surf.size(),
nFaces);
305 SubList<point> subPoints(newPoints, surf.points().size(),
nPoints);
306 SubList<label> subCells(meshCells_, surf.size(),
nFaces);
308 newZones[surfi] = surfZone
316 subFaces = surf.surfFaces();
317 subPoints = surf.points();
318 subCells = surf.meshCells();
322 for (face&
f : subFaces)
324 for (label& pointi :
f)
337 std::move(newPoints),
342 surface_.transfer(combined);
346 if (subMeshPtr_ && meshCells_.size())
349 UIndirectList<label>(subMeshPtr_->cellMap(), meshCells_);
354void Foam::sampledCuttingPlane::createGeometry()
358 Pout<<
"sampledCuttingPlane::createGeometry :updating geometry."
365 isoSurfacePtr_.reset(
nullptr);
371 pointDistance_.clear();
372 cellDistancePtr_.clear();
374 const bool hasCellZones =
377 const fvMesh& fvm =
static_cast<const fvMesh&
>(this->
mesh());
386 subMeshPtr_.reset(
nullptr);
389 if (!ignoreCellsPtr_)
391 ignoreCellsPtr_.reset(
new bitSet);
395 bitSet
select(
mesh().cellZones().selection(zoneNames_));
402 *ignoreCellsPtr_ = std::move(select);
413 ignoreCellsPtr_->clearStorage();
417 ignoreCellsPtr_.reset(
new bitSet);
421 if (!subMeshPtr_ && hasCellZones)
423 const label exposedPatchi =
426 bitSet cellsToSelect(
mesh().cellZones().selection(zoneNames_));
429 <<
"Allocating subset of size "
430 << cellsToSelect.count() <<
" with exposed faces into patch "
431 << exposedPatchi <<
endl;
437 const boundBox& clipBb = isoParams_.getClipBounds();
438 if (clipBb.valid() && cellsToSelect.any())
440 const auto& cellCentres = fvm.C();
442 for (
const label celli : cellsToSelect)
444 const point& cc = cellCentres[celli];
446 if (!clipBb.contains(cc))
448 cellsToSelect.unset(celli);
453 <<
"Bounded subset of size "
454 << cellsToSelect.count() <<
endl;
459 new fvMeshSubset(fvm, cellsToSelect, exposedPatchi)
469 ? subMeshPtr_->subMesh()
473 checkBoundsIntersection(plane_,
mesh.
bounds());
479 cellDistancePtr_.reset
498 setDistanceFields(plane_);
502 Pout<<
"Writing cell distance:" << cellDistance.objectPath() <<
endl;
503 cellDistance.
write();
518 pointDist.primitiveFieldRef() = pointDistance_;
520 Pout<<
"Writing point distance:" << pointDist.objectPath() <<
endl;
527 PtrList<isoSurfaceBase> isoSurfPtrs(offsets_.size());
546 combineSurfaces(isoSurfPtrs);
552 cellDistancePtr_.reset(
nullptr);
553 pointDistance_.clear();
582 average_(
dict.getOrDefault(
"average", false)),
583 simpleSubMesh_(
dict.getOrDefault(
"simpleSubMesh", false)),
590 isoSurfacePtr_(nullptr),
592 subMeshPtr_(nullptr),
593 ignoreCellsPtr_(nullptr),
594 cellDistancePtr_(nullptr),
599 if (offsets_.
empty())
605 if (offsets_.
size() > 1)
607 const label nOrig = offsets_.
size();
611 if (nOrig != offsets_.
size())
614 <<
"Removed non-unique offsets" <<
nl;
621 simpleSubMesh_ =
false;
624 if (offsets_.
size() > 1)
627 <<
"Multiple offsets with iso-surface (point) not supported"
628 <<
" since needs original interpolators." <<
nl
647 <<
"Restricting to cellZone(s) " <<
flatOutput(zoneNames_)
648 <<
" with exposed internal faces into patch "
666 Pout<<
"sampledCuttingPlane::expire :"
667 <<
" needsUpdate:" << needsUpdate_ <<
endl;
672 isoSurfacePtr_.reset(
nullptr);
692 Pout<<
"sampledCuttingPlane::update :"
693 <<
" needsUpdate:" << needsUpdate_ <<
endl;
703 needsUpdate_ =
false;
714 return sampleOnFaces(sampler);
724 return sampleOnFaces(sampler);
734 return sampleOnFaces(sampler);
744 return sampleOnFaces(sampler);
754 return sampleOnFaces(sampler);
764 return sampleOnPoints(interpolator);
774 return sampleOnPoints(interpolator);
784 return sampleOnPoints(interpolator);
794 return sampleOnPoints(interpolator);
804 return sampleOnPoints(interpolator);
810 os <<
"sampledCuttingPlane: " <<
name() <<
" :"
811 <<
" plane:" << plane_
816 os <<
" faces:" << faces().size()
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<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
SubField< vector > subField
Declare type of subField.
Minimal example by using system/controlDict.functions:
GeometricBoundaryField< scalar, fvPatchField, volMesh > Boundary
Type of boundary fields.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
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,...
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
static word timeName(const scalar t, const int precision=precision_)
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.
label findIndex(const wordRe &key) const
Zone index for the first match, return -1 if not found.
static word defaultName
The default cloud name: defaultCloud.
Constructs cutting plane through a mesh.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
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
const volVectorField & C() const
Return cell centres as volVectorField.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const Time & time() const
Return the top-level database.
Abstract base class for volume field interpolation.
Preferences for controlling iso-surface algorithms.
algorithmType algorithm() const noexcept
Get current algorithm.
scalar print()
Print to screen.
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 boundBox & bounds() const
Return mesh bounding box.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
virtual const pointField & points() const
Return raw points.
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 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.
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 Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
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.
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 WarningInFunction
Report a warning using Foam::Warning.
List< bool > select(const label n, const labelUList &locations)
Ostream & print(Ostream &os, UIntType value, char off='0', char on='1')
Print 0/1 bits in the (unsigned) integral type.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
GeometricField< scalar, pointPatchField, pointMesh > pointScalarField
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
MeshedSurface< face > meshedSurface
void inplaceUniqueSort(ListType &input)
Inplace sorting and removal of duplicates.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
static constexpr const zero Zero
Global zero (0)
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)
fvPatchField< scalar > fvPatchScalarField
constexpr char nl
The newline '\n' character (0x0a)
List< treeBoundBox > meshBb(1, treeBoundBox(boundBox(coarseMesh.points(), false)).extend(rndGen, 1e-3))
#define forAll(list, i)
Loop across all elements in list.