47 template<
class T,
template<
class>
class CombineOp>
66 CombineOp<T>()(
x[i],
y[j]);
79 void Foam::removePoints::modifyFace
83 polyTopoChange& meshMod
102 bool zoneFlip =
false;
106 const faceZone& fZone = mesh_.
faceZones()[zoneID];
108 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
157 const edgeList& edges = mesh_.edges();
161 const edge&
e = edges[edgeI];
167 if (edge0[pointi] == -2)
171 else if (edge0[pointi] == -1)
174 edge0[pointi] = edgeI;
180 if (edge1[pointi] == -1)
183 edge1[pointi] = edgeI;
199 pointCanBeDeleted.
setSize(mesh_.nPoints());
200 pointCanBeDeleted =
false;
205 if (edge0[pointi] >= 0 && edge1[pointi] >= 0)
209 const edge& e0 = edges[edge0[pointi]];
210 const edge& e1 = edges[edge1[pointi]];
217 e0Vec /=
mag(e0Vec) + vSmall;
220 e1Vec /=
mag(e1Vec) + vSmall;
222 if ((e0Vec & e1Vec) > minCos)
224 pointCanBeDeleted[pointi] =
true;
228 else if (edge0[pointi] == -1)
231 pointCanBeDeleted[pointi] =
true;
241 forAll(mesh_.faces(), facei)
243 const face&
f = mesh_.faces()[facei];
248 if (pointCanBeDeleted[
f[fp]])
254 if ((
f.
size() - nCollapse) < 3)
259 if (pointCanBeDeleted[
f[fp]])
261 pointCanBeDeleted[
f[fp]] =
false;
283 forAll(pointCanBeDeleted, pointi)
285 if (pointCanBeDeleted[pointi])
303 forAll(pointCanBeDeleted, pointi)
305 if (pointCanBeDeleted[pointi])
322 savedPoints_.setSize(nDeleted);
323 pointToSaved.
resize(2*nDeleted);
332 forAll(pointCanBeDeleted, pointi)
334 if (pointCanBeDeleted[pointi])
338 pointToSaved.
insert(pointi, nDeleted);
339 savedPoints_[nDeleted++] = mesh_.points()[pointi];
361 savedFaceLabels_.setSize(facesAffected.
size());
362 savedFaces_.setSize(facesAffected.
size());
368 label facei = iter.key();
370 const face&
f = mesh_.faces()[facei];
380 if (!pointCanBeDeleted[pointi])
382 newFace[newI++] = pointi;
388 modifyFace(facei, newFace, meshMod);
393 savedFaceLabels_[nSaved] = facei;
395 face& savedFace = savedFaces_[nSaved++];
402 if (pointCanBeDeleted[pointi])
404 savedFace[fp] = -pointToSaved[pointi]-1;
408 savedFace[fp] = pointi;
419 forAll(savedFaceLabels_, saveI)
427 mesh_.faces()[savedFaceLabels_[saveI]]
442 if (meshPoints != keptPoints)
445 <<
"facei:" << savedFaceLabels_[saveI] <<
nl
446 <<
"meshPoints:" << meshPoints <<
nl
447 <<
"keptPoints:" << keptPoints <<
nl
460 forAll(savedFaceLabels_, localI)
462 if (savedFaceLabels_[localI] >= 0)
469 <<
"Old face " << savedFaceLabels_[localI]
470 <<
" seems to have disappeared."
473 savedFaceLabels_[localI] = newFacei;
482 face&
f = savedFaces_[i];
495 <<
"Old point " << pointi
496 <<
" seems to have disappeared."
507 forAll(savedFaceLabels_, saveI)
509 if (savedFaceLabels_[saveI] >= 0)
511 const face&
f = mesh_.faces()[savedFaceLabels_[saveI]];
514 const face& savedFace = savedFaces_[saveI];
521 label pointi = savedFace[fp];
525 keptFace[keptFp++] = pointi;
535 <<
"facei:" << savedFaceLabels_[saveI] <<
nl
536 <<
"face:" <<
f <<
nl
537 <<
"keptFace:" << keptFace <<
nl
567 <<
"removePoints not constructed with"
568 <<
" unrefinement capability."
575 faceSet undoFacesSet(mesh_,
"undoFacesSet", undoFaces);
578 undoFacesSet.
sync(mesh_);
579 if (sz != undoFacesSet.
size())
582 <<
"undoFaces not synchronised across coupled faces." <<
endl
583 <<
"Size before sync:" << sz
584 <<
" after sync:" << undoFacesSet.
size()
608 forAll(savedFaceLabels_, saveI)
610 if (savedFaceLabels_[saveI] < 0)
613 <<
"Illegal face label " << savedFaceLabels_[saveI]
614 <<
" at index " << saveI
618 if (undoFacesSet.
found(savedFaceLabels_[saveI]))
620 const face& savedFace = savedFaces_[saveI];
624 if (savedFace[fp] < 0)
626 label savedPointi = -savedFace[fp]-1;
631 <<
"Trying to restore point " << savedPointi
632 <<
" from mesh face " << savedFaceLabels_[saveI]
633 <<
" saved face:" << savedFace
634 <<
" which has already been undone."
638 localPointsSet.
insert(savedPointi);
649 boolListList faceVertexRestore(mesh_.nFaces()-mesh_.nInternalFaces());
652 forAll(savedFaces_, saveI)
654 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
658 const face& savedFace = savedFaces_[saveI];
660 boolList& fRestore = faceVertexRestore[bFacei];
667 if (savedFace[fp] < 0)
669 label savedPointi = -savedFace[fp]-1;
671 if (localPointsSet.
found(savedPointi))
694 forAll(savedFaces_, saveI)
696 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
700 const boolList& fRestore = faceVertexRestore[bFacei];
702 const face& savedFace = savedFaces_[saveI];
709 if (savedFace[fp] >= 0)
712 <<
"Problem: on coupled face:"
713 << savedFaceLabels_[saveI]
715 << mesh_.faceCentres()[savedFaceLabels_[saveI]]
717 <<
" my neighbour tries to restore the vertex"
718 <<
" at index " << fp
719 <<
" whereas my saved face:" << savedFace
720 <<
" does not indicate a deleted vertex"
721 <<
" at that position."
725 label savedPointi = -savedFace[fp]-1;
727 localPointsSet.
insert(savedPointi);
734 localPoints = localPointsSet.
toc();
742 forAll(savedFaces_, saveI)
744 const face& savedFace = savedFaces_[saveI];
748 if (savedFace[fp] < 0)
750 label savedPointi = -savedFace[fp]-1;
752 if (localPointsSet.
found(savedPointi))
754 localFacesSet.
insert(saveI);
759 localFaces = localFacesSet.
toc();
779 <<
"removePoints not constructed with"
780 <<
" unrefinement capability."
786 labelList addedPoints(savedPoints_.size(), -1);
790 label localI = localPoints[i];
795 <<
"Saved point " << localI <<
" already restored!"
803 savedPoints_[localI],
816 label saveI = localFaces[i];
820 face& savedFace = savedFaces_[saveI];
825 bool hasSavedPoints =
false;
829 if (savedFace[fp] < 0)
831 label addedPointi = addedPoints[-savedFace[fp]-1];
833 if (addedPointi != -1)
835 savedFace[fp] = addedPointi;
836 newFace[newFp++] = addedPointi;
840 hasSavedPoints =
true;
845 newFace[newFp++] = savedFace[fp];
850 modifyFace(savedFaceLabels_[saveI], newFace, meshMod);
855 savedFaceLabels_[saveI] = -1;
856 savedFaces_[saveI].clear();
864 forAll(savedFaceLabels_, saveI)
866 if (savedFaceLabels_[saveI] != -1)
868 if (newSaveI != saveI)
870 savedFaceLabels_[newSaveI] = savedFaceLabels_[saveI];
871 savedFaces_[newSaveI].transfer(savedFaces_[saveI]);
877 savedFaceLabels_.setSize(newSaveI);
878 savedFaces_.setSize(newSaveI);
884 forAll(savedFaceLabels_, saveI)
886 const face& savedFace = savedFaces_[saveI];
890 if (savedFace[fp] < 0)
892 label addedPointi = addedPoints[-savedFace[fp]-1];
894 if (addedPointi != -1)
897 <<
"Face:" << savedFaceLabels_[saveI]
898 <<
" savedVerts:" << savedFace
899 <<
" uses restored point:" << -savedFace[fp]-1
900 <<
" with new pointlabel:" << addedPointi
Inter-processor communication reduction functions.
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Indexes into negList (negative index) or posList (zero or positive index).
bool insert(const Key &key)
Insert a new entry.
List< Key > toc() const
Return the table of contents.
label size() const
Return number of elements in table.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
bool found(const Key &) const
Return true if hashedEntry is found in table.
void resize(const label newSize)
Resize the hash table for efficiency.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
A List with indirect addressing.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label otherVertex(const label a) const
Given one vertex, return the other.
label commonVertex(const edge &a) const
Return common vertex.
void operator()(List< T > &x, const List< T > &y) const
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
A face is a list of labels corresponding to mesh vertices.
Class containing data for point addition.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
const meshFaceZones & faceZones() const
Return face zones.
virtual const labelList & faceOwner() const
Return face owner.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Class containing data for point removal.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reversePointMap() const
Reverse point map.
const labelList & reverseFaceMap() const
Reverse face map.
Direct mesh changes based on v1.3 polyTopoChange syntax.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
Removes selected points from mesh and updates faces using these points.
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
removePoints(const polyMesh &mesh, const bool undoable=false)
Construct from mesh.
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
dimensioned< scalar > mag(const dimensioned< Type > &)
defineTypeNameAndDebug(combustionModel, 0)
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]