42 const Foam::scalar Foam::geomCellLooper::pointEqualTol_ = 1
e-3;
46 Foam::scalar Foam::geomCellLooper::snapTol_ = 0.1;
62 Foam::scalar Foam::geomCellLooper::minEdgeLen(
const label vertI)
const
64 scalar minLen = great;
70 const edge&
e =
mesh().
edges()[pEdges[pEdgeI]];
80 bool Foam::geomCellLooper::cutEdge
82 const plane& cutPlane,
89 const edge&
e = mesh().edges()[edgeI];
91 scalar
s = cutPlane.normalIntersect(pts[
e.start()],
e.vec(pts));
93 if ((
s > -pointEqualTol_) && (
s < 1 + pointEqualTol_))
117 const edge&
e = mesh().edges()[edgeI];
123 else if (weight > (1-tol))
140 scalar nComp =
n & base;
142 if (
mag(nComp) > 0.8)
151 if (
mag(nComp) > 0.8)
164 e0 /=
mag(e0) + vSmall;
178 bool Foam::geomCellLooper::edgeEndsCut
184 label edgeI = getEdge(loop[index]);
186 const edge&
e = mesh().edges()[edgeI];
188 const label prevCut = loop[loop.rcIndex(index)];
189 const label nextCut = loop[loop.fcIndex(index)];
191 if (!isEdge(prevCut) && !isEdge(nextCut))
195 label v0 = getVertex(prevCut);
196 label v1 = getVertex(nextCut);
200 (v0 ==
e[0] && v1 ==
e[1])
201 || (v0 ==
e[1] && v1 ==
e[0])
243 plane(mesh().cellCentres()[celli], refDir),
256 const plane& cutPlane,
267 const edgeList& edges = mesh().edges();
280 label nEstCuts = 2*mesh().cells()[celli].
size();
289 const labelList& cellEdges = mesh().cellEdges()[celli];
293 label edgeI = cellEdges[i];
295 const edge&
e = edges[edgeI];
297 bool useStart =
false;
305 if (!checkedPoints.
found(
e.start()))
307 checkedPoints.
insert(
e.start());
309 scalar typStartLen = pointEqualTol_ * minEdgeLen(
e.start());
315 localLoop.
append(vertToEVert(
e.start()));
316 localLoopWeights.
append(-great);
321 if (!checkedPoints.
found(
e.end()))
325 scalar typEndLen = pointEqualTol_ * minEdgeLen(
e.end());
331 localLoop.
append(vertToEVert(
e.end()));
332 localLoopWeights.
append(-great);
342 if (!useEnd && !useStart)
348 if (cutEdge(cutPlane, edgeI, cutWeight))
351 label cutVertI = snapToVert(snapTol_, edgeI, cutWeight);
356 localLoop.
append(edgeToEVert(edgeI));
357 localLoopWeights.
append(cutWeight);
364 label cut = vertToEVert(cutVertI);
368 localLoop.
append(vertToEVert(cutVertI));
369 localLoopWeights.
append(-great);
376 if (localLoop.
size() <= 2)
382 localLoopWeights.
shrink();
391 loopPoints[i] = coord(localLoop[i], localLoopWeights[i]);
392 ctr += loopPoints[i];
394 ctr /= localLoop.
size();
399 getBase(cutPlane.
normal(), e0, e1);
407 vector toCtr(loopPoints[i] - ctr);
424 loop[i] = localLoop[indices[i]];
425 loopWeights[i] = localLoopWeights[indices[i]];
430 bool filterLoop =
false;
436 if (isEdge(cut) && edgeEndsCut(loop, i))
455 if (isEdge(cut) && edgeEndsCut(loop, i))
461 filteredLoop[filterI] = loop[i];
462 filteredLoopWeights[filterI] = loopWeights[i];
467 filteredLoopWeights.
setSize(filterI);
470 loopWeights.
transfer(filteredLoopWeights);
478 Pout<<
"At angle:" << sortedAngles[i] <<
endl
481 writeCut(
Pout, loop[i], loopWeights[i]);
483 Pout<<
" coord:" << coord(loop[i], loopWeights[i]);
Various functions to operate on Lists.
#define forAll(list, i)
Loop across all elements in list.
Macros for easy insertion into run-time selection tables.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
bool insert(const Key &key)
Insert a new entry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
A list that is sorted upon construction or when explicitly requested with the sort() method.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
void sort()
(stable) sort the list (if changed after construction time)
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
const polyMesh & mesh() const
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Implementation of cellLooper. Does pure geometric cut through cell.
geomCellLooper(const polyMesh &mesh)
Construct from components.
virtual bool cut(const vector &refDir, const label celli, const boolList &vertIsCut, const boolList &edgeIsCut, const scalarField &edgeWeight, labelList &loop, scalarField &loopWeights) const
Create cut along circumference of celli. Gets current mesh cuts.
virtual ~geomCellLooper()
Destructor.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
scalar distance(const point &p) const
Return distance from the given point to the plane.
const vector & normal() const
Return the plane normal.
Mesh consisting of general polyhedral cells.
const labelListList & pointEdges() const
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
A class for handling words, derived from string.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const dimensionedScalar e
Elementary charge.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
vectorField pointField
pointField is a vectorField.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
Vector< scalar > vector
A scalar version of the templated Vector.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
scalar pseudoAngle(const vector &e0, const vector &e1, const vector &vec)
Estimate angle of vec in coordinate system (e0, e1, e0^e1).
prefixOSstream Pout(cout, "Pout")
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)