94 zeroGradientFvPatchScalarField::typeName
101 fld[celli] = elems[celli];
115 label
diff = neighbour[facei] - owner[facei];
129 const bool calculateIntersect,
135 scalar& sumSqrIntersect
143 label own = owner[facei];
144 label nei = neighbour[facei];
147 label
diff = nei-own;
148 cellBandwidth[nei] =
max(cellBandwidth[nei],
diff);
151 bandwidth =
max(cellBandwidth);
155 forAll(cellBandwidth, celli)
157 profile += 1.0*cellBandwidth[celli];
160 sumSqrIntersect = 0.0;
161 if (calculateIntersect)
165 for (label colI = celli-cellBandwidth[celli]; colI <= celli; colI++)
167 nIntersect[colI] += 1.0;
192 forAll(cellOrder, newCelli)
194 label oldCelli = cellOrder[newCelli];
203 label facei = cFaces[i];
209 if (nbrCelli == newCelli)
214 if (newCelli < nbrCelli)
234 for (
const label index : order)
236 if (nbr[index] != -1)
238 oldToNewFace[cFaces[index]] = newFacei++;
244 for (label facei = newFacei; facei <
mesh.
nFaces(); facei++)
246 oldToNewFace[facei] = facei;
251 forAll(oldToNewFace, facei)
253 if (oldToNewFace[facei] == -1)
256 <<
"Did not determine new position" <<
" for face " << facei
280 label prevRegion = -1;
282 forAll(cellOrder, newCelli)
284 label oldCelli = cellOrder[newCelli];
286 if (cellToRegion[oldCelli] != prevRegion)
288 prevRegion = cellToRegion[oldCelli];
297 label facei = cFaces[i];
303 if (nbrCelli == newCelli)
308 if (cellToRegion[oldCelli] != cellToRegion[cellOrder[nbrCelli]])
313 else if (newCelli < nbrCelli)
337 oldToNewFace[cFaces[nbr.indices()[i]]] = newFacei++;
343 label nRegions =
max(cellToRegion)+1;
353 if (ownRegion != neiRegion)
356 min(ownRegion, neiRegion)*nRegions
357 +
max(ownRegion, neiRegion);
366 label
key = sortKey[i];
378 oldToNewFace[sortKey.indices()[i]] = newFacei++;
383 for (label facei = newFacei; facei <
mesh.
nFaces(); facei++)
385 oldToNewFace[facei] = facei;
390 forAll(oldToNewFace, facei)
392 if (oldToNewFace[facei] == -1)
395 <<
"Did not determine new position" 396 <<
" for face " << facei
438 forAll(newNeighbour, facei)
440 label own = newOwner[facei];
441 label nei = newNeighbour[facei];
445 newFaces[facei].flip();
446 std::swap(newOwner[facei], newNeighbour[facei]);
447 flipFaceFlux.insert(facei);
461 oldPatchNMeshPoints[patchi] =
patches[patchi].nPoints();
488 label oldFacei = fZone[i];
489 newAddressing[i] = reverseFaceOrder[oldFacei];
490 if (flipFaceFlux.found(newAddressing[i]))
492 newFlipMap[i] = !fZone.
flipMap()[i];
496 newFlipMap[i] = fZone.
flipMap()[i];
565 Info<<
"Determining cell order:" <<
endl;
569 label nRegions =
max(cellToRegion)+1;
575 forAll(regionToCells, regioni)
577 Info<<
" region " << regioni <<
" starts at " << celli <<
endl;
585 const fvMesh& subMesh = subsetter.subMesh();
596 const labelList& cellMap = subsetter.cellMap();
600 cellOrder[celli++] = cellMap[subCellOrder[i]];
611 int main(
int argc,
char *argv[])
615 "Renumber mesh cells to reduce the bandwidth" 627 "Calculate the rms of the front-width" 639 Info<<
"renumberMesh built with zoltan support." <<
nl <<
endl;
640 (void)zoltanRenumber::typeName;
653 const bool readDict =
args.
found(
"dict");
654 const bool doFrontWidth =
args.
found(
"frontWidth");
655 const bool overwrite =
args.
found(
"overwrite");
667 scalar sumSqrIntersect;
692 <<
"Before renumbering :" <<
nl 693 <<
" band : " << band <<
nl 694 <<
" profile : " << profile <<
nl;
698 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
703 bool sortCoupledFaceCells =
false;
705 bool orderPoints =
false;
726 "sortCoupledFaceCells",
729 if (sortCoupledFaceCells)
731 Info<<
"Sorting cells on coupled boundaries to be last." <<
nl 738 Info<<
"Ordering cells into regions of size " << blockSize
739 <<
" (using decomposition);" 740 <<
" ordering faces into region-internal" 741 <<
" and region-external." 744 if (blockSize < 0 || blockSize >=
mesh.
nCells())
747 <<
"Block size " << blockSize
748 <<
" should be positive integer" 749 <<
" and less than the number of cells in the mesh." 754 orderPoints = renumberDict.
getOrDefault(
"orderPoints",
false);
757 Info<<
"Ordering points into internal and boundary points." 765 Info<<
"Writing renumber maps (new to old) to polyMesh." <<
nl 771 Info<<
"Using default renumberMethod." <<
nl <<
endl;
776 Info<<
"Selecting renumberMethod " << renumberPtr().type() <<
nl 786 "cellProcAddressing",
800 "faceProcAddressing",
813 "pointProcAddressing",
826 "boundaryProcAddressing",
921 Info<<
"nBlocks = " << nBlocks <<
endl;
924 dictionary decomposeDict(renumberDictPtr().subDict(
"blockCoeffs"));
925 decomposeDict.set(
"numberOfSubdomains", nBlocks);
936 decomposePtr().decompose
954 Info<<
nl <<
"Written decomposition as volScalarField to " 955 <<
"cellDist for use in postprocessing." 959 cellOrder = regionRenumber(renumberPtr(),
mesh, cellToRegion);
962 faceOrder = getRegionFaceOrder
972 cellOrder = renumberPtr().renumber
978 if (sortCoupledFaceCells)
989 nBndCells += pbm[patchi].
size();
1007 if (reverseCellOrder[celli] != -1)
1009 bndCells[nBndCells] = celli;
1010 bndCellMap[nBndCells++] =
1011 reverseCellOrder[celli];
1012 reverseCellOrder[celli] = -1;
1018 bndCellMap.setSize(nBndCells);
1029 label origCelli = bndCells[order[i]];
1030 newReverseCellOrder[origCelli] = --sortedI;
1033 Info<<
"Ordered all " << nBndCells
1034 <<
" cells with a coupled face" 1035 <<
" to the end of the cell list, starting at " << sortedI
1040 forAll(cellOrder, newCelli)
1042 label origCelli = cellOrder[newCelli];
1043 if (newReverseCellOrder[origCelli] == -1)
1045 newReverseCellOrder[origCelli] = sortedI++;
1055 faceOrder = getFaceOrder
1089 pointOrderMap().pointMap()
1094 pointOrderMap().reversePointMap(),
1095 const_cast<labelList&>(map().reversePointMap())
1104 if (cellProcAddressing.headerOk())
1108 Info<<
"Renumbering processor cell decomposition map " 1109 << cellProcAddressing.name() <<
endl;
1118 Info<<
"Not writing inconsistent processor cell decomposition" 1119 <<
" map " << cellProcAddressing.filePath() <<
endl;
1128 if (faceProcAddressing.headerOk())
1132 Info<<
"Renumbering processor face decomposition map " 1133 << faceProcAddressing.name() <<
endl;
1142 for (
const label facei : fff)
1144 label masterFacei = faceProcAddressing[facei];
1146 faceProcAddressing[facei] = -masterFacei;
1148 if (masterFacei == 0)
1151 <<
" masterFacei:" << masterFacei
1158 Info<<
"Not writing inconsistent processor face decomposition" 1159 <<
" map " << faceProcAddressing.filePath() <<
endl;
1168 if (pointProcAddressing.headerOk())
1172 Info<<
"Renumbering processor point decomposition map " 1173 << pointProcAddressing.name() <<
endl;
1182 Info<<
"Not writing inconsistent processor point decomposition" 1183 <<
" map " << pointProcAddressing.filePath() <<
endl;
1192 if (boundaryProcAddressing.headerOk())
1206 Info<<
"Not writing inconsistent processor patch decomposition" 1207 <<
" map " << boundaryProcAddressing.filePath() <<
endl;
1220 if (map().hasMotionPoints())
1229 scalar sumSqrIntersect;
1251 Info<<
"After renumbering :" <<
nl 1252 <<
" band : " << band <<
nl 1253 <<
" profile : " << profile <<
nl;
1258 Info<<
" rms frontwidth : " << rmsFrontwidth <<
nl;
1303 <<
" total : " << nTotPoints <<
nl 1304 <<
" internal: " << nTotIntPoints <<
nl 1305 <<
" boundary: " << nTotPoints-nTotIntPoints <<
nl 1307 <<
" total : " << nTotEdges <<
nl 1308 <<
" internal: " << nTotIntEdges <<
nl 1309 <<
" internal using 0 boundary points: " 1310 << nTotInt0Edges <<
nl 1311 <<
" internal using 1 boundary points: " 1312 << nTotInt1Edges-nTotInt0Edges <<
nl 1313 <<
" internal using 2 boundary points: " 1314 << nTotIntEdges-nTotInt1Edges <<
nl 1315 <<
" boundary: " << nTotEdges-nTotIntEdges <<
nl 1349 refData.updateMesh(map());
1377 <<
"Written current cellID and origCellID as volScalarField" 1378 <<
" for use in postprocessing." <<
nl <<
endl;
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
List< labelList > labelListList
A List of labelList.
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.
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...
virtual bool write(const bool valid=true) const
Write mesh using IO settings from time.
Cell-face mesh analysis engine.
static const pointMesh & New(const polyMesh &mesh, Args &&... args)
Get existing or create a new MeshObject.
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.
bool coupled(solutionDict.getOrDefault("coupledEnergyField", false))
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.
const Time & time() const
Return the top-level database.
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.
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)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
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.
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 INVALID.
virtual void resetAddressing(const labelUList &addr, const bool flipMapValue)
Reset addressing - use uniform flip map value.
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)
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 elements in the list.
Foam::PtrList< Foam::fvMesh > meshes(regionNames.size())
virtual const labelList & faceOwner() const
Return face owner.
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.
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.
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 word timeName(const scalar t, const int precision=precision_)
Return time name of given scalar time 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.
UIndirectList< label > labelUIndList
UIndirectList of labels.
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)
UIndirectList< bool > boolUIndList
UIndirectList of bools.
bool found(const word &optName) const
Return true if the named option is found.
IOList< label > labelIOList
Label container classes.
static constexpr const zero Zero
Global zero (0)