34template<
class EdgeOrientIntersect,
class EdgeAlphaIntersect>
39 const EdgeOrientIntersect& edgeOrientIntersect,
40 const EdgeAlphaIntersect& edgeAlphaIntersect,
41 const bool triangulate,
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)
Map from edge (expressed as its endpoints) to value. For easier forward declaration it is currently i...
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
Return true if hashed entry is found in table.
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()
Clear all entries from table.
void transfer(List< T > &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()
Non-const access to global points.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
List< face > & storedFaces()
Non-const access to the faces.
const Field< point_type > & points() const noexcept
Return reference to global points.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
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.
T & last()
Return the last element of the list.
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 point labels. The functionality it provides supports the discretisation on a...
vector vec(const UList< point > &pts) const
Return the vector (end - start)
A face is a list of labels corresponding to mesh vertices.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
Cell-face mesh analysis engine.
const cellList & cells() const
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.
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.