42 void Foam::refinementHistory::writeEntry
44 const List<splitCell8>& splitCells,
45 const splitCell8& split
49 if (split.addedCellsPtr_.valid())
51 Pout<<
"parent:" << split.parent_
52 <<
" subCells:" << split.addedCellsPtr_()
57 Pout<<
"parent:" << split.parent_
62 if (split.parent_ >= 0)
68 writeEntry(splitCells, splitCells[split.parent_]);
77 const List<splitCell8>& splitCells
83 forAll(visibleCells, celli)
85 label index = visibleCells[celli];
89 Pout<<
"Cell from refinement:" << celli <<
" index:" << index
99 Pout<<
"Unrefined cell:" << celli <<
" index:" << index <<
endl;
111 addedCellsPtr_(nullptr)
149 FatalErrorIn(
"splitCell8::operator=(const Foam::splitCell8&)")
150 <<
"Attempted assignment to self" 198 is >> sc.
parent_ >> addedCells;
200 if (addedCells.
size())
223 if (sc.addedCellsPtr_.valid())
239 void Foam::refinementHistory::checkIndices()
const 244 if (visibleCells_[i] < 0 && visibleCells_[i] >= splitCells_.size())
247 <<
"Illegal entry " << visibleCells_[i]
248 <<
" in visibleCells at location" << i <<
nl 249 <<
"It points outside the range of splitCells : 0.." 250 << splitCells_.size()-1
257 Foam::label Foam::refinementHistory::allocateSplitCell
265 if (freeSplitCells_.size())
267 index = freeSplitCells_.remove();
273 index = splitCells_.size();
282 splitCell8& parentSplit = splitCells_[parent];
284 if (parentSplit.addedCellsPtr_.empty())
294 parentSplits[i] = index;
301 void Foam::refinementHistory::freeSplitCell(
const label index)
306 if (split.parent_ >= 0)
309 splitCells_[split.parent_].addedCellsPtr_;
311 if (subCellsPtr.
valid())
320 <<
"Problem: cannot find myself in" 325 subCells[myPos] = -1;
334 freeSplitCells_.append(index);
338 void Foam::refinementHistory::markSplit
345 if (oldToNew[index] == -1)
351 oldToNew[index] = newSplitCells.
size();
352 newSplitCells.
append(split);
354 if (split.parent_ >= 0)
356 markSplit(split.parent_, oldToNew, newSplitCells);
358 if (split.addedCellsPtr_.valid())
366 markSplit(splits[i], oldToNew, newSplitCells);
374 void Foam::refinementHistory::mark
381 splitToVal[index] = val;
385 if (split.addedCellsPtr_.valid())
393 mark(val, splits[i], splitToVal);
400 Foam::label Foam::refinementHistory::markCommonCells
407 labelList splitToCluster(splitCells_.size(), -1);
410 forAll(visibleCells_, cellI)
412 label index = visibleCells_[cellI];
417 while (splitCells_[index].
parent_ != -1)
419 index = splitCells_[index].parent_;
423 if (splitToCluster[index] == -1)
425 mark(clusterI, index, splitToCluster);
432 cellToCluster.
setSize(visibleCells_.size(), -1);
434 forAll(visibleCells_, cellI)
436 label index = visibleCells_[cellI];
440 cellToCluster[cellI] = splitToCluster[index];
462 markCommonCells(cellToCluster);
467 label nUnblocked = 0;
474 if (ownCluster != -1 && ownCluster == neiCluster)
476 if (blockedFace[faceI])
478 blockedFace[faceI] =
false;
484 if (refinementHistory::debug)
487 Info<<
type() <<
" : unblocked " << nUnblocked <<
" faces" <<
endl;
507 label nClusters = markCommonCells(cellToCluster);
521 label ownCluster = cellToCluster[own];
522 label neiCluster = cellToCluster[nei];
524 if (ownCluster != -1 && ownCluster == neiCluster)
526 if (clusterToProc[ownCluster] == -1)
528 clusterToProc[ownCluster] = decomposition[own];
531 if (decomposition[own] != clusterToProc[ownCluster])
533 decomposition[own] = clusterToProc[ownCluster];
536 if (decomposition[nei] != clusterToProc[ownCluster])
538 decomposition[nei] = clusterToProc[ownCluster];
544 if (refinementHistory::debug)
547 Info<<
type() <<
" : changed decomposition on " << nChanged
564 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 565 <<
" does not support automatic rereading." 587 Pout<<
"refinementHistory::refinementHistory :" 588 <<
" constructed history from IOobject :" 589 <<
" splitCells:" << splitCells_.size()
590 <<
" visibleCells:" << visibleCells_.
size()
591 <<
" active:" << active_
607 splitCells_(splitCells),
609 visibleCells_(visibleCells)
615 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 616 <<
" does not support automatic rereading." 636 Pout<<
"refinementHistory::refinementHistory :" 637 <<
" constructed history from IOobject or components :" 638 <<
" splitCells:" << splitCells_.size()
639 <<
" visibleCells:" << visibleCells_.
size()
640 <<
" active:" << active_
660 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 661 <<
" does not support automatic rereading." 678 splitCells_.setCapacity(nCells);
680 for (
label cellI = 0; cellI < nCells; cellI++)
682 visibleCells_[cellI] = cellI;
695 Pout<<
"refinementHistory::refinementHistory :" 696 <<
" constructed history from IOobject or initial size :" 697 <<
" splitCells:" << splitCells_.size()
698 <<
" visibleCells:" << visibleCells_.
size()
699 <<
" active:" << active_
721 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 722 <<
" does not support automatic rereading." 739 splitCells_.setCapacity(nCells);
741 for (
label celli = 0; celli < nCells; celli++)
743 visibleCells_[celli] = celli;
753 Pout<<
"refinementHistory::refinementHistory :" 754 <<
" constructed history from IOobject or initial size :" 755 <<
" splitCells:" << splitCells_.size()
756 <<
" visibleCells:" << visibleCells_.
size()
757 <<
" active:" << active_
777 Pout<<
"refinementHistory::refinementHistory : constructed initial" 778 <<
" history." <<
endl;
802 "refinementHistory::refinementHistory(const IOobject&" 803 ", const labelListList&, const PtrList<refinementHistory>&)" 804 ) <<
"read option IOobject::MUST_READ, READ_IF_PRESENT or " 805 <<
"MUST_READ_IF_MODIFIED" 806 <<
" suggests that a read constructor would be more appropriate." 819 offsets[refI+1] = offsets[refI]+subSplits.
size();
823 splitCells_.setSize(offsets.last());
829 splitCell8& newSplit = splitCells_[offsets[refI]+i];
832 newSplit = subSplits[i];
837 newSplit.
parent_ += offsets[refI];
848 splits[i] += offsets[refI];
860 const labelList& cellMap = cellMaps[refI];
861 const labelList& subVis = refs[refI].visibleCells();
865 label& newVis = visibleCells_[cellMap[i]];
870 newVis += offsets[refI];
893 Pout<<
"refinementHistory::refinementHistory :" 894 <<
" constructed history from multiple refinementHistories :" 895 <<
" splitCells:" << splitCells_.size()
896 <<
" visibleCells:" << visibleCells_.
size()
916 Pout<<
"refinementHistory::refinementHistory :" 917 <<
" constructed history from Istream" 918 <<
" splitCells:" << splitCells_.size()
919 <<
" visibleCells:" << visibleCells_.
size()
943 oldToNewSplit.
setSize(splitCells_.size());
952 forAll(splitCells_, index)
954 if (splitCellProc[index] == procI && splitCellNum[index] == 8)
957 oldToNewSplit[index] = newSplitCells.
size();
958 newSplitCells.
append(splitCells_[index]);
963 forAll(visibleCells_, cellI)
965 label index = visibleCells_[cellI];
967 if (index >= 0 && decomposition[cellI] == procI)
969 label parent = splitCells_[index].parent_;
972 oldToNewSplit[index] = newSplitCells.
size();
986 forAll(newSplitCells, index)
1002 splits[i] = oldToNewSplit[splits[i]];
1011 forAll(decomposition, cellI)
1013 if (decomposition[cellI] == procI)
1022 forAll(visibleCells_, cellI)
1024 if (decomposition[cellI] == procI)
1026 label index = visibleCells_[cellI];
1029 index = oldToNewSplit[index];
1031 newVisibleCells[nSub++] = index;
1060 decomposition[cellMap[i]] = 1;
1065 labelList splitCellProc(splitCells_.size(), -1);
1068 labelList splitCellNum(splitCells_.size(), 0);
1070 forAll(visibleCells_, cellI)
1072 label index = visibleCells_[cellI];
1078 splitCells_[index].parent_,
1079 decomposition[cellI],
1119 Pout<<
"refinementHistory::resize from " << oldSize <<
" to " << size
1120 <<
" cells" <<
endl;
1126 for (
label i = oldSize; i < visibleCells_.
size(); i++)
1128 visibleCells_[i] = -1;
1143 forAll(visibleCells_, celli)
1145 if (visibleCells_[celli] != -1)
1147 label index = visibleCells_[celli];
1150 if (splitCells_[index].addedCellsPtr_.valid())
1156 label newCelli = reverseCellMap[celli];
1160 newVisibleCells[newCelli] = index;
1167 Pout<<
"refinementHistory::updateMesh : from " 1168 << visibleCells_.
size()
1169 <<
" to " << newVisibleCells.size()
1170 <<
" cells" <<
endl;
1173 visibleCells_.
transfer(newVisibleCells);
1189 forAll(newVisibleCells, celli)
1191 label oldCelli = cellMap[celli];
1193 label index = visibleCells_[oldCelli];
1196 if (index >= 0 && splitCells_[index].addedCellsPtr_.valid())
1202 newVisibleCells[celli] = index;
1207 Pout<<
"refinementHistory::updateMesh : from " 1208 << visibleCells_.
size()
1209 <<
" to " << newVisibleCells.size()
1210 <<
" cells" <<
endl;
1213 visibleCells_.
transfer(newVisibleCells);
1218 void Foam::refinementHistory::countProc
1221 const label newProcNo,
1226 if (splitCellProc[index] != newProcNo)
1230 splitCellProc[index] = newProcNo;
1231 splitCellNum[index] = 1;
1235 splitCellNum[index]++;
1238 if (splitCellNum[index] == 8)
1242 Pout<<
"Moving " << splitCellNum[index]
1243 <<
" cells originating from cell " << index
1245 <<
" to processor " << splitCellProc[index]
1249 label parent = splitCells_[index].parent_;
1253 countProc(parent, newProcNo, splitCellProc, splitCellNum);
1297 forAll(subCellMap, proci)
1299 const labelList& newToOld = subCellMap[proci];
1303 label oldCelli = newToOld[i];
1305 destination[oldCelli] = proci;
1310 labelList splitCellProc(splitCells_.size(), -1);
1312 labelList splitCellNum(splitCells_.size(), 0);
1314 forAll(visibleCells_, celli)
1316 label index = visibleCells_[celli];
1322 splitCells_[index].parent_,
1344 labelList oldToNew(splitCells_.size(), -1);
1352 forAll(splitCells_, index)
1354 if (splitCellProc[index] == proci && splitCellNum[index] == 8)
1357 oldToNew[index] = newSplitCells.
size();
1358 newSplitCells.
append(splitCells_[index]);
1363 forAll(visibleCells_, celli)
1365 label index = visibleCells_[celli];
1367 if (index >= 0 && destination[celli] == proci)
1369 label parent = splitCells_[index].parent_;
1372 oldToNew[index] = newSplitCells.
size();
1386 forAll(newSplitCells, index)
1402 splits[i] = oldToNew[splits[i]];
1409 const labelList& subMap = subCellMap[proci];
1416 label oldCelli = subMap[newCelli];
1418 label oldIndex = visibleCells_[oldCelli];
1422 newVisibleCells[newCelli] = oldToNew[oldIndex];
1433 toNbr << newSplitCells << newVisibleCells;
1441 splitCells_.clear();
1461 label offset = splitCells_.size();
1466 forAll(newSplitCells, index)
1482 splits[i] += offset;
1487 splitCells_.append(split);
1494 forAll(newVisibleCells, i)
1496 if (newVisibleCells[i] >= 0)
1498 visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
1502 splitCells_.shrink();
1514 Pout<<
"refinementHistory::compact() Entering with:" 1515 <<
" freeSplitCells_:" << freeSplitCells_.
size()
1516 <<
" splitCells_:" << splitCells_.size()
1517 <<
" visibleCells_:" << visibleCells_.
size()
1521 forAll(freeSplitCells_, i)
1523 label index = freeSplitCells_[i];
1525 if (splitCells_[index].parent_ != -2)
1528 <<
"Problem index:" << index
1534 forAll(visibleCells_, celli)
1538 visibleCells_[celli] >= 0
1539 && splitCells_[visibleCells_[celli]].parent_ == -2
1543 <<
"Problem : visible cell:" << celli
1552 labelList oldToNew(splitCells_.size(), -1);
1558 forAll(visibleCells_, celli)
1560 label index = visibleCells_[celli];
1568 splitCells_[index].parent_ != -1
1569 || splitCells_[index].addedCellsPtr_.valid()
1572 markSplit(index, oldToNew, newSplitCells);
1578 forAll(splitCells_, index)
1580 if (splitCells_[index].parent_ == -2)
1586 splitCells_[index].parent_ == -1
1587 && splitCells_[index].addedCellsPtr_.empty()
1596 markSplit(index, oldToNew, newSplitCells);
1604 forAll(newSplitCells, index)
1620 splits[i] = oldToNew[splits[i]];
1629 Pout<<
"refinementHistory::compact : compacted splitCells from " 1630 << splitCells_.size() <<
" to " << newSplitCells.
size() <<
endl;
1633 splitCells_.transfer(newSplitCells);
1639 Pout<<
"refinementHistory::compact() NOW:" 1640 <<
" freeSplitCells_:" << freeSplitCells_.
size()
1641 <<
" splitCells_:" << splitCells_.size()
1642 <<
" newSplitCells:" << newSplitCells.
size()
1643 <<
" visibleCells_:" << visibleCells_.
size()
1649 forAll(visibleCells_, celli)
1651 label index = visibleCells_[celli];
1656 visibleCells_[celli] = oldToNew[index];
1680 if (visibleCells_[celli] != -1)
1685 parentIndex = visibleCells_[celli];
1689 visibleCells_[celli] = -1;
1694 parentIndex = allocateSplitCell(-1, -1);
1701 label addedCelli = addedCells[i];
1705 visibleCells_[addedCelli] = allocateSplitCell(parentIndex, i);
1712 const label masterCelli,
1722 label celli = combinedCells[i];
1724 freeSplitCell(visibleCells_[celli]);
1725 visibleCells_[celli] = -1;
1766 is >> rh.splitCells_ >> rh.visibleCells_;
1779 return os <<
"// splitCells" <<
nl 1780 << rh.splitCells_ <<
nl 1781 <<
"// visibleCells" <<
nl 1782 << rh.visibleCells_;
#define WarningIn(functionName)
Report a warning using Foam::Warning.
autoPtr< IOobject > clone() const
Clone.
#define forAll(list, i)
Loop across all elements in list.
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 DynamicList< splitCell8 > & splitCells() const
Storage for splitCell8s.
const labelList & cellMap() const
Old cell map.
bool bad() const
Return true if stream is corrupted.
A 1D vector of objects of type <T> with a fixed size <Size>.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
bool active() const
Is there unrefinement history?
virtual const labelList & faceNeighbour() const
Return face neighbour.
const mapDistribute & cellMap() const
Cell distribute map.
const labelListList & subMap() const
From subsetted data back to original data.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
void size(const label)
Override size to be inconsistent with allocated storage.
static int myProcNo(const label communicator=0)
Number of this process (starting from masterNo() = 0)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool headerOk()
Read and check header info.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
autoPtr< FixedList< label, 8 > > addedCellsPtr_
Cells this cell was refined into.
splitCell8()
Construct null (parent = -1)
refinementHistory(const IOobject &)
Construct (read) given an IOobject. If global number of visible.
bool operator==(const splitCell8 &s) const
bool good() const
Return true if next operation might succeed.
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
regIOobject(const IOobject &, const bool isTime=false)
Construct from IOobject. Optional flag for if IOobject is the.
Input inter-processor communications stream.
const string & prefix() const
Return the prefix of the stream.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
void combineCells(const label masterCelli, const labelList &combinedCells)
Store combining 8 cells into master.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
void close()
Close Istream.
Istream & operator>>(Istream &, directionInfo &)
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update numbering for subsetting.
virtual const labelList & faceOwner() const
Return face owner.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Istream & readStream(const word &, const bool read=true)
Return Istream and check object type against that given.
List< label > labelList
A List of labels.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
errorManip< error > abort(error &err)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
bool operator!=(const splitCell8 &s) const
virtual bool read()
Read object. If global number of visible cells > 0 becomes active.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & shrink()
Shrink the allocated space to the number of elements used.
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation. Note:
const labelList & reverseCellMap() const
Reverse cell map.
defineTypeNameAndDebug(combustionModel, 0)
const DynamicList< label > & freeSplitCells() const
Cache of unused indices in splitCells.
void compact()
Compact splitCells_. Removes all freeSplitCells_ elements.
Output inter-processor communications stream.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
void storeSplit(const label celli, const labelList &addedCells)
Store splitting of cell into 8.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
void updateMesh(const mapPolyMesh &)
Update numbering for mesh changes.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined)
label size() const
Return the number of elements in the UPtrList.
void setSize(const label)
Reset size of List.
static bool & parRun()
Is this a parallel run?
static label nProcs(const label communicator=0)
Number of processes in parallel run.
void apply(const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &decomposition) const
Apply any additional post-decomposition constraints.
#define WarningInFunction
Report a warning using Foam::Warning.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
void operator=(const splitCell8 &s)
Copy operator since autoPtr otherwise 'steals' storage.
prefixOSstream Pout(cout, "Pout")
label parentIndex(const label celli) const
Get parent of cell.
Ostream & operator<<(Ostream &, const ensightPart &)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
void clearStorage()
Clear the list and delete storage.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Mesh consisting of general polyhedral cells.
All refinement history. Used in unrefinement.
void add(boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my decomposition constraints.
const objectRegistry & db() const
Return the local objectRegistry.
void writeDebug() const
Debug write.
readOption readOpt() const
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void resize(const label nCells)
Extend/shrink storage. additional visibleCells_ elements get.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.