51void Foam::undoableMeshCutter::printCellRefTree
55 const splitCell* splitCellPtr
62 word subIndent =
indent +
"--";
64 printCellRefTree(
os, subIndent, splitCellPtr->master());
66 printCellRefTree(
os, subIndent, splitCellPtr->slave());
72void Foam::undoableMeshCutter::printRefTree(
Ostream&
os)
const
79 while (splitPtr->parent())
81 if (!splitPtr->isMaster())
89 splitPtr = splitPtr->parent();
97 printCellRefTree(
os,
word(
""), splitPtr);
105void Foam::undoableMeshCutter::updateLabels
113 bool changed =
false;
122 <<
"Problem: null pointer on liveSplitCells list"
128 if (celli != map[celli])
149 const label celli = splitPtr->
cellLabel();
151 const label newCelli = map[celli];
153 if (
debug && (celli != newCelli))
155 Pout<<
"undoableMeshCutter::updateLabels :"
156 <<
" Updating live (split)cell from " << celli
157 <<
" to " << newCelli <<
endl;
164 splitPtr->cellLabel() = newCelli;
167 newLiveSplitCells.insert(newCelli, splitPtr);
177Foam::undoableMeshCutter::undoableMeshCutter
179 const polyMesh&
mesh,
185 liveSplitCells_(
mesh.nCells()/100 + 100),
214 otherSidePtr->
parent() =
nullptr;
216 splitPtr->
parent() =
nullptr;
222 splitPtr = parentPtr;
244 const label celli = iter.key();
245 const label addedCelli = iter.val();
250 auto findCell = liveSplitCells_.find(celli);
252 if (!findCell.good())
267 parentPtr->master() = masterPtr;
268 parentPtr->slave() = slavePtr;
272 if (liveSplitCells_.found(addedCelli))
275 <<
"problem addedCell:" << addedCelli
279 liveSplitCells_.insert(celli, masterPtr);
280 liveSplitCells_.insert(addedCelli, slavePtr);
288 liveSplitCells_.erase(findCell);
296 parentPtr->master() = masterPtr;
297 parentPtr->slave() = slavePtr;
301 if (liveSplitCells_.found(addedCelli))
304 <<
"problem addedCell:" << addedCelli
308 liveSplitCells_.insert(celli, masterPtr);
309 liveSplitCells_.insert(addedCelli, slavePtr);
315 Pout<<
"** After refinement: liveSplitCells_:" <<
endl;
331 faceRemover_.updateMesh(morphMap);
336 updateLabels(morphMap.reverseCellMap(), liveSplitCells_);
346 <<
"Only call if constructed with unrefinement capability"
356 if (!splitPtr->parent())
359 <<
"Live split cell without parent" <<
endl
360 <<
"splitCell:" << splitPtr->cellLabel()
365 if (splitPtr->isMaster())
371 liveSplitCells_.found(slavePtr->cellLabel())
372 && splitPtr->isUnrefined()
373 && slavePtr->isUnrefined()
379 label celli = splitPtr->cellLabel();
381 label slaveCelli = slavePtr->cellLabel();
391 liveSplitFaces.append(commonFacei);
396 return labelList(std::move(liveSplitFaces));
407 <<
"Only call if constructed with unrefinement capability"
411 Map<label> addedCells(liveSplitCells_.size());
417 if (!splitPtr->parent())
420 <<
"Live split cell without parent" <<
endl
421 <<
"splitCell:" << splitPtr->cellLabel()
426 if (splitPtr->isMaster())
432 liveSplitCells_.found(slavePtr->cellLabel())
433 && splitPtr->isUnrefined()
434 && slavePtr->isUnrefined()
438 addedCells.insert(splitPtr->cellLabel(), slavePtr->cellLabel());
455 <<
"Only call if constructed with unrefinement capability"
465 faceRemover().compatibleRemoves
473 if (facesToRemove.size() != splitFaces.size())
475 Pout<<
"cellRegion:" << cellRegion <<
endl;
476 Pout<<
"cellRegionMaster:" << cellRegionMaster <<
endl;
479 <<
"Faces to remove:" << splitFaces <<
endl
480 <<
"to be removed:" << facesToRemove
487 forAll(facesToRemove, facesToRemoveI)
489 label facei = facesToRemove[facesToRemoveI];
491 if (!
mesh().isInternalFace(facei))
494 <<
"Trying to remove face that is not internal"
501 auto ownFind = liveSplitCells_.
find(own);
502 auto nbrFind = liveSplitCells_.find(nbr);
504 if (ownFind.good() && nbrFind.good())
518 Pout<<
"Updating for removed splitFace " << facei
519 <<
" own:" << own <<
" nbr:" << nbr
520 <<
" ownPtr:" << ownPtr->cellLabel()
521 <<
" nbrPtr:" << nbrPtr->cellLabel()
527 <<
"No parent for owner " << ownPtr->cellLabel()
531 if (!nbrPtr->parent())
534 <<
"No parent for neighbour " << nbrPtr->cellLabel()
538 if (parentPtr != nbrPtr->parent())
541 <<
"Owner and neighbour liveSplitCell entries do not have"
542 <<
" same parent. facei:" << facei <<
" owner:" << own
543 <<
" ownparent:" << parentPtr->cellLabel()
544 <<
" neighbour:" << nbr
545 <<
" nbrparent:" << nbrPtr->parent()->cellLabel()
551 !ownPtr->isUnrefined()
552 || !nbrPtr->isUnrefined()
553 || parentPtr->isUnrefined()
558 <<
"Owner and neighbour liveSplitCell entries are"
559 <<
" refined themselves or the parent is not refined"
561 <<
"owner unrefined:" << ownPtr->isUnrefined()
562 <<
" neighbour unrefined:" << nbrPtr->isUnrefined()
563 <<
" master unrefined:" << parentPtr->isUnrefined()
568 liveSplitCells_.erase(ownFind);
571 liveSplitCells_.erase(liveSplitCells_.find(nbr));
582 if (parentPtr->parent())
586 parentPtr->cellLabel() = own;
590 liveSplitCells_.insert(own, parentPtr);
603 faceRemover().setRefinement
611 return facesToRemove;
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
A HashTable to objects of type <T> with a label key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
void size(const label n)
Older name for setAddressableSize.
label find(const T &val) const
Find index of the first occurrence of the value.
Description of cuts across cells.
const polyMesh & mesh() const
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const noexcept
Reverse cell map.
void updateMesh(const mapPolyMesh &)
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.
const Map< label > & addedCells() const
Cells added. Per split cell label of added cell.
Mesh consisting of general polyhedral cells.
virtual const labelList & faceOwner() const
Return face owner.
virtual const labelList & faceNeighbour() const
Return face neighbour.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in....
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 * parent() const
splitCell * master() const
splitCell * getOther() const
Returns other half of split cell. I.e. slave if this is master.
splitCell * slave() const
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.
const removeFaces & faceRemover() const
~undoableMeshCutter()
Destructor.
Map< label > getAddedCells() const
Like getSplitFaces but returns map from original to added cell.
void updateMesh(const mapPolyMesh &morphMap)
Update stored refinement pattern for changes to mesh. Only.
const Map< splitCell * > & liveSplitCells() const
All current live split cells. Warning: cell labels will change.
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.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
Namespace for handling debugging switches.
List< label > labelList
A List of labels.
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
errorManip< error > abort(error &err)
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
dimensionedScalar cos(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
#define forAllConstIters(container, iter)
Iterate across all elements of the container object with const access.
Unit conversion functions.