70 sc.addedCellsPtr_.valid()
86 <<
"Attempted assignment to self"
94 s.addedCellsPtr_.valid()
103 if (addedCellsPtr_.valid() !=
s.addedCellsPtr_.valid())
107 else if (parent_ !=
s.parent_)
111 else if (addedCellsPtr_.valid())
113 return addedCellsPtr_() ==
s.addedCellsPtr_();
134 is >> sc.
parent_ >> addedCells;
136 if (addedCells.
size())
152 const refinementHistory::splitCell8& sc
222 Pout<<
"Cell from refinement:" << cellI <<
" index:" << index
232 Pout<<
"Unrefined cell:" << cellI <<
" index:" << index <<
endl;
248 <<
" in visibleCells at location" << i <<
nl
249 <<
"It points outside the range of splitCells : 0.."
294 parentSplits[i] = index;
311 if (subCellsPtr.
valid())
320 <<
"Problem: cannot find myself in"
325 subCells[myPos] = -1;
346 if (oldToNew[index] == -1)
352 oldToNew[index] = newSplitCells.size();
353 newSplitCells.
append(split);
367 markSplit(splits[i], oldToNew, newSplitCells);
383 splitToVal[index] = val;
395 mark(val, splits[i], splitToVal);
425 if (splitToCluster[index] == -1)
427 mark(clusterI, index, splitToCluster);
442 cellToCluster[cellI] = splitToCluster[index];
469 label nUnblocked = 0;
473 label ownCluster = cellToCluster[
mesh.faceOwner()[faceI]];
474 label neiCluster = cellToCluster[
mesh.faceNeighbour()[faceI]];
476 if (ownCluster != -1 && ownCluster == neiCluster)
478 if (blockedFace[faceI])
480 blockedFace[faceI] =
false;
486 if (refinementHistory::debug)
489 Info<<
type() <<
" : unblocked " << nUnblocked <<
" faces" <<
endl;
523 label ownCluster = cellToCluster[own];
524 label neiCluster = cellToCluster[nei];
526 if (ownCluster != -1 && ownCluster == neiCluster)
528 if (clusterToProc[ownCluster] == -1)
530 clusterToProc[ownCluster] = decomposition[own];
533 if (decomposition[own] != clusterToProc[ownCluster])
535 decomposition[own] = clusterToProc[ownCluster];
538 if (decomposition[nei] != clusterToProc[ownCluster])
540 decomposition[nei] = clusterToProc[ownCluster];
546 if (refinementHistory::debug)
549 Info<<
type() <<
" : changed decomposition on " << nChanged
567 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
568 <<
" does not support automatic rereading."
590 Pout<<
"refinementHistory::refinementHistory :"
591 <<
" constructed history from IOobject :"
611 splitCells_(splitCells),
613 visibleCells_(visibleCells)
619 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
620 <<
" does not support automatic rereading."
631 readStream(typeName) >> *
this;
640 Pout<<
"refinementHistory::refinementHistory :"
641 <<
" constructed history from IOobject or components :"
642 <<
" splitCells:" << splitCells_.size()
643 <<
" visibleCells:" << visibleCells_.size()
665 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
666 <<
" does not support automatic rereading."
677 readStream(typeName) >> *
this;
682 visibleCells_.setSize(nCells);
683 splitCells_.setCapacity(nCells);
685 for (
label cellI = 0; cellI < nCells; cellI++)
687 visibleCells_[cellI] = cellI;
700 Pout<<
"refinementHistory::refinementHistory :"
701 <<
" constructed history from IOobject or initial size :"
702 <<
" splitCells:" << splitCells_.size()
703 <<
" visibleCells:" << visibleCells_.size()
726 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class"
727 <<
" does not support automatic rereading."
738 readStream(typeName) >> *
this;
743 visibleCells_.setSize(nCells);
744 splitCells_.setCapacity(nCells);
746 for (
label cellI = 0; cellI < nCells; cellI++)
748 visibleCells_[cellI] = cellI;
758 Pout<<
"refinementHistory::refinementHistory :"
759 <<
" constructed history from IOobject or initial size :"
760 <<
" splitCells:" << splitCells_.size()
761 <<
" visibleCells:" << visibleCells_.size()
783 Pout<<
"refinementHistory::refinementHistory : constructed initial"
784 <<
" history." <<
endl;
809 <<
"read option IOobject::MUST_READ, READ_IF_PRESENT or "
810 <<
"MUST_READ_IF_MODIFIED"
811 <<
" suggests that a read constructor would be more appropriate."
824 offsets[refI+1] = offsets[refI]+subSplits.size();
828 splitCells_.
setSize(offsets.last());
834 splitCell8& newSplit = splitCells_[offsets[refI]+i];
837 newSplit = subSplits[i];
842 newSplit.
parent_ += offsets[refI];
853 splits[i] += offsets[refI];
865 const labelList& cellMap = cellMaps[refI];
866 const labelList& subVis = refs[refI].visibleCells();
870 label& newVis = visibleCells_[cellMap[i]];
875 newVis += offsets[refI];
886 if (refs[refI].active())
898 Pout<<
"refinementHistory::refinementHistory :"
899 <<
" constructed history from multiple refinementHistories :"
900 <<
" splitCells:" << splitCells_.size()
901 <<
" visibleCells:" << visibleCells_.size()
923 Pout<<
"refinementHistory::refinementHistory :"
924 <<
" constructed history from Istream"
950 oldToNewSplit.
setSize(splitCells_.size());
959 forAll(splitCells_, index)
961 if (splitCellProc[index] == procI && splitCellNum[index] == 8)
964 oldToNewSplit[index] = newSplitCells.size();
965 newSplitCells.
append(splitCells_[index]);
970 forAll(visibleCells_, cellI)
972 label index = visibleCells_[cellI];
974 if (index >= 0 && decomposition[cellI] == procI)
976 label parent = splitCells_[index].parent_;
979 oldToNewSplit[index] = newSplitCells.size();
993 forAll(newSplitCells, index)
1009 splits[i] = oldToNewSplit[splits[i]];
1018 forAll(decomposition, cellI)
1020 if (decomposition[cellI] == procI)
1029 forAll(visibleCells_, cellI)
1031 if (decomposition[cellI] == procI)
1033 label index = visibleCells_[cellI];
1036 index = oldToNewSplit[index];
1038 newVisibleCells[nSub++] = index;
1064 labelList decomposition(visibleCells_.size(), 0);
1067 decomposition[cellMap[i]] = 1;
1072 labelList splitCellProc(splitCells_.size(), -1);
1075 labelList splitCellNum(splitCells_.size(), 0);
1077 forAll(visibleCells_, cellI)
1079 label index = visibleCells_[cellI];
1085 splitCells_[index].parent_,
1086 decomposition[cellI],
1122 label oldSize = visibleCells_.size();
1126 Pout<<
"refinementHistory::resize from " << oldSize <<
" to " << size
1127 <<
" cells" <<
endl;
1130 visibleCells_.setSize(size);
1133 for (
label i = oldSize; i < visibleCells_.size(); i++)
1135 visibleCells_[i] = -1;
1150 forAll(visibleCells_, cellI)
1152 if (visibleCells_[cellI] != -1)
1154 label index = visibleCells_[cellI];
1157 if (splitCells_[index].addedCellsPtr_.valid())
1163 label newCellI = reverseCellMap[cellI];
1167 newVisibleCells[newCellI] = index;
1174 Pout<<
"refinementHistory::updateMesh : from "
1175 << visibleCells_.size()
1176 <<
" to " << newVisibleCells.
size()
1177 <<
" cells" <<
endl;
1180 visibleCells_.transfer(newVisibleCells);
1197 forAll(newVisibleCells, cellI)
1199 label oldCellI = cellMap[cellI];
1201 label index = visibleCells_[oldCellI];
1204 if (index >= 0 && splitCells_[index].addedCellsPtr_.valid())
1210 newVisibleCells[cellI] = index;
1215 Pout<<
"refinementHistory::updateMesh : from "
1216 << visibleCells_.size()
1217 <<
" to " << newVisibleCells.
size()
1218 <<
" cells" <<
endl;
1221 visibleCells_.transfer(newVisibleCells);
1229 const label newProcNo,
1234 if (splitCellProc[index] != newProcNo)
1238 splitCellProc[index] = newProcNo;
1239 splitCellNum[index] = 1;
1243 splitCellNum[index]++;
1246 if (splitCellNum[index] == 8)
1250 Pout<<
"Moving " << splitCellNum[index]
1251 <<
" cells originating from cell " << index
1253 <<
" to processor " << splitCellProc[index]
1257 label parent = splitCells_[index].parent_;
1261 countProc(parent, newProcNo, splitCellProc, splitCellNum);
1301 labelList destination(visibleCells_.size());
1305 forAll(subCellMap, procI)
1307 const labelList& newToOld = subCellMap[procI];
1311 label oldCellI = newToOld[i];
1313 destination[oldCellI] = procI;
1318 labelList splitCellProc(splitCells_.size(), -1);
1320 labelList splitCellNum(splitCells_.size(), 0);
1322 forAll(visibleCells_, cellI)
1324 label index = visibleCells_[cellI];
1330 splitCells_[index].parent_,
1352 labelList oldToNew(splitCells_.size(), -1);
1360 forAll(splitCells_, index)
1362 if (splitCellProc[index] == procI && splitCellNum[index] == 8)
1365 oldToNew[index] = newSplitCells.size();
1366 newSplitCells.
append(splitCells_[index]);
1371 forAll(visibleCells_, cellI)
1373 label index = visibleCells_[cellI];
1375 if (index >= 0 && destination[cellI] == procI)
1377 label parent = splitCells_[index].parent_;
1380 oldToNew[index] = newSplitCells.size();
1394 forAll(newSplitCells, index)
1410 splits[i] = oldToNew[splits[i]];
1417 const labelList& subMap = subCellMap[procI];
1424 label oldCellI = subMap[newCellI];
1426 label oldIndex = visibleCells_[oldCellI];
1430 newVisibleCells[newCellI] = oldToNew[oldIndex];
1441 toNbr << newSplitCells << newVisibleCells;
1449 splitCells_.
clear();
1469 label offset = splitCells_.size();
1474 forAll(newSplitCells, index)
1490 splits[i] += offset;
1495 splitCells_.append(split);
1502 forAll(newVisibleCells, i)
1504 if (newVisibleCells[i] >= 0)
1506 visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
1510 splitCells_.shrink();
1522 Pout<<
"refinementHistory::compact() Entering with:"
1523 <<
" freeSplitCells_:" << freeSplitCells_.size()
1524 <<
" splitCells_:" << splitCells_.size()
1525 <<
" visibleCells_:" << visibleCells_.size()
1529 forAll(freeSplitCells_, i)
1531 label index = freeSplitCells_[i];
1533 if (splitCells_[index].parent_ != -2)
1536 <<
"Problem index:" << index
1542 forAll(visibleCells_, cellI)
1546 visibleCells_[cellI] >= 0
1547 && splitCells_[visibleCells_[cellI]].parent_ == -2
1551 <<
"Problem : visible cell:" << cellI
1560 labelList oldToNew(splitCells_.size(), -1);
1566 forAll(visibleCells_, cellI)
1568 label index = visibleCells_[cellI];
1576 splitCells_[index].parent_ != -1
1577 || splitCells_[index].addedCellsPtr_.valid()
1580 markSplit(index, oldToNew, newSplitCells);
1586 forAll(splitCells_, index)
1588 if (splitCells_[index].parent_ == -2)
1594 splitCells_[index].parent_ == -1
1595 && splitCells_[index].addedCellsPtr_.empty()
1604 markSplit(index, oldToNew, newSplitCells);
1612 forAll(newSplitCells, index)
1628 splits[i] = oldToNew[splits[i]];
1637 Pout<<
"refinementHistory::compact : compacted splitCells from "
1638 << splitCells_.size() <<
" to " << newSplitCells.size() <<
endl;
1641 splitCells_.transfer(newSplitCells);
1642 freeSplitCells_.clearStorage();
1647 Pout<<
"refinementHistory::compact() NOW:"
1648 <<
" freeSplitCells_:" << freeSplitCells_.size()
1649 <<
" splitCells_:" << splitCells_.size()
1650 <<
" newSplitCells:" << newSplitCells.size()
1651 <<
" visibleCells_:" << visibleCells_.size()
1657 forAll(visibleCells_, cellI)
1659 label index = visibleCells_[cellI];
1664 visibleCells_[cellI] = oldToNew[index];
1676 writeDebug(visibleCells_, splitCells_);
1686 label parentIndex = -1;
1688 if (visibleCells_[cellI] != -1)
1693 parentIndex = visibleCells_[cellI];
1697 visibleCells_[cellI] = -1;
1702 parentIndex = allocateSplitCell(-1, -1);
1709 label addedCellI = addedCells[i];
1713 visibleCells_[addedCellI] = allocateSplitCell(parentIndex, i);
1720 const label masterCellI,
1725 label parentIndex = splitCells_[visibleCells_[masterCellI]].parent_;
1730 label cellI = combinedCells[i];
1732 freeSplitCell(visibleCells_[cellI]);
1733 visibleCells_[cellI] = -1;
1736 splitCell8& parentSplit = splitCells_[parentIndex];
1738 visibleCells_[masterCellI] = parentIndex;
1744 bool ok = readData(readStream(typeName));
1785 const_cast<refinementHistory&
>(rh).compact();
1787 return os <<
"// splitCells" <<
nl
1788 << rh.splitCells_ <<
nl
1789 <<
"// visibleCells" <<
nl
1790 << rh.visibleCells_;