92 label diff = neighbour[facei] - owner[facei];
106 const bool calculateIntersect,
112 scalar& sumSqrIntersect
120 label own = owner[facei];
121 label nei = neighbour[facei];
125 cellBandwidth[nei] =
max(cellBandwidth[nei],
diff);
128 bandwidth =
max(cellBandwidth);
132 forAll(cellBandwidth, celli)
134 profile += 1.0*cellBandwidth[celli];
137 sumSqrIntersect = 0.0;
138 if (calculateIntersect)
142 for (
label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
144 nIntersect[colI] += 1.0;
169 forAll(cellOrder, newCelli)
171 label oldCelli = cellOrder[newCelli];
180 label facei = cFaces[i];
186 if (nbrCelli == newCelli)
191 if (newCelli < nbrCelli)
215 if (nbr[index] != -1)
217 oldToNewFace[cFaces[index]] = newFacei++;
225 oldToNewFace[facei] = facei;
230 forAll(oldToNewFace, facei)
232 if (oldToNewFace[facei] == -1)
235 <<
"Did not determine new position" <<
" for face " << facei
259 label prevRegion = -1;
261 forAll(cellOrder, newCelli)
263 label oldCelli = cellOrder[newCelli];
265 if (cellToRegion[oldCelli] != prevRegion)
267 prevRegion = cellToRegion[oldCelli];
276 label facei = cFaces[i];
282 if (nbrCelli == newCelli)
287 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
292 else if (newCelli < nbrCelli)
316 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
322 label nRegions =
max(cellToRegion)+1;
332 if (ownRegion != neiRegion)
335 min(ownRegion, neiRegion)*nRegions
336 +
max(ownRegion, neiRegion);
345 label key = sortKey[i];
357 oldToNewFace[sortKey.indices()[i]] = newFacei++;
364 oldToNewFace[facei] = facei;
369 forAll(oldToNewFace, facei)
371 if (oldToNewFace[facei] == -1)
374 <<
"Did not determine new position"
375 <<
" for face " << facei
417 forAll(newNeighbour, facei)
419 label own = newOwner[facei];
420 label nei = newNeighbour[facei];
424 newFaces[facei].flip();
425 Swap(newOwner[facei], newNeighbour[facei]);
426 flipFaceFlux.insert(facei);
446 NullObjectMove<pointField>(),
470 move(reverseFaceOrder),
471 move(reverseCellOrder),
476 move(oldPatchNMeshPoints),
491 Info<<
"Determining cell order:" <<
endl;
495 label nRegions =
max(cellToRegion)+1;
501 forAll(regionToCells, regionI)
503 Info<<
" region " << regionI <<
" starts at " << celli <<
endl;
511 subsetter.setLargeCellSubset(cellToRegion, regionI);
513 const fvMesh& subMesh = subsetter.subMesh();
524 const labelList& cellMap = subsetter.cellMap();
528 cellOrder[celli++] = cellMap[subCellOrder[i]];
539 int main(
int argc,
char *argv[])
543 "Renumber mesh to minimise bandwidth"
554 "calculate the rms of the frontwidth"
559 "do not update fields"
578 scalar sumSqrIntersect;
602 <<
"Before renumbering :" <<
nl
603 <<
" band : " << band <<
nl
604 <<
" profile : " << profile <<
nl;
608 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
613 bool sortCoupledFaceCells =
false;
614 bool writeMaps =
false;
615 bool orderPoints =
false;
617 bool renumberSets =
true;
625 renumberDictPtr.
reset
629 const dictionary& renumberDict = renumberDictPtr();
635 "sortCoupledFaceCells",
638 if (sortCoupledFaceCells)
640 Info<<
"Sorting cells on coupled boundaries to be last." <<
nl
647 Info<<
"Ordering cells into regions of size " << blockSize
648 <<
" (using decomposition);"
649 <<
" ordering faces into region-internal and region-external."
652 if (blockSize < 0 || blockSize >=
mesh.
nCells())
655 <<
"Block size " << blockSize
656 <<
" should be positive integer"
657 <<
" and less than the number of cells in the mesh."
665 Info<<
"Ordering points into internal and boundary points." <<
nl
669 renumberDict.
lookup(
"writeMaps") >> writeMaps;
672 Info<<
"Writing renumber maps (new to old) to polyMesh." <<
nl
680 Info<<
"Using default renumberMethod." <<
nl <<
endl;
684 Info<<
"Selecting renumberMethod " << renumberPtr().type() <<
nl <<
endl;
692 "cellProcAddressing",
705 "faceProcAddressing",
717 "pointProcAddressing",
766 Info<<
"nBlocks = " << nBlocks <<
endl;
769 dictionary decomposeDict(renumberDictPtr().typeDict(
"block"));
770 decomposeDict.set(
"numberOfSubdomains", nBlocks);
782 decomposePtr().decompose
799 Info<<
nl <<
"Written decomposition as volScalarField::Internal to "
800 <<
"cellProc for use in postprocessing."
803 cellOrder = regionRenumber(renumberPtr(),
mesh, cellToRegion);
806 faceOrder = getRegionFaceOrder
816 cellOrder = renumberPtr().renumber
822 if (sortCoupledFaceCells)
831 if (pbm[
patchi].coupled())
844 if (pbm[
patchi].coupled())
849 label celli = faceCells[i];
851 if (reverseCellOrder[celli] != -1)
853 bndCells[nBndCells] = celli;
854 bndCellMap[nBndCells++] = reverseCellOrder[celli];
855 reverseCellOrder[celli] = -1;
861 bndCellMap.setSize(nBndCells);
874 newReverseCellOrder[origCelli] = --sortedI;
877 Info<<
"Ordered all " << nBndCells <<
" cells with a coupled face"
878 <<
" to the end of the cell list, starting at " << sortedI
883 forAll(cellOrder, newCelli)
885 label origCelli = cellOrder[newCelli];
886 if (newReverseCellOrder[origCelli] == -1)
888 newReverseCellOrder[origCelli] = sortedI++;
898 faceOrder = getFaceOrder
931 pointOrderMap().pointMap()
936 pointOrderMap().reversePointMap(),
937 const_cast<labelList&
>(map().reversePointMap())
949 cellProcAddressing.headerOk()
953 Info<<
"Renumbering processor cell decomposition map "
954 << cellProcAddressing.name() <<
endl;
963 faceProcAddressing.headerOk()
967 Info<<
"Renumbering processor face decomposition map "
968 << faceProcAddressing.name() <<
endl;
979 label facei = iter.key();
980 label masterFacei = faceProcAddressing[facei];
982 faceProcAddressing[facei] = -masterFacei;
984 if (masterFacei == 0)
993 pointProcAddressing.headerOk()
997 Info<<
"Renumbering processor point decomposition map "
998 << pointProcAddressing.name() <<
endl;
1010 scalar sumSqrIntersect;
1032 Info<<
"After renumbering :" <<
nl
1033 <<
" band : " << band <<
nl
1034 <<
" profile : " << profile <<
nl;
1039 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1085 <<
" total : " << nTotPoints <<
nl
1086 <<
" internal: " << nTotIntPoints <<
nl
1087 <<
" boundary: " << nTotPoints-nTotIntPoints <<
nl
1089 <<
" total : " << nTotEdges <<
nl
1090 <<
" internal: " << nTotIntEdges <<
nl
1091 <<
" internal using 0 boundary points: "
1092 << nTotInt0Edges <<
nl
1093 <<
" internal using 1 boundary points: "
1094 << nTotInt1Edges-nTotInt0Edges <<
nl
1095 <<
" internal using 2 boundary points: "
1096 << nTotIntEdges-nTotInt1Edges <<
nl
1097 <<
" boundary: " << nTotEdges-nTotIntEdges <<
nl
1111 refData.topoChange(map);
1114 if (cellProcAddressing.headerOk())
1117 if (cellProcAddressing.size() ==
mesh.
nCells())
1119 cellProcAddressing.write();
1124 const fileName fName(cellProcAddressing.filePath());
1127 Info<<
"Deleting inconsistent processor cell decomposition"
1128 <<
" map " << fName <<
endl;
1134 if (faceProcAddressing.headerOk())
1137 if (faceProcAddressing.size() ==
mesh.
nFaces())
1139 faceProcAddressing.write();
1143 const fileName fName(faceProcAddressing.filePath());
1146 Info<<
"Deleting inconsistent processor face decomposition"
1147 <<
" map " << fName <<
endl;
1153 if (pointProcAddressing.headerOk())
1158 pointProcAddressing.write();
1162 const fileName fName(pointProcAddressing.filePath());
1165 Info<<
"Deleting inconsistent processor point decomposition"
1166 <<
" map " << fName <<
endl;
1189 Info<<
nl <<
"Written current cellID and origCellID as volScalarField"
1190 <<
" for use in postprocessing."
1252 Info<<
"Renumbering cellSets:" <<
endl;
1257 cs.topoChange(map());
1268 Info<<
"Renumbering faceSets:" <<
endl;
1273 fs.topoChange(map());
1284 Info<<
"Renumbering pointSets:" <<
endl;
1289 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.
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 keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
T lookupOrDefault(const word &, const T &) const
Find and return a T, if not found return the given default.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
static const dictionary null
Null dictionary.
const word & name() const
Return const reference to name.
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.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
const word & name() const
Return reference to name.
virtual void topoChange(const polyTopoChangeMap &map)
Update mesh corresponding to the given map.
const polyMesh & poly() const
Return reference to polyMesh.
label nTotalCells() const
Return total number of cells in decomposed mesh.
Various for reading/decomposing/reconstructing/distributing refinement data.
Mesh consisting of general polyhedral cells.
const fileName & facesInstance() const
Return the current instance directory for faces.
const polyBoundaryMesh & boundary() const
Return boundary mesh.
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.
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.
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.
label nInternal1Edges() const
Internal edges using 0 or 1 boundary point.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
label nInternalPoints() const
Points not on boundary.
label nInternalFaces() const
const vectorField & cellCentres() const
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
const cellList & cells() const
label nInternal0Edges() const
Internal edges (i.e. not on boundary face) using.
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.
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#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(lagrangian::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(), lagrangian::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)
const dimensionSet & dimless
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList invert(const label len, const labelUList &)
Invert one-to-one map. Unmapped elements will be -1.
String typeName(const std::type_info &info)
Return the un-mangled name given the standard type info.
int order(const scalar s)
errorManip< error > abort(error &err)
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
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.
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
ListType reorder(const label size, const typename ListType::value_type &defaultValue, const labelUList &oldToNew, const ListType &lst)
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.
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
IOList< label > labelIOList
Label container classes.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
static const label labelMax
labelList identityMap(const label len)
Create identity map (map[i] == i) of given length.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion, const fileName &path=fileName::null)
void sortedOrder(const UList< T > &, labelList &order)
Generate the (stable) sort order for the list.
void sqrt(LagrangianPatchField< scalar > &f, const LagrangianPatchField< scalar > &f1)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
Foam::argList args(argc, argv)