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
76 const splitCell* splitPtr = iter.val();
79 while (splitPtr->parent())
81 if (!splitPtr->isMaster())
89 splitPtr = splitPtr->parent();
97 printCellRefTree(
os, word(
""), splitPtr);
105void 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;
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.found())
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);
346 <<
"Only call if constructed with unrefinement capability"
359 <<
"Live split cell without parent" <<
endl
371 liveSplitCells_.found(slavePtr->
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());
420 <<
"Live split cell without parent" <<
endl
432 liveSplitCells_.found(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.found() && nbrFind.found())
518 Pout<<
"Updating for removed splitFace " << facei
519 <<
" own:" << own <<
" nbr:" << nbr
527 <<
"No parent for owner " << ownPtr->
cellLabel()
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
558 <<
"Owner and neighbour liveSplitCell entries are"
559 <<
" refined themselves or the parent is not refined"
562 <<
" neighbour unrefined:" << nbrPtr->
isUnrefined()
563 <<
" master unrefined:" << parentPtr->
isUnrefined()
568 liveSplitCells_.erase(ownFind);
571 liveSplitCells_.erase(liveSplitCells_.find(nbr));
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.
DynamicList< T, SizeMin > & shrink()
Shrink the allocated space to the number of elements used.
void append(const T &val)
Copy append an element to the end of this list.
bool insert(const Key &key, const T &obj)
Copy insert a new entry, not overwriting existing entries.
A HashTable to objects of type <T> with a label key.
label find(const T &val, label pos=0) const
Find index of the first occurrence of the value.
void size(const label n)
Older name for setAddressableSize.
Description of cuts across cells.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
const labelList & reverseCellMap() const
Reverse cell map.
void setRefinement(const cellCuts &cuts, polyTopoChange &meshMod)
Do actual cutting with cut description. Inserts mesh changes.
void updateMesh()
Update for new mesh topology.
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.
~undoableMeshCutter()
Destructor.
Map< label > getAddedCells() const
Like getSplitFaces but returns map from original to added cell.
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 defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
OBJstream os(runTime.globalPath()/outputName)
List< label > labelList
A List of labels.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Ostream & indent(Ostream &os)
Indent stream.
constexpr scalar degToRad() noexcept
Multiplication factor for degrees to radians conversion.
errorManip< error > abort(error &err)
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.