34 template<
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())
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
A HashTable with keys but without contents that is similar to std::unordered_set. ...
void size(const label n)
Older name for setAddressableSize.
A face is a list of labels corresponding to mesh vertices.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
bool found(const Key &key) const
Same as contains()
Cell-face mesh analysis engine.
constexpr char nl
The newline '\n' character (0x0a)
bool empty() const noexcept
True if List is empty (ie, size() is zero)
void resize(const label len)
Alter addressable list size, allocating new space if required while recovering old content...
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
Description of cuts across cells.
#define forAll(list, i)
Loop across all elements in list.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
List< T > values(const HashTable< T, Key, Hash > &tbl, const bool doSort=false)
List of values from HashTable, optionally sorted.
label size() const noexcept
The number of elements in table.
const dimensionedScalar e
Elementary charge.
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.
List< Face > & storedFaces()
Non-const access to the faces.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
void clear()
Clear the list, i.e. set size to zero.
void clear()
Remove all entries from table.
pointField & storedPoints()
Non-const access to global points.
virtual label triangulate()
Triangulate in-place, returning the number of triangles added.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
const Field< point_type > & points() const noexcept
Return reference to global points.
void append(const T &val)
Copy append an element to the end of this list.
vector vec(const UList< point > &pts) const
Return the vector (from first to second).
labelList meshCells_
List of the cells cut.
#define DebugInfo
Report an information message using Foam::Info.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
void clear() noexcept
Clear the addressed list, i.e. set the size to zero.
T & last()
Access last element of the list, position [size()-1].
bool erase(const iterator &iter)
Erase an entry specified by given iterator.
const T & lookup(const Key &key, const T &deflt) const
Return hashed entry if it exists, or return the given default.
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
#define WarningInFunction
Report a warning using Foam::Warning.
A cell is defined as a list of faces with extra functionality.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
const volScalarField & p0
FlatOutput::OutputAdaptor< Container, Delimiters > flatOutput(const Container &obj, Delimiters delim)
Global flatOutput() function with specified output delimiters.