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 minimise bandwidth" 623 "calculate the rms of the frontwidth" 629 runTime.functionObjects().off();
634 #ifdef FOAM_USE_ZOLTAN 635 Info<<
"renumberMesh built with zoltan support." << nl <<
endl;
636 (void)zoltanRenumber::typeName;
646 runTime.setTime(Times[startTime], startTime);
657 scalar sumSqrIntersect;
681 <<
"Before renumbering :" << nl
682 <<
" band : " << band << nl
683 <<
" profile : " << profile <<
nl;
687 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
692 bool sortCoupledFaceCells =
false;
693 bool writeMaps =
false;
694 bool orderPoints =
false;
696 bool renumberSets =
true;
716 "sortCoupledFaceCells",
719 if (sortCoupledFaceCells)
721 Info<<
"Sorting cells on coupled boundaries to be last." << nl
728 Info<<
"Ordering cells into regions of size " << blockSize
729 <<
" (using decomposition);" 730 <<
" ordering faces into region-internal and region-external." 733 if (blockSize < 0 || blockSize >= mesh.
nCells())
736 <<
"Block size " << blockSize
737 <<
" should be positive integer" 738 <<
" and less than the number of cells in the mesh." 746 Info<<
"Ordering points into internal and boundary points." << nl
750 renumberDict.
lookup(
"writeMaps") >> writeMaps;
753 Info<<
"Writing renumber maps (new to old) to polyMesh." << nl
761 Info<<
"Using default renumberMethod." << nl <<
endl;
766 Info<<
"Selecting renumberMethod " << renumberPtr().type() << nl <<
endl;
775 "cellProcAddressing",
788 "faceProcAddressing",
789 mesh.facesInstance(),
800 "pointProcAddressing",
801 mesh.pointsInstance(),
812 "boundaryProcAddressing",
813 mesh.pointsInstance(),
892 label nBlocks = mesh.nCells()/blockSize;
893 Info<<
"nBlocks = " << nBlocks <<
endl;
896 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
897 decomposeDict.set(
"numberOfSubdomains", nBlocks);
909 decomposePtr().decompose
927 Info<< nl <<
"Written decomposition as volScalarField to " 928 <<
"cellDist for use in postprocessing." 932 cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion);
935 faceOrder = getRegionFaceOrder
945 cellOrder = renumberPtr().renumber
951 if (sortCoupledFaceCells)
960 if (pbm[
patchi].coupled())
973 if (pbm[
patchi].coupled())
978 label celli = faceCells[i];
980 if (reverseCellOrder[celli] != -1)
982 bndCells[nBndCells] = celli;
983 bndCellMap[nBndCells++] = reverseCellOrder[celli];
984 reverseCellOrder[celli] = -1;
990 bndCellMap.setSize(nBndCells);
997 labelList newReverseCellOrder(mesh.nCells(), -1);
999 label sortedI = mesh.nCells();
1002 label origCelli = bndCells[order[i]];
1003 newReverseCellOrder[origCelli] = --sortedI;
1006 Info<<
"Ordered all " << nBndCells <<
" cells with a coupled face" 1007 <<
" to the end of the cell list, starting at " << sortedI
1012 forAll(cellOrder, newCelli)
1014 label origCelli = cellOrder[newCelli];
1015 if (newReverseCellOrder[origCelli] == -1)
1017 newReverseCellOrder[origCelli] = sortedI++;
1022 cellOrder =
invert(mesh.nCells(), newReverseCellOrder);
1027 faceOrder = getFaceOrder
1061 pointOrderMap().pointMap()
1066 pointOrderMap().reversePointMap(),
1067 const_cast<labelList&>(map().reversePointMap())
1073 mesh.updateMesh(map);
1078 cellProcAddressing.headerOk()
1079 && cellProcAddressing.size() == mesh.nCells()
1082 Info<<
"Renumbering processor cell decomposition map " 1083 << cellProcAddressing.name() <<
endl;
1096 Info<<
"Renumbering processor face decomposition map " 1108 label facei = iter.key();
1113 if (masterFacei == 0)
1122 pointProcAddressing.headerOk()
1123 && pointProcAddressing.size() == mesh.nPoints()
1126 Info<<
"Renumbering processor point decomposition map " 1127 << pointProcAddressing.name() <<
endl;
1137 if (map().hasMotionPoints())
1139 mesh.movePoints(map().preMotionPoints());
1146 scalar sumSqrIntersect;
1152 mesh.faceNeighbour(),
1165 )/mesh.globalData().nTotalCells()
1168 Info<<
"After renumbering :" << nl
1169 <<
" band : " << band << nl
1170 <<
" profile : " << profile <<
nl;
1175 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1194 mesh.nInternalPoints(),
1205 mesh.nInternalEdges(),
1210 mesh.nInternal0Edges(),
1215 mesh.nInternal1Edges(),
1219 Info<<
"Points:" << nl
1220 <<
" total : " << nTotPoints << nl
1221 <<
" internal: " << nTotIntPoints << nl
1222 <<
" boundary: " << nTotPoints-nTotIntPoints << nl
1224 <<
" total : " << nTotEdges << nl
1225 <<
" internal: " << nTotIntEdges << nl
1226 <<
" internal using 0 boundary points: " 1227 << nTotInt0Edges << nl
1228 <<
" internal using 1 boundary points: " 1229 << nTotInt1Edges-nTotInt0Edges << nl
1230 <<
" internal using 2 boundary points: " 1231 << nTotIntEdges-nTotInt1Edges << nl
1232 <<
" boundary: " << nTotEdges-nTotIntEdges << nl
1239 mesh.setInstance(oldInstance);
1242 Info<<
"Writing mesh to " << mesh.facesInstance() <<
endl;
1246 if (cellProcAddressing.headerOk())
1248 cellProcAddressing.instance() = mesh.facesInstance();
1249 if (cellProcAddressing.size() == mesh.nCells())
1251 cellProcAddressing.
write();
1256 const fileName fName(cellProcAddressing.filePath());
1259 Info<<
"Deleting inconsistent processor cell decomposition" 1260 <<
" map " << fName <<
endl;
1278 Info<<
"Deleting inconsistent processor face decomposition" 1279 <<
" map " << fName <<
endl;
1285 if (pointProcAddressing.headerOk())
1287 pointProcAddressing.instance() = mesh.facesInstance();
1288 if (pointProcAddressing.size() == mesh.nPoints())
1290 pointProcAddressing.write();
1294 const fileName fName(pointProcAddressing.filePath());
1297 Info<<
"Deleting inconsistent processor point decomposition" 1298 <<
" map " << fName <<
endl;
1304 if (boundaryProcAddressing.headerOk())
1306 boundaryProcAddressing.instance() = mesh.facesInstance();
1307 if (boundaryProcAddressing.size() == mesh.boundaryMesh().size())
1309 boundaryProcAddressing.write();
1313 const fileName fName(boundaryProcAddressing.filePath());
1316 Info<<
"Deleting inconsistent processor patch decomposition" 1317 <<
" map " << fName <<
endl;
1340 Info<< nl <<
"Written current cellID and origCellID as volScalarField" 1341 <<
" for use in postprocessing." 1349 mesh.facesInstance(),
1364 mesh.facesInstance(),
1379 mesh.facesInstance(),
1397 IOobjectList objects(mesh, mesh.facesInstance(),
"polyMesh/sets");
1400 IOobjectList cSets(objects.lookupClass(cellSet::typeName));
1403 Info<<
"Renumbering cellSets:" <<
endl;
1408 cs.updateMesh(map());
1409 cs.instance() = mesh.facesInstance();
1416 IOobjectList fSets(objects.lookupClass(faceSet::typeName));
1419 Info<<
"Renumbering faceSets:" <<
endl;
1424 fs.updateMesh(map());
1425 fs.instance() = mesh.facesInstance();
1432 IOobjectList pSets(objects.lookupClass(pointSet::typeName));
1435 Info<<
"Renumbering pointSets:" <<
endl;
1440 ps.updateMesh(map());
1441 ps.instance() = mesh.facesInstance();
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.
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.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const boolList & flipMap() const
Return face flip map.
A list of keyword definitions, which are a keyword followed by any number of values (e...
const fileName & facesInstance() const
Return the current instance directory for faces.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
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.
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
#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.
Field reading functions for post-processing utilities.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const cellList & cells() const
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
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.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
void reset(T *=0)
If object pointer already set, delete object and set to given.
bool optionFound(const word &opt) const
Return true if the named option is found.
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.
Cuthill-McKee renumbering.
const vectorField & cellCentres() const
static const label labelMax
List< label > labelList
A List of labels.
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
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.
const globalMeshData & globalData() const
Return parallel info.
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.
void setSize(const label)
Reset size of List.
static bool & parRun()
Is this a parallel run?
const cellZoneMesh & cellZones() const
Return cell zone mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
word dictName("noiseDict")
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...
const fileName & pointsInstance() const
Return the current instance directory for points.
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.
virtual const labelList & faceOwner() const =0
Face face-owner addresing.
const faceZoneMesh & faceZones() const
Return face zone mesh.
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.
virtual const labelList & faceOwner() const
Return face owner.
virtual const faceList & faces() const
Return raw faces.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
label nTotalCells() const
Return total number of cells in decomposed mesh.
label nInternalFaces() const
IOList< label > labelIOList
Label container classes.
const Time & time() const
Return the top-level database.
label size() const
Return the number of elements in the UPtrList.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.