53 void Foam::topoCellLooper::subsetList
69 lst.setCapacity(freeI);
75 for (
label elemI = startI; elemI < freeI; elemI++)
77 lst[newI++] = lst[elemI];
80 if ((freeI - startI) < 0)
86 lst.setCapacity(freeI - startI);
132 void Foam::topoCellLooper::walkFace
134 const cellFeatures& features,
136 const label startEdgeI,
137 const label startVertI,
138 const label nFeaturePts,
144 const labelList& fEdges = mesh().faceEdges()[facei];
156 vertI = mesh().edges()[edgeI].start();
158 if (features.isFeatureVertex(facei, vertI))
168 edgeI = getFirstVertEdge(facei, vertI);
178 if (nVisited == nFeaturePts)
183 vertI = mesh().edges()[edgeI].otherVertex(vertI);
185 if (features.isFeatureVertex(facei, vertI))
199 const cellFeatures& features,
201 const label startEdgeI,
202 const label startVertI
205 const labelList& fEdges = mesh().faceEdges()[facei];
208 label superVertI = 0;
211 label edgeI = startEdgeI;
213 label vertI = startVertI;
215 superVerts[superVertI++] = vertI;
217 label prevEdgeI = -1;
221 vertI = mesh().edges()[edgeI].otherVertex(vertI);
223 superVerts[superVertI++] = vertI;
229 while (!features.isFeaturePoint(prevEdgeI, edgeI));
231 superVerts.setSize(superVertI);
239 Foam::label Foam::topoCellLooper::getAlignedNonFeatureEdge
243 const cellFeatures& features
246 const labelList& cEdges = mesh().cellEdges()[celli];
248 const point& ctr = mesh().cellCentres()[celli];
251 scalar maxCos = -great;
255 label edgeI = cEdges[cEdgeI];
257 if (!features.isFeatureEdge(edgeI))
259 const edge&
e = mesh().edges()[edgeI];
262 vector e0 = mesh().points()[
e.start()] - ctr;
263 vector e1 = mesh().points()[
e.end()] - ctr;
268 scalar cosAngle =
mag(refDir &
n);
270 if (cosAngle > maxCos)
286 void Foam::topoCellLooper::walkAcrossFace
288 const cellFeatures& features,
290 const label startEdgeI,
291 const label startVertI,
298 label oppositeVertI = -1;
299 label oppositeEdgeI = -1;
325 label sz = superEdge.size();
333 edgeI = oppositeEdgeI;
337 vertI = superEdge[1];
347 Pout<<
" Don't know what to do. Stepped to non-feature point "
348 <<
"at index " << index <<
" in superEdge:" << superEdge
352 vertI = superEdge[index];
372 void Foam::topoCellLooper::walkSplitHex
375 const cellFeatures& features,
376 const label fromFacei,
377 const label fromEdgeI,
378 const label fromVertI,
380 DynamicList<label>& loop,
381 DynamicList<scalar>& loopWeights
385 label facei = fromFacei;
386 label edgeI = fromEdgeI;
387 label vertI = fromVertI;
393 Pout<<
"Entering walk with : cell:" << celli <<
" face:" << facei;
396 Pout<<
" verts:" << mesh().faces()[facei];
398 Pout<<
" edge:" << edgeI;
401 Pout<<
" verts:" << mesh().edges()[edgeI];
406 label startLoop = -1;
424 label firstFree = loop.size();
426 subsetList(startLoop, firstFree, loop);
427 subsetList(startLoop, firstFree, loopWeights);
447 label firstFree = loop.size();
449 subsetList(startLoop, firstFree, loop);
450 subsetList(startLoop, firstFree, loopWeights);
465 loop.append(edgeToEVert(edgeI));
466 loopWeights.append(0.5);
473 Pout<<
" stepped across edge " << mesh().edges()[edgeI]
474 <<
" to face " << facei <<
" verts:"
475 << mesh().faces()[facei] <<
endl;
478 label nextEdgeI = -1;
479 label nextVertI = -1;
501 loop.append(vertToEVert(vertI));
502 loopWeights.append(-great);
508 labelList nextEdges = getVertEdgesNonFace
515 if (nextEdges.empty())
537 Pout<<
" stepped from non-edge vertex " << vertI
538 <<
" to face " << facei <<
" verts:"
539 << mesh().faces()[facei]
540 <<
" since candidate edges:" << nextEdges <<
endl;
543 label nextEdgeI = -1;
544 label nextVertI = -1;
561 else if (nextEdges.size() == 1)
564 edgeI = nextEdges[0];
568 Pout<<
" stepped from non-edge vertex " << vertI
569 <<
" along edge " << edgeI <<
" verts:"
570 << mesh().edges()[edgeI]
571 <<
" out of candidate edges:"
572 << nextEdges <<
endl;
575 vertI = mesh().edges()[edgeI].otherVertex(vertI);
584 label index = nextEdges.size()/2;
586 edgeI = nextEdges[index];
590 Pout<<
" stepped from non-edge vertex " << vertI
591 <<
" along edge " << edgeI <<
" verts:"
592 << mesh().edges()[edgeI]
593 <<
" out of candidate edges:" << nextEdges <<
endl;
596 vertI = mesh().edges()[edgeI].otherVertex(vertI);
612 if (nextFaces.size() == 1)
615 facei = nextFaces[0];
617 label nextEdgeI = -1;
618 label nextVertI = -1;
635 else if (nextFaces.size() == 2)
648 vertI = mesh().edges()[edgeI].otherVertex(vertI);
653 <<
"Choosing from more than "
654 <<
"two candidates:" << nextFaces
655 <<
" when coming from vertex " << vertI <<
" on cell "
663 Pout<<
"Walked to : face:" << facei;
666 Pout<<
" verts:" << mesh().faces()[facei];
668 Pout<<
" edge:" << edgeI;
671 Pout<<
" verts:" << mesh().edges()[edgeI];
709 if (mesh().
cellShapes()[celli].model() == hex_)
731 getAlignedNonFeatureEdge
745 vertI = mesh().edges()[edgeI].start();
751 edgeI = getMisAlignedEdge(refDir, celli);
761 label nEstCuts = 2*mesh().cells()[celli].size();
778 if (localLoop.
size() <=2)
785 loopWeights.
transfer(localLoopWeights);
810 const plane& cutPlane,
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.
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.
const faceList & faces() const
Abstract base class. Concrete implementations know how to cut a cell (i.e. determine a loop around th...
Implementation of cellLooper.
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 cellMatcher for hex cells.
Geometric class that creates a 2D plane and can return the intersection point between a line and the ...
Mesh consisting of general polyhedral cells.
Implementation of cellLooper. This one recognises splitHexes and tries to make a cut such that if the...
static const scalar featureCos
Cos of angle for feature recognition (of splitHexes)
topoCellLooper(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 ~topoCellLooper()
Destructor.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const cellShapeList & cellShapes
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.
errorManip< error > abort(error &err)
vector point
Point is a vector.
Vector< scalar > vector
A scalar version of the templated Vector.
bool isA(const Type &t)
Check if a dynamic_cast to typeid is possible.
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
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,.
dimensionedScalar cos(const dimensionedScalar &ds)
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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]=cellShape(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];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } 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};const 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, &mergedCyclicPolyPatch::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< SLList< face > > pFaces[nBCs]
Unit conversion functions.