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),
208 otherSidePtr->
parent() =
nullptr;
210 splitPtr->
parent() =
nullptr;
216 splitPtr = parentPtr;
238 label celli = iter.key();
240 label addedCelli = iter();
247 liveSplitCells_.
find(celli);
249 if (findCell == liveSplitCells_.
end())
264 parentPtr->
master() = masterPtr;
265 parentPtr->
slave() = slavePtr;
269 if (liveSplitCells_.found(addedCelli))
272 <<
"problem addedCell:" << addedCelli
276 liveSplitCells_.insert(celli, masterPtr);
277 liveSplitCells_.insert(addedCelli, slavePtr);
285 liveSplitCells_.erase(findCell);
293 parentPtr->
master() = masterPtr;
294 parentPtr->
slave() = slavePtr;
298 if (liveSplitCells_.found(addedCelli))
301 <<
"problem addedCell:" << addedCelli
305 liveSplitCells_.insert(celli, masterPtr);
306 liveSplitCells_.insert(addedCelli, slavePtr);
312 Pout<<
"** After refinement: liveSplitCells_:" <<
endl;
328 faceRemover_.topoChange(map);
343 <<
"Only call if constructed with unrefinement capability"
356 <<
"Live split cell without parent" <<
endl
368 liveSplitCells_.found(slavePtr->
cellLabel())
388 liveSplitFaces.
append(commonFacei);
393 return liveSplitFaces.
shrink();
404 <<
"Only call if constructed with unrefinement capability"
408 Map<label> addedCells(liveSplitCells_.size());
417 <<
"Live split cell without parent" <<
endl
429 liveSplitCells_.found(slavePtr->
cellLabel())
452 <<
"Only call if constructed with unrefinement capability"
462 faceRemover().compatibleRemoves
470 if (facesToRemove.
size() != splitFaces.
size())
472 Pout<<
"cellRegion:" << cellRegion <<
endl;
473 Pout<<
"cellRegionMaster:" << cellRegionMaster <<
endl;
476 <<
"Faces to remove:" << splitFaces <<
endl
477 <<
"to be removed:" << facesToRemove
484 forAll(facesToRemove, facesToRemoveI)
486 label facei = facesToRemove[facesToRemoveI];
488 if (!mesh().isInternalFace(facei))
491 <<
"Trying to remove face that is not internal"
495 label own = mesh().faceOwner()[facei];
497 label nbr = mesh().faceNeighbour()[facei];
505 (ownFind == liveSplitCells_.
end())
506 || (nbrFind == liveSplitCells_.
end())
526 Pout<<
"Updating for removed splitFace " << facei
527 <<
" own:" << own <<
" nbr:" << nbr
535 <<
"No parent for owner " << ownPtr->
cellLabel()
542 <<
"No parent for neighbour " << nbrPtr->
cellLabel()
546 if (parentPtr != nbrPtr->
parent())
549 <<
"Owner and neighbour liveSplitCell entries do not have"
550 <<
" same parent. facei:" << facei <<
" owner:" << own
551 <<
" ownparent:" << parentPtr->
cellLabel()
552 <<
" neighbour:" << nbr
566 <<
"Owner and neighbour liveSplitCell entries are"
567 <<
" refined themselves or the parent is not refined"
570 <<
" neighbour unrefined:" << nbrPtr->
isUnrefined()
571 <<
" master unrefined:" << parentPtr->
isUnrefined()
576 liveSplitCells_.erase(ownFind);
579 liveSplitCells_.erase(liveSplitCells_.find(nbr));
599 liveSplitCells_.insert(own, parentPtr);
612 faceRemover().setRefinement
620 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.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the 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 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.
scalar degToRad(const scalar deg)
Convert degrees to radians.
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)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable