49 for (label celli = 0; celli < mesh_.nCells(); ++celli)
51 if (ignoreCells.
test(celli))
59 ignoreCells.
set(celli);
75 bitSet blockedFaces(mesh_.nFaces());
77 const labelList& faceOwn = mesh_.faceOwner();
78 const labelList& faceNei = mesh_.faceNeighbour();
81 for (label facei = 0; facei < mesh_.nInternalFaces(); ++facei)
88 ignoreCells.test(faceOwn[facei])
89 != ignoreCells.test(faceNei[facei])
92 blockedFaces.set(facei);
105 const label facei =
patch.start() + patchFacei;
106 if (ignoreCells.test(faceOwn[facei]))
108 blockedFaces.set(facei);
125 bitSet blockedFaces(filterPrepareRegionSplit(ignoreCells));
129 blockedFaces.clearStorage();
137 forAll(regionColour, celli)
139 if (!ignoreCells.
test(celli))
141 ++nCutsPerRegion[regionColour[celli]];
150 boolList keepRegion(rs.nRegions(),
false);
154 const label largest =
findMax(nCutsPerRegion);
163 keepRegion[largest] =
true;
168 Info<<
"Had " <<
sum(nCutsPerRegion) <<
" cuts, in "
169 << nCutsPerRegion.size() <<
" regions, largest is "
176 forAll(regionColour, celli)
178 if (!keepRegion.test(regionColour[celli]))
180 ignoreCells.
set(celli);
191 if (nearestPoints_.empty())
194 <<
"Ignoring nearestPoints - no points provided" <<
nl
200 bitSet blockedFaces(filterPrepareRegionSplit(ignoreCells));
204 blockedFaces.clearStorage();
221 if (ignoreCells.test(celli))
226 const point& pt = cc[celli];
227 const label regioni = regionColour[celli];
229 ++nCutsPerRegion[regioni];
232 for (nearInfo& near : nearest)
234 const scalar distSqr =
magSqr(nearPts[pointi] - pt);
237 if (distSqr < near.first())
239 near.first() = distSqr;
240 near.second() = regioni;
254 boolList keepRegion(rs.nRegions(),
false);
258 const label largest =
findMax(nCutsPerRegion);
260 for (
const nearInfo& near : nearest)
262 const scalar distSqr = near.first();
263 const label regioni = near.second();
265 if (regioni != -1 && distSqr < maxDistanceSqr_)
267 keepRegion[regioni] =
true;
273 Info<<
"Had " <<
sum(nCutsPerRegion) <<
" cuts, in "
274 << nCutsPerRegion.size() <<
" regions, largest is "
277 Info<<
"nearestPoints (max distance = "
278 <<
sqrt(maxDistanceSqr_) <<
")" <<
nl;
282 const scalar dist =
sqrt(nearest[pointi].first());
283 const label regioni = nearest[pointi].second();
285 Info<<
" " << nearPts[pointi] <<
" region "
286 << regioni <<
" distance "
289 if (!keepRegion.test(regioni))
300 forAll(regionColour, celli)
302 if (!keepRegion.test(regionColour[celli]))
304 ignoreCells.set(celli);
318 const pointField& fc = surface_.faceCentres();
321 bitSet blockedFaces(filterPrepareRegionSplit(ignoreCells));
325 blockedFaces.clearStorage();
341 calcAbsoluteDistance(faceDistance, fc, nearest);
350 const label celli = meshCells_[facei];
351 const label regioni = regionColour[celli];
353 const scalar faceArea = surface_[facei].mag(surface_.points());
354 distRegion[regioni] += (faceDistance[facei] * faceArea);
355 areaRegion[regioni] += (faceArea);
363 forAll(distRegion, regioni)
365 distRegion[regioni] /= (areaRegion[regioni] + VSMALL);
374 bitSet acceptFaces(fc.size());
379 const label celli = meshCells_[facei];
380 const label regioni = regionColour[celli];
386 if (absProximity_ < distRegion[regioni])
392 acceptFaces.set(facei);
418 [&](
const label celli){
return regionColour[celli]; }
440 forAll(faceDistance, facei)
442 if (absProximity_ < faceDistance[facei])
448 acceptFaces.set(facei);
458 surface_.subsetMesh(acceptFaces, pointMap,
faceMap)
460 surface_.transfer(filtered);
469 const searchableSurface& geom = geometryPtr_();
472 const pointField& fc = surface_.faceCentres();
478 List<pointIndexHit> nearest;
486 calcAbsoluteDistance(faceDistance, fc, nearest);
492 geom.getNormal(nearest, norms);
494 faceNormalDistance.
resize(fc.size());
513 bitSet acceptFaces(fc.size());
517 forAll(faceDistance, facei)
519 if (absProximity_ < faceDistance[facei])
524 Pout<<
"trim reject: "
525 << faceDistance[facei] <<
nl;
530 acceptFaces.set(facei);
550 writer.
write(
"normal-distance", faceNormalDistance);
566 surface_.subsetMesh(acceptFaces, pointMap,
faceMap)
568 surface_.transfer(filtered);
Various functions to operate on Lists.
vtk::lineWriter writer(edgeCentres, edgeList::null(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edgesCentres")))
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
void clearStorage()
Clear the list and delete storage.
void reset()
Clear all bits but do not adjust the addressable size.
static void listGather(UList< T > &values, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Gather (reduce) list elements, applying bop to each list element.
static void listCombineGather(UList< T > &values, CombineOp cop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Forwards to Pstream::listGather with an in-place cop.
A 2-tuple for storing two objects of dissimilar types. The container is similar in purpose to std::pa...
A List with indirect addressing. Like IndirectList but does not store addressing.
bool test(const label i) const
Test bool value at specified position, always false for out-of-range access.
void size(const label n)
Older name for setAddressableSize.
static bool master(const label communicator=worldComm)
True if process corresponds to the master rank in the communicator.
@ broadcast
broadcast [MPI]
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
void set(const bitSet &bitset)
Set specified bits from another bitset.
bool none() const
True if no bits in this bitset are set.
bool test(const label pos) const
Test for True value at specified position, never auto-vivify entries.
void filterFaceProximity()
Adjust extracted iso-surface to remove far faces.
bitSet filterPrepareRegionSplit(const bitSet &ignoreCells) const
Prepare blockedFaces for region split.
void filterRegionProximity(bitSet &ignoreCells) const
Remove region(s) that have far faces.
void filterKeepNearestRegions(bitSet &ignoreCells) const
Keep region(s) closest to the nearest points.
bool refineBlockedCells(bitSet &ignoreCells, const isoSurfaceBase &isoContext) const
Re-filter the blocked cells based on the anticipated cuts.
void filterKeepLargestRegion(bitSet &ignoreCells) const
Keep region with the most cuts (after region split).
const word & surfaceName() const
The name of the underlying searchableSurface.
A class for handling file names.
Low-level components common to various iso-surface algorithms.
@ ANYCUT
Any cut type (bitmask).
cutType getCellCutType(const label celli) const
Cell cut for an individual cell, with special handling for TETCUT and SPHERE cuts.
A patch is a list of labels that address the faces in the global face list.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundaryMesh reference.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
label nRegions() const
Return total number of regions.
Base class of (analytical or triangulated) surface. Encapsulates all the search routines....
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
virtual void getNormal(const List< pointIndexHit > &, vectorField &normal) const =0
From a set of points and indices get the normal.
A surfaceWriter for VTK legacy (.vtk) or XML (.vtp) format.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
void write(const word &fieldName, const UList< Type > &field)
Write primitive field of CellData (Poly or Line) or PointData values.
word outputName("finiteArea-edges.obj")
#define WarningInFunction
Report a warning using Foam::Warning.
List< T > create(const UList< T2 > &input, const UnaryOperation &op)
Create a List from a List of a dissimilar type, using the entire list.
List< T > createWithValue(const label len, const labelUList &locations, const T &val, const T &deflt=T())
Create a List filled with default values and various locations with another specified value.
Namespace for handling debugging switches.
const std::string patch
OpenFOAM patch number as a std::string.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
List< label > labelList
A List of labels.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensionedScalar sqrt(const dimensionedScalar &ds)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
MeshedSurface< face > meshedSurface
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
bool returnReduceAnd(const bool value, const int communicator=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
Field< vector > vectorField
Specialisation of Field<T> for vector.
Field< label > labelField
Specialisation of Field<T> for label.
vector point
Point is a vector.
List< bool > boolList
A List of bools.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
label findMax(const ListType &input, label start=0)
Linear search for the index of the max element, similar to std::max_element but for lists and returns...
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
Assign tuple-like container to use the one with the smaller value of first.