Go to the documentation of this file.
64 return decompDict.
get<label>(
"numberOfSubdomains");
74 const label nDomainsGlobal = nDomains(decompDict);
79 if (regionDict.
readIfPresent(
"numberOfSubdomains", nDomainsRegion))
81 if (nDomainsRegion >= 1 && nDomainsRegion <= nDomainsGlobal)
83 return nDomainsRegion;
87 <<
"ignoring out of range numberOfSubdomains "
88 << nDomainsRegion <<
" for region " <<
regionName
93 return nDomainsGlobal;
103 auto finder = decompDict.
csearch(
"regions");
111 return finder.dict();
121 bool Foam::decompositionMethod::constraintCompat(
const word& modelType)
const
123 bool usable = decompDict_.found(modelType);
129 for (
const auto& item : constraints_)
131 if (modelType == item.type())
141 <<
nl <<
" Using '" << modelType
142 <<
"' constraint specification." <<
nl;
147 <<
nl <<
" Ignoring '" << modelType
148 <<
"' constraint specification - was already specified." <<
nl;
158 void Foam::decompositionMethod::readConstraints()
160 constraints_.clear();
162 const dictionary* dictptr = decompDict_.findDict(
"constraints");
166 for (
const entry& dEntry : *dictptr)
168 if (!dEntry.isDict())
174 const dictionary&
dict = dEntry.dict();
184 if (constraintCompat(
"preserveBaffles"))
188 new decompositionConstraints::preserveBaffles()
192 if (constraintCompat(
"preservePatches"))
196 new decompositionConstraints::preservePatches
198 decompDict_.get<wordRes>(
"preservePatches")
203 if (constraintCompat(
"preserveFaceZones"))
207 new decompositionConstraints::preserveFaceZones
209 decompDict_.get<wordRes>(
"preserveFaceZones")
214 if (constraintCompat(
"singleProcessorFaceSets"))
218 new decompositionConstraints::singleProcessorFaceSets
220 decompDict_.lookup(
"singleProcessorFaceSets")
231 const word& coeffsName,
242 !(select & selectionType::EXACT)
251 if (select & selectionType::MANDATORY)
254 <<
"'" << coeffsName <<
"' dictionary not found in dictionary "
259 if (select & selectionType::NULL_DICT)
270 const word& coeffsName,
278 !decompRegionDict_.empty()
281 (fnd = decompRegionDict_.csearch(coeffsName)).isDict()
284 !(select & selectionType::EXACT)
285 && (fnd = decompRegionDict_.csearch(
defaultName)).isDict()
295 (fnd = decompDict_.csearch(coeffsName)).isDict()
298 !(select & selectionType::EXACT)
299 && (fnd = decompDict_.csearch(
defaultName)).isDict()
307 if (select & selectionType::MANDATORY)
310 <<
"'" << coeffsName <<
"' dictionary not found in dictionary "
311 << decompDict_.name() <<
endl
315 if (select & selectionType::NULL_DICT)
326 Foam::decompositionMethod::decompositionMethod
331 decompDict_(decompDict),
333 nDomains_(nDomains(decompDict))
339 Foam::decompositionMethod::decompositionMethod
345 decompDict_(decompDict),
363 const word methodType(decompDict.
get<
word>(
"method"));
365 auto cstrIter = dictionaryConstructorTablePtr_->cfind(methodType);
367 if (!cstrIter.found())
372 "decompositionMethod",
374 *dictionaryConstructorTablePtr_
380 Info<<
"Selecting decompositionMethod " << methodType
381 <<
" [" << (nDomains(decompDict)) <<
"]" <<
endl;
396 if (regionDict.empty())
405 auto cstrIter = dictionaryRegionConstructorTablePtr_->cfind(methodType);
407 if (!cstrIter.found())
411 <<
"Unknown region decompositionMethod "
412 << methodType <<
nl <<
nl
413 <<
"Valid decompositionMethods : " <<
endl
414 << dictionaryRegionConstructorTablePtr_->sortedToc() <<
nl
415 <<
"Reverting to non-region version" <<
nl
423 Info<<
"Selecting decompositionMethod " << methodType
424 <<
" [" << (nDomains(decompDict,
regionName)) <<
"] (region "
474 labelList fineDistribution(fineToCoarse.size());
476 forAll(fineDistribution, i)
478 fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
481 return fineDistribution;
492 scalarField weights(coarsePoints.size(), scalar(1));
512 return decompose(globalCellCells, cc, weights);
520 const label nLocalCoarse,
549 if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp)))
551 label facei = pp.start();
556 globalNeighbour[bFacei] = globalAgglom.
toGlobal
558 agglom[faceOwner[facei]]
579 const label own = agglom[faceOwner[facei]];
580 const label nei = agglom[faceNeighbour[facei]];
582 nFacesPerCell[own]++;
583 nFacesPerCell[nei]++;
588 if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp)))
590 label facei = pp.start();
595 const label own = agglom[faceOwner[facei]];
596 const label globalNei = globalNeighbour[bFacei];
600 !globalAgglom.
isLocal(globalNei)
601 || globalAgglom.
toLocal(globalNei) != own
604 nFacesPerCell[own]++;
617 cellCells.
setSize(nFacesPerCell);
627 const label own = agglom[faceOwner[facei]];
628 const label nei = agglom[faceNeighbour[facei]];
630 m[offsets[own] + nFacesPerCell[own]++] = globalAgglom.
toGlobal(nei);
631 m[offsets[nei] + nFacesPerCell[nei]++] = globalAgglom.
toGlobal(own);
637 if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp)))
639 label facei = pp.start();
644 const label own = agglom[faceOwner[facei]];
645 const label globalNei = globalNeighbour[bFacei];
649 !globalAgglom.
isLocal(globalNei)
650 || globalAgglom.
toLocal(globalNei) != own
653 m[offsets[own] + nFacesPerCell[own]++] = globalNei;
667 if (cellCells.
size() == 0)
675 label startIndex = cellCells.
offsets()[0];
682 const label endIndex = cellCells.
offsets()[celli+1];
684 for (label i = startIndex; i < endIndex; ++i)
686 if (nbrCells.
insert(cellCells.
m()[i]))
688 cellCells.
m()[newIndex++] = cellCells.
m()[i];
691 startIndex = endIndex;
692 cellCells.
offsets()[celli+1] = newIndex;
718 const label nLocalCoarse,
748 if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp)))
750 label facei = pp.start();
755 globalNeighbour[bFacei] = globalAgglom.
toGlobal
757 agglom[faceOwner[facei]]
778 const label own = agglom[faceOwner[facei]];
779 const label nei = agglom[faceNeighbour[facei]];
781 nFacesPerCell[own]++;
782 nFacesPerCell[nei]++;
787 if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp)))
789 label facei = pp.start();
794 const label own = agglom[faceOwner[facei]];
795 const label globalNei = globalNeighbour[bFacei];
799 !globalAgglom.
isLocal(globalNei)
800 || globalAgglom.
toLocal(globalNei) != own
803 nFacesPerCell[own]++;
816 cellCells.
setSize(nFacesPerCell);
817 cellCellWeights.
setSize(nFacesPerCell);
828 const label own = agglom[faceOwner[facei]];
829 const label nei = agglom[faceNeighbour[facei]];
831 const label ownIndex = offsets[own] + nFacesPerCell[own]++;
832 const label neiIndex = offsets[nei] + nFacesPerCell[nei]++;
834 m[ownIndex] = globalAgglom.
toGlobal(nei);
836 m[neiIndex] = globalAgglom.
toGlobal(own);
843 if (pp.coupled() && (parallel || !isA<processorPolyPatch>(pp)))
845 label facei = pp.start();
850 const label own = agglom[faceOwner[facei]];
851 const label globalNei = globalNeighbour[bFacei];
855 !globalAgglom.
isLocal(globalNei)
856 || globalAgglom.
toLocal(globalNei) != own
859 const label ownIndex = offsets[own] + nFacesPerCell[own]++;
860 m[ownIndex] = globalNei;
875 if (cellCells.
size() == 0)
883 label startIndex = cellCells.
offsets()[0];
890 const label endIndex = cellCells.
offsets()[celli+1];
892 for (label i = startIndex; i < endIndex; ++i)
894 if (nbrCells.
insert(cellCells.
m()[i]))
896 cellCells.
m()[newIndex] = cellCells.
m()[i];
897 cellCellWeights.
m()[newIndex] = cellCellWeights.
m()[i];
901 startIndex = endIndex;
902 cellCells.
offsets()[celli+1] = newIndex;
903 cellCellWeights.
offsets()[celli+1] = newIndex;
907 cellCellWeights.
m().
setSize(newIndex);
936 if (hasWeights && cellWeights.size() !=
mesh.
nCells())
939 <<
"Number of weights " << cellWeights.size()
940 <<
" differs from number of cells " <<
mesh.
nCells()
945 const bool hasUnblocked =
948 (!blockedFace.empty() && !
BitOps::all(blockedFace)),
956 explicitConnections.size(),
963 for (
const labelList& procset : specifiedProcessorFaces)
965 nProcSets += procset.size();
972 if (!hasUnblocked && !nConnections && !nProcSets)
990 regionSplit localRegion(
mesh, blockedFace, explicitConnections,
false);
995 const label nUnblocked =
1006 Info<<
"Constrained decomposition:" <<
nl
1007 <<
" faces with same owner and neighbour processor : "
1009 <<
" baffle faces with same owner processor : "
1010 << nConnections <<
nl
1011 <<
" faces all on same processor : "
1032 forAll(localRegion, celli)
1034 const label regioni = localRegion[celli];
1036 regionWeights[regioni] += cellWeights[celli];
1046 forAll(localRegion, celli)
1048 const label regioni = localRegion[celli];
1050 regionWeights[regioni] += 1.0;
1073 for (
const labelPair& baffle : explicitConnections)
1075 const label f0 = baffle.first();
1076 const label f1 = baffle.second();
1078 if (!blockedFace[f0] && !blockedFace[f1])
1092 else if (blockedFace[f0] != blockedFace[f1])
1095 <<
"On explicit connection between faces " << f0
1097 <<
" the two blockedFace status are not equal : "
1098 << blockedFace[f0] <<
" and " << blockedFace[f1]
1121 label nUnblocked = 0;
1122 forAll(blockedFace, facei)
1124 if (blockedFace[facei])
1126 faceData[facei] =
minData(-123);
1139 forAll(blockedFace, facei)
1141 if (!blockedFace[facei])
1144 seedFaces[nUnblocked] = facei;
1145 seedData[nUnblocked] =
minData(finalDecomp[own]);
1163 forAll(finalDecomp, celli)
1165 if (cellData[celli].valid(deltaCalc.data()))
1167 finalDecomp[celli] = cellData[celli].data();
1186 forAll(specifiedProcessorFaces, seti)
1190 label proci = specifiedProcessor[seti];
1205 for (
const label facei :
set)
1208 for (
const label pointi :
f)
1211 for (
const label pFacei :
pFaces)
1236 const label facei = pp.start()+i;
1240 if (!blockedFace[facei])
1242 const label ownProc = finalDecomp[own];
1243 const label nbrProc = nbrDecomp[bFacei];
1245 if (ownProc != nbrProc)
1248 <<
"patch:" << pp.name()
1249 <<
" face:" << facei
1251 <<
" ownProc:" << ownProc
1252 <<
" nbrProc:" << nbrProc
1277 specifiedProcessorFaces.
clear();
1278 explicitConnections.
clear();
1282 decompConstraint.add
1286 specifiedProcessorFaces,
1306 decompConstraint.apply
1310 specifiedProcessorFaces,
1312 explicitConnections,
1335 specifiedProcessorFaces,
1349 specifiedProcessorFaces,
1361 specifiedProcessorFaces,
1363 explicitConnections,
const List< label > & offsets() const
Return the offset table (= size()+1)
int debug
Static debugging option.
const List< T > & m() const
Return the packed matrix of data.
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool global, CompactListList< label > &cellCells)
Helper: determine (local or global) cellCells from mesh.
Abstract class for handling decomposition constraints.
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
For use with FaceCellWave. Transports minimum passive data.
A class for handling words, derived from Foam::string.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
static const dictionary & optionalRegionDict(const dictionary &decompDict, const word ®ionName)
Return an optional region dictionary from "regions" sub-dictionary.
static constexpr const zero Zero
Global zero (0)
label nInternalFaces() const
Number of internal faces.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
label nFaces() const
Number of mesh faces.
const labelListList & pointFaces() const
static bool & parRun()
Test if this a parallel run, or allow modify access.
label nTotalCells() const
Return total number of cells in decomposed mesh.
bool isLocal(const label i) const
Is on local processor.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Helper: extract constraints:
Mesh consisting of general polyhedral cells.
bool all(const UList< bool > &bools)
True if all entries are 'true' or if the set is empty.
static autoPtr< decompositionConstraint > New(const dictionary &constraintDict)
Return a reference to the selected decompositionConstraint.
#define forAll(list, i)
Loop across all elements in list.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
Generic const/non-const dictionary entry searcher.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
const fileName & name() const
The dictionary name.
label nCells() const
Number of mesh cells.
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=cellModel::ref(cellModel::HEX);labelList hexLabels(8);label activeCells=0;labelList pointMap(nPoints);forAll(pointMap, i){ pointMap[i]=i;}for(label i=0;i< nPoints;i++){ if(f[i] > 0.0) { hexLabels[0]=i;hexLabels[1]=i1tab[i];hexLabels[2]=i3tab[i1tab[i]];hexLabels[3]=i3tab[i];hexLabels[4]=i8tab[i];hexLabels[5]=i1tab[i8tab[i]];hexLabels[6]=i3tab[i1tab[i8tab[i]]];hexLabels[7]=i3tab[i8tab[i]];cellShapes[activeCells]=cellShape(hex, hexLabels);edgeList edges=cellShapes[activeCells].edges();forAll(edges, ei) { if(edges[ei].mag(points)< SMALL) { label start=pointMap[edges[ei].start()];while(start !=pointMap[start]) { start=pointMap[start];} label end=pointMap[edges[ei].end()];while(end !=pointMap[end]) { end=pointMap[end];} label minLabel=min(start, end);pointMap[start]=pointMap[end]=minLabel;} } cellZoning[activeCells]=idreg[i];activeCells++;}}cellShapes.setSize(activeCells);cellZoning.setSize(activeCells);forAll(cellShapes, celli){ cellShape &cs=cellShapes[celli];forAll(cs, i) { cs[i]=pointMap[cs[i]];} cs.collapse();}label bcIDs[11]={-1, 0, 2, 4, -1, 5, -1, 6, 7, 8, 9};const label nBCs=12;const word *kivaPatchTypes[nBCs]={ &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &wallPolyPatch::typeName, &symmetryPolyPatch::typeName, &wedgePolyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, &oldCyclicPolyPatch::typeName};enum patchTypeNames{ PISTON, VALVE, LINER, CYLINDERHEAD, AXIS, WEDGE, INFLOW, OUTFLOW, PRESIN, PRESOUT, SYMMETRYPLANE, CYCLIC};const char *kivaPatchNames[nBCs]={ "piston", "valve", "liner", "cylinderHead", "axis", "wedge", "inflow", "outflow", "presin", "presout", "symmetryPlane", "cyclic"};List< SLList< face > > pFaces[nBCs]
void setSize(const label mRows)
Reset size of CompactListList.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
virtual const labelList & faceOwner() const
Return face owner.
const_searcher csearch(const word &keyword, enum keyType::option=keyType::REGEX) const
Search dictionary for given keyword.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
static const word defaultName("coeffs")
dict_reference dict() const
Reference the found entry as a dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
label nBoundaryFaces() const
Number of boundary faces (== nFaces - nInternalFaces)
label nDomains() const
Number of domains.
void clear()
Clear the PtrList. Delete allocated entries and set size to zero.
errorManip< error > abort(error &err)
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Wave propagation of information through grid. Every iteration information goes through one layer of c...
label toLocal(const label i) const
From global to local on current processor.
const vectorField & cellCentres() const
static int & msgType()
Message tag of standard messages.
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static void warnAboutAge(const char *what, const int version)
Emit warning on stderr about something being old.
static const Vector< Cmpt > max
void clear()
Clear all entries from table.
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
static label worldComm
Default communicator (all processors)
virtual labelList decompose(const pointField &points, const scalarField &pointWeights) const
Return for every coordinate the wanted processor number.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
const vectorField & faceCentres() const
void clear()
Clear the list, i.e. set size to zero.
bool insert(const Key &key)
Insert a new entry, not overwriting existing entries.
const polyBoundaryMesh & patches
label size() const noexcept
The primary size (the number of rows)
A face is a list of labels corresponding to mesh vertices.
const globalMeshData & globalData() const
Return parallel info.
void applyConstraints(const polyMesh &mesh, const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &finalDecomp) const
Helper: apply constraints to a decomposition.
void setSize(const label newSize)
Alias for resize(const label)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
defineTypeNameAndDebug(combustionModel, 0)
#define WarningInFunction
Report a warning using Foam::Warning.
label nLocalRegions() const
Return local number of regions.
static const dictionary & findCoeffsDict(const dictionary &dict, const word &coeffsName, int select=selectionType::DEFAULT)
virtual const labelList & faceNeighbour() const
Return face neighbour.
static autoPtr< decompositionMethod > New(const dictionary &decompDict)
Return a reference to the selected decomposition method.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
label toGlobal(const label i) const
From local to global index.
const vectorField & faceAreas() const