50template<
class T,
template<
class>
class CombineOp>
69 CombineOp<T>()(
x[i],
y[j]);
82void Foam::removePoints::modifyFace
86 polyTopoChange& meshMod
105 bool zoneFlip =
false;
111 zoneFlip = fZone.flipMap()[fZone.whichFace(facei)];
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]];
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];
358 savedFaceLabels_.setSize(facesAffected.
size());
359 savedFaces_.setSize(facesAffected.
size());
363 for (
const label facei : facesAffected)
365 const face&
f = mesh_.faces()[facei];
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++];
395 label pointi =
f[fp];
397 if (pointCanBeDeleted[pointi])
399 savedFace[fp] = -pointToSaved[pointi]-1;
403 savedFace[fp] = pointi;
414 forAll(savedFaceLabels_, saveI)
422 mesh_.faces()[savedFaceLabels_[saveI]]
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)
464 <<
"Old face " << savedFaceLabels_[localI]
465 <<
" seems to have disappeared."
468 savedFaceLabels_[localI] = newFacei;
477 face&
f = savedFaces_[i];
481 label pointi =
f[fp];
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];
516 label pointi = savedFace[fp];
520 keptFace[keptFp++] = pointi;
530 <<
"facei:" << savedFaceLabels_[saveI] <<
nl
531 <<
"face:" <<
f <<
nl
532 <<
"keptFace:" << keptFace <<
nl
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];
662 if (savedFace[fp] < 0)
664 label savedPointi = -savedFace[fp]-1;
666 if (localPointsSet.
found(savedPointi))
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];
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];
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
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
Return true if hashed entry is found in table.
void resize(const label sz)
Resize the hash table for efficiency.
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(const 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.
void size(const label n)
Older name for setAddressableSize.
label whichZone(const label objectIndex) const
Given a global object index, return the zone it is in.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
label otherVertex(const label pointLabel) const
Given the point label for one vertex, return the other one.
label commonVertex(const edge &other) const
Return vertex common with other edge or -1 on failure.
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.
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.
void updateMesh()
Update for new mesh topology.
static const complex max
complex (VGREAT,VGREAT)
Class containing data for point addition.
label whichPatch(const label faceIndex) const
Return patch index for a given face label.
Mesh consisting of general polyhedral cells.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
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 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 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.
const labelIOList & zoneID
quaternion normalised(const quaternion &q)
Return the normalised (unit) quaternion of the given quaternion.
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=UPstream::msgType(), const label comm=UPstream::worldComm)
Reduce (copy) and return value.
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];} 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]
#define forAll(list, i)
Loop across all elements in list.