44 template<
class T,
template<
class>
class CombineOp>
63 CombineOp<T>()(
x[i],
y[j]);
76 void Foam::removePoints::modifyFace
80 polyTopoChange& meshMod
137 const edgeList& edges = mesh_.edges();
141 const edge&
e = edges[edgeI];
147 if (edge0[pointi] == -2)
151 else if (edge0[pointi] == -1)
154 edge0[pointi] = edgeI;
160 if (edge1[pointi] == -1)
163 edge1[pointi] = edgeI;
179 pointCanBeDeleted.
setSize(mesh_.nPoints());
180 pointCanBeDeleted =
false;
185 if (edge0[pointi] >= 0 && edge1[pointi] >= 0)
189 const edge& e0 = edges[edge0[pointi]];
190 const edge& e1 = edges[edge1[pointi]];
197 e0Vec /=
mag(e0Vec) + vSmall;
200 e1Vec /=
mag(e1Vec) + vSmall;
202 if ((e0Vec & e1Vec) > minCos)
204 pointCanBeDeleted[pointi] =
true;
208 else if (edge0[pointi] == -1)
211 pointCanBeDeleted[pointi] =
true;
221 forAll(mesh_.faces(), facei)
223 const face&
f = mesh_.faces()[facei];
228 if (pointCanBeDeleted[
f[fp]])
234 if ((
f.
size() - nCollapse) < 3)
239 if (pointCanBeDeleted[
f[fp]])
241 pointCanBeDeleted[
f[fp]] =
false;
263 forAll(pointCanBeDeleted, pointi)
265 if (pointCanBeDeleted[pointi])
283 forAll(pointCanBeDeleted, pointi)
285 if (pointCanBeDeleted[pointi])
302 savedPoints_.setSize(nDeleted);
303 pointToSaved.
resize(2*nDeleted);
312 forAll(pointCanBeDeleted, pointi)
314 if (pointCanBeDeleted[pointi])
318 pointToSaved.
insert(pointi, nDeleted);
319 savedPoints_[nDeleted++] = mesh_.points()[pointi];
341 savedFaceLabels_.setSize(facesAffected.
size());
342 savedFaces_.setSize(facesAffected.
size());
348 label facei = iter.key();
350 const face&
f = mesh_.faces()[facei];
360 if (!pointCanBeDeleted[pointi])
362 newFace[newI++] = pointi;
368 modifyFace(facei, newFace, meshMod);
373 savedFaceLabels_[nSaved] = facei;
375 face& savedFace = savedFaces_[nSaved++];
382 if (pointCanBeDeleted[pointi])
384 savedFace[fp] = -pointToSaved[pointi]-1;
388 savedFace[fp] = pointi;
399 forAll(savedFaceLabels_, saveI)
407 mesh_.faces()[savedFaceLabels_[saveI]]
422 if (meshPoints != keptPoints)
425 <<
"facei:" << savedFaceLabels_[saveI] <<
nl
426 <<
"meshPoints:" << meshPoints <<
nl
427 <<
"keptPoints:" << keptPoints <<
nl
440 forAll(savedFaceLabels_, localI)
442 if (savedFaceLabels_[localI] >= 0)
449 <<
"Old face " << savedFaceLabels_[localI]
450 <<
" seems to have disappeared."
453 savedFaceLabels_[localI] = newFacei;
462 face&
f = savedFaces_[i];
475 <<
"Old point " << pointi
476 <<
" seems to have disappeared."
487 forAll(savedFaceLabels_, saveI)
489 if (savedFaceLabels_[saveI] >= 0)
491 const face&
f = mesh_.faces()[savedFaceLabels_[saveI]];
494 const face& savedFace = savedFaces_[saveI];
501 label pointi = savedFace[fp];
505 keptFace[keptFp++] = pointi;
515 <<
"facei:" << savedFaceLabels_[saveI] <<
nl
516 <<
"face:" <<
f <<
nl
517 <<
"keptFace:" << keptFace <<
nl
547 <<
"removePoints not constructed with"
548 <<
" unrefinement capability."
555 faceSet undoFacesSet(mesh_,
"undoFacesSet", undoFaces);
558 undoFacesSet.
sync(mesh_);
559 if (sz != undoFacesSet.
size())
562 <<
"undoFaces not synchronised across coupled faces." <<
endl
563 <<
"Size before sync:" << sz
564 <<
" after sync:" << undoFacesSet.
size()
588 forAll(savedFaceLabels_, saveI)
590 if (savedFaceLabels_[saveI] < 0)
593 <<
"Illegal face label " << savedFaceLabels_[saveI]
594 <<
" at index " << saveI
598 if (undoFacesSet.
found(savedFaceLabels_[saveI]))
600 const face& savedFace = savedFaces_[saveI];
604 if (savedFace[fp] < 0)
606 label savedPointi = -savedFace[fp]-1;
611 <<
"Trying to restore point " << savedPointi
612 <<
" from mesh face " << savedFaceLabels_[saveI]
613 <<
" saved face:" << savedFace
614 <<
" which has already been undone."
618 localPointsSet.
insert(savedPointi);
629 boolListList faceVertexRestore(mesh_.nFaces()-mesh_.nInternalFaces());
632 forAll(savedFaces_, saveI)
634 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
638 const face& savedFace = savedFaces_[saveI];
640 boolList& fRestore = faceVertexRestore[bFacei];
647 if (savedFace[fp] < 0)
649 label savedPointi = -savedFace[fp]-1;
651 if (localPointsSet.
found(savedPointi))
674 forAll(savedFaces_, saveI)
676 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
680 const boolList& fRestore = faceVertexRestore[bFacei];
682 const face& savedFace = savedFaces_[saveI];
689 if (savedFace[fp] >= 0)
692 <<
"Problem: on coupled face:"
693 << savedFaceLabels_[saveI]
695 << mesh_.faceCentres()[savedFaceLabels_[saveI]]
697 <<
" my neighbour tries to restore the vertex"
698 <<
" at index " << fp
699 <<
" whereas my saved face:" << savedFace
700 <<
" does not indicate a deleted vertex"
701 <<
" at that position."
705 label savedPointi = -savedFace[fp]-1;
707 localPointsSet.
insert(savedPointi);
714 localPoints = localPointsSet.
toc();
722 forAll(savedFaces_, saveI)
724 const face& savedFace = savedFaces_[saveI];
728 if (savedFace[fp] < 0)
730 label savedPointi = -savedFace[fp]-1;
732 if (localPointsSet.
found(savedPointi))
734 localFacesSet.
insert(saveI);
739 localFaces = localFacesSet.
toc();
759 <<
"removePoints not constructed with"
760 <<
" unrefinement capability."
766 labelList addedPoints(savedPoints_.size(), -1);
770 label localI = localPoints[i];
775 <<
"Saved point " << localI <<
" already restored!"
779 addedPoints[localI] = meshMod.
addPoint
781 savedPoints_[localI],
792 label saveI = localFaces[i];
796 face& savedFace = savedFaces_[saveI];
801 bool hasSavedPoints =
false;
805 if (savedFace[fp] < 0)
807 label addedPointi = addedPoints[-savedFace[fp]-1];
809 if (addedPointi != -1)
811 savedFace[fp] = addedPointi;
812 newFace[newFp++] = addedPointi;
816 hasSavedPoints =
true;
821 newFace[newFp++] = savedFace[fp];
826 modifyFace(savedFaceLabels_[saveI], newFace, meshMod);
831 savedFaceLabels_[saveI] = -1;
832 savedFaces_[saveI].clear();
840 forAll(savedFaceLabels_, saveI)
842 if (savedFaceLabels_[saveI] != -1)
844 if (newSaveI != saveI)
846 savedFaceLabels_[newSaveI] = savedFaceLabels_[saveI];
847 savedFaces_[newSaveI].transfer(savedFaces_[saveI]);
853 savedFaceLabels_.setSize(newSaveI);
854 savedFaces_.setSize(newSaveI);
860 forAll(savedFaceLabels_, saveI)
862 const face& savedFace = savedFaces_[saveI];
866 if (savedFace[fp] < 0)
868 label addedPointi = addedPoints[-savedFace[fp]-1];
870 if (addedPointi != -1)
873 <<
"Face:" << savedFaceLabels_[saveI]
874 <<
" savedVerts:" << savedFace
875 <<
" uses restored point:" << -savedFace[fp]-1
876 <<
" 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.
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.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
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 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.
void removePoint(const label, const label)
Remove point / merge points.
label addPoint(const point &, const label masterPointID, const bool inCell)
Add point and return new point index.
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]