55void Foam::topoCellLooper::subsetList
71 lst.setCapacity(freeI);
77 for (label elemI = startI; elemI < freeI; elemI++)
79 lst[newI++] = lst[elemI];
82 if ((freeI - startI) < 0)
88 lst.setCapacity(freeI - startI);
134void Foam::topoCellLooper::walkFace
138 const label startEdgeI,
139 const label startVertI,
140 const label nFeaturePts,
160 if (features.isFeatureVertex(facei, vertI))
170 edgeI = getFirstVertEdge(facei, vertI);
180 if (nVisited == nFeaturePts)
185 vertI =
mesh().
edges()[edgeI].otherVertex(vertI);
187 if (features.isFeatureVertex(facei, vertI))
203 const label startEdgeI,
204 const label startVertI
210 label superVertI = 0;
213 label edgeI = startEdgeI;
215 label vertI = startVertI;
217 superVerts[superVertI++] = vertI;
219 label prevEdgeI = -1;
223 vertI =
mesh().
edges()[edgeI].otherVertex(vertI);
225 superVerts[superVertI++] = vertI;
231 while (!features.isFeaturePoint(prevEdgeI, edgeI));
233 superVerts.setSize(superVertI);
241Foam::label Foam::topoCellLooper::getAlignedNonFeatureEdge
253 scalar maxCos = -GREAT;
257 label edgeI = cEdges[cEdgeI];
259 if (!features.isFeatureEdge(edgeI))
269 scalar cosAngle =
mag(refDir &
n);
271 if (cosAngle > maxCos)
287void Foam::topoCellLooper::walkAcrossFace
291 const label startEdgeI,
292 const label startVertI,
299 label oppositeVertI = -1;
300 label oppositeEdgeI = -1;
326 label sz = superEdge.size();
334 edgeI = oppositeEdgeI;
338 vertI = superEdge[1];
348 Pout<<
" Don't know what to do. Stepped to non-feature point "
349 <<
"at index " << index <<
" in superEdge:" << superEdge
353 vertI = superEdge[index];
373void Foam::topoCellLooper::walkSplitHex
377 const label fromFacei,
378 const label fromEdgeI,
379 const label fromVertI,
386 label facei = fromFacei;
387 label edgeI = fromEdgeI;
388 label vertI = fromVertI;
394 Pout<<
"Entering walk with : cell:" << celli <<
" face:" << facei;
399 Pout<<
" edge:" << edgeI;
407 label startLoop = -1;
412 && (startLoop = loop.find(vertToEVert(vertI))) != -1
416 label firstFree = loop.size();
419 subsetList(startLoop, firstFree, loopWeights);
426 && (startLoop = loop.find(edgeToEVert(edgeI))) != -1
430 label firstFree = loop.size();
433 subsetList(startLoop, firstFree, loopWeights);
448 loop.append(edgeToEVert(edgeI));
449 loopWeights.append(0.5);
457 <<
" to face " << facei <<
" verts:"
461 label nextEdgeI = -1;
462 label nextVertI = -1;
484 loop.append(vertToEVert(vertI));
485 loopWeights.append(-GREAT);
491 labelList nextEdges = getVertEdgesNonFace
498 if (nextEdges.empty())
505 label thisFacei =
pFaces[pFacei];
520 Pout<<
" stepped from non-edge vertex " << vertI
521 <<
" to face " << facei <<
" verts:"
523 <<
" since candidate edges:" << nextEdges <<
endl;
526 label nextEdgeI = -1;
527 label nextVertI = -1;
544 else if (nextEdges.size() == 1)
547 edgeI = nextEdges[0];
551 Pout<<
" stepped from non-edge vertex " << vertI
552 <<
" along edge " << edgeI <<
" verts:"
554 <<
" out of candidate edges:"
555 << nextEdges <<
endl;
558 vertI =
mesh().
edges()[edgeI].otherVertex(vertI);
567 label index = nextEdges.size()/2;
569 edgeI = nextEdges[index];
573 Pout<<
" stepped from non-edge vertex " << vertI
574 <<
" along edge " << edgeI <<
" verts:"
576 <<
" out of candidate edges:" << nextEdges <<
endl;
579 vertI =
mesh().
edges()[edgeI].otherVertex(vertI);
595 if (nextFaces.size() == 1)
598 facei = nextFaces[0];
600 label nextEdgeI = -1;
601 label nextVertI = -1;
618 else if (nextFaces.size() == 2)
631 vertI =
mesh().
edges()[edgeI].otherVertex(vertI);
636 <<
"Choosing from more than "
637 <<
"two candidates:" << nextFaces
638 <<
" when coming from vertex " << vertI <<
" on cell "
646 Pout<<
"Walked to : face:" << facei;
651 Pout<<
" edge:" << edgeI;
665Foam::topoCellLooper::topoCellLooper(
const polyMesh&
mesh)
702 cellFeatures superCell(
mesh(), featureCos, celli);
707 getAlignedNonFeatureEdge
727 edgeI = getMisAlignedEdge(refDir, celli);
754 if (localLoop.size() <=2)
761 loopWeights.
transfer(localLoopWeights);
786 const plane& cutPlane,
Various functions to operate on Lists.
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
iterator end() noexcept
Return an iterator to end traversing the UList.
void size(const label n)
Older name for setAddressableSize.
const faceList & faces() const
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
label getMisAlignedEdge(const vector &refDir, const label celli) const
Return edge from cellEdges that is most perpendicular.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
const cellModel & hex_
Reference to hex cell shape.
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.
static bool test(const UList< face > &faces)
Test if given list of faces satisfies criteria for HEX. (6 quad).
Geometric class that creates a 3D plane and can return the intersection point between a line and the ...
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const pointField & points() const
Return raw points.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & cellEdges() const
const vectorField & cellCentres() const
const labelListList & pointFaces() const
const labelListList & faceEdges() const
const cellList & cells() const
Implementation of cellLooper. This one recognizes splitHexes and tries to make a cut such that if the...
static const scalar featureCos
Cos of angle for feature recognition (of splitHexes).
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.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
List< label > labelList
A List of labels.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< T > subsetList(const UList< T > &input, const UnaryPredicate &pred, const bool invert=false)
Copy a subset of the input list when predicate is true.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
vector point
Point is a vector.
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensionedScalar cos(const dimensionedScalar &ds)
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells].reset(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};constexpr label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< DynamicList< face > > pFaces[nBCs]
#define forAll(list, i)
Loop across all elements in list.
Unit conversion functions.