53 #ifdef FOAM_USE_ZOLTAN 76 zeroGradientFvPatchScalarField::typeName
83 fld[celli] = elems[celli];
97 label diff = neighbour[facei] - owner[facei];
111 const bool calculateIntersect,
117 scalar& sumSqrIntersect
125 label own = owner[facei];
126 label nei = neighbour[facei];
130 cellBandwidth[nei] =
max(cellBandwidth[nei], diff);
133 bandwidth =
max(cellBandwidth);
137 forAll(cellBandwidth, celli)
139 profile += 1.0*cellBandwidth[celli];
142 sumSqrIntersect = 0.0;
143 if (calculateIntersect)
147 for (
label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
149 nIntersect[colI] += 1.0;
174 forAll(cellOrder, newCelli)
176 label oldCelli = cellOrder[newCelli];
178 const cell& cFaces = mesh.
cells()[oldCelli];
185 label facei = cFaces[i];
191 if (nbrCelli == newCelli)
193 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
196 if (newCelli < nbrCelli)
219 label index = order[i];
220 if (nbr[index] != -1)
222 oldToNewFace[cFaces[index]] = newFacei++;
228 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
230 oldToNewFace[facei] = facei;
235 forAll(oldToNewFace, facei)
237 if (oldToNewFace[facei] == -1)
240 <<
"Did not determine new position" <<
" for face " << facei
264 label prevRegion = -1;
266 forAll(cellOrder, newCelli)
268 label oldCelli = cellOrder[newCelli];
270 if (cellToRegion[oldCelli] != prevRegion)
272 prevRegion = cellToRegion[oldCelli];
275 const cell& cFaces = mesh.
cells()[oldCelli];
281 label facei = cFaces[i];
287 if (nbrCelli == newCelli)
289 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
292 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
297 else if (newCelli < nbrCelli)
321 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
327 label nRegions =
max(cellToRegion)+1;
337 if (ownRegion != neiRegion)
340 min(ownRegion, neiRegion)*nRegions
341 +
max(ownRegion, neiRegion);
350 label key = sortKey[i];
362 oldToNewFace[sortKey.indices()[i]] = newFacei++;
367 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
369 oldToNewFace[facei] = facei;
374 forAll(oldToNewFace, facei)
376 if (oldToNewFace[facei] == -1)
379 <<
"Did not determine new position" 380 <<
" for face " << facei
422 forAll(newNeighbour, facei)
424 label own = newOwner[facei];
425 label nei = newNeighbour[facei];
429 newFaces[facei].flip();
430 Swap(newOwner[facei], newNeighbour[facei]);
431 flipFaceFlux.insert(facei);
445 oldPatchNMeshPoints[
patchi] = patches[
patchi].nPoints();
451 NullObjectMove<pointField>(),
472 label oldFacei = fZone[i];
473 newAddressing[i] = reverseFaceOrder[oldFacei];
474 if (flipFaceFlux.found(newAddressing[i]))
476 newFlipMap[i] = !fZone.
flipMap()[i];
480 newFlipMap[i] = fZone.
flipMap()[i];
553 Info<<
"Determining cell order:" <<
endl;
557 label nRegions =
max(cellToRegion)+1;
563 forAll(regionToCells, regionI)
565 Info<<
" region " << regionI <<
" starts at " << celli <<
endl;
573 subsetter.setLargeCellSubset(cellToRegion, regionI);
575 const fvMesh& subMesh = subsetter.subMesh();
586 const labelList& cellMap = subsetter.cellMap();
590 cellOrder[celli++] = cellMap[subCellOrder[i]];
601 int main(
int argc,
char *argv[])
605 "Renumber mesh to minimize bandwidth" 615 "calculate the rms of the frontwidth" 620 "do not update fields" 629 #ifdef FOAM_USE_ZOLTAN 630 Info<<
"renumberMesh built with zoltan support." << nl <<
endl;
631 (void)zoltanRenumber::typeName;
652 scalar sumSqrIntersect;
676 <<
"Before renumbering :" << nl
677 <<
" band : " << band << nl
678 <<
" profile : " << profile <<
nl;
682 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
687 bool sortCoupledFaceCells =
false;
688 bool writeMaps =
false;
689 bool orderPoints =
false;
691 bool renumberSets =
true;
711 "sortCoupledFaceCells",
714 if (sortCoupledFaceCells)
716 Info<<
"Sorting cells on coupled boundaries to be last." << nl
723 Info<<
"Ordering cells into regions of size " << blockSize
724 <<
" (using decomposition);" 725 <<
" ordering faces into region-internal and region-external." 728 if (blockSize < 0 || blockSize >= mesh.
nCells())
731 <<
"Block size " << blockSize
732 <<
" should be positive integer" 733 <<
" and less than the number of cells in the mesh." 741 Info<<
"Ordering points into internal and boundary points." << nl
745 renumberDict.
lookup(
"writeMaps") >> writeMaps;
748 Info<<
"Writing renumber maps (new to old) to polyMesh." << nl
756 Info<<
"Using default renumberMethod." << nl <<
endl;
761 Info<<
"Selecting renumberMethod " << renumberPtr().type() << nl <<
endl;
770 "cellProcAddressing",
783 "faceProcAddressing",
784 mesh.facesInstance(),
795 "pointProcAddressing",
796 mesh.pointsInstance(),
807 "boundaryProcAddressing",
808 mesh.pointsInstance(),
820 if (fields)
Info<<
"Reading geometric fields" << nl <<
endl;
838 label nBlocks = mesh.nCells()/blockSize;
839 Info<<
"nBlocks = " << nBlocks <<
endl;
842 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
843 decomposeDict.set(
"numberOfSubdomains", nBlocks);
855 decomposePtr().decompose
873 Info<< nl <<
"Written decomposition as volScalarField to " 874 <<
"cellDist for use in postprocessing." 878 cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion);
881 faceOrder = getRegionFaceOrder
891 cellOrder = renumberPtr().renumber
897 if (sortCoupledFaceCells)
906 if (pbm[
patchi].coupled())
919 if (pbm[
patchi].coupled())
924 label celli = faceCells[i];
926 if (reverseCellOrder[celli] != -1)
928 bndCells[nBndCells] = celli;
929 bndCellMap[nBndCells++] = reverseCellOrder[celli];
930 reverseCellOrder[celli] = -1;
936 bndCellMap.setSize(nBndCells);
943 labelList newReverseCellOrder(mesh.nCells(), -1);
945 label sortedI = mesh.nCells();
948 label origCelli = bndCells[order[i]];
949 newReverseCellOrder[origCelli] = --sortedI;
952 Info<<
"Ordered all " << nBndCells <<
" cells with a coupled face" 953 <<
" to the end of the cell list, starting at " << sortedI
958 forAll(cellOrder, newCelli)
960 label origCelli = cellOrder[newCelli];
961 if (newReverseCellOrder[origCelli] == -1)
963 newReverseCellOrder[origCelli] = sortedI++;
968 cellOrder =
invert(mesh.nCells(), newReverseCellOrder);
973 faceOrder = getFaceOrder
1007 pointOrderMap().pointMap()
1012 pointOrderMap().reversePointMap(),
1013 const_cast<labelList&>(map().reversePointMap())
1019 mesh.updateMesh(map);
1024 cellProcAddressing.headerOk()
1025 && cellProcAddressing.size() == mesh.nCells()
1028 Info<<
"Renumbering processor cell decomposition map " 1029 << cellProcAddressing.name() <<
endl;
1042 Info<<
"Renumbering processor face decomposition map " 1054 label facei = iter.key();
1059 if (masterFacei == 0)
1068 pointProcAddressing.headerOk()
1069 && pointProcAddressing.size() == mesh.nPoints()
1072 Info<<
"Renumbering processor point decomposition map " 1073 << pointProcAddressing.name() <<
endl;
1083 if (map().hasMotionPoints())
1085 mesh.movePoints(map().preMotionPoints());
1092 scalar sumSqrIntersect;
1098 mesh.faceNeighbour(),
1111 )/mesh.globalData().nTotalCells()
1114 Info<<
"After renumbering :" << nl
1115 <<
" band : " << band << nl
1116 <<
" profile : " << profile <<
nl;
1121 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1140 mesh.nInternalPoints(),
1151 mesh.nInternalEdges(),
1156 mesh.nInternal0Edges(),
1161 mesh.nInternal1Edges(),
1165 Info<<
"Points:" << nl
1166 <<
" total : " << nTotPoints << nl
1167 <<
" internal: " << nTotIntPoints << nl
1168 <<
" boundary: " << nTotPoints-nTotIntPoints << nl
1170 <<
" total : " << nTotEdges << nl
1171 <<
" internal: " << nTotIntEdges << nl
1172 <<
" internal using 0 boundary points: " 1173 << nTotInt0Edges << nl
1174 <<
" internal using 1 boundary points: " 1175 << nTotInt1Edges-nTotInt0Edges << nl
1176 <<
" internal using 2 boundary points: " 1177 << nTotIntEdges-nTotInt1Edges << nl
1178 <<
" boundary: " << nTotEdges-nTotIntEdges << nl
1185 mesh.setInstance(oldInstance);
1188 Info<<
"Writing mesh to " << mesh.facesInstance() <<
endl;
1192 if (cellProcAddressing.headerOk())
1194 cellProcAddressing.instance() = mesh.facesInstance();
1195 if (cellProcAddressing.size() == mesh.nCells())
1197 cellProcAddressing.
write();
1202 const fileName fName(cellProcAddressing.filePath());
1205 Info<<
"Deleting inconsistent processor cell decomposition" 1206 <<
" map " << fName <<
endl;
1224 Info<<
"Deleting inconsistent processor face decomposition" 1225 <<
" map " << fName <<
endl;
1231 if (pointProcAddressing.headerOk())
1233 pointProcAddressing.instance() = mesh.facesInstance();
1234 if (pointProcAddressing.size() == mesh.nPoints())
1236 pointProcAddressing.write();
1240 const fileName fName(pointProcAddressing.filePath());
1243 Info<<
"Deleting inconsistent processor point decomposition" 1244 <<
" map " << fName <<
endl;
1250 if (boundaryProcAddressing.headerOk())
1252 boundaryProcAddressing.instance() = mesh.facesInstance();
1253 if (boundaryProcAddressing.size() == mesh.boundaryMesh().size())
1255 boundaryProcAddressing.write();
1259 const fileName fName(boundaryProcAddressing.filePath());
1262 Info<<
"Deleting inconsistent processor patch decomposition" 1263 <<
" map " << fName <<
endl;
1286 Info<< nl <<
"Written current cellID and origCellID as volScalarField" 1287 <<
" for use in postprocessing." 1295 mesh.facesInstance(),
1310 mesh.facesInstance(),
1325 mesh.facesInstance(),
1349 Info<<
"Renumbering cellSets:" <<
endl;
1354 cs.updateMesh(map());
1355 cs.instance() = mesh.facesInstance();
1365 Info<<
"Renumbering faceSets:" <<
endl;
1370 fs.updateMesh(map());
1371 fs.instance() = mesh.facesInstance();
1381 Info<<
"Renumbering pointSets:" <<
endl;
1386 ps.updateMesh(map());
1387 ps.instance() = mesh.facesInstance();
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
List< labelList > labelListList
A List of labelList.
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
#define forAll(list, i)
Loop across all elements in list.
void clearAddressing()
Clear addressing.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual void resetAddressing(const labelUList &, const boolList &)
Reset addressing and flip map (clearing demand-driven data)
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
A class for handling file names.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
List of IOobjects with searching and retrieving facilities.
const faceZoneMesh & faceZones() const
Return face zone mesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
void off()
Switch the function objects off.
A list of keyword definitions, which are a keyword followed by any number of values (e...
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label nInternalFaces() const
virtual const labelList & faceNeighbour() const
Return face neighbour.
A list that is sorted upon construction or when explicitly requested with the sort() method...
Cell-face mesh analysis engine.
PtrList< labelIOList > & faceProcAddressing
dimensionedSymmTensor sqr(const dimensionedVector &dv)
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void size(const label)
Override size to be inconsistent with allocated storage.
const boolList & flipMap() const
Return face flip map.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
label nTotalCells() const
Return total number of cells in decomposed mesh.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
const cellList & cells() const
Field reading functions for post-processing utilities.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Mesh &, const dimensionSet &, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
Return a temporary field constructed from name, mesh, dimensionSet.
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
Abstract base class for renumbering.
vectorField pointField
pointField is a vectorField.
const fileName & pointsInstance() const
Return the current instance directory for points.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
A class for handling words, derived from string.
const cellZoneMesh & cellZones() const
Return cell zone mesh.
Cuthill-McKee renumbering.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
static const label labelMax
List< label > labelList
A List of labels.
const word dictName("particleTrackDict")
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
virtual const faceList & faces() const
Return raw faces.
const vectorField & cellCentres() const
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
static autoPtr< decompositionMethod > New(const dictionary &decompositionDict)
Return a reference to the selected decomposition method.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
ListType reorder(const labelUList &oldToNew, const ListType &)
Reorder the elements (indices, not values) of a list.
void resetPrimitives(pointField &&points, faceList &&faces, labelList &&owner, labelList &&neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
Post-processing mesh subset tool. Given the original mesh and the list of selected cells...
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
IOobject dictIO(dictName, runTime.constant(), mesh, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE)
Internal & ref()
Return a reference to the dimensioned internal field.
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?
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
const functionObjectList & functionObjects() const
Return the list of function objects.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A cell is defined as a list of faces with extra functionality.
A collection of cell labels.
Mesh data needed to do the Finite Volume discretisation.
A List with indirect addressing.
Direct mesh changes based on v1.3 polyTopoChange syntax.
instantList times() const
Search the case for valid time directories.
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
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...
virtual Ostream & write(const token &)=0
Write next token to stream.
Mesh consisting of general polyhedral cells.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
A subset of mesh faces organised as a primitive patch.
static void addNote(const string &)
Add extra notes for the usage information.
A class for managing temporary objects.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
IOList< label > labelIOList
Label container classes.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.