45 void Foam::refinementHistory::writeEntry
47 const List<splitCell8>& splitCells,
48 const splitCell8& split
52 if (split.addedCellsPtr_.valid())
54 Pout<<
"parent:" << split.parent_
55 <<
" subCells:" << split.addedCellsPtr_()
60 Pout<<
"parent:" << split.parent_
65 if (split.parent_ >= 0)
71 writeEntry(splitCells, splitCells[split.parent_]);
80 const List<splitCell8>& splitCells
86 forAll(visibleCells, cellI)
88 label index = visibleCells[cellI];
92 Pout<<
"Cell from refinement:" << cellI <<
" index:" << index
97 writeEntry(splitCells, splitCells[index]);
102 Pout<<
"Unrefined cell:" << cellI <<
" index:" << index <<
endl;
153 is >> sc.
parent_ >> addedCells;
155 if (addedCells.
size())
192 void Foam::refinementHistory::checkIndices()
const 197 if (visibleCells_[i] < 0 && visibleCells_[i] >= splitCells_.size())
200 <<
"Illegal entry " << visibleCells_[i]
201 <<
" in visibleCells at location" << i <<
nl 202 <<
"It points outside the range of splitCells : 0.." 203 << splitCells_.size()-1
210 Foam::label Foam::refinementHistory::allocateSplitCell
218 if (freeSplitCells_.size())
220 index = freeSplitCells_.remove();
226 index = splitCells_.size();
235 splitCell8& parentSplit = splitCells_[parent];
247 parentSplits[i] = index;
254 void Foam::refinementHistory::freeSplitCell(
const label index)
262 splitCells_[split.
parent_].addedCellsPtr_;
264 if (subCellsPtr.
valid())
273 <<
"Problem: cannot find myself in" 278 subCells[myPos] = -1;
287 freeSplitCells_.append(index);
292 void Foam::refinementHistory::markSplit
299 if (oldToNew[index] == -1)
305 oldToNew[index] = newSplitCells.
size();
306 newSplitCells.
append(split);
310 markSplit(split.
parent_, oldToNew, newSplitCells);
320 markSplit(splits[i], oldToNew, newSplitCells);
339 "refinementHistory::refinementHistory(const IOobject&)" 340 ) <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 341 <<
" does not support automatic rereading." 358 Pout<<
"refinementHistory::refinementHistory :" 359 <<
" constructed history from IOobject :" 360 <<
" splitCells:" << splitCells_.size()
361 <<
" visibleCells:" << visibleCells_.
size()
376 splitCells_(splitCells),
378 visibleCells_(visibleCells)
385 "refinementHistory::refinementHistory" 386 "(const IOobject&, const List<splitCell8>&, const labelList&)" 387 ) <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 388 <<
" does not support automatic rereading." 408 Pout<<
"refinementHistory::refinementHistory :" 409 <<
" constructed history from IOobject or components :" 410 <<
" splitCells:" << splitCells_.size()
411 <<
" visibleCells:" << visibleCells_.
size()
432 "refinementHistory::refinementHistory" 433 "(const IOobject&, const label)" 434 ) <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 435 <<
" does not support automatic rereading." 452 splitCells_.setCapacity(nCells);
454 for (
label cellI = 0; cellI < nCells; cellI++)
456 visibleCells_[cellI] = cellI;
466 Pout<<
"refinementHistory::refinementHistory :" 467 <<
" constructed history from IOobject or initial size :" 468 <<
" splitCells:" << splitCells_.size()
469 <<
" visibleCells:" << visibleCells_.
size()
489 Pout<<
"refinementHistory::refinementHistory : constructed initial" 490 <<
" history." <<
endl;
508 Pout<<
"refinementHistory::refinementHistory :" 509 <<
" constructed history from Istream" 510 <<
" splitCells:" << splitCells_.size()
511 <<
" visibleCells:" << visibleCells_.
size()
525 Pout<<
"refinementHistory::resize from " << oldSize <<
" to " << size
532 for (
label i = oldSize; i < visibleCells_.
size(); i++)
534 visibleCells_[i] = -1;
549 forAll(visibleCells_, cellI)
551 if (visibleCells_[cellI] != -1)
553 label index = visibleCells_[cellI];
556 if (splitCells_[index].addedCellsPtr_.valid())
560 "refinementHistory::updateMesh(const mapPolyMesh&)" 564 label newCellI = reverseCellMap[cellI];
568 newVisibleCells[newCellI] = index;
575 Pout<<
"refinementHistory::updateMesh : from " 576 << visibleCells_.
size()
577 <<
" to " << newVisibleCells.size()
581 visibleCells_.
transfer(newVisibleCells);
598 forAll(newVisibleCells, cellI)
600 label oldCellI = cellMap[cellI];
602 label index = visibleCells_[oldCellI];
605 if (index >= 0 && splitCells_[index].addedCellsPtr_.valid())
609 "refinementHistory::subset" 610 "(const labelList&, const labelList&, const labelList&)" 614 newVisibleCells[cellI] = index;
619 Pout<<
"refinementHistory::updateMesh : from " 620 << visibleCells_.
size()
621 <<
" to " << newVisibleCells.size()
625 visibleCells_.
transfer(newVisibleCells);
630 void Foam::refinementHistory::countProc
633 const label newProcNo,
638 if (splitCellProc[index] != newProcNo)
642 splitCellProc[index] = newProcNo;
643 splitCellNum[index] = 1;
647 splitCellNum[index]++;
650 if (splitCellNum[index] == 8)
654 Pout<<
"Moving " << splitCellNum[index]
655 <<
" cells originating from cell " << index
657 <<
" to processor " << splitCellProc[index]
661 label parent = splitCells_[index].parent_;
665 countProc(parent, newProcNo, splitCellProc, splitCellNum);
678 "refinementHistory::distribute(const mapDistributePolyMesh&)" 713 const labelList& newToOld = subCellMap[procI];
717 label oldCellI = newToOld[i];
719 destination[oldCellI] = procI;
727 labelList splitCellProc(splitCells_.size(), -1);
729 labelList splitCellNum(splitCells_.size(), 0);
731 forAll(visibleCells_, cellI)
733 label index = visibleCells_[cellI];
739 splitCells_[index].parent_,
761 labelList oldToNew(splitCells_.size(), -1);
769 forAll(splitCells_, index)
776 if (splitCellProc[index] == procI && splitCellNum[index] == 8)
779 oldToNew[index] = newSplitCells.
size();
780 newSplitCells.
append(splitCells_[index]);
790 forAll(visibleCells_, cellI)
792 label index = visibleCells_[cellI];
794 if (index >= 0 && destination[cellI] == procI)
796 label parent = splitCells_[index].parent_;
803 oldToNew[index] = newSplitCells.
size();
817 forAll(newSplitCells, index)
833 splits[i] = oldToNew[splits[i]];
840 const labelList& subMap = subCellMap[procI];
847 label oldCellI = subMap[newCellI];
849 label oldIndex = visibleCells_[oldCellI];
853 newVisibleCells[newCellI] = oldToNew[oldIndex];
864 toNbr << newSplitCells << newVisibleCells;
890 label offset = splitCells_.size();
895 forAll(newSplitCells, index)
916 splitCells_.append(split);
923 forAll(newVisibleCells, i)
925 if (newVisibleCells[i] >= 0)
927 visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
931 splitCells_.shrink();
943 Pout<<
"refinementHistory::compact() Entering with:" 944 <<
" freeSplitCells_:" << freeSplitCells_.
size()
945 <<
" splitCells_:" << splitCells_.size()
946 <<
" visibleCells_:" << visibleCells_.
size()
950 forAll(freeSplitCells_, i)
952 label index = freeSplitCells_[i];
954 if (splitCells_[index].parent_ != -2)
957 <<
"Problem index:" << index
963 forAll(visibleCells_, cellI)
967 visibleCells_[cellI] >= 0
968 && splitCells_[visibleCells_[cellI]].parent_ == -2
972 <<
"Problem : visible cell:" << cellI
981 labelList oldToNew(splitCells_.size(), -1);
987 forAll(visibleCells_, cellI)
989 label index = visibleCells_[cellI];
997 splitCells_[index].parent_ != -1
998 || splitCells_[index].addedCellsPtr_.valid()
1001 markSplit(index, oldToNew, newSplitCells);
1007 forAll(splitCells_, index)
1009 if (splitCells_[index].parent_ == -2)
1015 splitCells_[index].parent_ == -1
1016 && splitCells_[index].addedCellsPtr_.empty()
1025 markSplit(index, oldToNew, newSplitCells);
1033 forAll(newSplitCells, index)
1049 splits[i] = oldToNew[splits[i]];
1058 Pout<<
"refinementHistory::compact : compacted splitCells from " 1059 << splitCells_.size() <<
" to " << newSplitCells.
size() <<
endl;
1062 splitCells_.transfer(newSplitCells);
1068 Pout<<
"refinementHistory::compact() NOW:" 1069 <<
" freeSplitCells_:" << freeSplitCells_.
size()
1070 <<
" splitCells_:" << splitCells_.size()
1071 <<
" newSplitCells:" << newSplitCells.
size()
1072 <<
" visibleCells_:" << visibleCells_.
size()
1078 forAll(visibleCells_, cellI)
1080 label index = visibleCells_[cellI];
1085 visibleCells_[cellI] = oldToNew[index];
1109 if (visibleCells_[cellI] != -1)
1114 parentIndex = visibleCells_[cellI];
1118 visibleCells_[cellI] = -1;
1123 parentIndex = allocateSplitCell(-1, -1);
1130 label addedCellI = addedCells[i];
1134 visibleCells_[addedCellI] = allocateSplitCell(parentIndex, i);
1141 const label masterCellI,
1151 label cellI = combinedCells[i];
1153 freeSplitCell(visibleCells_[cellI]);
1154 visibleCells_[cellI] = -1;
1184 is >> rh.splitCells_ >> rh.visibleCells_;
1197 return os <<
"// splitCells" <<
nl 1198 << rh.splitCells_ <<
nl 1199 <<
"// visibleCells" <<
nl 1200 << rh.visibleCells_;
static bool & parRun()
Is this a parallel run?
const string & prefix() const
Return the prefix of the stream.
const labelListList & subMap() const
From subsetted data back to original data.
readOption readOpt() const
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurence of given element and return index,.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
autoPtr< FixedList< label, 8 > > addedCellsPtr_
Cells this cell was refined into.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
bool bad() const
Return true if stream is corrupted.
const mapDistribute & cellMap() const
Cell distribute map.
void writeDebug() const
Debug write.
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void storeSplit(const label cellI, const labelList &addedCells)
Store splitting of cell into 8.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined)
void size(const label)
Override size to be inconsistent with allocated storage.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Output inter-processor communications stream.
Various functions to operate on Lists.
All refinement history. Used in unrefinement.
A 1D vector of objects of type <T> with a fixed size <Size>.
Ostream & operator<<(Ostream &, const edgeMesh &)
void resize(const label nCells)
Extend/shrink storage. additional visibleCells_ elements get.
static label nProcs(const label communicator=0)
Number of processes in parallel run.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
regIOobject(const IOobject &, const bool isTime=false)
Construct from IOobject. Optional flag for if IOobject is the.
void setSize(const label)
Reset size of List.
Ostream & endl(Ostream &os)
Add newline and flush stream.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
#define WarningIn(functionName)
Report a warning using Foam::Warning.
const polyMesh & mesh() const
void close()
Close Istream.
bool good() const
Return true if next operation might succeed.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
const DynamicList< label > & freeSplitCells() const
Cache of unused indices in splitCells.
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
splitCell8()
Construct null (parent = -1)
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
errorManip< error > abort(error &err)
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
void updateMesh(const mapPolyMesh &)
Update numbering for mesh changes.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
void compact()
Compact splitCells_. Removes all freeSplitCells_ elements.
void combineCells(const label masterCellI, const labelList &combinedCells)
Store combining 8 cells into master.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
Input inter-processor communications stream.
refinementHistory(const IOobject &)
Construct (read) given an IOobject.
List< label > labelList
A List of labels.
Istream & operator>>(Istream &, edgeMesh &)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
const labelList & reverseCellMap() const
Reverse cell map.
void clearStorage()
Clear the list and delete storage.
const DynamicList< splitCell8 > & splitCells() const
Storage for splitCell8s.
bool headerOk()
Read and check header info.
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
bool active() const
Is there unrefinement history. Note that this will fall over if.
Istream & readStream(const word &)
Return Istream and check object type against that given.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update numbering for subsetting.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
const labelList & cellMap() const
Old cell map.
label parentIndex(const label cellI) const
Get parent of cell.