54 #ifdef FOAM_USE_ZOLTAN 77 zeroGradientFvPatchScalarField::typeName
84 fld[celli] = elems[celli];
98 label diff = neighbour[facei] - owner[facei];
112 const bool calculateIntersect,
118 scalar& sumSqrIntersect
126 label own = owner[facei];
127 label nei = neighbour[facei];
131 cellBandwidth[nei] =
max(cellBandwidth[nei], diff);
134 bandwidth =
max(cellBandwidth);
138 forAll(cellBandwidth, celli)
140 profile += 1.0*cellBandwidth[celli];
143 sumSqrIntersect = 0.0;
144 if (calculateIntersect)
148 for (
label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
150 nIntersect[colI] += 1.0;
175 forAll(cellOrder, newCelli)
177 label oldCelli = cellOrder[newCelli];
179 const cell& cFaces = mesh.
cells()[oldCelli];
186 label facei = cFaces[i];
192 if (nbrCelli == newCelli)
194 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
197 if (newCelli < nbrCelli)
220 label index = order[i];
221 if (nbr[index] != -1)
223 oldToNewFace[cFaces[index]] = newFacei++;
229 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
231 oldToNewFace[facei] = facei;
236 forAll(oldToNewFace, facei)
238 if (oldToNewFace[facei] == -1)
241 <<
"Did not determine new position" <<
" for face " << facei
265 label prevRegion = -1;
267 forAll(cellOrder, newCelli)
269 label oldCelli = cellOrder[newCelli];
271 if (cellToRegion[oldCelli] != prevRegion)
273 prevRegion = cellToRegion[oldCelli];
276 const cell& cFaces = mesh.
cells()[oldCelli];
282 label facei = cFaces[i];
288 if (nbrCelli == newCelli)
290 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
293 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
298 else if (newCelli < nbrCelli)
322 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
328 label nRegions =
max(cellToRegion)+1;
338 if (ownRegion != neiRegion)
341 min(ownRegion, neiRegion)*nRegions
342 +
max(ownRegion, neiRegion);
351 label key = sortKey[i];
363 oldToNewFace[sortKey.indices()[i]] = newFacei++;
368 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
370 oldToNewFace[facei] = facei;
375 forAll(oldToNewFace, facei)
377 if (oldToNewFace[facei] == -1)
380 <<
"Did not determine new position" 381 <<
" for face " << facei
423 forAll(newNeighbour, facei)
425 label own = newOwner[facei];
426 label nei = newNeighbour[facei];
430 newFaces[facei].flip();
431 Swap(newOwner[facei], newNeighbour[facei]);
432 flipFaceFlux.insert(facei);
446 oldPatchNMeshPoints[
patchi] = patches[
patchi].nPoints();
452 NullObjectMove<pointField>(),
473 label oldFacei = fZone[i];
474 newAddressing[i] = reverseFaceOrder[oldFacei];
475 if (flipFaceFlux.found(newAddressing[i]))
477 newFlipMap[i] = !fZone.
flipMap()[i];
481 newFlipMap[i] = fZone.
flipMap()[i];
554 Info<<
"Determining cell order:" <<
endl;
558 label nRegions =
max(cellToRegion)+1;
564 forAll(regionToCells, regionI)
566 Info<<
" region " << regionI <<
" starts at " << celli <<
endl;
574 subsetter.setLargeCellSubset(cellToRegion, regionI);
576 const fvMesh& subMesh = subsetter.subMesh();
587 const labelList& cellMap = subsetter.cellMap();
591 cellOrder[celli++] = cellMap[subCellOrder[i]];
602 int main(
int argc,
char *argv[])
606 "Renumber mesh to minimise bandwidth" 616 "calculate the rms of the frontwidth" 621 "do not update fields" 630 #ifdef FOAM_USE_ZOLTAN 631 Info<<
"renumberMesh built with zoltan support." << nl <<
endl;
632 (void)zoltanRenumber::typeName;
653 scalar sumSqrIntersect;
677 <<
"Before renumbering :" << nl
678 <<
" band : " << band << nl
679 <<
" profile : " << profile <<
nl;
683 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
688 bool sortCoupledFaceCells =
false;
689 bool writeMaps =
false;
690 bool orderPoints =
false;
692 bool renumberSets =
true;
700 renumberDictPtr.
reset 704 const dictionary& renumberDict = renumberDictPtr();
710 "sortCoupledFaceCells",
713 if (sortCoupledFaceCells)
715 Info<<
"Sorting cells on coupled boundaries to be last." << nl
722 Info<<
"Ordering cells into regions of size " << blockSize
723 <<
" (using decomposition);" 724 <<
" ordering faces into region-internal and region-external." 727 if (blockSize < 0 || blockSize >= mesh.
nCells())
730 <<
"Block size " << blockSize
731 <<
" should be positive integer" 732 <<
" and less than the number of cells in the mesh." 740 Info<<
"Ordering points into internal and boundary points." << nl
744 renumberDict.
lookup(
"writeMaps") >> writeMaps;
747 Info<<
"Writing renumber maps (new to old) to polyMesh." << nl
755 Info<<
"Using default renumberMethod." << nl <<
endl;
760 Info<<
"Selecting renumberMethod " << renumberPtr().type() << nl <<
endl;
769 "cellProcAddressing",
782 "faceProcAddressing",
783 mesh.facesInstance(),
794 "pointProcAddressing",
795 mesh.pointsInstance(),
806 "boundaryProcAddressing",
807 mesh.pointsInstance(),
819 if (fields)
Info<<
"Reading geometric fields" << nl <<
endl;
837 label nBlocks = mesh.nCells()/blockSize;
838 Info<<
"nBlocks = " << nBlocks <<
endl;
841 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
842 decomposeDict.set(
"numberOfSubdomains", nBlocks);
854 decomposePtr().decompose
872 Info<< nl <<
"Written decomposition as volScalarField to " 873 <<
"cellDist for use in postprocessing." 877 cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion);
880 faceOrder = getRegionFaceOrder
890 cellOrder = renumberPtr().renumber
896 if (sortCoupledFaceCells)
905 if (pbm[
patchi].coupled())
918 if (pbm[
patchi].coupled())
923 label celli = faceCells[i];
925 if (reverseCellOrder[celli] != -1)
927 bndCells[nBndCells] = celli;
928 bndCellMap[nBndCells++] = reverseCellOrder[celli];
929 reverseCellOrder[celli] = -1;
935 bndCellMap.setSize(nBndCells);
942 labelList newReverseCellOrder(mesh.nCells(), -1);
944 label sortedI = mesh.nCells();
947 label origCelli = bndCells[order[i]];
948 newReverseCellOrder[origCelli] = --sortedI;
951 Info<<
"Ordered all " << nBndCells <<
" cells with a coupled face" 952 <<
" to the end of the cell list, starting at " << sortedI
957 forAll(cellOrder, newCelli)
959 label origCelli = cellOrder[newCelli];
960 if (newReverseCellOrder[origCelli] == -1)
962 newReverseCellOrder[origCelli] = sortedI++;
967 cellOrder =
invert(mesh.nCells(), newReverseCellOrder);
972 faceOrder = getFaceOrder
1006 pointOrderMap().pointMap()
1011 pointOrderMap().reversePointMap(),
1012 const_cast<labelList&>(map().reversePointMap())
1018 mesh.updateMesh(map);
1023 cellProcAddressing.headerOk()
1024 && cellProcAddressing.size() == mesh.nCells()
1027 Info<<
"Renumbering processor cell decomposition map " 1028 << cellProcAddressing.name() <<
endl;
1041 Info<<
"Renumbering processor face decomposition map " 1053 label facei = iter.key();
1058 if (masterFacei == 0)
1067 pointProcAddressing.headerOk()
1068 && pointProcAddressing.size() == mesh.nPoints()
1071 Info<<
"Renumbering processor point decomposition map " 1072 << pointProcAddressing.name() <<
endl;
1082 if (map().hasMotionPoints())
1084 mesh.movePoints(map().preMotionPoints());
1091 scalar sumSqrIntersect;
1097 mesh.faceNeighbour(),
1110 )/mesh.globalData().nTotalCells()
1113 Info<<
"After renumbering :" << nl
1114 <<
" band : " << band << nl
1115 <<
" profile : " << profile <<
nl;
1120 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1139 mesh.nInternalPoints(),
1150 mesh.nInternalEdges(),
1155 mesh.nInternal0Edges(),
1160 mesh.nInternal1Edges(),
1164 Info<<
"Points:" << nl
1165 <<
" total : " << nTotPoints << nl
1166 <<
" internal: " << nTotIntPoints << nl
1167 <<
" boundary: " << nTotPoints-nTotIntPoints << nl
1169 <<
" total : " << nTotEdges << nl
1170 <<
" internal: " << nTotIntEdges << nl
1171 <<
" internal using 0 boundary points: " 1172 << nTotInt0Edges << nl
1173 <<
" internal using 1 boundary points: " 1174 << nTotInt1Edges-nTotInt0Edges << nl
1175 <<
" internal using 2 boundary points: " 1176 << nTotIntEdges-nTotInt1Edges << nl
1177 <<
" boundary: " << nTotEdges-nTotIntEdges << nl
1184 mesh.setInstance(oldInstance);
1187 Info<<
"Writing mesh to " << mesh.facesInstance() <<
endl;
1191 if (cellProcAddressing.headerOk())
1193 cellProcAddressing.instance() = mesh.facesInstance();
1194 if (cellProcAddressing.size() == mesh.nCells())
1196 cellProcAddressing.
write();
1201 const fileName fName(cellProcAddressing.filePath());
1204 Info<<
"Deleting inconsistent processor cell decomposition" 1205 <<
" map " << fName <<
endl;
1223 Info<<
"Deleting inconsistent processor face decomposition" 1224 <<
" map " << fName <<
endl;
1230 if (pointProcAddressing.headerOk())
1232 pointProcAddressing.instance() = mesh.facesInstance();
1233 if (pointProcAddressing.size() == mesh.nPoints())
1235 pointProcAddressing.write();
1239 const fileName fName(pointProcAddressing.filePath());
1242 Info<<
"Deleting inconsistent processor point decomposition" 1243 <<
" map " << fName <<
endl;
1249 if (boundaryProcAddressing.headerOk())
1251 boundaryProcAddressing.instance() = mesh.facesInstance();
1252 if (boundaryProcAddressing.size() == mesh.boundaryMesh().size())
1254 boundaryProcAddressing.write();
1258 const fileName fName(boundaryProcAddressing.filePath());
1261 Info<<
"Deleting inconsistent processor patch decomposition" 1262 <<
" map " << fName <<
endl;
1285 Info<< nl <<
"Written current cellID and origCellID as volScalarField" 1286 <<
" for use in postprocessing." 1294 mesh.facesInstance(),
1309 mesh.facesInstance(),
1324 mesh.facesInstance(),
1348 Info<<
"Renumbering cellSets:" <<
endl;
1353 cs.updateMesh(map());
1354 cs.instance() = mesh.facesInstance();
1364 Info<<
"Renumbering faceSets:" <<
endl;
1369 fs.updateMesh(map());
1370 fs.instance() = mesh.facesInstance();
1380 Info<<
"Renumbering pointSets:" <<
endl;
1385 ps.updateMesh(map());
1386 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.
virtual Ostream & write(const char)=0
Write character.
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.
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.
const meshCellZones & cellZones() const
Return cell zones.
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.
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, const Internal &, const PtrList< fvPatchField< scalar >> &)
Return a temporary field constructed from name,.
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.
const dimensionSet dimless
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
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)
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.
Cuthill-McKee renumbering.
virtual const labelList & faceOwner() const
Return face owner.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
const globalMeshData & globalData() const
Return parallel info.
static const label labelMax
List< label > labelList
A List of labels.
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)
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?
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.
const meshFaceZones & faceZones() const
Return face zones.
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...
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...
void clearAddressing()
Clear addressing.
IOList< label > labelIOList
Label container classes.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.