48 void Foam::undoableMeshCutter::printCellRefTree
52 const splitCell* splitCellPtr
57 os <<
indent << splitCellPtr->cellLabel() <<
endl;
59 word subIndent =
indent +
"--";
61 printCellRefTree(os, subIndent, splitCellPtr->master());
63 printCellRefTree(os, subIndent, splitCellPtr->slave());
69 void Foam::undoableMeshCutter::printRefTree(Ostream& os)
const
73 const splitCell* splitPtr = iter();
76 while (splitPtr->parent())
78 if (!splitPtr->isMaster())
86 splitPtr = splitPtr->parent();
94 printCellRefTree(os, word(
""), splitPtr);
102 void Foam::undoableMeshCutter::updateLabels
105 Map<splitCell*>& liveSplitCells
110 bool changed =
false;
114 const splitCell* splitPtr = iter();
119 <<
"Problem: null pointer on liveSplitCells list"
123 label celli = splitPtr->cellLabel();
125 if (celli != map[celli])
140 Map<splitCell*> newLiveSplitCells(2*liveSplitCells.size());
142 forAllIter(Map<splitCell*>, liveSplitCells, iter)
144 splitCell* splitPtr = iter();
146 label celli = splitPtr->cellLabel();
148 label newCelli = map[celli];
150 if (debug && (celli != newCelli))
152 Pout<<
"undoableMeshCutter::updateLabels :"
153 <<
" Updating live (split)cell from " << celli
154 <<
" to " << newCelli <<
endl;
161 splitPtr->cellLabel() = newCelli;
164 newLiveSplitCells.insert(newCelli, splitPtr);
167 liveSplitCells = newLiveSplitCells;
183 liveSplitCells_(mesh.nCells()/100 + 100),
212 otherSidePtr->
parent() =
nullptr;
214 splitPtr->
parent() =
nullptr;
220 splitPtr = parentPtr;
242 label celli = iter.key();
244 label addedCelli = iter();
251 liveSplitCells_.find(celli);
253 if (findCell == liveSplitCells_.end())
268 parentPtr->
master() = masterPtr;
269 parentPtr->
slave() = slavePtr;
273 if (liveSplitCells_.found(addedCelli))
276 <<
"problem addedCell:" << addedCelli
280 liveSplitCells_.insert(celli, masterPtr);
281 liveSplitCells_.insert(addedCelli, slavePtr);
289 liveSplitCells_.erase(findCell);
297 parentPtr->
master() = masterPtr;
298 parentPtr->
slave() = slavePtr;
302 if (liveSplitCells_.found(addedCelli))
305 <<
"problem addedCell:" << addedCelli
309 liveSplitCells_.insert(celli, masterPtr);
310 liveSplitCells_.insert(addedCelli, slavePtr);
316 Pout<<
"** After refinement: liveSplitCells_:" <<
endl;
332 faceRemover_.topoChange(map);
347 <<
"Only call if constructed with unrefinement capability"
360 <<
"Live split cell without parent" <<
endl
372 liveSplitCells_.found(slavePtr->
cellLabel())
392 liveSplitFaces.
append(commonFacei);
397 return liveSplitFaces.
shrink();
408 <<
"Only call if constructed with unrefinement capability"
412 Map<label> addedCells(liveSplitCells_.size());
421 <<
"Live split cell without parent" <<
endl
433 liveSplitCells_.found(slavePtr->
cellLabel())
456 <<
"Only call if constructed with unrefinement capability"
466 faceRemover().compatibleRemoves
474 if (facesToRemove.
size() != splitFaces.
size())
476 Pout<<
"cellRegion:" << cellRegion <<
endl;
477 Pout<<
"cellRegionMaster:" << cellRegionMaster <<
endl;
480 <<
"Faces to remove:" << splitFaces <<
endl
481 <<
"to be removed:" << facesToRemove
488 forAll(facesToRemove, facesToRemoveI)
490 label facei = facesToRemove[facesToRemoveI];
492 if (!mesh().isInternalFace(facei))
495 <<
"Trying to remove face that is not internal"
499 label own = mesh().faceOwner()[facei];
501 label nbr = mesh().faceNeighbour()[facei];
509 (ownFind == liveSplitCells_.end())
510 || (nbrFind == liveSplitCells_.end())
530 Pout<<
"Updating for removed splitFace " << facei
531 <<
" own:" << own <<
" nbr:" << nbr
539 <<
"No parent for owner " << ownPtr->
cellLabel()
546 <<
"No parent for neighbour " << nbrPtr->
cellLabel()
550 if (parentPtr != nbrPtr->
parent())
553 <<
"Owner and neighbour liveSplitCell entries do not have"
554 <<
" same parent. facei:" << facei <<
" owner:" << own
555 <<
" ownparent:" << parentPtr->
cellLabel()
556 <<
" neighbour:" << nbr
570 <<
"Owner and neighbour liveSplitCell entries are"
571 <<
" refined themselves or the parent is not refined"
574 <<
" neighbour unrefined:" << nbrPtr->
isUnrefined()
575 <<
" master unrefined:" << parentPtr->
isUnrefined()
580 liveSplitCells_.erase(ownFind);
583 liveSplitCells_.erase(liveSplitCells_.find(nbr));
603 liveSplitCells_.insert(own, parentPtr);
616 faceRemover().setRefinement
624 return facesToRemove;
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
An STL-conforming iterator.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
void size(const label)
Override size to be inconsistent with allocated storage.
A HashTable to objects of type <T> with a label key.
Description of cuts across cells.
void topoChange(const polyTopoChangeMap &)
Force recalculation of locally stored data on topological change.
void setRefinement(const cellCuts &cuts, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
Mesh consisting of general polyhedral cells.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const
Reverse cell map.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in....
splitCell * parent() const
splitCell * slave() const
bool isMaster() const
Check if this is master cell of split.
bool isUnrefined() const
Check if this is unrefined (i.e. has no master or slave)
splitCell * master() const
splitCell * getOther() const
Returns other half of split cell. I.e. slave if this is master.
The main refinement handler. Gets cellCuts which is structure that describes which cells are to be cu...
labelList getSplitFaces() const
Calculate split faces from current liveCells. Only.
~undoableMeshCutter()
Destructor.
Map< label > getAddedCells() const
Like getSplitFaces but returns map from original to added cell.
void topoChange(const polyTopoChangeMap &map)
Update stored refinement pattern for changes to mesh. Only.
undoableMeshCutter(const polyMesh &mesh, const bool undoable=true)
Construct from mesh and flag whether refinement pattern needs.
void setRefinement(const cellCuts &cuts, polyTopoChange &)
Refine cells acc. to cellCuts. Plays topology changes.
labelList removeSplitFaces(const labelList &splitFaces, polyTopoChange &)
Remove some refinement. Needs to be supplied subset of.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout, "Pout")
Ostream & indent(Ostream &os)
Indent stream.
dimensionedScalar cos(const dimensionedScalar &ds)
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
Unit conversion functions.