Go to the documentation of this file.
92 zeroGradientFvPatchScalarField::typeName
99 fld[celli] = elems[celli];
113 label
diff = neighbour[facei] - owner[facei];
127 const bool calculateIntersect,
133 scalar& sumSqrIntersect
141 label own = owner[facei];
142 label nei = neighbour[facei];
145 label
diff = nei-own;
146 cellBandwidth[nei] =
max(cellBandwidth[nei],
diff);
149 bandwidth =
max(cellBandwidth);
153 forAll(cellBandwidth, celli)
155 profile += 1.0*cellBandwidth[celli];
158 sumSqrIntersect = 0.0;
159 if (calculateIntersect)
163 for (label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
165 nIntersect[colI] += 1.0;
190 forAll(cellOrder, newCelli)
192 label oldCelli = cellOrder[newCelli];
201 label facei = cFaces[i];
207 if (nbrCelli == newCelli)
212 if (newCelli < nbrCelli)
232 for (
const label index : order)
234 if (nbr[index] != -1)
236 oldToNewFace[cFaces[index]] = newFacei++;
242 for (label facei = newFacei; facei <
mesh.
nFaces(); facei++)
244 oldToNewFace[facei] = facei;
249 forAll(oldToNewFace, facei)
251 if (oldToNewFace[facei] == -1)
254 <<
"Did not determine new position" <<
" for face " << facei
278 label prevRegion = -1;
280 forAll(cellOrder, newCelli)
282 label oldCelli = cellOrder[newCelli];
284 if (cellToRegion[oldCelli] != prevRegion)
286 prevRegion = cellToRegion[oldCelli];
295 label facei = cFaces[i];
301 if (nbrCelli == newCelli)
306 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
311 else if (newCelli < nbrCelli)
335 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
341 label nRegions =
max(cellToRegion)+1;
351 if (ownRegion != neiRegion)
354 min(ownRegion, neiRegion)*nRegions
355 +
max(ownRegion, neiRegion);
364 label key = sortKey[i];
376 oldToNewFace[sortKey.indices()[i]] = newFacei++;
381 for (label facei = newFacei; facei <
mesh.
nFaces(); facei++)
383 oldToNewFace[facei] = facei;
388 forAll(oldToNewFace, facei)
390 if (oldToNewFace[facei] == -1)
393 <<
"Did not determine new position"
394 <<
" for face " << facei
436 forAll(newNeighbour, facei)
438 label own = newOwner[facei];
439 label nei = newNeighbour[facei];
443 newFaces[facei].flip();
444 Swap(newOwner[facei], newNeighbour[facei]);
445 flipFaceFlux.insert(facei);
457 patchSizes[patchi] =
patches[patchi].size();
459 oldPatchNMeshPoints[patchi] =
patches[patchi].nPoints();
486 label oldFacei = fZone[i];
487 newAddressing[i] = reverseFaceOrder[oldFacei];
488 if (flipFaceFlux.found(newAddressing[i]))
490 newFlipMap[i] = !fZone.
flipMap()[i];
494 newFlipMap[i] = fZone.
flipMap()[i];
563 Info<<
"Determining cell order:" <<
endl;
565 labelList cellOrder(cellToRegion.size());
567 label nRegions =
max(cellToRegion)+1;
573 forAll(regionToCells, regioni)
575 Info<<
" region " << regioni <<
" starts at " << celli <<
endl;
584 const fvMesh& subMesh = subsetter.subMesh();
595 const labelList& cellMap = subsetter.cellMap();
599 cellOrder[celli++] = cellMap[subCellOrder[i]];
610 int main(
int argc,
char *argv[])
614 "Renumber mesh cells to reduce the bandwidth"
626 "Calculate the rms of the front-width"
638 Info<<
"renumberMesh built with zoltan support." <<
nl <<
endl;
639 (void)zoltanRenumber::typeName;
655 const bool readDict =
args.
found(
"dict");
656 const bool doFrontWidth =
args.
found(
"frontWidth");
657 const bool overwrite =
args.
found(
"overwrite");
661 scalar sumSqrIntersect;
685 <<
"Before renumbering :" <<
nl
686 <<
" band : " << band <<
nl
687 <<
" profile : " << profile <<
nl;
691 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
696 bool sortCoupledFaceCells =
false;
697 bool writeMaps =
false;
698 bool orderPoints =
false;
719 "sortCoupledFaceCells",
722 if (sortCoupledFaceCells)
724 Info<<
"Sorting cells on coupled boundaries to be last." <<
nl
731 Info<<
"Ordering cells into regions of size " << blockSize
732 <<
" (using decomposition);"
733 <<
" ordering faces into region-internal and region-external."
736 if (blockSize < 0 || blockSize >=
mesh.
nCells())
739 <<
"Block size " << blockSize
740 <<
" should be positive integer"
741 <<
" and less than the number of cells in the mesh."
746 orderPoints = renumberDict.
getOrDefault(
"orderPoints",
false);
749 Info<<
"Ordering points into internal and boundary points." <<
nl
753 renumberDict.
readEntry(
"writeMaps", writeMaps);
756 Info<<
"Writing renumber maps (new to old) to polyMesh." <<
nl
762 Info<<
"Using default renumberMethod." <<
nl <<
endl;
767 Info<<
"Selecting renumberMethod " << renumberPtr().type() <<
nl <<
endl;
776 "cellProcAddressing",
790 "faceProcAddressing",
803 "pointProcAddressing",
816 "boundaryProcAddressing",
911 Info<<
"nBlocks = " << nBlocks <<
endl;
914 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
915 decomposeDict.set(
"numberOfSubdomains", nBlocks);
927 decomposePtr().decompose
945 Info<<
nl <<
"Written decomposition as volScalarField to "
946 <<
"cellDist for use in postprocessing."
950 cellOrder = regionRenumber(renumberPtr(),
mesh, cellToRegion);
953 faceOrder = getRegionFaceOrder
963 cellOrder = renumberPtr().renumber
969 if (sortCoupledFaceCells)
978 if (pbm[patchi].coupled())
980 nBndCells += pbm[patchi].size();
991 if (pbm[patchi].coupled())
998 if (reverseCellOrder[celli] != -1)
1000 bndCells[nBndCells] = celli;
1001 bndCellMap[nBndCells++] = reverseCellOrder[celli];
1002 reverseCellOrder[celli] = -1;
1008 bndCellMap.setSize(nBndCells);
1019 label origCelli = bndCells[order[i]];
1020 newReverseCellOrder[origCelli] = --sortedI;
1023 Info<<
"Ordered all " << nBndCells <<
" 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())
1095 bool localOk = (cellProcAddressing.size() ==
mesh.
nCells());
1099 Info<<
"Renumbering processor cell decomposition map "
1100 << cellProcAddressing.name() <<
endl;
1109 Info<<
"Not writing inconsistent processor cell decomposition"
1110 <<
" map " << cellProcAddressing.filePath() <<
endl;
1125 Info<<
"Renumbering processor face decomposition map "
1135 for (
const label facei : fff)
1141 if (masterFacei == 0)
1150 Info<<
"Not writing inconsistent processor face decomposition"
1160 if (pointProcAddressing.headerOk())
1162 bool localOk = (pointProcAddressing.size() ==
mesh.
nPoints());
1166 Info<<
"Renumbering processor point decomposition map "
1167 << pointProcAddressing.name() <<
endl;
1176 Info<<
"Not writing inconsistent processor point decomposition"
1177 <<
" map " << pointProcAddressing.filePath() <<
endl;
1186 if (boundaryProcAddressing.headerOk())
1190 boundaryProcAddressing.size()
1199 Info<<
"Not writing inconsistent processor patch decomposition"
1200 <<
" map " << boundaryProcAddressing.filePath() <<
endl;
1213 if (map().hasMotionPoints())
1222 scalar sumSqrIntersect;
1244 Info<<
"After renumbering :" <<
nl
1245 <<
" band : " << band <<
nl
1246 <<
" profile : " << profile <<
nl;
1251 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1296 <<
" total : " << nTotPoints <<
nl
1297 <<
" internal: " << nTotIntPoints <<
nl
1298 <<
" boundary: " << nTotPoints-nTotIntPoints <<
nl
1300 <<
" total : " << nTotEdges <<
nl
1301 <<
" internal: " << nTotIntEdges <<
nl
1302 <<
" internal using 0 boundary points: "
1303 << nTotInt0Edges <<
nl
1304 <<
" internal using 1 boundary points: "
1305 << nTotInt1Edges-nTotInt0Edges <<
nl
1306 <<
" internal using 2 boundary points: "
1307 << nTotIntEdges-nTotInt1Edges <<
nl
1308 <<
" boundary: " << nTotEdges-nTotIntEdges <<
nl
1342 refData.updateMesh(map());
1369 Info<<
nl <<
"Written current cellID and origCellID as volScalarField"
1370 <<
" for use in postprocessing."
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
List< label > labelList
A List of labels.
vectorField pointField
pointField is a vectorField.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
PtrList< labelIOList > & faceProcAddressing
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
const word & name() const
Return name.
A class for handling words, derived from Foam::string.
label nInternal0Edges() const
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
T returnReduce(const T &Value, const BinaryOp &bop, const int tag=Pstream::msgType(), const label comm=UPstream::worldComm)
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
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.
Given the original mesh and the list of selected cells, it creates the mesh consisting only of the de...
static constexpr const zero Zero
Global zero (0)
label nInternalFaces() const
Number of internal faces.
label nFaces() const
Number of mesh faces.
virtual void resetAddressing(const labelUList &addr, const bool flipMapValue)
Reset addressing - use uniform flip map value.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static bool & parRun()
Is this a parallel run?
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
static word timeName(const scalar t, const int precision=precision_)
const cellList & cells() const
Direct mesh changes based on v1.3 polyTopoChange syntax.
label nTotalCells() const
Return total number of cells in decomposed mesh.
static void addNote(const string ¬e)
Add extra notes for the usage information.
const word dictName("blockMeshDict")
label nEdges() const
Number of mesh edges.
const fileName & facesInstance() const
Return the current instance directory for faces.
const cellZoneMesh & cellZones() const
Return cell zone mesh.
label nInternal1Edges() const
Internal edges using 0 or 1 boundary point.
virtual tmp< scalarField > movePoints(const pointField &)
Move points, returns volumes swept by faces in motion.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const edgeList & edges() const
Return mesh edges. Uses calcEdges.
IOList< label > labelIOList
Label container classes.
void Swap(DynamicList< T, SizeMin1 > &a, DynamicList< T, SizeMin2 > &b)
label start() const
The start label of the boundary faces in the polyMesh face list.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
labelList invert(const label len, const labelUList &map)
Create an inverse one-to-one mapping.
void inplaceRenumber(const labelUList &oldToNew, IntListType &input)
Inplace renumber the values (not the indices) of a list.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
const faceZoneMesh & faceZones() const
Return face zone mesh.
scalar diff(const triad &A, const triad &B)
Return a quantity of the difference between two triads.
const fileName & pointsInstance() const
Return the current instance directory for points.
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
void reduce(const List< UPstream::commsStruct > &comms, T &Value, const BinaryOp &bop, const int tag, const label comm)
static void noFunctionObjects(bool addWithOption=false)
Remove '-noFunctionObjects' option and ignore any occurrences.
label nCells() const
Number of mesh cells.
virtual void updateMesh(const mapPolyMesh &morphMap)
Update any stored data for new labels. Not implemented.
UIndirectList< bool > boolUIndList
UIndirectList of bools.
A subset of mesh faces organised as a primitive patch.
messageStream Info
Information stream (uses stdout - output is on the master only)
word name(const complex &c)
Return string representation of complex.
label nInternalEdges() const
Internal edges using 0,1 or 2 boundary points.
virtual const labelList & faceOwner() const
Return face owner.
instantList times() const
Search the case for valid time directories.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
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.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
ListType reorder(const labelUList &oldToNew, const ListType &input, const bool prune=false)
Reorder the elements of a list.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
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))
Various for reading/decomposing/reconstructing/distributing refinement data.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
A list that is sorted upon construction or when explicitly requested with the sort() method.
Mesh data needed to do the Finite Volume discretisation.
errorManip< error > abort(error &err)
List of IOobjects with searching and retrieving facilities.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Abstract base class for renumbering.
static void addBoolOption(const word &optName, const string &usage="", bool advanced=false)
Add a bool option to validOptions with usage information.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
List< labelList > labelListList
A List of labelList.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
const vectorField & cellCentres() const
virtual const faceList & faces() const
Return raw faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Field reading functions for post-processing utilities.
dimensionedScalar sqrt(const dimensionedScalar &ds)
bool isInternalFace(const label faceIndex) const
Return true if given face label is internal to the mesh.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
static void removeFiles(const polyMesh &mesh)
Helper: remove all procAddressing files from mesh instance.
label nPoints() const
Number of mesh points.
labelList identity(const label len, label start=0)
Create identity map of the given length with (map[i] == i)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const polyBoundaryMesh & patches
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
#define forAllReverse(list, i)
Reverse loop across all elements in list.
const Time & time() const
Return the top-level database.
A List with indirect addressing.
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
labelList sortedOrder(const UList< T > &input)
Return the (stable) sort order for the list.
void clearAddressing()
Clear addressing.
const globalMeshData & globalData() const
Return parallel info.
void setSize(const label newSize)
Alias for resize(const label)
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
label nInternalPoints() const
Points not on boundary.
Cuthill-McKee renumbering.
static void addOption(const word &optName, const string ¶m="", const string &usage="", bool advanced=false)
Add an option to validOptions with usage information.
Foam::argList args(argc, argv)
labelListList invertOneToMany(const label len, const labelUList &map)
Invert one-to-many map. Unmapped elements will be size 0.
const boolList & flipMap() const
Return face flip map.
A cell is defined as a list of faces with extra functionality.
Smooth ATC in cells next to a set of patches supplied by type.
void setInstance(const fileName &instance, const IOobject::writeOption wOpt=IOobject::AUTO_WRITE)
Set the instance for mesh files.
virtual const labelList & faceNeighbour() const
Return face neighbour.
static autoPtr< decompositionMethod > New(const dictionary &decompDict)
Return a reference to the selected decomposition method.
bool found(const word &optName) const
Return true if the named option is found.
UIndirectList< label > labelUIndList
UIndirectList of labels.
Cell-face mesh analysis engine.