47 template<
class T,
template<
class>
class CombineOp>
66 CombineOp<T>()(x[i], y[j]);
99 void Foam::removePoints::modifyFace
108 label owner = mesh_.faceOwner()[faceI];
109 label neighbour = -1;
111 if (mesh_.isInternalFace(faceI))
113 neighbour = mesh_.faceNeighbour()[faceI];
117 patchI = mesh_.boundaryMesh().whichPatch(faceI);
120 label zoneID = mesh_.faceZones().whichZone(faceI);
122 bool zoneFlip =
false;
126 const faceZone& fZone = mesh_.faceZones()[zoneID];
152 Foam::removePoints::removePoints
178 const edgeList& edges = mesh_.edges();
182 const edge&
e = edges[edgeI];
186 label pointI = e[eI];
188 if (edge0[pointI] == -2)
192 else if (edge0[pointI] == -1)
195 edge0[pointI] = edgeI;
201 if (edge1[pointI] == -1)
204 edge1[pointI] = edgeI;
220 pointCanBeDeleted.
setSize(mesh_.nPoints());
221 pointCanBeDeleted =
false;
226 if (edge0[pointI] >= 0 && edge1[pointI] >= 0)
230 const edge& e0 = edges[edge0[pointI]];
231 const edge& e1 = edges[edge1[pointI]];
237 vector e0Vec = points[common] - points[vLeft];
238 e0Vec /=
mag(e0Vec) + VSMALL;
240 vector e1Vec = points[vRight] - points[common];
241 e1Vec /=
mag(e1Vec) + VSMALL;
243 if ((e0Vec & e1Vec) > minCos)
245 pointCanBeDeleted[pointI] =
true;
249 else if (edge0[pointI] == -1)
252 pointCanBeDeleted[pointI] =
true;
262 forAll(mesh_.faces(), faceI)
264 const face&
f = mesh_.faces()[faceI];
269 if (pointCanBeDeleted[f[fp]])
275 if ((f.
size() - nCollapse) < 3)
280 if (pointCanBeDeleted[f[fp]])
282 pointCanBeDeleted[f[fp]] =
false;
304 forAll(pointCanBeDeleted, pointI)
306 if (pointCanBeDeleted[pointI])
324 forAll(pointCanBeDeleted, pointI)
326 if (pointCanBeDeleted[pointI])
343 savedPoints_.setSize(nDeleted);
344 pointToSaved.
resize(2*nDeleted);
353 forAll(pointCanBeDeleted, pointI)
355 if (pointCanBeDeleted[pointI])
359 pointToSaved.
insert(pointI, nDeleted);
360 savedPoints_[nDeleted++] = mesh_.points()[pointI];
369 facesAffected.
insert(pFaces[i]);
382 savedFaceLabels_.setSize(facesAffected.
size());
383 savedFaces_.setSize(facesAffected.
size());
389 label faceI = iter.key();
391 const face&
f = mesh_.faces()[faceI];
399 label pointI = f[fp];
401 if (!pointCanBeDeleted[pointI])
403 newFace[newI++] = pointI;
409 modifyFace(faceI, newFace, meshMod);
414 savedFaceLabels_[nSaved] = faceI;
416 face& savedFace = savedFaces_[nSaved++];
421 label pointI = f[fp];
423 if (pointCanBeDeleted[pointI])
425 savedFace[fp] = -pointToSaved[pointI]-1;
429 savedFace[fp] = pointI;
440 forAll(savedFaceLabels_, saveI)
448 mesh_.faces()[savedFaceLabels_[saveI]]
463 if (meshPoints != keptPoints)
466 <<
"faceI:" << savedFaceLabels_[saveI] <<
nl 467 <<
"meshPoints:" << meshPoints <<
nl 468 <<
"keptPoints:" << keptPoints <<
nl 481 forAll(savedFaceLabels_, localI)
483 if (savedFaceLabels_[localI] >= 0)
491 "removePoints::updateMesh(const mapPolyMesh&)" 492 ) <<
"Old face " << savedFaceLabels_[localI]
493 <<
" seems to have dissapeared." 496 savedFaceLabels_[localI] = newFaceI;
505 face&
f = savedFaces_[i];
509 label pointI = f[fp];
519 "removePoints::updateMesh(const mapPolyMesh&)" 520 ) <<
"Old point " << pointI
521 <<
" seems to have dissapeared." 532 forAll(savedFaceLabels_, saveI)
534 if (savedFaceLabels_[saveI] >= 0)
536 const face&
f = mesh_.faces()[savedFaceLabels_[saveI]];
539 const face& savedFace = savedFaces_[saveI];
546 label pointI = savedFace[fp];
550 keptFace[keptFp++] = pointI;
560 <<
"faceI:" << savedFaceLabels_[saveI] <<
nl 561 <<
"face:" << f <<
nl 562 <<
"keptFace:" << keptFace <<
nl 593 "removePoints::getUnrefimentSet(const labelList&" 594 ", labelList&, labelList&) const" 595 ) <<
"removePoints not constructed with" 596 <<
" unrefinement capability." 603 faceSet undoFacesSet(mesh_,
"undoFacesSet", undoFaces);
606 undoFacesSet.
sync(mesh_);
607 if (sz != undoFacesSet.
size())
611 "removePoints::getUnrefimentSet(const labelList&" 612 ", labelList&, labelList&) const" 613 ) <<
"undoFaces not synchronised across coupled faces." <<
endl 614 <<
"Size before sync:" << sz
615 <<
" after sync:" << undoFacesSet.
size()
639 forAll(savedFaceLabels_, saveI)
641 if (savedFaceLabels_[saveI] < 0)
645 "removePoints::getUnrefimentSet(const labelList&" 646 ", labelList&, labelList&) const" 647 ) <<
"Illegal face label " << savedFaceLabels_[saveI]
648 <<
" at index " << saveI
652 if (undoFacesSet.
found(savedFaceLabels_[saveI]))
654 const face& savedFace = savedFaces_[saveI];
658 if (savedFace[fp] < 0)
660 label savedPointI = -savedFace[fp]-1;
666 "removePoints::getUnrefimentSet" 667 "(const labelList&, labelList&, labelList&)" 669 ) <<
"Trying to restore point " << savedPointI
670 <<
" from mesh face " << savedFaceLabels_[saveI]
671 <<
" saved face:" << savedFace
672 <<
" which has already been undone." 676 localPointsSet.insert(savedPointI);
687 boolListList faceVertexRestore(mesh_.nFaces()-mesh_.nInternalFaces());
690 forAll(savedFaces_, saveI)
692 label bFaceI = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
696 const face& savedFace = savedFaces_[saveI];
698 boolList& fRestore = faceVertexRestore[bFaceI];
705 if (savedFace[fp] < 0)
707 label savedPointI = -savedFace[fp]-1;
709 if (localPointsSet.found(savedPointI))
732 forAll(savedFaces_, saveI)
734 label bFaceI = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
738 const boolList& fRestore = faceVertexRestore[bFaceI];
740 const face& savedFace = savedFaces_[saveI];
747 if (savedFace[fp] >= 0)
751 "removePoints::getUnrefimentSet" 752 "(const labelList&, labelList&, labelList&)" 754 ) <<
"Problem: on coupled face:" 755 << savedFaceLabels_[saveI]
757 << mesh_.faceCentres()[savedFaceLabels_[saveI]]
759 <<
" my neighbour tries to restore the vertex" 760 <<
" at index " << fp
761 <<
" whereas my saved face:" << savedFace
762 <<
" does not indicate a deleted vertex" 763 <<
" at that position." 767 label savedPointI = -savedFace[fp]-1;
769 localPointsSet.insert(savedPointI);
776 localPoints = localPointsSet.toc();
784 forAll(savedFaces_, saveI)
786 const face& savedFace = savedFaces_[saveI];
790 if (savedFace[fp] < 0)
792 label savedPointI = -savedFace[fp]-1;
794 if (localPointsSet.found(savedPointI))
796 localFacesSet.insert(saveI);
801 localFaces = localFacesSet.toc();
822 "removePoints::setUnrefinement(const labelList&" 823 ", labelList&, polyTopoChange&)" 824 ) <<
"removePoints not constructed with" 825 <<
" unrefinement capability." 831 labelList addedPoints(savedPoints_.size(), -1);
835 label localI = localPoints[i];
841 "removePoints::setUnrefinement(const labelList&" 842 ", labelList&, polyTopoChange&)" 843 ) <<
"Saved point " << localI <<
" already restored!" 851 savedPoints_[localI],
864 label saveI = localFaces[i];
868 face& savedFace = savedFaces_[saveI];
873 bool hasSavedPoints =
false;
877 if (savedFace[fp] < 0)
879 label addedPointI = addedPoints[-savedFace[fp]-1];
881 if (addedPointI != -1)
883 savedFace[fp] = addedPointI;
884 newFace[newFp++] = addedPointI;
888 hasSavedPoints =
true;
893 newFace[newFp++] = savedFace[fp];
898 modifyFace(savedFaceLabels_[saveI], newFace, meshMod);
903 savedFaceLabels_[saveI] = -1;
904 savedFaces_[saveI].clear();
912 forAll(savedFaceLabels_, saveI)
914 if (savedFaceLabels_[saveI] != -1)
916 if (newSaveI != saveI)
918 savedFaceLabels_[newSaveI] = savedFaceLabels_[saveI];
919 savedFaces_[newSaveI].transfer(savedFaces_[saveI]);
925 savedFaceLabels_.setSize(newSaveI);
926 savedFaces_.setSize(newSaveI);
932 forAll(savedFaceLabels_, saveI)
934 const face& savedFace = savedFaces_[saveI];
938 if (savedFace[fp] < 0)
940 label addedPointI = addedPoints[-savedFace[fp]-1];
942 if (addedPointI != -1)
945 <<
"Face:" << savedFaceLabels_[saveI]
946 <<
" savedVerts:" << savedFace
947 <<
" uses restored point:" << -savedFace[fp]-1
948 <<
" with new pointlabel:" << addedPointI
const pointField & points
const boolList & flipMap() const
Return face flip map.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
const labelList & reverseFaceMap() const
Reverse face map.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
label commonVertex(const edge &a) const
Return common vertex.
dimensioned< scalar > mag(const dimensioned< Type > &)
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.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
A subset of mesh faces organised as a primitive patch.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
void resize(const label newSize)
Resize the hash table for efficiency.
void size(const label)
Override size to be inconsistent with allocated storage.
static void syncBoundaryFaceList(const polyMesh &, UList< T > &, const CombineOp &cop, const TransformOp &top)
Synchronize values on boundary faces only.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
A face is a list of labels corresponding to mesh vertices.
void clear()
Clear the list, i.e. set size to zero.
const double e
Elementary charge.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
A List with indirect addressing.
label otherVertex(const label a) const
Given one vertex, return the other.
void operator()(List< T > &x, const List< T > &y) const
Class describing modification of a face.
label size() const
Return number of elements in table.
errorManip< error > abort(error &err)
static void syncPointList(const polyMesh &, List< T > &, const CombineOp &cop, const T &nullValue, const TransformOp &top)
Synchronize values on all mesh points.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Mesh consisting of general polyhedral cells.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Dummy transform to be used with syncTools.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
Class containing data for point addition.
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]
Indexes into negList (negative index) or posList (zero or positive index).
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
bool found(const Key &) const
Return true if hashedEntry is found in table.
defineTypeNameAndDebug(combustionModel, 0)
Combine-reduce operator to combine data on faces. Takes care.
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
bool insert(const Key &key)
Insert a new entry.