Go to the documentation of this file.
47 template<
class T,
template<
class>
class CombineOp>
66 CombineOp<T>()(
x[i],
y[j]);
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];
178 const edgeList& edges = mesh_.edges();
182 const edge&
e = edges[edgeI];
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]];
238 e0Vec /=
mag(e0Vec) + VSMALL;
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;
295 syncTools::syncPointList
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];
382 savedFaceLabels_.setSize(facesAffected.
size());
383 savedFaces_.setSize(facesAffected.
size());
389 label faceI = iter.key();
391 const face&
f = mesh_.faces()[faceI];
393 face newFace(
f.size());
401 if (!pointCanBeDeleted[pointI])
403 newFace[newI++] = pointI;
409 modifyFace(faceI, newFace, meshMod);
414 savedFaceLabels_[nSaved] = faceI;
416 face& savedFace = savedFaces_[nSaved++];
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
491 <<
" seems to have dissapeared."
516 <<
"Old point " << pointI
517 <<
" seems to have dissapeared."
542 label pointI = savedFace[fp];
546 keptFace[keptFp++] = pointI;
557 <<
"face:" <<
f <<
nl
558 <<
"keptFace:" << keptFace <<
nl
588 <<
"removePoints not constructed with"
589 <<
" unrefinement capability."
596 faceSet undoFacesSet(mesh_,
"undoFacesSet", undoFaces);
599 undoFacesSet.
sync(mesh_);
600 if (sz != undoFacesSet.
size())
603 <<
"undoFaces not synchronised across coupled faces." <<
endl
604 <<
"Size before sync:" << sz
605 <<
" after sync:" << undoFacesSet.
size()
629 forAll(savedFaceLabels_, saveI)
631 if (savedFaceLabels_[saveI] < 0)
634 <<
"Illegal face label " << savedFaceLabels_[saveI]
635 <<
" at index " << saveI
639 if (undoFacesSet.
found(savedFaceLabels_[saveI]))
641 const face& savedFace = savedFaces_[saveI];
645 if (savedFace[fp] < 0)
647 label savedPointI = -savedFace[fp]-1;
652 <<
"Trying to restore point " << savedPointI
653 <<
" from mesh face " << savedFaceLabels_[saveI]
654 <<
" saved face:" << savedFace
655 <<
" which has already been undone."
659 localPointsSet.
insert(savedPointI);
670 boolListList faceVertexRestore(mesh_.nFaces()-mesh_.nInternalFaces());
673 forAll(savedFaces_, saveI)
675 label bFaceI = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
679 const face& savedFace = savedFaces_[saveI];
681 boolList& fRestore = faceVertexRestore[bFaceI];
688 if (savedFace[fp] < 0)
690 label savedPointI = -savedFace[fp]-1;
692 if (localPointsSet.
found(savedPointI))
715 forAll(savedFaces_, saveI)
717 label bFaceI = savedFaceLabels_[saveI] - mesh_.nInternalFaces();
721 const boolList& fRestore = faceVertexRestore[bFaceI];
723 const face& savedFace = savedFaces_[saveI];
730 if (savedFace[fp] >= 0)
733 <<
"Problem: on coupled face:"
734 << savedFaceLabels_[saveI]
736 << mesh_.faceCentres()[savedFaceLabels_[saveI]]
738 <<
" my neighbour tries to restore the vertex"
739 <<
" at index " << fp
740 <<
" whereas my saved face:" << savedFace
741 <<
" does not indicate a deleted vertex"
742 <<
" at that position."
746 label savedPointI = -savedFace[fp]-1;
748 localPointsSet.
insert(savedPointI);
755 localPoints = localPointsSet.
toc();
763 forAll(savedFaces_, saveI)
765 const face& savedFace = savedFaces_[saveI];
769 if (savedFace[fp] < 0)
771 label savedPointI = -savedFace[fp]-1;
773 if (localPointsSet.
found(savedPointI))
775 localFacesSet.
insert(saveI);
780 localFaces = localFacesSet.
toc();
800 <<
"removePoints not constructed with"
801 <<
" unrefinement capability."
807 labelList addedPoints(savedPoints_.size(), -1);
811 label localI = localPoints[i];
816 <<
"Saved point " << localI <<
" already restored!"
824 savedPoints_[localI],
837 label saveI = localFaces[i];
841 face& savedFace = savedFaces_[saveI];
846 bool hasSavedPoints =
false;
850 if (savedFace[fp] < 0)
852 label addedPointI = addedPoints[-savedFace[fp]-1];
854 if (addedPointI != -1)
856 savedFace[fp] = addedPointI;
857 newFace[newFp++] = addedPointI;
861 hasSavedPoints =
true;
866 newFace[newFp++] = savedFace[fp];
871 modifyFace(savedFaceLabels_[saveI], newFace, meshMod);
876 savedFaceLabels_[saveI] = -1;
877 savedFaces_[saveI].clear();
885 forAll(savedFaceLabels_, saveI)
887 if (savedFaceLabels_[saveI] != -1)
889 if (newSaveI != saveI)
891 savedFaceLabels_[newSaveI] = savedFaceLabels_[saveI];
892 savedFaces_[newSaveI].transfer(savedFaces_[saveI]);
898 savedFaceLabels_.setSize(newSaveI);
899 savedFaces_.setSize(newSaveI);
905 forAll(savedFaceLabels_, saveI)
907 const face& savedFace = savedFaces_[saveI];
911 if (savedFace[fp] < 0)
913 label addedPointI = addedPoints[-savedFace[fp]-1];
915 if (addedPointI != -1)
918 <<
"Face:" << savedFaceLabels_[saveI]
919 <<
" savedVerts:" << savedFace
920 <<
" uses restored point:" << -savedFace[fp]-1
921 <<
" with new pointlabel:" << addedPointI
virtual const pointField & points() const
Return raw points.
removePoints(const removePoints &)
Disallow default bitwise copy construct.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
Class containing data for point removal.
List< Key > toc() const
Return the table of contents.
#define forAll(list, i)
Loop across all elements in list.
faceList savedFaces_
If undoable: per stored face the vertices. Negative indices.
const polyMesh & mesh_
Reference to mesh.
Direct mesh changes based on v1.3 polyTopoChange syntax.
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
void getUnrefimentSet(const labelList &undoFaces, labelList &localFaces, labelList &localPoints) const
Given set of faces to restore calculates a consistent set of.
Class describing modification of a face.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void operator()(List< T > &x, const List< T > &y) const
dimensioned< scalar > mag(const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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]
virtual void sync(const polyMesh &mesh)
Sync faceSet across coupled patches.
labelList savedFaceLabels_
If undoable: per stored face the original mesh face label.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Pre-declare SubField and related Field type.
A subset of mesh faces organised as a primitive patch.
void modifyFace(const label faceI, const face &, polyTopoChange &) const
Change the vertices of the face whilst keeping everything else.
Indexes into negList (negative index) or posList (zero or positive index).
void setUnrefinement(const labelList &localFaces, const labelList &localPoints, polyTopoChange &)
Restore selected faces and vertices.
label size() const
Return number of elements in table.
Combine-reduce operator to combine data on faces. Takes care.
bool found(const Key &) const
Return true if hashedEntry is found in table.
label whichFace(const label globalCellID) const
Helper function to re-direct to zone::localID(...)
errorManip< error > abort(error &err)
label commonVertex(const edge &a) const
Return common vertex.
const labelList & reverseFaceMap() const
Reverse face map.
void setSize(const label)
Reset size of List.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label setAction(const topoAction &action)
For compatibility with polyTopoChange: set topological action.
const bool undoable_
Whether undoable.
const labelList & reversePointMap() const
Reverse point map.
const dimensionedScalar e
Elementary charge.
void clear()
Clear the list, i.e. set size to zero.
bool insert(const Key &key)
Insert a new entry.
Class containing data for point addition.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A List with indirect addressing.
A face is a list of labels corresponding to mesh vertices.
void size(const label)
Override size to be inconsistent with allocated storage.
pointField savedPoints_
If undoable: deleted points.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
void setRefinement(const boolList &, polyTopoChange &)
Play commands into polyTopoChange to remove points. Gets.
label otherVertex(const label a) const
Given one vertex, return the other.
const boolList & flipMap() const
Return face flip map.
defineTypeNameAndDebug(combustionModel, 0)
label countPointUsage(const scalar minCos, boolList &pointCanBeDeleted) const
Mark in pointCanBeDeleted the points that can be deleted.