60 const label localnWeights =
65 if (localnWeights && localnWeights !=
nWeights)
68 <<
"Number of weights on this processor " << localnWeights
69 <<
" does not equal the maximum number of weights " <<
nWeights
83 const label nWeights = this->nWeights(
points, pointWeights);
88 <<
"decompositionMethod " <<
type()
89 <<
" does not support multiple constraints"
104 decompositionDict_(decompositionDict),
107 decompositionDict.lookup<
label>(
"numberOfSubdomains")
130 constraintTypes_.
last()
146 const word methodType
150 {
"decomposer",
"method"}
154 Info<<
"Selecting decomposer " << methodType <<
endl;
160 decomposerConstructorTablePtr_
163 decomposerConstructorTable::iterator cstrIter =
164 decomposerConstructorTablePtr_->find(methodType);
166 if (cstrIter == decomposerConstructorTablePtr_->end())
169 <<
"Unknown decomposer "
170 << methodType <<
nl <<
nl
171 <<
"Valid decomposers are : " <<
endl
172 << decomposerConstructorTablePtr_->sortedToc()
186 const word methodType
190 {
"distributor",
"method"}
194 Info<<
"Selecting distributor " << methodType <<
endl;
200 distributorConstructorTablePtr_
203 distributorConstructorTable::iterator cstrIter =
204 distributorConstructorTablePtr_->find(methodType);
206 if (cstrIter == distributorConstructorTablePtr_->end())
209 <<
"Unknown distributor "
210 << methodType <<
nl <<
nl
211 <<
"Valid distributors are : " <<
endl
212 << distributorConstructorTablePtr_->sortedToc()
245 return decompose(mesh,
points, weights);
272 coarseCellCells.
list(),
281 forAll(fineDistribution, i)
283 fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
286 return fineDistribution;
317 return decompose(globalCellCells, cellCentres, cellWeights);
325 const bool distributed
333 const scalar sumWeights
339 const scalar scale =
labelMax/(2*sumWeights);
345 intWeights[i] = ceil(scale*weights[i]);
387 sumIntWeights[i % nWeights] += intWeights[i];
396 boolList nonZeroWeights(nWeights,
false);
397 label nNonZeroWeights = 0;
400 if (sumIntWeights[i] != 0)
402 nonZeroWeights[i] =
true;
408 if (nNonZeroWeights != nWeights)
413 if (nonZeroWeights[i % nWeights])
415 intWeights[j++] = intWeights[i];
420 intWeights.
setSize(nNonZeroWeights*(intWeights.
size()/nWeights));
423 nWeights = nNonZeroWeights;
435 const label nLocalCoarse,
466 if (pp.
coupled() && (parallel || !isA<processorPolyPatch>(pp)))
473 globalNeighbour[bFacei] = globalAgglom.
toGlobal
475 agglom[faceOwner[facei]]
492 labelList nFacesPerCell(nLocalCoarse, 0);
496 label own = agglom[faceOwner[facei]];
497 label nei = agglom[faceNeighbour[facei]];
499 nFacesPerCell[own]++;
500 nFacesPerCell[nei]++;
507 if (pp.
coupled() && (parallel || !isA<processorPolyPatch>(pp)))
514 label own = agglom[faceOwner[facei]];
516 label globalNei = globalNeighbour[bFacei];
519 !globalAgglom.
isLocal(globalNei)
520 || globalAgglom.
toLocal(globalNei) != own
523 nFacesPerCell[own]++;
536 cellCells.
setSize(nFacesPerCell);
546 label own = agglom[faceOwner[facei]];
547 label nei = agglom[faceNeighbour[facei]];
549 m[offsets[own] + nFacesPerCell[own]++] = globalAgglom.
toGlobal(nei);
550 m[offsets[nei] + nFacesPerCell[nei]++] = globalAgglom.
toGlobal(own);
558 if (pp.
coupled() && (parallel || !isA<processorPolyPatch>(pp)))
565 label own = agglom[faceOwner[facei]];
567 label globalNei = globalNeighbour[bFacei];
571 !globalAgglom.
isLocal(globalNei)
572 || globalAgglom.
toLocal(globalNei) != own
575 m[offsets[own] + nFacesPerCell[own]++] = globalNei;
592 if (cellCells.
size() == 0)
606 for (
label i = startIndex; i < endIndex; i++)
608 if (nbrCells.
insert(cellCells.
m()[i]))
610 cellCells.
m()[newIndex++] = cellCells.
m()[i];
613 startIndex = endIndex;
614 cellCells.
offsets()[celli+1] = newIndex;
625 const label nLocalCoarse,
657 if (pp.
coupled() && (parallel || !isA<processorPolyPatch>(pp)))
664 globalNeighbour[bFaceI] = globalAgglom.
toGlobal
666 agglom[faceOwner[faceI]]
683 labelList nFacesPerCell(nLocalCoarse, 0);
687 label own = agglom[faceOwner[faceI]];
688 label nei = agglom[faceNeighbour[faceI]];
690 nFacesPerCell[own]++;
691 nFacesPerCell[nei]++;
698 if (pp.
coupled() && (parallel || !isA<processorPolyPatch>(pp)))
705 label own = agglom[faceOwner[faceI]];
707 label globalNei = globalNeighbour[bFaceI];
710 !globalAgglom.
isLocal(globalNei)
711 || globalAgglom.
toLocal(globalNei) != own
714 nFacesPerCell[own]++;
727 cellCells.
setSize(nFacesPerCell);
728 cellCellWeights.
setSize(nFacesPerCell);
739 label own = agglom[faceOwner[faceI]];
740 label nei = agglom[faceNeighbour[faceI]];
742 label ownIndex = offsets[own] + nFacesPerCell[own]++;
743 label neiIndex = offsets[nei] + nFacesPerCell[nei]++;
745 m[ownIndex] = globalAgglom.
toGlobal(nei);
747 m[neiIndex] = globalAgglom.
toGlobal(own);
756 if (pp.
coupled() && (parallel || !isA<processorPolyPatch>(pp)))
763 label own = agglom[faceOwner[faceI]];
765 label globalNei = globalNeighbour[bFaceI];
769 !globalAgglom.
isLocal(globalNei)
770 || globalAgglom.
toLocal(globalNei) != own
773 label ownIndex = offsets[own] + nFacesPerCell[own]++;
774 m[ownIndex] = globalNei;
792 if (cellCells.
size() == 0)
806 for (
label i = startIndex; i < endIndex; i++)
808 if (nbrCells.
insert(cellCells.
m()[i]))
810 cellCells.
m()[newIndex] = cellCells.
m()[i];
811 cellCellWeights.
m()[newIndex] = cellCellWeights.
m()[i];
815 startIndex = endIndex;
816 cellCells.
offsets()[cellI+1] = newIndex;
817 cellCellWeights.
offsets()[cellI+1] = newIndex;
821 cellCellWeights.
setSize(cellCells.
size(), newIndex);
836 const bool hasWeights =
841 forAll(specifiedProcessorFaces, setI)
843 nProcSets += specifiedProcessorFaces[setI].
size();
850 explicitConnections.
size(),
855 label nUnblocked = 0;
856 forAll(blockedFace, facei)
858 if (!blockedFace[facei])
871 if (nProcSets+nConnections+nUnblocked == 0)
877 finalDecomp = decompose
893 Info<<
"Constrained decomposition:" <<
endl
894 <<
" faces with same owner and neighbour processor : "
895 << nUnblocked <<
endl
896 <<
" baffle faces with same owner processor : "
897 << nConnections <<
endl
898 <<
" faces all on same processor : "
903 regionSplit localRegion(mesh, blockedFace, explicitConnections,
false);
908 Info<<
"Constrained decomposition:" <<
endl
924 forAll(localRegion, celli)
926 label regionI = localRegion[celli];
930 regionCentres[regionI] = mesh.
cellCentres()[celli];
941 forAll(localRegion, celli)
943 const label regionI = localRegion[celli];
945 regionWeights[regionI] += cellWeights[celli];
950 forAll(localRegion, celli)
952 label regionI = localRegion[celli];
954 regionWeights[regionI] += 1.0;
958 finalDecomp = decompose
970 forAll(explicitConnections, i)
972 const labelPair& baffle = explicitConnections[i];
976 if (!blockedFace[f0] && !blockedFace[f1])
984 finalDecomp[mesh.
faceOwner()[f1]] = proci;
990 else if (blockedFace[f0] != blockedFace[f1])
993 <<
"On explicit connection between faces " << f0
995 <<
" the two blockedFace status are not equal : "
996 << blockedFace[f0] <<
" and " << blockedFace[f1]
1016 label nUnblocked = 0;
1017 forAll(blockedFace, facei)
1019 if (blockedFace[facei])
1021 faceData[facei] =
minData(-123);
1034 forAll(blockedFace, facei)
1036 if (!blockedFace[facei])
1039 seedFaces[nUnblocked] = facei;
1040 seedData[nUnblocked] =
minData(finalDecomp[own]);
1058 forAll(finalDecomp, celli)
1060 if (cellData[celli].
valid(deltaCalc.
data()))
1062 finalDecomp[celli] = cellData[celli].
data();
1081 forAll(specifiedProcessorFaces, setI)
1083 const labelList& set = specifiedProcessorFaces[setI];
1085 label proci = specifiedProcessor[setI];
1090 proci = finalDecomp[mesh.
faceOwner()[set[0]]];
1103 finalDecomp[mesh.
faceOwner()[facei]] = proci;
1131 if (!blockedFace[facei])
1133 label ownProc = finalDecomp[own];
1134 label nbrProc = nbrDecomp[bFacei];
1135 if (ownProc != nbrProc)
1138 <<
"patch:" << pp.
name()
1139 <<
" face:" << facei
1141 <<
" ownProc:" << ownProc
1142 <<
" nbrProc:" << nbrProc
1168 specifiedProcessorFaces.
clear();
1169 explicitConnections.
clear();
1171 forAll(constraints_, constraintI)
1173 constraints_[constraintI].add
1177 specifiedProcessorFaces,
1195 forAll(constraints_, constraintI)
1197 constraints_[constraintI].apply
1201 specifiedProcessorFaces,
1203 explicitConnections,
1226 specifiedProcessorFaces,
1240 specifiedProcessorFaces,
1252 specifiedProcessorFaces,
1254 explicitConnections,
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
void setSize(const label mRows)
Reset size of CompactListList.
Wave propagation of information through grid. Every iteration information goes through one layer of c...
const TrackingData & data() const
Additional data to be passed into container.
bool insert(const Key &key)
Insert a new entry.
void clear()
Clear all entries from table.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void append(const T &)
Append an element at the end of the list.
void size(const label)
Override size to be inconsistent with allocated storage.
void clear()
Clear the list, i.e. set size to zero.
void setSize(const label)
Reset size of List.
const Type & second() const
Return second.
const Type & first() const
Return first.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
static const word & system()
Return system name.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
List< Container > list() const
Convert to List<Container>
const UList< label > & offsets() const
Return the offset table (= size()+1)
const UList< T > & m() const
Return the packed matrix of data.
label size() const
Return the primary size, i.e. the number of rows.
T * data()
Return a pointer to the first data element,.
T & last()
Return the last element of the list.
static label worldComm
Default communicator (all processors)
static bool & parRun()
Is this a parallel run?
static int & msgType()
Message tag of standard messages.
label size() const
Return the number of elements in the UPtrList.
static autoPtr< decompositionConstraint > New(const dictionary &constraintsDict, const word &type)
Return a reference to the selected decompositionConstraint.
Abstract base class for decomposition.
decompositionMethod(const dictionary &decompositionDict)
Construct given the decomposition dictionary.
static IOdictionary decomposeParDict(const Time &time)
Read and return the decomposeParDict.
PtrList< decompositionConstraint > constraints_
Optional constraints.
label nWeights(const pointField &points, const scalarField &pointWeights) const
Return the number of weights per point.
virtual labelList decompose(const pointField &points, const scalarField &pointWeights)
Return for every coordinate the wanted processor number.
void setConstraints(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections)
Helper: extract constraints:
dictionary decompositionDict_
label checkWeights(const pointField &points, const scalarField &pointWeights) const
Check the weights against the points.
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.
static autoPtr< decompositionMethod > NewDistributor(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
static labelList scaleWeights(const scalarField &weights, label &nWeights, const bool distributed=true)
Convert the given scalar weights to labels.
void applyConstraints(const polyMesh &mesh, const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &finalDecomp)
Helper: apply constraints to a decomposition. This gives.
static autoPtr< decompositionMethod > NewDecomposer(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
A list of keyword definitions, which are a keyword followed by any number of values (e....
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
A face is a list of labels corresponding to mesh vertices.
Calculates a unique integer (label so might not have enough room - 2G max) for processor + local inde...
label toGlobal(const label i) const
From local to global.
label toLocal(const label i) const
From global to local on current processor.
bool isLocal(const label i) const
Is on local processor.
label nTotalCells() const
Return total number of cells in decomposed mesh.
For use with FaceCellWave. Transports minimum passive data.
const word & name() const
Return name.
Mesh consisting of general polyhedral cells.
virtual const faceList & faces() const
Return raw faces.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
A patch is a list of labels that address the faces in the global face list.
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
label start() const
Return start label of this patch in the polyMesh face list.
const vectorField & faceCentres() const
const vectorField & cellCentres() const
label nInternalFaces() const
const scalarField & magFaceAreas() const
const labelListList & pointFaces() const
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
This class separates the mesh into distinct unconnected regions, each of which is then given a label ...
label nLocalRegions() const
Return local number of regions.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const fvPatchList & patches
bool valid(const PtrList< ModelType > &l)
errorManipArg< error, int > exit(error &err, const int errNo=1)
dlLibraryTable libs
Table of loaded dynamic libraries.
Type gSum(const FieldField< Field, Type > &f)
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
defineTypeNameAndDebug(combustionModel, 0)
static const label labelMax
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Info<< "Finished reading KIVA file"<< endl;cellShapeList cellShapes(nPoints);labelList cellZoning(nPoints, -1);const cellModel &hex=*(cellModeller::lookup("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, &mergedCyclicPolyPatch::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]
Operator to apply a binary operation to a pair of lists.