53 #ifdef FOAM_USE_ZOLTAN 84 zeroGradientFvPatchScalarField::typeName
91 fld[celli] = elems[celli];
105 label diff = neighbour[facei] - owner[facei];
119 const bool calculateIntersect,
125 scalar& sumSqrIntersect
133 label own = owner[facei];
134 label nei = neighbour[facei];
138 cellBandwidth[nei] =
max(cellBandwidth[nei], diff);
141 bandwidth =
max(cellBandwidth);
145 forAll(cellBandwidth, celli)
147 profile += 1.0*cellBandwidth[celli];
150 sumSqrIntersect = 0.0;
151 if (calculateIntersect)
155 for (
label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
157 nIntersect[colI] += 1.0;
182 forAll(cellOrder, newCelli)
184 label oldCelli = cellOrder[newCelli];
186 const cell& cFaces = mesh.
cells()[oldCelli];
193 label facei = cFaces[i];
199 if (nbrCelli == newCelli)
201 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
204 if (newCelli < nbrCelli)
227 label index = order[i];
228 if (nbr[index] != -1)
230 oldToNewFace[cFaces[index]] = newFacei++;
236 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
238 oldToNewFace[facei] = facei;
243 forAll(oldToNewFace, facei)
245 if (oldToNewFace[facei] == -1)
248 <<
"Did not determine new position" <<
" for face " << facei
272 label prevRegion = -1;
274 forAll(cellOrder, newCelli)
276 label oldCelli = cellOrder[newCelli];
278 if (cellToRegion[oldCelli] != prevRegion)
280 prevRegion = cellToRegion[oldCelli];
283 const cell& cFaces = mesh.
cells()[oldCelli];
289 label facei = cFaces[i];
295 if (nbrCelli == newCelli)
297 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
300 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
305 else if (newCelli < nbrCelli)
329 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
335 label nRegions =
max(cellToRegion)+1;
345 if (ownRegion != neiRegion)
348 min(ownRegion, neiRegion)*nRegions
349 +
max(ownRegion, neiRegion);
358 label key = sortKey[i];
370 oldToNewFace[sortKey.indices()[i]] = newFacei++;
375 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
377 oldToNewFace[facei] = facei;
382 forAll(oldToNewFace, facei)
384 if (oldToNewFace[facei] == -1)
387 <<
"Did not determine new position" 388 <<
" for face " << facei
430 forAll(newNeighbour, facei)
432 label own = newOwner[facei];
433 label nei = newNeighbour[facei];
437 newFaces[facei].flip();
438 Swap(newOwner[facei], newNeighbour[facei]);
439 flipFaceFlux.insert(facei);
453 oldPatchNMeshPoints[
patchi] = patches[
patchi].nPoints();
480 label oldFacei = fZone[i];
481 newAddressing[i] = reverseFaceOrder[oldFacei];
482 if (flipFaceFlux.found(newAddressing[i]))
484 newFlipMap[i] = !fZone.
flipMap()[i];
488 newFlipMap[i] = fZone.
flipMap()[i];
561 Info<<
"Determining cell order:" <<
endl;
565 label nRegions =
max(cellToRegion)+1;
571 forAll(regionToCells, regionI)
573 Info<<
" region " << regionI <<
" starts at " << celli <<
endl;
581 subsetter.setLargeCellSubset(cellToRegion, regionI);
583 const fvMesh& subMesh = subsetter.subMesh();
594 const labelList& cellMap = subsetter.cellMap();
598 cellOrder[celli++] = cellMap[subCellOrder[i]];
609 int main(
int argc,
char *argv[])
613 "Renumber mesh to minimize bandwidth" 623 "calculate the rms of the frontwidth" 628 "do not update fields" 637 #ifdef FOAM_USE_ZOLTAN 638 Info<<
"renumberMesh built with zoltan support." << nl <<
endl;
639 (void)zoltanRenumber::typeName;
660 scalar sumSqrIntersect;
684 <<
"Before renumbering :" << nl
685 <<
" band : " << band << nl
686 <<
" profile : " << profile <<
nl;
690 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
695 bool sortCoupledFaceCells =
false;
696 bool writeMaps =
false;
697 bool orderPoints =
false;
699 bool renumberSets =
true;
719 "sortCoupledFaceCells",
722 if (sortCoupledFaceCells)
724 Info<<
"Sorting cells on coupled boundaries to be last." << nl
731 Info<<
"Ordering cells into regions of size " << blockSize
732 <<
" (using decomposition);" 733 <<
" ordering faces into region-internal and region-external." 736 if (blockSize < 0 || blockSize >= mesh.
nCells())
739 <<
"Block size " << blockSize
740 <<
" should be positive integer" 741 <<
" and less than the number of cells in the mesh." 749 Info<<
"Ordering points into internal and boundary points." << nl
753 renumberDict.
lookup(
"writeMaps") >> writeMaps;
756 Info<<
"Writing renumber maps (new to old) to polyMesh." << nl
764 Info<<
"Using default renumberMethod." << nl <<
endl;
769 Info<<
"Selecting renumberMethod " << renumberPtr().type() << nl <<
endl;
778 "cellProcAddressing",
791 "faceProcAddressing",
792 mesh.facesInstance(),
803 "pointProcAddressing",
804 mesh.pointsInstance(),
815 "boundaryProcAddressing",
816 mesh.pointsInstance(),
829 if (fields)
Info<<
"Reading geometric fields" << nl <<
endl;
834 if (fields)
ReadFields(mesh, objects, vsFlds);
837 if (fields)
ReadFields(mesh, objects, vvFlds);
840 if (fields)
ReadFields(mesh, objects, vstFlds);
843 if (fields)
ReadFields(mesh, objects, vsymtFlds);
846 if (fields)
ReadFields(mesh, objects, vtFlds);
852 if (fields)
ReadFields(mesh, objects, ssFlds);
855 if (fields)
ReadFields(mesh, objects, svFlds);
858 if (fields)
ReadFields(mesh, objects, sstFlds);
861 if (fields)
ReadFields(mesh, objects, ssymtFlds);
864 if (fields)
ReadFields(mesh, objects, stFlds);
897 label nBlocks = mesh.nCells()/blockSize;
898 Info<<
"nBlocks = " << nBlocks <<
endl;
901 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
902 decomposeDict.set(
"numberOfSubdomains", nBlocks);
914 decomposePtr().decompose
932 Info<< nl <<
"Written decomposition as volScalarField to " 933 <<
"cellDist for use in postprocessing." 937 cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion);
940 faceOrder = getRegionFaceOrder
950 cellOrder = renumberPtr().renumber
956 if (sortCoupledFaceCells)
965 if (pbm[
patchi].coupled())
978 if (pbm[
patchi].coupled())
983 label celli = faceCells[i];
985 if (reverseCellOrder[celli] != -1)
987 bndCells[nBndCells] = celli;
988 bndCellMap[nBndCells++] = reverseCellOrder[celli];
989 reverseCellOrder[celli] = -1;
995 bndCellMap.setSize(nBndCells);
1002 labelList newReverseCellOrder(mesh.nCells(), -1);
1004 label sortedI = mesh.nCells();
1007 label origCelli = bndCells[order[i]];
1008 newReverseCellOrder[origCelli] = --sortedI;
1011 Info<<
"Ordered all " << nBndCells <<
" cells with a coupled face" 1012 <<
" to the end of the cell list, starting at " << sortedI
1017 forAll(cellOrder, newCelli)
1019 label origCelli = cellOrder[newCelli];
1020 if (newReverseCellOrder[origCelli] == -1)
1022 newReverseCellOrder[origCelli] = sortedI++;
1027 cellOrder =
invert(mesh.nCells(), newReverseCellOrder);
1032 faceOrder = getFaceOrder
1066 pointOrderMap().pointMap()
1071 pointOrderMap().reversePointMap(),
1072 const_cast<labelList&>(map().reversePointMap())
1078 mesh.updateMesh(map);
1083 cellProcAddressing.headerOk()
1084 && cellProcAddressing.size() == mesh.nCells()
1087 Info<<
"Renumbering processor cell decomposition map " 1088 << cellProcAddressing.name() <<
endl;
1101 Info<<
"Renumbering processor face decomposition map " 1113 label facei = iter.key();
1118 if (masterFacei == 0)
1127 pointProcAddressing.headerOk()
1128 && pointProcAddressing.size() == mesh.nPoints()
1131 Info<<
"Renumbering processor point decomposition map " 1132 << pointProcAddressing.name() <<
endl;
1142 if (map().hasMotionPoints())
1144 mesh.movePoints(map().preMotionPoints());
1151 scalar sumSqrIntersect;
1157 mesh.faceNeighbour(),
1170 )/mesh.globalData().nTotalCells()
1173 Info<<
"After renumbering :" << nl
1174 <<
" band : " << band << nl
1175 <<
" profile : " << profile <<
nl;
1180 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1199 mesh.nInternalPoints(),
1210 mesh.nInternalEdges(),
1215 mesh.nInternal0Edges(),
1220 mesh.nInternal1Edges(),
1224 Info<<
"Points:" << nl
1225 <<
" total : " << nTotPoints << nl
1226 <<
" internal: " << nTotIntPoints << nl
1227 <<
" boundary: " << nTotPoints-nTotIntPoints << nl
1229 <<
" total : " << nTotEdges << nl
1230 <<
" internal: " << nTotIntEdges << nl
1231 <<
" internal using 0 boundary points: " 1232 << nTotInt0Edges << nl
1233 <<
" internal using 1 boundary points: " 1234 << nTotInt1Edges-nTotInt0Edges << nl
1235 <<
" internal using 2 boundary points: " 1236 << nTotIntEdges-nTotInt1Edges << nl
1237 <<
" boundary: " << nTotEdges-nTotIntEdges << nl
1244 mesh.setInstance(oldInstance);
1247 Info<<
"Writing mesh to " << mesh.facesInstance() <<
endl;
1251 if (cellProcAddressing.headerOk())
1253 cellProcAddressing.instance() = mesh.facesInstance();
1254 if (cellProcAddressing.size() == mesh.nCells())
1256 cellProcAddressing.
write();
1261 const fileName fName(cellProcAddressing.filePath());
1264 Info<<
"Deleting inconsistent processor cell decomposition" 1265 <<
" map " << fName <<
endl;
1283 Info<<
"Deleting inconsistent processor face decomposition" 1284 <<
" map " << fName <<
endl;
1290 if (pointProcAddressing.headerOk())
1292 pointProcAddressing.instance() = mesh.facesInstance();
1293 if (pointProcAddressing.size() == mesh.nPoints())
1295 pointProcAddressing.write();
1299 const fileName fName(pointProcAddressing.filePath());
1302 Info<<
"Deleting inconsistent processor point decomposition" 1303 <<
" map " << fName <<
endl;
1309 if (boundaryProcAddressing.headerOk())
1311 boundaryProcAddressing.instance() = mesh.facesInstance();
1312 if (boundaryProcAddressing.size() == mesh.boundaryMesh().size())
1314 boundaryProcAddressing.write();
1318 const fileName fName(boundaryProcAddressing.filePath());
1321 Info<<
"Deleting inconsistent processor patch decomposition" 1322 <<
" map " << fName <<
endl;
1345 Info<< nl <<
"Written current cellID and origCellID as volScalarField" 1346 <<
" for use in postprocessing." 1354 mesh.facesInstance(),
1369 mesh.facesInstance(),
1384 mesh.facesInstance(),
1402 IOobjectList objects(mesh, mesh.facesInstance(),
"polyMesh/sets");
1405 IOobjectList cSets(objects.lookupClass(cellSet::typeName));
1408 Info<<
"Renumbering cellSets:" <<
endl;
1413 cs.updateMesh(map());
1414 cs.instance() = mesh.facesInstance();
1421 IOobjectList fSets(objects.lookupClass(faceSet::typeName));
1424 Info<<
"Renumbering faceSets:" <<
endl;
1429 fs.updateMesh(map());
1430 fs.instance() = mesh.facesInstance();
1437 IOobjectList pSets(objects.lookupClass(pointSet::typeName));
1440 Info<<
"Renumbering pointSets:" <<
endl;
1445 ps.updateMesh(map());
1446 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.
A simple container for copying or transferring objects of type <T>.
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.
wordList ReadFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields, const bool syncPar=true)
Read all fields of the specified type.
#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.
const Time & time() const
Return the top-level database.
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)
static const pointMesh & New(const polyMesh &mesh)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
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.
void resetPrimitives(const Xfer< pointField > &points, const Xfer< faceList > &faces, const Xfer< labelList > &owner, const Xfer< labelList > &neighbour, const labelList &patchSizes, const labelList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
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.
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 templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
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.