47 template<
class T,
template<
class>
class CombineOp>
66 CombineOp<T>()(x[i], y[j]);
79 void Foam::removePoints::modifyFace
88 label owner = mesh_.faceOwner()[facei];
91 if (mesh_.isInternalFace(facei))
93 neighbour = mesh_.faceNeighbour()[facei];
97 patchi = mesh_.boundaryMesh().whichPatch(facei);
100 label zoneID = mesh_.faceZones().whichZone(facei);
102 bool zoneFlip =
false;
106 const faceZone& fZone = mesh_.faceZones()[zoneID];
131 Foam::removePoints::removePoints
157 const edgeList& edges = mesh_.edges();
161 const edge&
e = edges[edgeI];
165 label pointi = e[eI];
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]];
216 vector e0Vec = points[common] - points[vLeft];
217 e0Vec /=
mag(e0Vec) + vSmall;
219 vector e1Vec = points[vRight] - points[common];
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];
348 facesAffected.
insert(pFaces[i]);
361 savedFaceLabels_.setSize(facesAffected.
size());
362 savedFaces_.setSize(facesAffected.
size());
368 label facei = iter.key();
370 const face&
f = mesh_.faces()[facei];
378 label pointi = f[fp];
380 if (!pointCanBeDeleted[pointi])
382 newFace[newI++] = pointi;
388 modifyFace(facei, newFace, meshMod);
393 savedFaceLabels_[nSaved] = facei;
395 face& savedFace = savedFaces_[nSaved++];
400 label pointi = f[fp];
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];
486 label pointi = f[fp];
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
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
#define forAll(list, i)
Loop across all elements in list.
const labelList & reversePointMap() const
Reverse point map.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Inter-processor communication reduction functions.
static const Vector< scalar > max
Class describing modification of a face.
A face is a list of labels corresponding to mesh vertices.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label rcIndex(const label i) const
Return the reverse circular index, i.e. the previous index.
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 getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
const boolList & flipMap() const
Return face flip map.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Class containing data for point addition.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
label otherVertex(const label a) const
Given one vertex, return the other.
bool insert(const Key &key)
Insert a new entry.
label commonVertex(const edge &a) const
Return common vertex.
label size() const
Return number of elements in table.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
void operator()(List< T > &x, const List< T > &y) const
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
bool found(const Key &) const
Return true if hashedEntry is found in table.
void clear()
Clear the list, i.e. set size to zero.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
defineTypeNameAndDebug(combustionModel, 0)
Indexes into negList (negative index) or posList (zero or positive index).
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.
void setSize(const label)
Reset size of List.
A List with indirect addressing.
Direct mesh changes based on v1.3 polyTopoChange syntax.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
dimensioned< scalar > mag(const dimensioned< Type > &)
void resize(const label newSize)
Resize the hash table for efficiency.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
const doubleScalar e
Elementary charge.
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
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]
Class containing data for point removal.
const labelList & reverseFaceMap() const
Reverse face map.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.