37 const Foam::scalar zeroish = Foam::small;
38 const Foam::scalar positive = Foam::small * 1E3;
43 void Foam::cuttingPlane::calcCutCells
45 const primitiveMesh& mesh,
51 const edgeList& edges = mesh.edges();
53 label listSize = cellEdges.size();
56 listSize = cellIdLabels.size();
63 const bool isZoneEmpty
65 (
returnReduce(cellIdLabels.size(), sumOp<label>()) > 0) ?
false :
true 70 for (
label listI = 0; listI < listSize; ++listI)
76 celli = cellIdLabels[listI];
89 const labelList& cEdges = cellEdges[celli];
95 const edge& e = edges[cEdges[i]];
99 (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
100 || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
107 cutCells_[cutcelli++] = celli;
120 void Foam::cuttingPlane::intersectEdges
122 const primitiveMesh& mesh,
124 List<label>& edgePoint
128 const edgeList& edges = mesh.edges();
132 edgePoint.
setSize(edges.size());
134 DynamicList<point> dynCuttingPoints(4*cutCells_.
size());
138 const edge& e = edges[edgeI];
142 (dotProducts[e[0]] < zeroish && dotProducts[e[1]] > positive)
143 || (dotProducts[e[1]] < zeroish && dotProducts[e[0]] > positive)
147 edgePoint[edgeI] = dynCuttingPoints.size();
149 const point& p0 = points[e[0]];
150 const point& p1 = points[e[1]];
156 dynCuttingPoints.append(p0);
158 else if (alpha >= 1.0)
160 dynCuttingPoints.append(p1);
164 dynCuttingPoints.append((1-alpha)*p0 + alpha*p1);
169 edgePoint[edgeI] = -1;
177 bool Foam::cuttingPlane::walkCell
179 const primitiveMesh& mesh,
182 const label startEdgeI,
183 DynamicList<label>& faceVerts
187 label edgeI = startEdgeI;
194 faceVerts.append(edgePoint[edgeI]);
200 const labelList& fEdges = mesh.faceEdges()[facei];
202 label nextEdgeI = -1;
211 label edge2I = fEdges[i];
213 if (edge2I != edgeI && edgePoint[edge2I] != -1)
224 <<
"Did not find closed walk along surface of cell " << celli
225 <<
" starting from edge " << startEdgeI
226 <<
" in " << nIter <<
" iterations." <<
nl 227 <<
"Collected cutPoints so far:" << faceVerts
240 <<
"Did not find closed walk along surface of cell " << celli
241 <<
" starting from edge " << startEdgeI
242 <<
" in " << nIter <<
" iterations." <<
nl 243 <<
"Collected cutPoints so far:" << faceVerts
248 }
while (edgeI != startEdgeI);
251 if (faceVerts.size() >= 3)
258 <<
"Did not find closed walk along surface of cell " << celli
259 <<
" starting from edge " << startEdgeI <<
nl 260 <<
"Collected cutPoints so far:" << faceVerts
268 void Foam::cuttingPlane::walkCellCuts
270 const primitiveMesh& mesh,
271 const bool triangulate,
278 DynamicList<face> dynCutFaces(cutCells_.
size());
279 DynamicList<label> dynCutCells(cutCells_.
size());
282 DynamicList<label> faceVerts(10);
285 polygonTriangulate triEngine;
289 label celli = cutCells_[i];
292 const labelList& cEdges = mesh.cellEdges()[celli];
294 label startEdgeI = -1;
298 label edgeI = cEdges[cEdgeI];
300 if (edgePoint[edgeI] != -1)
308 if (startEdgeI == -1)
311 <<
"Cannot find cut edge for cut cell " << celli
316 bool okCut = walkCell
330 if ((
f.area(cutPoints) &
normal()) < 0)
338 triEngine.triangulate
340 UIndirectList<point>(cutPoints,
f)
342 forAll(triEngine.triPoints(), i)
344 dynCutFaces.append(triEngine.triPoints(i,
f));
345 dynCutCells.append(celli);
350 dynCutFaces.append(
f);
351 dynCutCells.append(celli);
366 const bool triangulate,
376 calcCutCells(mesh, dotProducts, cellIdLabels);
381 intersectEdges(mesh, dotProducts, edgePoint);
384 walkCellCuts(mesh, triangulate, edgePoint);
401 newCutCells[facei] = cutCells_[faceMap[facei]];
420 const bool triangulate,
426 reCut(mesh, triangulate, cellIdLabels);
List< labelList > labelListList
A List of labelList.
#define forAll(list, i)
Loop across all elements in list.
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void reCut(const primitiveMesh &, const bool triangulate, const labelUList &cellIdLabels=labelUList::null())
Recut mesh with existing planeDesc, restricted to a list of cells.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Cell-face mesh analysis engine.
void size(const label)
Override size to be inconsistent with allocated storage.
virtual void clear()
Clear all storage.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const pointField & points() const =0
Return mesh points.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
UList< label > labelUList
plane(const vector &normalVector)
Construct from normal vector through the origin.
vectorField pointField
pointField is a vectorField.
line< point, const point & > linePointRef
Line using referred points.
List< face > & storedFaces()
Non-const access to the faces.
void clear()
Clear the list, i.e. set size to zero.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const point & refPoint() const
Return or return plane base point.
pointField & storedPoints()
Non-const access to global points.
virtual void remapFaces(const labelUList &faceMap)
Remap action on triangulation or cleanup.
const Field< PointType > & points() const
Return reference to global points.
List< label > labelList
A List of labels.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
volScalarField scalarField(fieldObject, mesh)
scalar lineIntersect(const line< Point, PointRef > &l) const
Return the cutting point between the plane and.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
void setSize(const label)
Reset size of List.
const vector & normal() const
Return plane normal.
virtual void remapFaces(const labelUList &faceMap)
Set new zones from faceMap.
vector point
Point is a vector.
#define WarningInFunction
Report a warning using Foam::Warning.
cuttingPlane(const plane &)
Construct plane description without cutting.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
label size() const
Return the number of elements in the UList.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.