34template<
class EdgeOrientIntersect,
class EdgeAlphaIntersect>
39 const EdgeOrientIntersect& edgeOrientIntersect,
40 const EdgeAlphaIntersect& edgeAlphaIntersect,
51 const label nCellCuts =
cellCuts.count();
60 nFaceCuts = 4*nCellCuts;
93 label unwindPoint = 0;
96 const auto unwindWalk =
97 [&](
const label failedCellId = -1) ->
void
100 dynCutPoints.
resize(unwindPoint);
103 endPoints.
erase(localEndPoints);
106 if (failedCellId != -1)
108 failedCells.
insert(failedCellId);
121 localFaceLoop.
clear();
122 localEndPoints.
clear();
124 unwindPoint = dynCutPoints.
size();
129 unsigned pointCutType = 0u;
131 for (
const label facei : cFace)
133 const face&
f = faces[facei];
140 if (!edgeOrientIntersect(
e))
158 label cutPointId = handledEdges.
lookup(
e, -1);
163 localEdges.
insert(
e, cutPointId);
168 cutPointId = dynCutPoints.
size();
174 const scalar
alpha = edgeAlphaIntersect(
e);
180 const label endp =
e.first();
182 if (endPoints.
insert(endp, cutPointId))
184 localEndPoints.
insert(endp);
189 cutPointId = endPoints[endp];
192 else if (
alpha >= (1.0 - SMALL))
196 const label endp =
e.last();
198 if (endPoints.
insert(endp, cutPointId))
200 localEndPoints.
insert(endp);
205 cutPointId = endPoints[endp];
216 localEdges.
insert(
e, cutPointId);
240 if (pointCutType == 1 || pointCutType == 2)
246 <<
"skip duplicate on-place cut for cell " << celli
247 <<
" type (" << pointCutType <<
")" <<
endl;
265 <<
"search face " << nextFace <<
" IN " << localEdges <<
endl;
279 <<
"lookup " << nextFace <<
" in " << iter.val() <<
nl;
282 const label got = iter.val().which(nextFace);
289 nextFace = iter.val()[(got?0:1)];
292 localFaceLoop.
append(localEdges[iter.key()]);
295 <<
" faces " << iter.val()
296 <<
" point " << localFaceLoop.
last()
297 <<
" edge=" << iter.key() <<
" nextFace=" << nextFace
315 if (nTargetLoop != localFaceLoop.
size())
318 <<
"Warn expected " << nTargetLoop <<
" but got "
327 handledEdges += localEdges;
329 face f(localFaceLoop);
332 if ((
f.areaNormal(dynCutPoints) & refEdge.
vec(
points)) < 0)
340 label nTri =
f.triangles(dynCutPoints, dynCutFaces);
343 dynCutCells.
append(celli);
349 dynCutCells.
append(celli);
353 if (failedCells.
size())
356 <<
"Failed cuts for " << failedCells.
size() <<
" cells:" <<
nl
363 if (dynCutCells.
empty())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
void append(const T &val)
Copy append an element to the end of this list.
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content.
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
A HashTable with keys but without contents that is similar to std::unordered_set.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
bool found(const Key &key) const
Same as contains().
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
void clear()
Remove all entries from table.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
pointField & storedPoints()
virtual label triangulate()
List< face > & storedFaces()
const Field< point_type > & points() const noexcept
const List< face_type > & localFaces() const
bool empty() const noexcept
True if List is empty (ie, size() is zero).
void size(const label n)
Older name for setAddressableSize.
T & last()
Access last element of the list, position [size()-1].
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Description of cuts across cells.
A cell is defined as a list of faces with extra functionality.
void walkCellCuts(const primitiveMesh &mesh, const bitSet &cellCuts, const EdgeOrientIntersect &edgeOrientIntersect, const EdgeAlphaIntersect &edgeAlphaIntersect, const bool triangulate, label nFaceCuts=0)
Walk cell cuts to create faces.
labelList meshCells_
List of the cells cut.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
vector vec(const UList< point > &pts) const
Return the vector (from first to second).
A face is a list of labels corresponding to mesh vertices.
Cell-face mesh analysis engine.
const volScalarField & p0
#define DebugInfo
Report an information message using Foam::Info.
#define WarningInFunction
Report a warning using Foam::Warning.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
List< face > faceList
List of faces.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< cell > cellList
List of cell.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
vector point
Point is a vector.
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
#define forAll(list, i)
Loop across all elements in list.
#define forAllIters(container, iter)
Iterate across all elements in the container object.