86 auto&
fld = tfld.ref();
90 fld[celli] = elems[celli];
104 label
diff = neighbour[facei] - owner[facei];
118 const bool calculateIntersect,
124 scalar& sumSqrIntersect
132 label own = owner[facei];
133 label nei = neighbour[facei];
136 label
diff = nei-own;
137 cellBandwidth[nei] =
max(cellBandwidth[nei],
diff);
140 bandwidth =
max(cellBandwidth);
144 forAll(cellBandwidth, celli)
146 profile += 1.0*cellBandwidth[celli];
149 sumSqrIntersect = 0.0;
150 if (calculateIntersect)
154 for (label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
156 nIntersect[colI] += 1.0;
181 forAll(cellOrder, newCelli)
183 label oldCelli = cellOrder[newCelli];
192 label facei = cFaces[i];
198 if (nbrCelli == newCelli)
203 if (newCelli < nbrCelli)
223 for (
const label index : order)
225 if (nbr[index] != -1)
227 oldToNewFace[cFaces[index]] = newFacei++;
233 for (label facei = newFacei; facei <
mesh.
nFaces(); facei++)
235 oldToNewFace[facei] = facei;
240 forAll(oldToNewFace, facei)
242 if (oldToNewFace[facei] == -1)
245 <<
"Did not determine new position" <<
" for face " << facei
269 label prevRegion = -1;
271 forAll(cellOrder, newCelli)
273 label oldCelli = cellOrder[newCelli];
275 if (cellToRegion[oldCelli] != prevRegion)
277 prevRegion = cellToRegion[oldCelli];
286 label facei = cFaces[i];
292 if (nbrCelli == newCelli)
297 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
302 else if (newCelli < nbrCelli)
326 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
332 label nRegions =
max(cellToRegion)+1;
342 if (ownRegion != neiRegion)
345 min(ownRegion, neiRegion)*nRegions
346 +
max(ownRegion, neiRegion);
355 label
key = sortKey[i];
367 oldToNewFace[sortKey.indices()[i]] = newFacei++;
372 for (label facei = newFacei; facei <
mesh.
nFaces(); facei++)
374 oldToNewFace[facei] = facei;
379 forAll(oldToNewFace, facei)
381 if (oldToNewFace[facei] == -1)
384 <<
"Did not determine new position" 385 <<
" for face " << facei
427 forAll(newNeighbour, facei)
429 label own = newOwner[facei];
430 label nei = newNeighbour[facei];
434 newFaces[facei].flip();
435 std::swap(newOwner[facei], newNeighbour[facei]);
436 flipFaceFlux.insert(facei);
450 oldPatchNMeshPoints[patchi] =
patches[patchi].nPoints();
477 label oldFacei = fZone[i];
478 newAddressing[i] = reverseFaceOrder[oldFacei];
479 if (flipFaceFlux.found(newAddressing[i]))
481 newFlipMap[i] = !fZone.
flipMap()[i];
485 newFlipMap[i] = fZone.
flipMap()[i];
554 Info<<
"Determining cell order:" <<
endl;
558 label nRegions =
max(cellToRegion)+1;
564 forAll(regionToCells, regioni)
566 Info<<
" region " << regioni <<
" starts at " << celli <<
endl;
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 cells to reduce the bandwidth" 616 "Calculate the rms of the front-width" 628 Info<<
"renumberMesh built with zoltan support." <<
nl <<
endl;
629 (void)zoltanRenumber::typeName;
642 const bool readDict =
args.
found(
"dict");
643 const bool doFrontWidth =
args.
found(
"frontWidth");
644 const bool overwrite =
args.
found(
"overwrite");
656 scalar sumSqrIntersect;
681 <<
"Before renumbering :" <<
nl 682 <<
" band : " << band <<
nl 683 <<
" profile : " << profile <<
nl;
687 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
692 bool sortCoupledFaceCells =
false;
694 bool orderPoints =
false;
715 "sortCoupledFaceCells",
718 if (sortCoupledFaceCells)
720 Info<<
"Sorting cells on coupled boundaries to be last." <<
nl 727 Info<<
"Ordering cells into regions of size " << blockSize
728 <<
" (using decomposition);" 729 <<
" ordering faces into region-internal" 730 <<
" 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." 743 orderPoints = renumberDict.
getOrDefault(
"orderPoints",
false);
746 Info<<
"Ordering points into internal and boundary points." 754 Info<<
"Writing renumber maps (new to old) to polyMesh." <<
nl 760 Info<<
"Using default renumberMethod." <<
nl <<
endl;
765 Info<<
"Selecting renumberMethod " << renumberPtr().type() <<
nl 775 "cellProcAddressing",
789 "faceProcAddressing",
802 "pointProcAddressing",
815 "boundaryProcAddressing",
910 Info<<
"nBlocks = " << nBlocks <<
endl;
913 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
914 decomposeDict.set(
"numberOfSubdomains", nBlocks);
925 decomposePtr().decompose
943 Info<<
nl <<
"Written decomposition as volScalarField to " 944 <<
"cellDist for use in postprocessing." 948 cellOrder = regionRenumber(renumberPtr(),
mesh, cellToRegion);
951 faceOrder = getRegionFaceOrder
961 cellOrder = renumberPtr().renumber
967 if (sortCoupledFaceCells)
978 nBndCells +=
pbm[patchi].
size();
996 if (reverseCellOrder[celli] != -1)
998 bndCells[nBndCells] = celli;
999 bndCellMap[nBndCells++] =
1000 reverseCellOrder[celli];
1001 reverseCellOrder[celli] = -1;
1007 bndCellMap.setSize(nBndCells);
1018 label origCelli = bndCells[order[i]];
1019 newReverseCellOrder[origCelli] = --sortedI;
1022 Info<<
"Ordered all " << nBndCells
1023 <<
" cells with a coupled face" 1024 <<
" to the end of the cell list, starting at " << sortedI
1029 forAll(cellOrder, newCelli)
1031 label origCelli = cellOrder[newCelli];
1032 if (newReverseCellOrder[origCelli] == -1)
1034 newReverseCellOrder[origCelli] = sortedI++;
1044 faceOrder = getFaceOrder
1078 pointOrderMap().pointMap()
1083 pointOrderMap().reversePointMap(),
1084 const_cast<labelList&>(map().reversePointMap())
1093 if (cellProcAddressing.headerOk())
1097 Info<<
"Renumbering processor cell decomposition map " 1098 << cellProcAddressing.name() <<
endl;
1107 Info<<
"Not writing inconsistent processor cell decomposition" 1108 <<
" map " << cellProcAddressing.filePath() <<
endl;
1117 if (faceProcAddressing.headerOk())
1121 Info<<
"Renumbering processor face decomposition map " 1122 << faceProcAddressing.name() <<
endl;
1131 for (
const label facei : fff)
1133 label masterFacei = faceProcAddressing[facei];
1135 faceProcAddressing[facei] = -masterFacei;
1137 if (masterFacei == 0)
1140 <<
" masterFacei:" << masterFacei
1147 Info<<
"Not writing inconsistent processor face decomposition" 1148 <<
" map " << faceProcAddressing.filePath() <<
endl;
1157 if (pointProcAddressing.headerOk())
1161 Info<<
"Renumbering processor point decomposition map " 1162 << pointProcAddressing.name() <<
endl;
1171 Info<<
"Not writing inconsistent processor point decomposition" 1172 <<
" map " << pointProcAddressing.filePath() <<
endl;
1181 if (boundaryProcAddressing.headerOk())
1195 Info<<
"Not writing inconsistent processor patch decomposition" 1196 <<
" map " << boundaryProcAddressing.filePath() <<
endl;
1209 if (map().hasMotionPoints())
1218 scalar sumSqrIntersect;
1240 Info<<
"After renumbering :" <<
nl 1241 <<
" band : " << band <<
nl 1242 <<
" profile : " << profile <<
nl;
1247 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1292 <<
" total : " << nTotPoints <<
nl 1293 <<
" internal: " << nTotIntPoints <<
nl 1294 <<
" boundary: " << nTotPoints-nTotIntPoints <<
nl 1296 <<
" total : " << nTotEdges <<
nl 1297 <<
" internal: " << nTotIntEdges <<
nl 1298 <<
" internal using 0 boundary points: " 1299 << nTotInt0Edges <<
nl 1300 <<
" internal using 1 boundary points: " 1301 << nTotInt1Edges-nTotInt0Edges <<
nl 1302 <<
" internal using 2 boundary points: " 1303 << nTotIntEdges-nTotInt1Edges <<
nl 1304 <<
" boundary: " << nTotEdges-nTotIntEdges <<
nl 1338 refData.updateMesh(map());
1366 <<
"Written current cellID and origCellID as volScalarField" 1367 <<
" for use in postprocessing." <<
nl <<
endl;
static const word & zeroGradientType() noexcept
The type name for zeroGradient patch fields.
const polyBoundaryMesh & pbm
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited (ie. from ordered back to original cell label)...
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
static void addNote(const string ¬e)
Add extra notes for the usage information.
void size(const label n)
Older name for setAddressableSize.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1)
void clearAddressing()
Clear addressing.
wordList ReadFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh >> &fields, const bool syncPar=true, const bool readOldTime=false)
Read Geometric fields of templated type.
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
label nPoints() const noexcept
Number of mesh points.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
virtual const labelList & faceNeighbour() const
Return face neighbour.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
const word & name() const noexcept
Return the object name.
A list that is sorted upon construction or when explicitly requested with the sort() method...
Cell-face mesh analysis engine.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
constexpr char nl
The newline '\n' character (0x0a)
label start() const noexcept
The start label of boundary faces in the polyMesh face list.
UIndirectList< label > labelUIndList
UIndirectList of labels.
const word dictName("faMeshDefinition")
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
dimensionedScalar sqrt(const dimensionedScalar &ds)
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual void movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
static bool & parRun() noexcept
Test if this a parallel run.
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
void resetPrimitives(autoPtr< pointField > &&points, autoPtr< faceList > &&faces, autoPtr< labelList > &&owner, autoPtr< labelList > &&neighbour, const labelUList &patchSizes, const labelUList &patchStarts, const bool validBoundary=true)
Reset mesh primitive data. Assumes all patch info correct.
const cellList & cells() const
Field reading functions for post-processing utilities.
Ignore writing from objectRegistry::writeObject()
const dimensionSet dimless
Dimensionless.
Smooth ATC in cells next to a set of patches supplied by type.
label nFaces() const noexcept
Number of mesh faces.
T returnReduce(const T &value, const BinaryOp &bop, const int tag=UPstream::msgType(), const label comm=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
List< labelList > labelListList
List of labelList.
bool isInternalFace(const label faceIndex) const noexcept
Return true if given face label is internal to the mesh.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
#define forAll(list, i)
Loop across all elements in list.
label nInternal1Edges() const
Internal edges using 0 or 1 boundary point.
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect...
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Abstract base class for renumbering.
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
bool returnReduceAnd(const bool value, const label comm=UPstream::worldComm)
Perform logical (and) MPI Allreduce on a copy. Uses UPstream::reduceAnd.
vectorField pointField
pointField is a vectorField.
const fileName & pointsInstance() const
Return the current instance directory for points.
IOList< label > labelIOList
IO for a List of label.
void setSize(const label n)
Alias for resize()
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
labelList identity(const label len, label start=0)
Return an identity map of the given length with (map[i] == i), works like std::iota() but returning a...
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
A class for handling words, derived from Foam::string.
void sort(UList< T > &list)
Sort the list.
Cuthill-McKee renumbering.
label nInternalPoints() const noexcept
Points not on boundary.
label size() const noexcept
The number of entries in the list.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
virtual const labelList & faceOwner() const
Return face owner.
Reading is optional [identical to LAZY_READ].
virtual void resetAddressing(faceZone &&zn)
Move reset addressing and flip map from another zone.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
const globalMeshData & globalData() const
Return parallel info (demand-driven)
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
label nInternalFaces() const noexcept
Number of internal faces.
virtual const faceList & faces() const
Return raw faces.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const vectorField & cellCentres() const
errorManip< error > abort(error &err)
label nEdges() const
Number of mesh edges.
virtual bool write(const bool writeOnProc=true) const
Write mesh using IO settings from time.
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
static tmp< GeometricField< scalar, fvPatchField, volMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvPatchField< scalar >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
static word timeName(const scalar t, const int precision=precision_)
Return a time name for the given scalar time value formatted with the given precision.
const faceZoneMesh & faceZones() const noexcept
Return face zone mesh.
Holds a reference to the original mesh (the baseMesh) and optionally to a subset of that mesh (the su...
label nTotalCells() const noexcept
Return total number of cells in decomposed mesh.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
static autoPtr< decompositionMethod > New(const dictionary &decompDict, const word ®ionName="")
Return a reference to the selected decomposition method, optionally region-specific.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
instantList times() const
Search the case for valid time directories.
void setInstance(const fileName &instance, const IOobjectOption::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
const word & name() const
Return reference to name.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
label nCells() const noexcept
Number of mesh cells.
auto key(const Type &t) -> typename std::enable_if< std::is_enum< Type >::value, typename std::underlying_type< Type >::type >::type
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
A cell is defined as a list of faces with extra functionality.
Mesh data needed to do the Finite Volume discretisation.
A List with indirect addressing. Like IndirectList but does not store addressing. ...
Direct mesh changes based on v1.3 polyTopoChange syntax.
const polyBoundaryMesh & patches
Automatically write from objectRegistry::writeObject()
const cellZoneMesh & cellZones() const noexcept
Return cell zone mesh.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
const boolList & flipMap() const noexcept
Return face flip map.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Various for reading/decomposing/reconstructing/distributing refinement data.
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Mesh consisting of general polyhedral cells.
A subset of mesh faces organised as a primitive patch.
#define forAllReverse(list, i)
Reverse loop across all elements in list.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
List< label > labelList
A List of labels.
A class for managing temporary objects.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Foam::argList args(argc, argv)
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
Defines the attributes of an object for which implicit objectRegistry management is supported...
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels. Not implemented.
label nInternal0Edges() const
Internal edges (i.e. not on boundary face) using no boundary point.
static void writeMaps(Ostream &os, const word &key, const labelListList &maps)
Do not request registration (bool: false)
UIndirectList< bool > boolUIndList
UIndirectList of bools.
bool found(const word &optName) const
Return true if the named option is found.
static constexpr const zero Zero
Global zero (0)