51 void Foam::undoableMeshCutter::printCellRefTree
55 const splitCell* splitCellPtr
62 word subIndent =
indent +
"--";
64 printCellRefTree(
os, subIndent, splitCellPtr->master());
66 printCellRefTree(
os, subIndent, splitCellPtr->slave());
72 void Foam::undoableMeshCutter::printRefTree(Ostream&
os)
const 76 const splitCell* splitPtr = iter.val();
79 while (splitPtr->parent())
81 if (!splitPtr->isMaster())
89 splitPtr = splitPtr->parent();
97 printCellRefTree(
os, word(
""), splitPtr);
105 void Foam::undoableMeshCutter::updateLabels
108 Map<splitCell*>& liveSplitCells
113 bool changed =
false;
117 const splitCell* splitPtr = iter.val();
122 <<
"Problem: null pointer on liveSplitCells list" 126 label celli = splitPtr->cellLabel();
128 if (celli != map[celli])
143 Map<splitCell*> newLiveSplitCells(2*liveSplitCells.size());
147 splitCell* splitPtr = iter.val();
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);
170 liveSplitCells = newLiveSplitCells;
177 Foam::undoableMeshCutter::undoableMeshCutter
179 const polyMesh&
mesh,
185 liveSplitCells_(
mesh.nCells()/100 + 100),
214 otherSidePtr->
parent() =
nullptr;
216 splitPtr->
parent() =
nullptr;
222 splitPtr = parentPtr;
232 const cellCuts& cuts,
233 polyTopoChange& meshMod
244 const label celli = iter.key();
245 const label addedCelli = iter.val();
250 auto findCell = liveSplitCells_.find(celli);
252 if (!findCell.found())
259 splitCell* parentPtr =
new splitCell(celli,
nullptr);
261 splitCell* masterPtr =
new splitCell(celli, parentPtr);
263 splitCell* slavePtr =
new splitCell(addedCelli, parentPtr);
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);
285 splitCell* parentPtr = findCell();
288 liveSplitCells_.erase(findCell);
290 splitCell* masterPtr =
new splitCell(celli, parentPtr);
292 splitCell* slavePtr =
new splitCell(addedCelli, parentPtr);
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" 350 DynamicList<label> liveSplitFaces(liveSplitCells_.size());
354 const splitCell* splitPtr = iter.val();
356 if (!splitPtr->parent())
359 <<
"Live split cell without parent" <<
endl 360 <<
"splitCell:" << splitPtr->cellLabel()
365 if (splitPtr->isMaster())
367 splitCell* slavePtr = splitPtr->getOther();
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 liveSplitFaces.shrink();
407 <<
"Only call if constructed with unrefinement capability" 411 Map<label> addedCells(liveSplitCells_.size());
415 const splitCell* splitPtr = iter.val();
417 if (!splitPtr->parent())
420 <<
"Live split cell without parent" <<
endl 421 <<
"splitCell:" << splitPtr->cellLabel()
426 if (splitPtr->isMaster())
428 splitCell* slavePtr = splitPtr->getOther();
432 liveSplitCells_.found(slavePtr->cellLabel())
433 && splitPtr->isUnrefined()
434 && slavePtr->isUnrefined()
438 addedCells.insert(splitPtr->cellLabel(), slavePtr->cellLabel());
449 polyTopoChange& meshMod
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.found() && nbrFind.found())
508 splitCell* ownPtr = ownFind.val();
510 splitCell* nbrPtr = nbrFind.val();
512 splitCell* parentPtr = ownPtr->
parent();
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;
Ostream & indent(Ostream &os)
Indent stream.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
~undoableMeshCutter()
Destructor.
virtual const labelList & faceNeighbour() const
Return face neighbour.
splitCell * getOther() const
Returns other half of split cell. I.e. slave if this is master.
Unit conversion functions.
Ostream & endl(Ostream &os)
Add newline and flush stream.
#define forAll(list, i)
Loop across all elements in list.
void updateMesh(const mapPolyMesh &)
Force recalculation of locally stored data on topological change.
dimensionedScalar cos(const dimensionedScalar &ds)
splitCell * parent() const
Description of cell after splitting. Contains cellLabel and pointers to cells it it split in...
virtual const labelList & faceOwner() const
Return face owner.
#define forAllIters(container, iter)
Iterate across all elements in the container object.
void setRefinement(const cellCuts &cuts, polyTopoChange &)
Refine cells acc. to cellCuts. Plays topology changes.
Map< label > getAddedCells() const
Like getSplitFaces but returns map from original to added cell.
errorManip< error > abort(error &err)
void setRefinement(const cellCuts &cuts, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
labelList removeSplitFaces(const labelList &splitFaces, polyTopoChange &)
Remove some refinement. Needs to be supplied subset of.
void updateMesh(const mapPolyMesh &morphMap)
Update stored refinement pattern for changes to mesh. Only.
labelList getSplitFaces() const
Calculate split faces from current liveCells. Only.
List< label > labelList
A List of labels.
constexpr scalar degToRad(const scalar deg) noexcept
Conversion from degrees to radians.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
forAllConstIters(mixture.phases(), phase)
A HashTable to objects of type <T> with a label key.