42 const Foam::scalar Foam::geomCellLooper::pointEqualTol_ = 1
e-3;
46 Foam::scalar Foam::geomCellLooper::snapTol_ = 0.1;
59 Foam::scalar Foam::geomCellLooper::minEdgeLen(
const label vertI)
const
61 scalar minLen = great;
67 const edge&
e =
mesh().
edges()[pEdges[pEdgeI]];
77 bool Foam::geomCellLooper::cutEdge
79 const plane& cutPlane,
86 const edge&
e = mesh().edges()[edgeI];
88 scalar
s = cutPlane.normalIntersect(pts[
e.start()],
e.vec(pts));
90 if ((
s > -pointEqualTol_) && (
s < 1 + pointEqualTol_))
114 const edge&
e = mesh().edges()[edgeI];
120 else if (weight > (1-tol))
137 scalar nComp =
n & base;
139 if (
mag(nComp) > 0.8)
148 if (
mag(nComp) > 0.8)
161 e0 /=
mag(e0) + vSmall;
175 bool Foam::geomCellLooper::edgeEndsCut
181 label edgeI = getEdge(loop[index]);
183 const edge&
e = mesh().edges()[edgeI];
185 const label prevCut = loop[loop.rcIndex(index)];
186 const label nextCut = loop[loop.fcIndex(index)];
188 if (!isEdge(prevCut) && !isEdge(nextCut))
192 label v0 = getVertex(prevCut);
193 label v1 = getVertex(nextCut);
197 (v0 ==
e[0] && v1 ==
e[1])
198 || (v0 ==
e[1] && v1 ==
e[0])
240 plane(mesh().cellCentres()[celli], refDir),
253 const plane& cutPlane,
264 const edgeList& edges = mesh().edges();
277 label nEstCuts = 2*mesh().cells()[celli].
size();
286 const labelList& cellEdges = mesh().cellEdges()[celli];
290 label edgeI = cellEdges[i];
292 const edge&
e = edges[edgeI];
294 bool useStart =
false;
302 if (!checkedPoints.
found(
e.start()))
304 checkedPoints.
insert(
e.start());
306 scalar typStartLen = pointEqualTol_ * minEdgeLen(
e.start());
312 localLoop.
append(vertToEVert(
e.start()));
313 localLoopWeights.
append(-great);
318 if (!checkedPoints.
found(
e.end()))
322 scalar typEndLen = pointEqualTol_ * minEdgeLen(
e.end());
328 localLoop.
append(vertToEVert(
e.end()));
329 localLoopWeights.
append(-great);
339 if (!useEnd && !useStart)
345 if (cutEdge(cutPlane, edgeI, cutWeight))
348 label cutVertI = snapToVert(snapTol_, edgeI, cutWeight);
353 localLoop.
append(edgeToEVert(edgeI));
354 localLoopWeights.
append(cutWeight);
361 label cut = vertToEVert(cutVertI);
365 localLoop.
append(vertToEVert(cutVertI));
366 localLoopWeights.
append(-great);
373 if (localLoop.
size() <= 2)
379 localLoopWeights.
shrink();
388 loopPoints[i] = coord(localLoop[i], localLoopWeights[i]);
389 ctr += loopPoints[i];
391 ctr /= localLoop.
size();
396 getBase(cutPlane.
normal(), e0, e1);
404 vector toCtr(loopPoints[i] - ctr);
421 loop[i] = localLoop[indices[i]];
422 loopWeights[i] = localLoopWeights[indices[i]];
427 bool filterLoop =
false;
433 if (isEdge(cut) && edgeEndsCut(loop, i))
452 if (isEdge(cut) && edgeEndsCut(loop, i))
458 filteredLoop[filterI] = loop[i];
459 filteredLoopWeights[filterI] = loopWeights[i];
464 filteredLoopWeights.
setSize(filterI);
467 loopWeights.
transfer(filteredLoopWeights);
475 Pout<<
"At angle:" << sortedAngles[i] <<
endl
478 writeCut(
Pout, loop[i], loopWeights[i]);
480 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.
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,.