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
94 writeEntry(splitCells, splitCells[index]);
99 Pout<<
"Unrefined cell:" << celli <<
" index:" << index <<
endl;
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);
339 void Foam::refinementHistory::markSplit
346 if (oldToNew[index] == -1)
352 oldToNew[index] = newSplitCells.
size();
353 newSplitCells.
append(split);
355 if (split.parent_ >= 0)
357 markSplit(split.parent_, oldToNew, newSplitCells);
359 if (split.addedCellsPtr_.valid())
367 markSplit(splits[i], oldToNew, newSplitCells);
376 void Foam::refinementHistory::mark
383 splitToVal[index] = val;
387 if (split.addedCellsPtr_.valid())
395 mark(val, splits[i], splitToVal);
402 Foam::label Foam::refinementHistory::markCommonCells
409 labelList splitToCluster(splitCells_.size(), -1);
412 forAll(visibleCells_, cellI)
414 label index = visibleCells_[cellI];
419 while (splitCells_[index].
parent_ != -1)
421 index = splitCells_[index].parent_;
425 if (splitToCluster[index] == -1)
427 mark(clusterI, index, splitToCluster);
434 cellToCluster.
setSize(visibleCells_.size(), -1);
436 forAll(visibleCells_, cellI)
438 label index = visibleCells_[cellI];
442 cellToCluster[cellI] = splitToCluster[index];
464 markCommonCells(cellToCluster);
469 label nUnblocked = 0;
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;
509 label nClusters = markCommonCells(cellToCluster);
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
566 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 567 <<
" does not support automatic rereading." 589 Pout<<
"refinementHistory::refinementHistory :" 590 <<
" constructed history from IOobject :" 591 <<
" splitCells:" << splitCells_.size()
592 <<
" visibleCells:" << visibleCells_.
size()
593 <<
" active:" << active_
609 splitCells_(splitCells),
611 visibleCells_(visibleCells)
617 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 618 <<
" does not support automatic rereading." 638 Pout<<
"refinementHistory::refinementHistory :" 639 <<
" constructed history from IOobject or components :" 640 <<
" splitCells:" << splitCells_.size()
641 <<
" visibleCells:" << visibleCells_.
size()
642 <<
" active:" << active_
662 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 663 <<
" does not support automatic rereading." 680 splitCells_.setCapacity(nCells);
682 for (
label cellI = 0; cellI < nCells; cellI++)
684 visibleCells_[cellI] = cellI;
697 Pout<<
"refinementHistory::refinementHistory :" 698 <<
" constructed history from IOobject or initial size :" 699 <<
" splitCells:" << splitCells_.size()
700 <<
" visibleCells:" << visibleCells_.
size()
701 <<
" active:" << active_
723 <<
"Specified IOobject::MUST_READ_IF_MODIFIED but class" 724 <<
" does not support automatic rereading." 741 splitCells_.setCapacity(nCells);
743 for (
label celli = 0; celli < nCells; celli++)
745 visibleCells_[celli] = celli;
755 Pout<<
"refinementHistory::refinementHistory :" 756 <<
" constructed history from IOobject or initial size :" 757 <<
" splitCells:" << splitCells_.size()
758 <<
" visibleCells:" << visibleCells_.
size()
759 <<
" active:" << active_
780 Pout<<
"refinementHistory::refinementHistory : constructed initial" 781 <<
" history." <<
endl;
806 "refinementHistory::refinementHistory(const IOobject&" 807 ", const labelListList&, const PtrList<refinementHistory>&)" 808 ) <<
"read option IOobject::MUST_READ, READ_IF_PRESENT or " 809 <<
"MUST_READ_IF_MODIFIED" 810 <<
" suggests that a read constructor would be more appropriate." 823 offsets[refI+1] = offsets[refI]+subSplits.
size();
827 splitCells_.setSize(offsets.last());
833 splitCell8& newSplit = splitCells_[offsets[refI]+i];
836 newSplit = subSplits[i];
841 newSplit.
parent_ += offsets[refI];
852 splits[i] += offsets[refI];
864 const labelList& cellMap = cellMaps[refI];
865 const labelList& subVis = refs[refI].visibleCells();
869 label& newVis = visibleCells_[cellMap[i]];
874 newVis += offsets[refI];
897 Pout<<
"refinementHistory::refinementHistory :" 898 <<
" constructed history from multiple refinementHistories :" 899 <<
" splitCells:" << splitCells_.size()
900 <<
" visibleCells:" << visibleCells_.
size()
921 Pout<<
"refinementHistory::refinementHistory :" 922 <<
" constructed history from Istream" 923 <<
" splitCells:" << splitCells_.size()
924 <<
" visibleCells:" << visibleCells_.
size()
948 oldToNewSplit.
setSize(splitCells_.size());
957 forAll(splitCells_, index)
959 if (splitCellProc[index] == procI && splitCellNum[index] == 8)
962 oldToNewSplit[index] = newSplitCells.
size();
963 newSplitCells.
append(splitCells_[index]);
968 forAll(visibleCells_, cellI)
970 label index = visibleCells_[cellI];
972 if (index >= 0 && decomposition[cellI] == procI)
974 label parent = splitCells_[index].parent_;
977 oldToNewSplit[index] = newSplitCells.
size();
991 forAll(newSplitCells, index)
1007 splits[i] = oldToNewSplit[splits[i]];
1016 forAll(decomposition, cellI)
1018 if (decomposition[cellI] == procI)
1027 forAll(visibleCells_, cellI)
1029 if (decomposition[cellI] == procI)
1031 label index = visibleCells_[cellI];
1034 index = oldToNewSplit[index];
1036 newVisibleCells[nSub++] = index;
1065 decomposition[cellMap[i]] = 1;
1070 labelList splitCellProc(splitCells_.size(), -1);
1073 labelList splitCellNum(splitCells_.size(), 0);
1075 forAll(visibleCells_, cellI)
1077 label index = visibleCells_[cellI];
1083 splitCells_[index].parent_,
1084 decomposition[cellI],
1124 Pout<<
"refinementHistory::resize from " << oldSize <<
" to " << size
1125 <<
" cells" <<
endl;
1131 for (
label i = oldSize; i < visibleCells_.
size(); i++)
1133 visibleCells_[i] = -1;
1148 forAll(visibleCells_, celli)
1150 if (visibleCells_[celli] != -1)
1152 label index = visibleCells_[celli];
1155 if (splitCells_[index].addedCellsPtr_.valid())
1161 label newCelli = reverseCellMap[celli];
1165 newVisibleCells[newCelli] = index;
1172 Pout<<
"refinementHistory::updateMesh : from " 1173 << visibleCells_.
size()
1174 <<
" to " << newVisibleCells.size()
1175 <<
" cells" <<
endl;
1178 visibleCells_.
transfer(newVisibleCells);
1195 forAll(newVisibleCells, celli)
1197 label oldCelli = cellMap[celli];
1199 label index = visibleCells_[oldCelli];
1202 if (index >= 0 && splitCells_[index].addedCellsPtr_.valid())
1208 newVisibleCells[celli] = index;
1213 Pout<<
"refinementHistory::updateMesh : from " 1214 << visibleCells_.
size()
1215 <<
" to " << newVisibleCells.size()
1216 <<
" cells" <<
endl;
1219 visibleCells_.
transfer(newVisibleCells);
1224 void Foam::refinementHistory::countProc
1227 const label newProcNo,
1232 if (splitCellProc[index] != newProcNo)
1236 splitCellProc[index] = newProcNo;
1237 splitCellNum[index] = 1;
1241 splitCellNum[index]++;
1244 if (splitCellNum[index] == 8)
1248 Pout<<
"Moving " << splitCellNum[index]
1249 <<
" cells originating from cell " << index
1251 <<
" to processor " << splitCellProc[index]
1255 label parent = splitCells_[index].parent_;
1259 countProc(parent, newProcNo, splitCellProc, splitCellNum);
1303 forAll(subCellMap, proci)
1305 const labelList& newToOld = subCellMap[proci];
1309 label oldCelli = newToOld[i];
1311 destination[oldCelli] = proci;
1316 labelList splitCellProc(splitCells_.size(), -1);
1318 labelList splitCellNum(splitCells_.size(), 0);
1320 forAll(visibleCells_, celli)
1322 label index = visibleCells_[celli];
1328 splitCells_[index].parent_,
1350 labelList oldToNew(splitCells_.size(), -1);
1358 forAll(splitCells_, index)
1360 if (splitCellProc[index] == proci && splitCellNum[index] == 8)
1363 oldToNew[index] = newSplitCells.
size();
1364 newSplitCells.
append(splitCells_[index]);
1369 forAll(visibleCells_, celli)
1371 label index = visibleCells_[celli];
1373 if (index >= 0 && destination[celli] == proci)
1375 label parent = splitCells_[index].parent_;
1378 oldToNew[index] = newSplitCells.
size();
1392 forAll(newSplitCells, index)
1408 splits[i] = oldToNew[splits[i]];
1415 const labelList& subMap = subCellMap[proci];
1422 label oldCelli = subMap[newCelli];
1424 label oldIndex = visibleCells_[oldCelli];
1428 newVisibleCells[newCelli] = oldToNew[oldIndex];
1439 toNbr << newSplitCells << newVisibleCells;
1447 splitCells_.clear();
1467 label offset = splitCells_.size();
1472 forAll(newSplitCells, index)
1488 splits[i] += offset;
1493 splitCells_.append(split);
1500 forAll(newVisibleCells, i)
1502 if (newVisibleCells[i] >= 0)
1504 visibleCells_[constructMap[i]] = newVisibleCells[i] + offset;
1508 splitCells_.shrink();
1520 Pout<<
"refinementHistory::compact() Entering with:" 1521 <<
" freeSplitCells_:" << freeSplitCells_.
size()
1522 <<
" splitCells_:" << splitCells_.size()
1523 <<
" visibleCells_:" << visibleCells_.
size()
1527 forAll(freeSplitCells_, i)
1529 label index = freeSplitCells_[i];
1531 if (splitCells_[index].parent_ != -2)
1534 <<
"Problem index:" << index
1540 forAll(visibleCells_, celli)
1544 visibleCells_[celli] >= 0
1545 && splitCells_[visibleCells_[celli]].parent_ == -2
1549 <<
"Problem : visible cell:" << celli
1558 labelList oldToNew(splitCells_.size(), -1);
1564 forAll(visibleCells_, celli)
1566 label index = visibleCells_[celli];
1574 splitCells_[index].parent_ != -1
1575 || splitCells_[index].addedCellsPtr_.valid()
1578 markSplit(index, oldToNew, newSplitCells);
1584 forAll(splitCells_, index)
1586 if (splitCells_[index].parent_ == -2)
1592 splitCells_[index].parent_ == -1
1593 && splitCells_[index].addedCellsPtr_.empty()
1602 markSplit(index, oldToNew, newSplitCells);
1610 forAll(newSplitCells, index)
1626 splits[i] = oldToNew[splits[i]];
1635 Pout<<
"refinementHistory::compact : compacted splitCells from " 1636 << splitCells_.size() <<
" to " << newSplitCells.
size() <<
endl;
1639 splitCells_.transfer(newSplitCells);
1645 Pout<<
"refinementHistory::compact() NOW:" 1646 <<
" freeSplitCells_:" << freeSplitCells_.
size()
1647 <<
" splitCells_:" << splitCells_.size()
1648 <<
" newSplitCells:" << newSplitCells.
size()
1649 <<
" visibleCells_:" << visibleCells_.
size()
1655 forAll(visibleCells_, celli)
1657 label index = visibleCells_[celli];
1662 visibleCells_[celli] = oldToNew[index];
1686 if (visibleCells_[celli] != -1)
1691 parentIndex = visibleCells_[celli];
1695 visibleCells_[celli] = -1;
1700 parentIndex = allocateSplitCell(-1, -1);
1707 label addedCelli = addedCells[i];
1711 visibleCells_[addedCelli] = allocateSplitCell(parentIndex, i);
1718 const label masterCelli,
1728 label celli = combinedCells[i];
1730 freeSplitCell(visibleCells_[celli]);
1731 visibleCells_[celli] = -1;
1772 is >> rh.splitCells_ >> rh.visibleCells_;
1785 return os <<
"// splitCells" <<
nl 1786 << rh.splitCells_ <<
nl 1787 <<
"// visibleCells" <<
nl 1788 << rh.visibleCells_;
const labelList & visibleCells() const
Per cell in the current mesh (i.e. visible) either -1 (unrefined)
#define WarningIn(functionName)
Report a warning using Foam::Warning.
#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 objectRegistry & db() const
Return the local objectRegistry.
const labelListList & constructMap() const
From subsetted data to new reconstructed data.
A 1D vector of objects of type <T> with a fixed size <Size>.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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)
bool good() const
Return true if next operation might succeed.
Ostream & endl(Ostream &os)
Add newline and flush stream.
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.
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.
void writeDebug() const
Debug write.
const DynamicList< splitCell8 > & splitCells() const
Storage for splitCell8s.
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))
Istream & readStream(const word &)
Return Istream and check object type against that given.
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...
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
void close()
Close Istream.
bool active() const
Is there unrefinement history?
void add(boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my decomposition constraints.
label parentIndex(const label celli) const
Get parent of cell.
Istream & operator>>(Istream &, directionInfo &)
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.
void subset(const labelList &pointMap, const labelList &faceMap, const labelList &cellMap)
Update numbering for subsetting.
Foam::autoPtr< IOobject > clone() const
Clone.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
const DynamicList< label > & freeSplitCells() const
Cache of unused indices in splitCells.
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...
errorManip< error > abort(error &err)
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set).
An Ostream is an abstract base class for all output systems (streams, files, token lists...
prefixOSstream Pout(cout,"Pout")
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:
defineTypeNameAndDebug(combustionModel, 0)
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 occurence of given element and return index,.
void storeSplit(const label celli, const labelList &addedCells)
Store splitting of cell into 8.
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.
bool operator!=(const splitCell8 &s) const
const mapDistribute & cellMap() const
Cell distribute map.
bool bad() const
Return true if stream is corrupted.
void distribute(const mapDistributePolyMesh &)
Update local numbering for mesh redistribution.
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.
virtual const labelList & faceNeighbour() const
Return face neighbour.
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
#define WarningInFunction
Report a warning using Foam::Warning.
const labelList & cellMap() const
Old cell map.
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.
Ostream & operator<<(Ostream &, const ensightPart &)
readOption readOpt() const
const labelList & reverseCellMap() const
Reverse cell map.
void clearStorage()
Clear the list and delete storage.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
bool headerOk()
Read and check header info.
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.
bool operator==(const splitCell8 &s) const
All refinement history. Used in unrefinement.
virtual const labelList & faceOwner() const
Return face owner.
const string & prefix() const
Return the prefix of the stream.
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.
label size() const
Return the number of elements in the UPtrList.