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;
693 "cellProcAddressing",
706 "faceProcAddressing",
718 "pointProcAddressing",
767 Info<<
"nBlocks = " << nBlocks <<
endl;
770 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
771 decomposeDict.set(
"numberOfSubdomains", nBlocks);
783 decomposePtr().decompose
800 Info<<
nl <<
"Written decomposition as volScalarField::Internal to "
801 <<
"cellProc for use in postprocessing."
804 cellOrder = regionRenumber(renumberPtr(),
mesh, cellToRegion);
807 faceOrder = getRegionFaceOrder
817 cellOrder = renumberPtr().renumber
823 if (sortCoupledFaceCells)
832 if (pbm[
patchi].coupled())
845 if (pbm[
patchi].coupled())
850 label celli = faceCells[i];
852 if (reverseCellOrder[celli] != -1)
854 bndCells[nBndCells] = celli;
855 bndCellMap[nBndCells++] = reverseCellOrder[celli];
856 reverseCellOrder[celli] = -1;
862 bndCellMap.setSize(nBndCells);
875 newReverseCellOrder[origCelli] = --sortedI;
878 Info<<
"Ordered all " << nBndCells <<
" cells with a coupled face"
879 <<
" to the end of the cell list, starting at " << sortedI
884 forAll(cellOrder, newCelli)
886 label origCelli = cellOrder[newCelli];
887 if (newReverseCellOrder[origCelli] == -1)
889 newReverseCellOrder[origCelli] = sortedI++;
899 faceOrder = getFaceOrder
932 pointOrderMap().pointMap()
937 pointOrderMap().reversePointMap(),
938 const_cast<labelList&
>(map().reversePointMap())
950 cellProcAddressing.headerOk()
954 Info<<
"Renumbering processor cell decomposition map "
955 << cellProcAddressing.name() <<
endl;
964 faceProcAddressing.headerOk()
968 Info<<
"Renumbering processor face decomposition map "
969 << faceProcAddressing.name() <<
endl;
980 label facei = iter.key();
981 label masterFacei = faceProcAddressing[facei];
983 faceProcAddressing[facei] = -masterFacei;
985 if (masterFacei == 0)
994 pointProcAddressing.headerOk()
998 Info<<
"Renumbering processor point decomposition map "
999 << pointProcAddressing.name() <<
endl;
1011 scalar sumSqrIntersect;
1033 Info<<
"After renumbering :" <<
nl
1034 <<
" band : " << band <<
nl
1035 <<
" profile : " << profile <<
nl;
1040 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1086 <<
" total : " << nTotPoints <<
nl
1087 <<
" internal: " << nTotIntPoints <<
nl
1088 <<
" boundary: " << nTotPoints-nTotIntPoints <<
nl
1090 <<
" total : " << nTotEdges <<
nl
1091 <<
" internal: " << nTotIntEdges <<
nl
1092 <<
" internal using 0 boundary points: "
1093 << nTotInt0Edges <<
nl
1094 <<
" internal using 1 boundary points: "
1095 << nTotInt1Edges-nTotInt0Edges <<
nl
1096 <<
" internal using 2 boundary points: "
1097 << nTotIntEdges-nTotInt1Edges <<
nl
1098 <<
" boundary: " << nTotEdges-nTotIntEdges <<
nl
1112 refData.topoChange(map);
1115 if (cellProcAddressing.headerOk())
1118 if (cellProcAddressing.size() ==
mesh.
nCells())
1120 cellProcAddressing.write();
1125 const fileName fName(cellProcAddressing.filePath());
1128 Info<<
"Deleting inconsistent processor cell decomposition"
1129 <<
" map " << fName <<
endl;
1135 if (faceProcAddressing.headerOk())
1138 if (faceProcAddressing.size() ==
mesh.
nFaces())
1140 faceProcAddressing.write();
1144 const fileName fName(faceProcAddressing.filePath());
1147 Info<<
"Deleting inconsistent processor face decomposition"
1148 <<
" map " << fName <<
endl;
1154 if (pointProcAddressing.headerOk())
1159 pointProcAddressing.write();
1163 const fileName fName(pointProcAddressing.filePath());
1166 Info<<
"Deleting inconsistent processor point decomposition"
1167 <<
" map " << fName <<
endl;
1190 Info<<
nl <<
"Written current cellID and origCellID as volScalarField"
1191 <<
" for use in postprocessing."
1253 Info<<
"Renumbering cellSets:" <<
endl;
1258 cs.topoChange(map());
1269 Info<<
"Renumbering faceSets:" <<
endl;
1274 fs.topoChange(map());
1285 Info<<
"Renumbering pointSets:" <<
endl;
1290 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.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrDefault(const word &, const T &, const bool writeDefault=writeOptionalEntries > 0) const
Find and return a T, if not found return the given default.
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.
virtual bool write(const bool write=true) const
Write mesh using IO settings from time.
const word & name() const
Return reference to name.
virtual void topoChange(const polyTopoChangeMap &map)
Update mesh corresponding to the given map.
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.
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.
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)
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.
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.
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)
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.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
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)
void sqr(LagrangianPatchField< typename outerProduct< Type, Type >::type > &f, const LagrangianPatchField< Type > &f1)
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)
Foam::argList args(argc, argv)