50 template<
class T,
template<
class>
class CombineOp>
68 CombineOp<T>()(
x[i],
y[j]);
81 void Foam::removePoints::modifyFace
85 polyTopoChange& meshMod
104 bool zoneFlip =
false;
108 const faceZone& fZone = mesh_.
faceZones()[zoneID];
110 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
133 Foam::removePoints::removePoints
159 const edgeList& edges = mesh_.edges();
163 const edge&
e = edges[edgeI];
167 label pointi =
e[eI];
169 if (edge0[pointi] == -2)
173 else if (edge0[pointi] == -1)
176 edge0[pointi] = edgeI;
182 if (edge1[pointi] == -1)
185 edge1[pointi] = edgeI;
201 pointCanBeDeleted.
setSize(mesh_.nPoints());
202 pointCanBeDeleted =
false;
207 if (edge0[pointi] >= 0 && edge1[pointi] >= 0)
211 const edge& e0 = edges[edge0[pointi]];
212 const edge& e1 = edges[edge1[pointi]];
214 label common = e0.commonVertex(e1);
215 label vLeft = e0.otherVertex(common);
216 label vRight = e1.otherVertex(common);
221 if ((e0Vec & e1Vec) > minCos)
223 pointCanBeDeleted[pointi] =
true;
227 else if (edge0[pointi] == -1)
230 pointCanBeDeleted[pointi] =
true;
240 forAll(mesh_.faces(), facei)
242 const face&
f = mesh_.faces()[facei];
247 if (pointCanBeDeleted[
f[fp]])
253 if ((
f.
size() - nCollapse) < 3)
258 if (pointCanBeDeleted[
f[fp]])
260 pointCanBeDeleted[
f[fp]] =
false;
282 forAll(pointCanBeDeleted, pointi)
284 if (pointCanBeDeleted[pointi])
297 polyTopoChange& meshMod
302 forAll(pointCanBeDeleted, pointi)
304 if (pointCanBeDeleted[pointi])
316 Map<label> pointToSaved;
321 savedPoints_.resize(nDeleted);
322 pointToSaved.reserve(nDeleted);
331 forAll(pointCanBeDeleted, pointi)
333 if (pointCanBeDeleted[pointi])
337 pointToSaved.insert(pointi, nDeleted);
338 savedPoints_[nDeleted++] = mesh_.points()[pointi];
340 meshMod.setAction(polyRemovePoint(pointi));
345 facesAffected.insert(
pFaces);
357 savedFaceLabels_.setSize(facesAffected.size());
358 savedFaces_.setSize(facesAffected.size());
362 for (
const label facei : facesAffected)
364 const face&
f = mesh_.faces()[facei];
366 face newFace(
f.
size());
372 label pointi =
f[fp];
374 if (!pointCanBeDeleted[pointi])
376 newFace[newI++] = pointi;
382 modifyFace(facei, newFace, meshMod);
387 savedFaceLabels_[nSaved] = facei;
389 face& savedFace = savedFaces_[nSaved++];
390 savedFace.setSize(
f.
size());
394 label pointi =
f[fp];
396 if (pointCanBeDeleted[pointi])
398 savedFace[fp] = -pointToSaved[pointi]-1;
402 savedFace[fp] = pointi;
413 forAll(savedFaceLabels_, saveI)
416 List<point> meshPoints
421 mesh_.faces()[savedFaceLabels_[saveI]]
426 List<point> keptPoints
428 BiIndirectList<point>
436 if (meshPoints != keptPoints)
439 <<
"facei:" << savedFaceLabels_[saveI] <<
nl 440 <<
"meshPoints:" << meshPoints <<
nl 441 <<
"keptPoints:" << keptPoints <<
nl 454 forAll(savedFaceLabels_, localI)
456 if (savedFaceLabels_[localI] >= 0)
458 label newFacei = map.reverseFaceMap()[savedFaceLabels_[localI]];
463 <<
"Old face " << savedFaceLabels_[localI]
464 <<
" seems to have disappeared." 467 savedFaceLabels_[localI] = newFacei;
476 face&
f = savedFaces_[i];
480 label pointi =
f[fp];
484 f[fp] = map.reversePointMap()[pointi];
489 <<
"Old point " << pointi
490 <<
" seems to have disappeared." 501 forAll(savedFaceLabels_, saveI)
503 if (savedFaceLabels_[saveI] >= 0)
505 const face&
f = mesh_.faces()[savedFaceLabels_[saveI]];
508 const face& savedFace = savedFaces_[saveI];
510 face keptFace(savedFace.size());
515 label pointi = savedFace[fp];
519 keptFace[keptFp++] = pointi;
522 keptFace.setSize(keptFp);
529 <<
"facei:" << savedFaceLabels_[saveI] <<
nl 530 <<
"face:" <<
f <<
nl 531 <<
"keptFace:" << keptFace <<
nl 533 << BiIndirectList<point>
561 <<
"removePoints not constructed with" 562 <<
" unrefinement capability." 569 faceSet undoFacesSet(mesh_,
"undoFacesSet", undoFaces);
570 label sz = undoFacesSet.size();
572 undoFacesSet.sync(mesh_);
573 if (sz != undoFacesSet.size())
576 <<
"undoFaces not synchronised across coupled faces." <<
endl 577 <<
"Size before sync:" << sz
578 <<
" after sync:" << undoFacesSet.size()
602 forAll(savedFaceLabels_, saveI)
604 if (savedFaceLabels_[saveI] < 0)
607 <<
"Illegal face label " << savedFaceLabels_[saveI]
608 <<
" at index " << saveI
612 if (undoFacesSet.found(savedFaceLabels_[saveI]))
614 const face& savedFace = savedFaces_[saveI];
618 if (savedFace[fp] < 0)
620 label savedPointi = -savedFace[fp]-1;
625 <<
"Trying to restore point " << savedPointi
626 <<
" from mesh face " << savedFaceLabels_[saveI]
627 <<
" saved face:" << savedFace
628 <<
" which has already been undone." 632 localPointsSet.insert(savedPointi);
646 forAll(savedFaces_, saveI)
648 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
652 const face& savedFace = savedFaces_[saveI];
654 boolList& fRestore = faceVertexRestore[bFacei];
656 fRestore.
setSize(savedFace.size());
661 if (savedFace[fp] < 0)
663 label savedPointi = -savedFace[fp]-1;
665 if (localPointsSet.found(savedPointi))
678 faceEqOp<bool, orEqOp>(),
688 forAll(savedFaces_, saveI)
690 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
694 const boolList& fRestore = faceVertexRestore[bFacei];
696 const face& savedFace = savedFaces_[saveI];
703 if (savedFace[fp] >= 0)
706 <<
"Problem: on coupled face:" 707 << savedFaceLabels_[saveI]
709 << mesh_.faceCentres()[savedFaceLabels_[saveI]]
711 <<
" my neighbour tries to restore the vertex" 712 <<
" at index " << fp
713 <<
" whereas my saved face:" << savedFace
714 <<
" does not indicate a deleted vertex" 715 <<
" at that position." 719 label savedPointi = -savedFace[fp]-1;
721 localPointsSet.insert(savedPointi);
728 localPoints = localPointsSet.toc();
736 forAll(savedFaces_, saveI)
738 const face& savedFace = savedFaces_[saveI];
742 if (savedFace[fp] < 0)
744 label savedPointi = -savedFace[fp]-1;
746 if (localPointsSet.found(savedPointi))
748 localFacesSet.insert(saveI);
753 localFaces = localFacesSet.toc();
773 <<
"removePoints not constructed with" 774 <<
" unrefinement capability." 780 labelList addedPoints(savedPoints_.size(), -1);
784 label localI = localPoints[i];
789 <<
"Saved point " << localI <<
" already restored!" 797 savedPoints_[localI],
810 label saveI = localFaces[i];
814 face& savedFace = savedFaces_[saveI];
816 face newFace(savedFace.size());
819 bool hasSavedPoints =
false;
823 if (savedFace[fp] < 0)
825 label addedPointi = addedPoints[-savedFace[fp]-1];
827 if (addedPointi != -1)
829 savedFace[fp] = addedPointi;
830 newFace[newFp++] = addedPointi;
834 hasSavedPoints =
true;
839 newFace[newFp++] = savedFace[fp];
842 newFace.setSize(newFp);
844 modifyFace(savedFaceLabels_[saveI], newFace, meshMod);
849 savedFaceLabels_[saveI] = -1;
850 savedFaces_[saveI].clear();
858 forAll(savedFaceLabels_, saveI)
860 if (savedFaceLabels_[saveI] != -1)
862 if (newSaveI != saveI)
864 savedFaceLabels_[newSaveI] = savedFaceLabels_[saveI];
865 savedFaces_[newSaveI].transfer(savedFaces_[saveI]);
871 savedFaceLabels_.setSize(newSaveI);
872 savedFaces_.setSize(newSaveI);
878 forAll(savedFaceLabels_, saveI)
880 const face& savedFace = savedFaces_[saveI];
884 if (savedFace[fp] < 0)
886 label addedPointi = addedPoints[-savedFace[fp]-1];
888 if (addedPointi != -1)
891 <<
"Face:" << savedFaceLabels_[saveI]
892 <<
" savedVerts:" << savedFace
893 <<
" uses restored point:" << -savedFace[fp]-1
894 <<
" with new pointlabel:" << addedPointi
void size(const label n)
Older name for setAddressableSize.
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
List< List< bool > > boolListList
List of boolList.
Inter-processor communication reduction functions.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
constexpr char nl
The newline '\n' character (0x0a)
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
Ostream & endl(Ostream &os)
Add newline and flush stream.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
#define forAll(list, i)
Loop across all elements in list.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
vectorField pointField
pointField is a vectorField.
const dimensionedScalar e
Elementary charge.
void setSize(const label n)
Alias for resize()
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
void clear()
Clear the list, i.e. set size to zero.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
virtual const labelList & faceOwner() const
Return face owner.
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]
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
int debug
Static debugging option.
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
defineTypeNameAndDebug(combustionModel, 0)
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
void operator()(List< T > &x, const UList< T > &y) const
Direct mesh changes based on v1.3 polyTopoChange syntax.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
Removes selected points from mesh and updates faces using these points.
Mesh consisting of general polyhedral cells.
List< label > labelList
A List of labels.
List< bool > boolList
A List of bools.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.