55 #ifdef FOAM_USE_ZOLTAN
96 label diff = neighbour[facei] - owner[facei];
110 const bool calculateIntersect,
116 scalar& sumSqrIntersect
124 label own = owner[facei];
125 label nei = neighbour[facei];
129 cellBandwidth[nei] =
max(cellBandwidth[nei],
diff);
132 bandwidth =
max(cellBandwidth);
136 forAll(cellBandwidth, celli)
138 profile += 1.0*cellBandwidth[celli];
141 sumSqrIntersect = 0.0;
142 if (calculateIntersect)
146 for (
label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
148 nIntersect[colI] += 1.0;
173 forAll(cellOrder, newCelli)
175 label oldCelli = cellOrder[newCelli];
177 const cell& cFaces = mesh.
cells()[oldCelli];
184 label facei = cFaces[i];
190 if (nbrCelli == newCelli)
192 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
195 if (newCelli < nbrCelli)
219 if (nbr[index] != -1)
221 oldToNewFace[cFaces[index]] = newFacei++;
227 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
229 oldToNewFace[facei] = facei;
234 forAll(oldToNewFace, facei)
236 if (oldToNewFace[facei] == -1)
239 <<
"Did not determine new position" <<
" for face " << facei
263 label prevRegion = -1;
265 forAll(cellOrder, newCelli)
267 label oldCelli = cellOrder[newCelli];
269 if (cellToRegion[oldCelli] != prevRegion)
271 prevRegion = cellToRegion[oldCelli];
274 const cell& cFaces = mesh.
cells()[oldCelli];
280 label facei = cFaces[i];
286 if (nbrCelli == newCelli)
288 nbrCelli = reverseCellOrder[mesh.
faceOwner()[facei]];
291 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
296 else if (newCelli < nbrCelli)
320 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
326 label nRegions =
max(cellToRegion)+1;
336 if (ownRegion != neiRegion)
339 min(ownRegion, neiRegion)*nRegions
340 +
max(ownRegion, neiRegion);
349 label key = sortKey[i];
361 oldToNewFace[sortKey.indices()[i]] = newFacei++;
366 for (
label facei = newFacei; facei < mesh.
nFaces(); facei++)
368 oldToNewFace[facei] = facei;
373 forAll(oldToNewFace, facei)
375 if (oldToNewFace[facei] == -1)
378 <<
"Did not determine new position"
379 <<
" for face " << facei
421 forAll(newNeighbour, facei)
423 label own = newOwner[facei];
424 label nei = newNeighbour[facei];
428 newFaces[facei].flip();
429 Swap(newOwner[facei], newNeighbour[facei]);
430 flipFaceFlux.insert(facei);
450 NullObjectMove<pointField>(),
471 label oldFacei = fZone[i];
472 newAddressing[i] = reverseFaceOrder[oldFacei];
473 if (flipFaceFlux.found(newAddressing[i]))
475 newFlipMap[i] = !fZone.
flipMap()[i];
479 newFlipMap[i] = fZone.
flipMap()[i];
552 Info<<
"Determining cell order:" <<
endl;
556 label nRegions =
max(cellToRegion)+1;
562 forAll(regionToCells, regionI)
564 Info<<
" region " << regionI <<
" starts at " << celli <<
endl;
572 subsetter.setLargeCellSubset(cellToRegion, regionI);
574 const fvMesh& subMesh = subsetter.subMesh();
585 const labelList& cellMap = subsetter.cellMap();
589 cellOrder[celli++] = cellMap[subCellOrder[i]];
600 int main(
int argc,
char *argv[])
604 "Renumber mesh to minimise bandwidth"
614 "calculate the rms of the frontwidth"
619 "do not update fields"
627 #ifdef FOAM_USE_ZOLTAN
628 Info<<
"renumberMesh built with zoltan support." <<
nl <<
endl;
629 (void)zoltanRenumber::typeName;
645 scalar sumSqrIntersect;
669 <<
"Before renumbering :" <<
nl
670 <<
" band : " << band <<
nl
671 <<
" profile : " << profile <<
nl;
675 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
680 bool sortCoupledFaceCells =
false;
681 bool writeMaps =
false;
682 bool orderPoints =
false;
684 bool renumberSets =
true;
692 renumberDictPtr.
reset
696 const dictionary& renumberDict = renumberDictPtr();
702 "sortCoupledFaceCells",
705 if (sortCoupledFaceCells)
707 Info<<
"Sorting cells on coupled boundaries to be last." <<
nl
714 Info<<
"Ordering cells into regions of size " << blockSize
715 <<
" (using decomposition);"
716 <<
" ordering faces into region-internal and region-external."
719 if (blockSize < 0 || blockSize >= mesh.
nCells())
722 <<
"Block size " << blockSize
723 <<
" should be positive integer"
724 <<
" and less than the number of cells in the mesh."
732 Info<<
"Ordering points into internal and boundary points." <<
nl
736 renumberDict.
lookup(
"writeMaps") >> writeMaps;
739 Info<<
"Writing renumber maps (new to old) to polyMesh." <<
nl
747 Info<<
"Using default renumberMethod." <<
nl <<
endl;
752 Info<<
"Selecting renumberMethod " << renumberPtr().type() <<
nl <<
endl;
761 "cellProcAddressing",
774 "faceProcAddressing",
786 "pointProcAddressing",
818 Info<<
"nBlocks = " << nBlocks <<
endl;
821 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
822 decomposeDict.set(
"numberOfSubdomains", nBlocks);
834 decomposePtr().decompose
851 Info<<
nl <<
"Written decomposition as volScalarField::Internal to "
852 <<
"cellProc for use in postprocessing."
855 cellOrder = regionRenumber(renumberPtr(), mesh, cellToRegion);
858 faceOrder = getRegionFaceOrder
868 cellOrder = renumberPtr().renumber
874 if (sortCoupledFaceCells)
883 if (pbm[
patchi].coupled())
896 if (pbm[
patchi].coupled())
901 label celli = faceCells[i];
903 if (reverseCellOrder[celli] != -1)
905 bndCells[nBndCells] = celli;
906 bndCellMap[nBndCells++] = reverseCellOrder[celli];
907 reverseCellOrder[celli] = -1;
913 bndCellMap.setSize(nBndCells);
926 newReverseCellOrder[origCelli] = --sortedI;
929 Info<<
"Ordered all " << nBndCells <<
" cells with a coupled face"
930 <<
" to the end of the cell list, starting at " << sortedI
935 forAll(cellOrder, newCelli)
937 label origCelli = cellOrder[newCelli];
938 if (newReverseCellOrder[origCelli] == -1)
940 newReverseCellOrder[origCelli] = sortedI++;
950 faceOrder = getFaceOrder
984 pointOrderMap().pointMap()
989 pointOrderMap().reversePointMap(),
990 const_cast<labelList&
>(map().reversePointMap())
1001 cellProcAddressing.headerOk()
1002 && cellProcAddressing.size() == mesh.
nCells()
1005 Info<<
"Renumbering processor cell decomposition map "
1006 << cellProcAddressing.name() <<
endl;
1015 faceProcAddressing.headerOk()
1016 && faceProcAddressing.size() == mesh.
nFaces()
1019 Info<<
"Renumbering processor face decomposition map "
1020 << faceProcAddressing.name() <<
endl;
1031 label facei = iter.key();
1032 label masterFacei = faceProcAddressing[facei];
1034 faceProcAddressing[facei] = -masterFacei;
1036 if (masterFacei == 0)
1045 pointProcAddressing.headerOk()
1046 && pointProcAddressing.size() == mesh.
nPoints()
1049 Info<<
"Renumbering processor point decomposition map "
1050 << pointProcAddressing.name() <<
endl;
1060 if (map().hasMotionPoints())
1062 mesh.
setPoints(map().preMotionPoints());
1069 scalar sumSqrIntersect;
1091 Info<<
"After renumbering :" <<
nl
1092 <<
" band : " << band <<
nl
1093 <<
" profile : " << profile <<
nl;
1098 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1143 <<
" total : " << nTotPoints <<
nl
1144 <<
" internal: " << nTotIntPoints <<
nl
1145 <<
" boundary: " << nTotPoints-nTotIntPoints <<
nl
1147 <<
" total : " << nTotEdges <<
nl
1148 <<
" internal: " << nTotIntEdges <<
nl
1149 <<
" internal using 0 boundary points: "
1150 << nTotInt0Edges <<
nl
1151 <<
" internal using 1 boundary points: "
1152 << nTotInt1Edges-nTotInt0Edges <<
nl
1153 <<
" internal using 2 boundary points: "
1154 << nTotIntEdges-nTotInt1Edges <<
nl
1155 <<
" boundary: " << nTotEdges-nTotIntEdges <<
nl
1169 if (cellProcAddressing.headerOk())
1172 if (cellProcAddressing.size() == mesh.
nCells())
1174 cellProcAddressing.write();
1179 const fileName fName(cellProcAddressing.filePath());
1182 Info<<
"Deleting inconsistent processor cell decomposition"
1183 <<
" map " << fName <<
endl;
1189 if (faceProcAddressing.headerOk())
1192 if (faceProcAddressing.size() == mesh.
nFaces())
1194 faceProcAddressing.write();
1198 const fileName fName(faceProcAddressing.filePath());
1201 Info<<
"Deleting inconsistent processor face decomposition"
1202 <<
" map " << fName <<
endl;
1208 if (pointProcAddressing.headerOk())
1211 if (pointProcAddressing.size() == mesh.
nPoints())
1213 pointProcAddressing.write();
1217 const fileName fName(pointProcAddressing.filePath());
1220 Info<<
"Deleting inconsistent processor point decomposition"
1221 <<
" map " << fName <<
endl;
1244 Info<<
nl <<
"Written current cellID and origCellID as volScalarField"
1245 <<
" for use in postprocessing."
1307 Info<<
"Renumbering cellSets:" <<
endl;
1312 cs.topoChange(map());
1323 Info<<
"Renumbering faceSets:" <<
endl;
1328 fs.topoChange(map());
1339 Info<<
"Renumbering pointSets:" <<
endl;
1344 ps.topoChange(map());
Field reading functions for post-processing utilities.
#define forAll(list, i)
Loop across all elements in list.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Cuthill-McKee renumbering.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
List of IOobjects with searching and retrieving facilities.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
void size(const label)
Override size to be inconsistent with allocated storage.
void setSize(const label)
Reset size of List.
void clearAddressing()
Clear addressing.
A list that is sorted upon construction or when explicitly requested with the sort() method.
A List with indirect addressing.
static bool & parRun()
Is this a parallel run?
label size() const
Return the number of elements in the UPtrList.
static void addNote(const string &)
Add extra notes for the usage information.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void reset(T *=nullptr)
If object pointer already set, delete object and set to given.
A collection of cell labels.
A cell is defined as a list of faces with extra functionality.
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....
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
const word & name() const
Return const reference to name.
A subset of mesh faces organised as a primitive patch.
const boolList & flipMap() const
Return face flip map.
virtual void resetAddressing(const labelUList &, const boolList &)
Reset addressing and flip map (clearing demand-driven data)
A class for handling file names.
Post-processing mesh subset tool. Given the original mesh and the list of selected cells,...
Mesh data needed to do the Finite Volume discretisation.
const Time & time() const
Return the top-level database.
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
virtual void topoChange(const polyTopoChangeMap &map)
Update mesh corresponding to the given map.
virtual void setPoints(const pointField &)
Reset the points.
label nTotalCells() const
Return total number of cells in decomposed mesh.
Mesh consisting of general polyhedral cells.
const fileName & facesInstance() const
Return the current instance directory for faces.
const meshFaceZones & faceZones() const
Return face zones.
virtual const faceList & faces() const
Return raw faces.
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.
virtual const labelList & faceOwner() const
Return face owner.
const globalMeshData & globalData() const
Return parallel info.
const fileName & pointsInstance() const
Return the current instance directory for points.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
virtual const labelList & faceNeighbour() const
Return face neighbour.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void setInstance(const fileName &)
Set the instance for mesh files.
const meshCellZones & cellZones() const
Return cell zones.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Direct mesh changes based on v1.3 polyTopoChange syntax.
Cell-face mesh analysis engine.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
label nInternal1Edges() const
Internal edges using 0 or 1 boundary point.
const vectorField & cellCentres() const
virtual const labelList & faceOwner() const =0
Face face-owner addressing.
label nInternalFaces() const
label nInternal0Edges() const
Internal edges (i.e. not on boundary face) using.
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
virtual const labelList & faceNeighbour() const =0
Face face-neighbour addressing.
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
label nInternalPoints() const
Points not on boundary.
const cellList & cells() const
virtual bool write(const bool write=true) const
Write using setting from DB.
Abstract base class for renumbering.
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
static instantList select0(Time &runTime, const argList &args)
Return the set of times selected based on the argList options.
A class for handling words, derived from string.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
gmvFile<< "tracers "<< particles.size()<< nl;{ pointField positions(particles.size());label particlei=0;forAllConstIter(Cloud< passiveParticle >, particles, iter) { positions[particlei++]=iter().position(mesh);} for(i=0;i< pTraits< point >::nComponents;i++) { forAll(positions, particlei) { gmvFile<< component(positions[particlei], i)<< ' ';} gmvFile<< nl;}}forAll(lagrangianScalarNames, i){ const word &name=lagrangianScalarNames[i];IOField< scalar > fld(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const fvPatchList & patches
Info<< "Calculating turbulent flame speed field St\n"<< endl;volScalarField St(IOobject("St", runTime.name(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), flameWrinkling->Xi() *Su);multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
errorManipArg< error, int > exit(error &err, const int errNo=1)
List< label > labelList
A List of labels.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool rm(const fileName &)
Remove a file, returning true if successful otherwise false.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
int order(const scalar s)
errorManip< error > abort(error &err)
const dimensionSet dimless
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
vectorField pointField
pointField is a vectorField.
labelListList invertOneToMany(const label len, const labelUList &)
Invert one-to-many map. Unmapped elements will be size 0.
List< scalar > scalarList
A List of scalars.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
dimensionedScalar sqrt(const dimensionedScalar &ds)
List< labelList > labelListList
A List of labelList.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
IOList< label > labelIOList
Label container classes.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
ListType reorder(const labelUList &oldToNew, const ListType &)
Reorder the elements (indices, not values) of a list.
static const label labelMax
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
Foam::argList args(argc, argv)