50template<
class T,
template<
class>
class CombineOp>
68 CombineOp<T>()(
x[i],
y[j]);
81void Foam::removePoints::modifyFace
85 polyTopoChange& meshMod
99 patchi = mesh_.boundaryMesh().whichPatch(facei);
102 label zoneID = mesh_.faceZones().whichZone(facei);
104 bool zoneFlip =
false;
108 const faceZone& fZone = mesh_.faceZones()[zoneID];
110 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
133Foam::removePoints::removePoints
159 const edgeList& edges = mesh_.edges();
163 const edge&
e = edges[edgeI];
167 label pointi =
e[eI];
169 if (edge0[pointi] == -2)
173 else if (edge0[pointi] == -1)
176 edge0[pointi] = edgeI;
182 if (edge1[pointi] == -1)
185 edge1[pointi] = edgeI;
201 pointCanBeDeleted.
setSize(mesh_.nPoints());
202 pointCanBeDeleted =
false;
207 if (edge0[pointi] >= 0 && edge1[pointi] >= 0)
211 const edge& e0 = edges[edge0[pointi]];
212 const edge& e1 = edges[edge1[pointi]];
214 label common = e0.commonVertex(e1);
215 label vLeft = e0.otherVertex(common);
216 label vRight = e1.otherVertex(common);
221 if ((e0Vec & e1Vec) > minCos)
223 pointCanBeDeleted[pointi] =
true;
227 else if (edge0[pointi] == -1)
230 pointCanBeDeleted[pointi] =
true;
240 forAll(mesh_.faces(), facei)
242 const face&
f = mesh_.faces()[facei];
247 if (pointCanBeDeleted[
f[fp]])
253 if ((
f.
size() - nCollapse) < 3)
258 if (pointCanBeDeleted[
f[fp]])
260 pointCanBeDeleted[
f[fp]] =
false;
282 forAll(pointCanBeDeleted, pointi)
284 if (pointCanBeDeleted[pointi])
302 forAll(pointCanBeDeleted, pointi)
304 if (pointCanBeDeleted[pointi])
321 savedPoints_.resize(nDeleted);
322 pointToSaved.reserve(nDeleted);
331 forAll(pointCanBeDeleted, pointi)
333 if (pointCanBeDeleted[pointi])
337 pointToSaved.insert(pointi, nDeleted);
338 savedPoints_[nDeleted++] = mesh_.points()[pointi];
345 facesAffected.insert(
pFaces);
357 savedFaceLabels_.setSize(facesAffected.size());
358 savedFaces_.setSize(facesAffected.size());
362 for (
const label facei : facesAffected)
364 const face&
f = mesh_.faces()[facei];
372 label pointi =
f[fp];
374 if (!pointCanBeDeleted[pointi])
376 newFace[newI++] = pointi;
379 newFace.setSize(newI);
382 modifyFace(facei, newFace, meshMod);
387 savedFaceLabels_[nSaved] = facei;
389 face& savedFace = savedFaces_[nSaved++];
394 label pointi =
f[fp];
396 if (pointCanBeDeleted[pointi])
398 savedFace[fp] = -pointToSaved[pointi]-1;
402 savedFace[fp] = pointi;
413 forAll(savedFaceLabels_, saveI)
421 mesh_.faces()[savedFaceLabels_[saveI]]
436 if (meshPoints != keptPoints)
439 <<
"facei:" << savedFaceLabels_[saveI] <<
nl
440 <<
"meshPoints:" << meshPoints <<
nl
441 <<
"keptPoints:" << keptPoints <<
nl
454 forAll(savedFaceLabels_, localI)
456 if (savedFaceLabels_[localI] >= 0)
458 label newFacei = map.reverseFaceMap()[savedFaceLabels_[localI]];
463 <<
"Old face " << savedFaceLabels_[localI]
464 <<
" seems to have disappeared."
467 savedFaceLabels_[localI] = newFacei;
476 face&
f = savedFaces_[i];
480 label pointi =
f[fp];
484 f[fp] = map.reversePointMap()[pointi];
489 <<
"Old point " << pointi
490 <<
" seems to have disappeared."
501 forAll(savedFaceLabels_, saveI)
503 if (savedFaceLabels_[saveI] >= 0)
505 const face&
f = mesh_.faces()[savedFaceLabels_[saveI]];
508 const face& savedFace = savedFaces_[saveI];
510 face keptFace(savedFace.size());
515 label pointi = savedFace[fp];
519 keptFace[keptFp++] = pointi;
522 keptFace.setSize(keptFp);
529 <<
"facei:" << savedFaceLabels_[saveI] <<
nl
530 <<
"face:" <<
f <<
nl
531 <<
"keptFace:" << keptFace <<
nl
561 <<
"removePoints not constructed with"
562 <<
" unrefinement capability."
569 faceSet undoFacesSet(mesh_,
"undoFacesSet", undoFaces);
570 label sz = undoFacesSet.size();
572 undoFacesSet.sync(mesh_);
573 if (sz != undoFacesSet.size())
576 <<
"undoFaces not synchronised across coupled faces." <<
endl
577 <<
"Size before sync:" << sz
578 <<
" after sync:" << undoFacesSet.size()
602 forAll(savedFaceLabels_, saveI)
604 if (savedFaceLabels_[saveI] < 0)
607 <<
"Illegal face label " << savedFaceLabels_[saveI]
608 <<
" at index " << saveI
612 if (undoFacesSet.found(savedFaceLabels_[saveI]))
614 const face& savedFace = savedFaces_[saveI];
618 if (savedFace[fp] < 0)
620 label savedPointi = -savedFace[fp]-1;
625 <<
"Trying to restore point " << savedPointi
626 <<
" from mesh face " << savedFaceLabels_[saveI]
627 <<
" saved face:" << savedFace
628 <<
" which has already been undone."
632 localPointsSet.insert(savedPointi);
646 forAll(savedFaces_, saveI)
648 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
652 const face& savedFace = savedFaces_[saveI];
654 boolList& fRestore = faceVertexRestore[bFacei];
656 fRestore.setSize(savedFace.size());
661 if (savedFace[fp] < 0)
663 label savedPointi = -savedFace[fp]-1;
665 if (localPointsSet.found(savedPointi))
679 Foam::dummyTransform()
688 forAll(savedFaces_, saveI)
690 label bFacei = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
694 const boolList& fRestore = faceVertexRestore[bFacei];
696 const face& savedFace = savedFaces_[saveI];
703 if (savedFace[fp] >= 0)
706 <<
"Problem: on coupled face:"
707 << savedFaceLabels_[saveI]
709 << mesh_.faceCentres()[savedFaceLabels_[saveI]]
711 <<
" my neighbour tries to restore the vertex"
712 <<
" at index " << fp
713 <<
" whereas my saved face:" << savedFace
714 <<
" does not indicate a deleted vertex"
715 <<
" at that position."
719 label savedPointi = -savedFace[fp]-1;
721 localPointsSet.insert(savedPointi);
728 localPoints = localPointsSet.toc();
736 forAll(savedFaces_, saveI)
738 const face& savedFace = savedFaces_[saveI];
742 if (savedFace[fp] < 0)
744 label savedPointi = -savedFace[fp]-1;
746 if (localPointsSet.found(savedPointi))
748 localFacesSet.insert(saveI);
753 localFaces = localFacesSet.toc();
773 <<
"removePoints not constructed with"
774 <<
" unrefinement capability."
780 labelList addedPoints(savedPoints_.size(), -1);
784 label localI = localPoints[i];
789 <<
"Saved point " << localI <<
" already restored!"
797 savedPoints_[localI],
810 label saveI = localFaces[i];
814 face& savedFace = savedFaces_[saveI];
816 face newFace(savedFace.size());
819 bool hasSavedPoints =
false;
823 if (savedFace[fp] < 0)
825 label addedPointi = addedPoints[-savedFace[fp]-1];
827 if (addedPointi != -1)
829 savedFace[fp] = addedPointi;
830 newFace[newFp++] = addedPointi;
834 hasSavedPoints =
true;
839 newFace[newFp++] = savedFace[fp];
842 newFace.setSize(newFp);
844 modifyFace(savedFaceLabels_[saveI], newFace, meshMod);
849 savedFaceLabels_[saveI] = -1;
850 savedFaces_[saveI].clear();
858 forAll(savedFaceLabels_, saveI)
860 if (savedFaceLabels_[saveI] != -1)
862 if (newSaveI != saveI)
864 savedFaceLabels_[newSaveI] = savedFaceLabels_[saveI];
865 savedFaces_[newSaveI].transfer(savedFaces_[saveI]);
871 savedFaceLabels_.setSize(newSaveI);
872 savedFaces_.setSize(newSaveI);
878 forAll(savedFaceLabels_, saveI)
880 const face& savedFace = savedFaces_[saveI];
884 if (savedFace[fp] < 0)
886 label addedPointi = addedPoints[-savedFace[fp]-1];
888 if (addedPointi != -1)
891 <<
"Face:" << savedFaceLabels_[saveI]
892 <<
" savedVerts:" << savedFace
893 <<
" uses restored point:" << -savedFace[fp]-1
894 <<
" with new pointlabel:" << addedPointi
Inter-processor communication reduction functions.
Indexes into negList (negative index) or posList (zero or positive index).
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
List< Key > toc() const
The table of contents (the keys) in unsorted order.
bool found(const Key &key) const
Same as contains().
void reserve(label numEntries)
Reserve space for at least the specified number of elements (not the number of buckets) and regenerat...
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
label size() const noexcept
The number of elements in table.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(label n)
Alias for resize().
void clear()
Clear the list, i.e. set size to zero.
A HashTable to objects of type <T> with a label key.
A List with indirect addressing. Like IndirectList but does not store addressing.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
An edge is a list of two vertex labels. This can correspond to a directed graph edge or an edge on a ...
label commonVertex(const edge &other) const
Return vertex common with other edge or -1 on failure.
label otherVertex(const label vertex) const
Given one vertex label, return the other one.
void operator()(List< T > &x, const UList< 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 mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseFaceMap() const noexcept
Reverse face map.
const labelList & reversePointMap() const noexcept
Reverse point map.
Class containing data for point addition.
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Class containing data for point removal.
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 noexcept
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 setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Namespace for handling debugging switches.
List< edge > edgeList
List of edge.
List< label > labelList
A List of labels.
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
HashSet< label, Hash< label > > labelHashSet
A HashSet of labels, uses label hasher.
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
Ostream & endl(Ostream &os)
Add newline and flush stream.
List< List< bool > > boolListList
List of boolList.
errorManip< error > abort(error &err)
List< bool > boolList
A List of bools.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
constexpr char nl
The newline '\n' character (0x0a).
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];} pointMap[start]=pointMap[end]=Foam::min(start, end);} } 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};constexpr 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< DynamicList< face > > pFaces[nBCs]
#define forAll(list, i)
Loop across all elements in list.