Go to the documentation of this file.
69 label faceI = cFaces[i];
71 label nbrCellI = faceNeighbour[faceI];
76 if (nbrCellI == cellI)
78 nbrCellI = faceOwner[faceI];
105 oldToNew[cFaces[nbr.
indices()[i]]] = newFaceI++;
110 nInternalFaces = newFaceI;
112 Pout<<
"nInternalFaces:" << nInternalFaces <<
endl;
117 for (
label faceI = newFaceI; faceI < faceOwner.
size(); faceI++)
119 oldToNew[faceI] = faceI;
126 if (oldToNew[faceI] == -1)
129 <<
"Did not determine new position"
130 <<
" for face " << faceI
161 label edgeI = fEdges[i];
170 if (
f.nextLabel(index) ==
e[1])
179 if (e0 != -1 && e1 != -1)
184 else if (
e[1] == pointI)
189 if (
f.nextLabel(index) ==
e[0])
198 if (e0 != -1 && e1 != -1)
207 <<
" that uses point:" << pointI
216 const label patchToDualOffset,
232 if (pointToDualPoint[meshPointI] >= 0)
237 dualFace.
append(pointToDualPoint[meshPointI]);
245 if (edgeToDualPoint[patch.
meshEdges()[edgeI]] < 0)
259 getPointEdges(patch, faceI, pointI, e0, e1);
273 dualFace.
append(faceI + patchToDualOffset);
277 getPointEdges(patch, faceI, pointI, e0, e1);
288 if (edgeToDualPoint[patch.
meshEdges()[edgeI]] >= 0)
296 if (eFaces.
size() == 1)
303 if (eFaces[0] == faceI)
330 const label patchToDualOffset,
334 const label startEdgeI,
350 label edgeI = startEdgeI;
357 getPointEdges(patch, faceI, pointI, e0, e1);
371 dualFace.
append(faceI + patchToDualOffset);
375 getPointEdges(patch, faceI, pointI, e0, e1);
386 if (edgeToDualPoint[meshEdges[edgeI]] >= 0)
389 dualFace.
append(edgeToDualPoint[meshEdges[edgeI]]);
390 featEdgeIndices.
append(dualFace.size()-1);
393 if (edgeI == startEdgeI)
401 if (eFaces[0] == faceI)
413 featEdgeIndices2.
transfer(featEdgeIndices);
420 forAll(featEdgeIndices2, i)
422 featEdgeIndices2[i] = dualFace2.
size() -1 - featEdgeIndices2[i];
450 if (pointToDualPoint[meshPointI] >= 0)
454 if (featEdgeIndices.
size() < 2)
458 dualOwner.
append(meshPointI);
467 forAll(featEdgeIndices, i)
469 label startFp = featEdgeIndices[i];
471 label endFp = featEdgeIndices[(i+1) % featEdgeIndices.
size()];
478 sz = endFp - startFp + 2;
482 sz = endFp + dualFace.
size() - startFp + 2;
487 subFace[0] = pointToDualPoint[patch.
meshPoints()[pointI]];
490 for (
label subFp = 1; subFp < subFace.
size(); subFp++)
492 subFace[subFp] = dualFace[startFp];
494 startFp = (startFp+1) % dualFace.
size();
498 dualOwner.
append(meshPointI);
507 if (featEdgeIndices.
size() < 2)
511 dualOwner.
append(meshPointI);
524 forAll(featEdgeIndices, featI)
526 label startFp = featEdgeIndices[featI];
527 label endFp = featEdgeIndices[featEdgeIndices.fcIndex(featI)];
533 label vertI = dualFace[fp];
542 fp = dualFace.fcIndex(fp);
545 if (subFace.size() > 2)
551 dualOwner.
append(meshPointI);
559 if (subFace.size() > 2)
565 dualOwner.
append(meshPointI);
580 const label patchToDualOffset,
607 forAll(doneEdgeSide, patchEdgeI)
611 if (eFaces.
size() == 1)
617 label bitMask = 1<<eI;
619 if ((doneEdgeSide[patchEdgeI] & bitMask) == 0)
626 label edgeI = patchEdgeI;
642 if (patch.
edges()[edgeI][0] == pointI)
644 doneEdgeSide[edgeI] |= 1;
648 doneEdgeSide[edgeI] |= 2;
656 doneEdgeSide[patchEdgeI] |= bitMask;
657 donePoint[pointI] =
true;
670 if (!donePoint[pointI])
674 collectPatchInternalFace
708 donePoint[pointI] =
true;
722 const label nIntFaces =
mesh.nInternalFaces();
731 mesh.nFaces() - nIntFaces,
752 meshEdges.
size() / 100
757 if (nonManifoldPoints.
size())
759 nonManifoldPoints.
write();
762 <<
"There are " << nonManifoldPoints.
size() <<
" points where"
763 <<
" the outside of the mesh is non-manifold." <<
nl
764 <<
"Such a mesh cannot be converted to a dual." <<
nl
765 <<
"Writing points at non-manifold sites to pointSet "
766 << nonManifoldPoints.
name()
785 +
mesh.nFaces() - nIntFaces
786 + featureEdges.
size()
787 + featurePoints.
size()
790 label dualPointI = 0;
796 cellPoint_.setSize(cellCentres.size());
798 forAll(cellCentres, cellI)
800 cellPoint_[cellI] = dualPointI;
801 dualPoints[dualPointI++] = cellCentres[cellI];
807 boundaryFacePoint_.setSize(
mesh.nFaces() - nIntFaces);
809 for (
label faceI = nIntFaces; faceI <
mesh.nFaces(); faceI++)
811 boundaryFacePoint_[faceI - nIntFaces] = dualPointI;
812 dualPoints[dualPointI++] = faceCentres[faceI];
821 forAll(meshEdges, patchEdgeI)
823 label edgeI = meshEdges[patchEdgeI];
825 edgeToDualPoint[edgeI] = -1;
830 label edgeI = featureEdges[i];
834 edgeToDualPoint[edgeI] = dualPointI;
835 dualPoints[dualPointI++] =
e.centre(
mesh.points());
853 pointToDualPoint[meshPoints[i]] = -2;
864 pointToDualPoint[meshPoints[loop[j]]] = -1;
871 label pointI = featurePoints[i];
873 pointToDualPoint[pointI] = dualPointI;
874 dualPoints[dualPointI++] =
mesh.points()[pointI];
890 forAll(meshEdges, patchEdgeI)
892 label edgeI = meshEdges[patchEdgeI];
897 label neighbour = -1;
916 <<
"Cannot handle edges with " <<
patchFaces.size()
917 <<
" connected boundary faces."
922 const face& f0 =
mesh.faces()[face0];
929 label startFaceI = -1;
949 if (edgeToDualPoint[edgeI] >= 0)
954 dualFace.
append(edgeToDualPoint[edgeI]);
962 dualFace.
append(
mesh.nCells() + startFaceI - nIntFaces);
964 label cellI =
mesh.faceOwner()[startFaceI];
965 label faceI = startFaceI;
986 if (faceI == endFaceI)
991 if (
mesh.faceOwner()[faceI] == cellI)
993 cellI =
mesh.faceNeighbour()[faceI];
997 cellI =
mesh.faceOwner()[faceI];
1002 dualFace.
append(
mesh.nCells() + endFaceI - nIntFaces);
1005 dynDualOwner.
append(owner);
1006 dynDualNeighbour.
append(neighbour);
1007 dynDualRegion.
append(-1);
1011 const face&
f = dynDualFaces.last();
1013 if (((
mesh.points()[owner] - dualPoints[
f[0]]) &
n) > 0)
1016 <<
" on boundary edge:" << edgeI
1017 <<
mesh.points()[
mesh.edges()[edgeI][0]]
1018 <<
mesh.points()[
mesh.edges()[edgeI][1]]
1028 forAll(edgeToDualPoint, edgeI)
1030 if (edgeToDualPoint[edgeI] == -2)
1039 label neighbour = -1;
1055 label cellI = eCells[0];
1063 const face& f0 =
mesh.faces()[face0];
1067 bool f0OrderOk = (f0.
nextLabel(index) == owner);
1069 label startFaceI = -1;
1071 if (f0OrderOk == (
mesh.faceOwner()[face0] == cellI))
1083 label faceI = startFaceI;
1104 if (faceI == startFaceI)
1109 if (
mesh.faceOwner()[faceI] == cellI)
1111 cellI =
mesh.faceNeighbour()[faceI];
1115 cellI =
mesh.faceOwner()[faceI];
1120 dynDualOwner.
append(owner);
1121 dynDualNeighbour.
append(neighbour);
1122 dynDualRegion.
append(-1);
1126 const face&
f = dynDualFaces.last();
1128 if (((
mesh.points()[owner] - dualPoints[
f[0]]) &
n) > 0)
1131 <<
" on internal edge:" << edgeI
1132 <<
mesh.points()[
mesh.edges()[edgeI][0]]
1133 <<
mesh.points()[
mesh.edges()[edgeI][1]]
1145 dynDualNeighbour.
shrink();
1148 OFstream str(
"dualInternalFaces.obj");
1149 Pout<<
"polyDualMesh::calcDual : dumping internal faces to "
1152 forAll(dualPoints, dualPointI)
1156 forAll(dynDualFaces, dualFaceI)
1158 const face&
f = dynDualFaces[dualFaceI];
1163 str<<
' ' <<
f[fp]+1;
1169 const label nInternalFaces = dynDualFaces.size();
1198 dynDualFaces.
clear();
1201 dynDualOwner.
clear();
1204 dynDualNeighbour.
clear();
1207 dynDualRegion.
clear();
1215 Pout<<
"polyDualMesh::calcDual : dumping all faces to "
1218 forAll(dualPoints, dualPointI)
1222 forAll(dualFaces, dualFaceI)
1224 const face&
f = dualFaces[dualFaceI];
1229 str<<
' ' <<
f[fp]+1;
1245 label cellI = dualOwner[faceI];
1253 forAll(dualNeighbour, faceI)
1255 label cellI = dualNeighbour[faceI];
1297 forAll(dualRegion, faceI)
1299 if (dualRegion[faceI] >= 0)
1301 patchSizes[dualRegion[faceI]]++;
1307 label faceI = nInternalFaces;
1311 patchStarts[patchI] = faceI;
1313 faceI += patchSizes[patchI];
1317 Pout<<
"nFaces:" << dualFaces.
size()
1318 <<
" patchSizes:" << patchSizes
1319 <<
" patchStarts:" << patchStarts
1330 dualPatches[patchI] = pp.
clone
1338 addPatches(dualPatches);
1364 time().findInstance(meshDir(),
"cellPoint"),
1375 "boundaryFacePoint",
1376 time().findInstance(meshDir(),
"boundaryFacePoint"),
1406 time().findInstance(meshDir(),
"faces"),
1418 "boundaryFacePoint",
1419 time().findInstance(meshDir(),
"faces"),
1428 calcDual(
mesh, featureEdges, featurePoints);
1436 const scalar featureCos
1451 time().findInstance(meshDir(),
"faces"),
1463 "boundaryFacePoint",
1464 time().findInstance(meshDir(),
"faces"),
1475 calcFeatures(
mesh, featureCos, featureEdges, featurePoints);
1476 calcDual(
mesh, featureEdges, featurePoints);
1483 const scalar featureCos,
1501 labelList allRegion(allBoundary.size());
1527 const labelList& eFaces = edgeFaces[edgeI];
1529 if (eFaces.
size() != 2)
1535 << meshPoints[
e[0]] <<
' ' << meshPoints[
e[1]]
1538 <<
" has more than 2 faces connected to it:"
1541 isFeatureEdge[edgeI] =
true;
1543 else if (allRegion[eFaces[0]] != allRegion[eFaces[1]])
1545 isFeatureEdge[edgeI] =
true;
1549 (faceNormals[eFaces[0]] & faceNormals[eFaces[1]])
1553 isFeatureEdge[edgeI] =
true;
1565 forAll(pointEdges, pointI)
1567 const labelList& pEdges = pointEdges[pointI];
1569 label nFeatEdges = 0;
1573 if (isFeatureEdge[pEdges[i]])
1584 featurePoints.
transfer(allFeaturePoints);
1590 Pout<<
"polyDualMesh::calcFeatures : dumping feature points to "
1595 label pointI = featurePoints[i];
1618 forAll(isFeatureEdge, edgeI)
1620 if (isFeatureEdge[edgeI])
1623 allFeatureEdges.
append(meshEdges[edgeI]);
1626 featureEdges.
transfer(allFeatureEdges);
vectorField pointField
pointField is a vectorField.
virtual const pointField & points() const
Return raw points.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
const labelListList & pointFaces() const
Return point-face addressing.
const labelListList & edgeFaces() const
Return edge-face addressing.
List< label > labelList
A List of labels.
void sort()
(stable) sort the list (if changed after construction time)
const edgeList & edges() const
Return list of edges, address into LOCAL point list.
#define forAll(list, i)
Loop across all elements in list.
void writeOBJ(Ostream &os, label &vertI, const tetPoints &tet)
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
A List obtained as a section of another List.
labelList meshEdges(const edgeList &allEdges, const labelListList &cellEdges, const labelList &faceCells) const
Return labels of patch edges in the global edge list using.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
virtual bool write() const
Write using setting from DB.
static labelList collectPatchSideFace(const polyPatch &patch, const label patchToDualOffset, const labelList &edgeToDualPoint, const labelList &pointToDualPoint, const label pointI, label &edgeI)
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
const labelListList & faceEdges() const
Return face-edge addressing.
labelList getFaceOrder(const primitiveMesh &mesh, const labelList &cellOrder)
labelList patchFaces(const polyBoundaryMesh &patches, const wordList &names)
Mesh consisting of general polyhedral cells.
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, &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< SLList< face > > pFaces[nBCs]
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
void calcDual(const polyMesh &mesh, const labelList &featureEdges, const labelList &featurePoints)
void inplaceReorder(const labelUList &oldToNew, ListType &)
Inplace reorder the elements of a list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
static void dualPatch(const polyPatch &patch, const label patchToDualOffset, const labelList &edgeToDualPoint, const labelList &pointToDualPoint, const pointField &dualPoints, DynamicList< face > &dualFaces, DynamicList< label > &dualOwner, DynamicList< label > &dualNeighbour, DynamicList< label > &dualRegion)
Pre-declare SubField and related Field type.
const labelListList & cellEdges() const
A patch is a list of labels that address the faces in the global face list.
const labelListList & pointEdges() const
Return point-edge addressing.
void clear()
Clear the addressed list, i.e. set the size to zero.
virtual const labelList & faceOwner() const
Return face owner.
void setCapacity(const label)
Alter the size of the underlying storage.
List< cell > cellList
list of cells
const word & name() const
Return name.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
label nPoints() const
Return number of points supporting patch faces.
label size() const
Return number of elements in table.
static void collectPatchInternalFace(const polyPatch &patch, const label patchToDualOffset, const labelList &edgeToDualPoint, const label pointI, const label startEdgeI, labelList &dualFace2, labelList &featEdgeIndices2)
label nInternalFaces() const
A list that is sorted upon construction or when explicitly requested with the sort() method.
errorManip< error > abort(error &err)
const double e
Elementary charge.
label start() const
Return start label of this patch in the polyMesh face list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void setSize(const label)
Reset size of List.
polyDualMesh(const polyDualMesh &)
Disallow default bitwise copy construct.
label nextLabel(const label i) const
Next vertex on face.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
prefixOSstream Pout(cout, "Pout")
const Field< PointType > & faceNormals() const
Return face normals for patch.
Xfer< T > xferCopy(const T &)
Construct by copying the contents of the arg.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
static void calcFeatures(const polyMesh &, const scalar featureCos, labelList &featureEdges, labelList &featurePoints)
Helper function to create feature edges and points based on.
const dimensionedScalar e
Elementary charge.
~polyDualMesh()
Destructor.
const labelList & indices() const
Return the list of sorted indices. Updated every sort.
static void getPointEdges(const primitivePatch &patch, const label faceI, const label pointI, label &e0, label &e1)
const List< Face > & localFaces() const
Return patch faces addressing into local point list.
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
A face is a list of labels corresponding to mesh vertices.
const fileName & name() const
Return the name of the stream.
void size(const label)
Override size to be inconsistent with allocated storage.
static void splitFace(const polyPatch &patch, const labelList &pointToDualPoint, const label pointI, const labelList &dualFace, const labelList &featEdgeIndices, DynamicList< face > &dualFaces, DynamicList< label > &dualOwner, DynamicList< label > &dualNeighbour, DynamicList< label > &dualRegion)
const labelList & meshEdges() const
Return global edge index for local edges.
const labelList & meshPoints() const
Return labelList of mesh points in patch.
bool checkPointManifold(const bool report=false, labelHashSet *setPtr=NULL) const
Checks primitivePatch for faces sharing point but not edge.
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
label index() const
Return the index of this patch in the boundaryMesh.
faceType reverseFace(const faceType &f)
reverse the face
static labelList getFaceOrder(const labelList &faceOwner, const labelList &faceNeighbour, const cellList &cells, label &nInternalFaces)
A list of faces which address into the list of points.
void reverse(UList< T > &, const label n)