50 template<
class T,
template<
class>
class CombineOp>
69 CombineOp<T>()(
x[i],
y[j]);
82 void Foam::removePoints::modifyFace
86 polyTopoChange& meshMod
105 bool zoneFlip =
false;
109 const faceZone& fZone = mesh_.
faceZones()[zoneID];
111 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
134 Foam::removePoints::removePoints
160 const edgeList& edges = mesh_.edges();
164 const edge&
e = edges[edgeI];
168 label pointi =
e[eI];
170 if (edge0[pointi] == -2)
174 else if (edge0[pointi] == -1)
177 edge0[pointi] = edgeI;
183 if (edge1[pointi] == -1)
186 edge1[pointi] = edgeI;
202 pointCanBeDeleted.
setSize(mesh_.nPoints());
203 pointCanBeDeleted =
false;
208 if (edge0[pointi] >= 0 && edge1[pointi] >= 0)
212 const edge& e0 = edges[edge0[pointi]];
213 const edge& e1 = edges[edge1[pointi]];
215 label common = e0.commonVertex(e1);
216 label vLeft = e0.otherVertex(common);
217 label vRight = e1.otherVertex(common);
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])
298 polyTopoChange& meshMod
303 forAll(pointCanBeDeleted, pointi)
305 if (pointCanBeDeleted[pointi])
317 Map<label> pointToSaved;
322 savedPoints_.resize(nDeleted);
323 pointToSaved.reserve(nDeleted);
332 forAll(pointCanBeDeleted, pointi)
334 if (pointCanBeDeleted[pointi])
338 pointToSaved.insert(pointi, nDeleted);
339 savedPoints_[nDeleted++] = mesh_.points()[pointi];
341 meshMod.setAction(polyRemovePoint(pointi));
346 facesAffected.insert(
pFaces);
358 savedFaceLabels_.setSize(facesAffected.size());
359 savedFaces_.setSize(facesAffected.size());
363 for (
const label facei : facesAffected)
365 const face&
f = mesh_.faces()[facei];
367 face newFace(
f.
size());
373 label pointi =
f[fp];
375 if (!pointCanBeDeleted[pointi])
377 newFace[newI++] = pointi;
383 modifyFace(facei, newFace, meshMod);
388 savedFaceLabels_[nSaved] = facei;
390 face& savedFace = savedFaces_[nSaved++];
391 savedFace.setSize(
f.
size());
395 label pointi =
f[fp];
397 if (pointCanBeDeleted[pointi])
399 savedFace[fp] = -pointToSaved[pointi]-1;
403 savedFace[fp] = pointi;
414 forAll(savedFaceLabels_, saveI)
417 List<point> meshPoints
422 mesh_.faces()[savedFaceLabels_[saveI]]
427 List<point> keptPoints
429 BiIndirectList<point>
437 if (meshPoints != keptPoints)
440 <<
"facei:" << savedFaceLabels_[saveI] <<
nl 441 <<
"meshPoints:" << meshPoints <<
nl 442 <<
"keptPoints:" << keptPoints <<
nl 455 forAll(savedFaceLabels_, localI)
457 if (savedFaceLabels_[localI] >= 0)
459 label newFacei = map.reverseFaceMap()[savedFaceLabels_[localI]];
464 <<
"Old face " << savedFaceLabels_[localI]
465 <<
" seems to have disappeared." 468 savedFaceLabels_[localI] = newFacei;
477 face&
f = savedFaces_[i];
481 label pointi =
f[fp];
485 f[fp] = map.reversePointMap()[pointi];
490 <<
"Old point " << pointi
491 <<
" seems to have disappeared." 502 forAll(savedFaceLabels_, saveI)
504 if (savedFaceLabels_[saveI] >= 0)
506 const face&
f = mesh_.faces()[savedFaceLabels_[saveI]];
509 const face& savedFace = savedFaces_[saveI];
511 face keptFace(savedFace.size());
516 label pointi = savedFace[fp];
520 keptFace[keptFp++] = pointi;
523 keptFace.setSize(keptFp);
530 <<
"facei:" << savedFaceLabels_[saveI] <<
nl 531 <<
"face:" <<
f <<
nl 532 <<
"keptFace:" << keptFace <<
nl 534 << BiIndirectList<point>
562 <<
"removePoints not constructed with" 563 <<
" unrefinement capability." 570 faceSet undoFacesSet(mesh_,
"undoFacesSet", undoFaces);
571 label sz = undoFacesSet.size();
573 undoFacesSet.sync(mesh_);
574 if (sz != undoFacesSet.size())
577 <<
"undoFaces not synchronised across coupled faces." <<
endl 578 <<
"Size before sync:" << sz
579 <<
" after sync:" << undoFacesSet.size()
603 forAll(savedFaceLabels_, saveI)
605 if (savedFaceLabels_[saveI] < 0)
608 <<
"Illegal face label " << savedFaceLabels_[saveI]
609 <<
" at index " << saveI
613 if (undoFacesSet.found(savedFaceLabels_[saveI]))
615 const face& savedFace = savedFaces_[saveI];
619 if (savedFace[fp] < 0)
621 label savedPointi = -savedFace[fp]-1;
626 <<
"Trying to restore point " << savedPointi
627 <<
" from mesh face " << savedFaceLabels_[saveI]
628 <<
" saved face:" << savedFace
629 <<
" which has already been undone." 633 localPointsSet.insert(savedPointi);
647 forAll(savedFaces_, saveI)
649 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
653 const face& savedFace = savedFaces_[saveI];
655 boolList& fRestore = faceVertexRestore[bFacei];
657 fRestore.
setSize(savedFace.size());
662 if (savedFace[fp] < 0)
664 label savedPointi = -savedFace[fp]-1;
666 if (localPointsSet.found(savedPointi))
679 faceEqOp<bool, orEqOp>(),
689 forAll(savedFaces_, saveI)
691 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
695 const boolList& fRestore = faceVertexRestore[bFacei];
697 const face& savedFace = savedFaces_[saveI];
704 if (savedFace[fp] >= 0)
707 <<
"Problem: on coupled face:" 708 << savedFaceLabels_[saveI]
710 << mesh_.faceCentres()[savedFaceLabels_[saveI]]
712 <<
" my neighbour tries to restore the vertex" 713 <<
" at index " << fp
714 <<
" whereas my saved face:" << savedFace
715 <<
" does not indicate a deleted vertex" 716 <<
" at that position." 720 label savedPointi = -savedFace[fp]-1;
722 localPointsSet.insert(savedPointi);
729 localPoints = localPointsSet.toc();
737 forAll(savedFaces_, saveI)
739 const face& savedFace = savedFaces_[saveI];
743 if (savedFace[fp] < 0)
745 label savedPointi = -savedFace[fp]-1;
747 if (localPointsSet.found(savedPointi))
749 localFacesSet.insert(saveI);
754 localFaces = localFacesSet.toc();
774 <<
"removePoints not constructed with" 775 <<
" unrefinement capability." 781 labelList addedPoints(savedPoints_.size(), -1);
785 label localI = localPoints[i];
790 <<
"Saved point " << localI <<
" already restored!" 798 savedPoints_[localI],
811 label saveI = localFaces[i];
815 face& savedFace = savedFaces_[saveI];
817 face newFace(savedFace.size());
820 bool hasSavedPoints =
false;
824 if (savedFace[fp] < 0)
826 label addedPointi = addedPoints[-savedFace[fp]-1];
828 if (addedPointi != -1)
830 savedFace[fp] = addedPointi;
831 newFace[newFp++] = addedPointi;
835 hasSavedPoints =
true;
840 newFace[newFp++] = savedFace[fp];
843 newFace.setSize(newFp);
845 modifyFace(savedFaceLabels_[saveI], newFace, meshMod);
850 savedFaceLabels_[saveI] = -1;
851 savedFaces_[saveI].clear();
859 forAll(savedFaceLabels_, saveI)
861 if (savedFaceLabels_[saveI] != -1)
863 if (newSaveI != saveI)
865 savedFaceLabels_[newSaveI] = savedFaceLabels_[saveI];
866 savedFaces_[newSaveI].transfer(savedFaces_[saveI]);
872 savedFaceLabels_.setSize(newSaveI);
873 savedFaces_.setSize(newSaveI);
879 forAll(savedFaceLabels_, saveI)
881 const face& savedFace = savedFaces_[saveI];
885 if (savedFace[fp] < 0)
887 label addedPointi = addedPoints[-savedFace[fp]-1];
889 if (addedPointi != -1)
892 <<
"Face:" << savedFaceLabels_[saveI]
893 <<
" savedVerts:" << savedFace
894 <<
" uses restored point:" << -savedFace[fp]-1
895 <<
" 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.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
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.
void operator()(List< T > &x, const List< T > &y) const
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.
label whichPatch(const label meshFacei) const
Return patch index for a given mesh face index. Uses binary search.
errorManip< error > abort(error &err)
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)
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];} 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]
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.
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.