55 const label masterMeshProcStart,
56 const label masterMeshProcEnd,
58 const label meshToAddProcStart,
59 const label meshToAddProcEnd,
77 label masterProci = masterMeshProcStart;
78 masterProci < masterMeshProcEnd;
84 label addProci = meshToAddProcStart;
85 addProci < meshToAddProcEnd;
89 const word masterToAddName
91 "procBoundary" +
name(masterProci) +
"to" +
name(addProci)
93 const word addToMasterName
95 "procBoundary" +
name(addProci) +
"to" +
name(masterProci)
98 const label masterToAddID =
100 const label addToMasterID =
103 if (masterToAddID != -1 && addToMasterID != -1)
105 const polyPatch& masterPp = masterPatches[masterToAddID];
109 masterFaces.append(masterPp.
start() + i);
112 const polyPatch& addPp = addPatches[addToMasterID];
116 addFaces.append(addPp.
start() + i);
120 if ((masterToAddID != -1) != (addToMasterID != -1))
122 const label foundProci =
123 masterToAddID != -1 ? masterProci : addProci;
124 const word& foundName =
125 masterToAddID != -1 ? masterToAddName : addToMasterName;
127 const label missingProci =
128 masterToAddID != -1 ? addProci : masterProci;
129 const word& missingName =
130 masterToAddID != -1 ? addToMasterName : masterToAddName;
133 <<
"Patch " << foundName <<
" found on processor " 134 << foundProci <<
" but corresponding patch " 135 << missingName <<
" missing on processor " 141 masterFaces.shrink();
157 void writeCellDistribution
181 forAll(cellProcAddressing, proci)
183 const labelList& pCells = cellProcAddressing[proci];
187 cellDecomposition.write();
189 Info<<
nl <<
"Wrote decomposition to " 190 << cellDecomposition.localObjectPath()
191 <<
" for use in manual decomposition." <<
endl;
197 const scalar oldTime = runTime.
value();
201 runTime.
setTime(0, oldIndex+1);
216 extrapolatedCalculatedFvPatchScalarField::typeName
219 forAll(cellDecomposition, celli)
221 cellDist[celli] = cellDecomposition[celli];
223 cellDist.correctBoundaryConditions();
227 Info<<
nl <<
"Wrote decomposition as volScalarField to " 228 << cellDist.name() <<
" for use in postprocessing." 232 runTime.
setTime(oldTime, oldIndex);
237 int main(
int argc,
char *argv[])
245 "write cell distribution as a labelList - for use with 'manual' " 246 "decomposition method or as a volScalarField for post-processing." 255 if (regionNames.size() > 1)
257 Info<<
"Operating on regions " << regionNames[0];
258 for (
label regioni = 1; regioni < regionNames.size() - 1; ++ regioni)
260 Info<<
", " << regionNames[regioni];
262 Info<<
" and " << regionNames.last() <<
nl <<
endl;
266 Info<<
"Operating on region " << regionNames[0] <<
nl <<
endl;
270 Info<<
"Found " << nProcs <<
" processor directories" <<
nl <<
endl;
276 Info<<
"Reading database " 296 databases[0].times(),
304 runTime.
setTime(timeDirs[timeI], timeI);
311 databases[proci].setTime(timeDirs[timeI], timeI);
314 forAll(regionNames, regioni)
316 const word& regionName = regionNames[regioni];
317 const word regionDir =
350 label masterInternalFaces;
360 for (
label proci=0; proci<nProcs; proci++)
394 boundaryProcAddressing[proci] =
419 map().addedCellMap(),
420 cellProcAddressing[proci]
424 map().addedFaceMap(),
425 faceProcAddressing[proci]
429 map().addedPointMap(),
430 pointProcAddressing[proci]
434 map().addedPatchMap(),
435 boundaryProcAddressing[proci]
440 for (
label step=2; step<nProcs*2; step*=2)
442 for (
label proci=0; proci<nProcs; proci+=step)
444 label next = proci + step/2;
450 Info<<
"Merging mesh " << proci <<
" with " << next
473 for (
label mergedI=proci; mergedI<next; mergedI++)
478 cellProcAddressing[mergedI]
483 faceProcAddressing[mergedI]
488 pointProcAddressing[mergedI]
493 boundaryProcAddressing[mergedI]
501 addedI<
min(proci+step, nProcs);
507 map().addedCellMap(),
508 cellProcAddressing[addedI]
512 map().addedFaceMap(),
513 faceProcAddressing[addedI]
517 map().addedPointMap(),
518 pointProcAddressing[addedI]
522 map().addedPatchMap(),
523 boundaryProcAddressing[addedI]
527 masterMesh.
set(next,
nullptr);
531 for (
label proci=0; proci<nProcs; proci++)
533 Info<<
"Reading mesh to add from " 534 << databases[proci].caseName()
535 <<
" for time = " << databases[proci].timeName()
545 Info<<
"\nWriting merged mesh to " 549 if (!masterMesh[0].
write())
552 <<
"Failed writing polyMesh." 558 writeCellDistribution
570 Info<<
"Reconstructing the addressing from the processor meshes" 571 <<
" to the newly reconstructed mesh" <<
nl <<
endl;
575 Info<<
"Reading processor " << proci <<
" mesh from " 576 << databases[proci].caseName() <<
endl;
591 Info<<
"Writing pointProcAddressing to " 592 << databases[proci].caseName()
593 /procMesh.facesInstance()
601 "pointProcAddressing",
602 procMesh.facesInstance(),
609 pointProcAddressing[proci]
615 Info<<
"Writing faceProcAddressing to " 616 << databases[proci].caseName()
617 /procMesh.facesInstance()
625 "faceProcAddressing",
626 procMesh.facesInstance(),
633 faceProcAddressing[proci]
638 forAll(faceProcAddr, procFacei)
640 const label masterFacei = faceProcAddr[procFacei];
644 !procMesh.isInternalFace(procFacei)
645 && masterFacei < masterInternalFaces
651 label procOwn = procMesh.faceOwner()[procFacei];
652 label masterOwn = masterOwner[masterFacei];
654 if (cellProcAddressing[proci][procOwn] == masterOwn)
657 faceProcAddr[procFacei]++;
662 faceProcAddr[procFacei] =
663 -1 - faceProcAddr[procFacei];
669 faceProcAddr[procFacei]++;
673 faceProcAddr.write();
678 Info<<
"Writing cellProcAddressing to " 679 << databases[proci].caseName()
680 /procMesh.facesInstance()
688 "cellProcAddressing",
689 procMesh.facesInstance(),
696 cellProcAddressing[proci]
703 Info<<
"Writing boundaryProcAddressing to " 704 << databases[proci].caseName()
705 /procMesh.facesInstance()
713 "boundaryProcAddressing",
714 procMesh.facesInstance(),
721 boundaryProcAddressing[proci]
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
#define forAll(list, i)
Loop across all elements in list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
void inplaceRenumber(const labelUList &oldToNew, ListType &)
Inplace renumber the values of a list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
const fileName & facesInstance() const
Return the current instance directory for faces.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
label nInternalFaces() const
const fileName & rootPath() const
Return root path.
PtrList< labelIOList > & faceProcAddressing
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
label findPatchID(const word &patchName) const
Find patch index given a name.
static void noParallel()
Remove the parallel options.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
const dimensionSet dimless
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Container for information needed to couple to meshes. When constructed from two meshes and a list of ...
vectorField pointField
pointField is a vectorField.
A class for handling words, derived from string.
const word & constant() const
Return constant name.
virtual const labelList & faceOwner() const
Return face owner.
const Type & value() const
Return const reference to value.
static const word null
An empty word.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
const fileOperation & fileHandler()
Get current file handler.
static word controlDictName
The default control dictionary name (normally "controlDict")
static autoPtr< mapAddedPolyMesh > add(fvMesh &mesh0, const fvMesh &mesh1, const faceCoupleInfo &coupleInfo, const bool validBoundary=true)
Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
instantList select(const instantList &) const
Select a list of Time values that are within the ranges.
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
word name(const complex &)
Return a string representation of a complex.
fileName path() const
Return the path to the caseName.
label size() const
Return the number of elements in the UPtrList.
bool set(const Key &, const T &newElmt)
Assign a new hashedEntry, overwriting existing entries.
label timeIndex() const
Return current time index.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Mesh data needed to do the Finite Volume discretisation.
A List with indirect addressing.
label start() const
Return start label of this patch in the polyMesh face list.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Mesh consisting of general polyhedral cells.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
static void addNote(const string &)
Add extra notes for the usage information.
virtual bool write(const bool write=true) const
Write using setting from DB.
A patch is a list of labels that address the faces in the global face list.
Foam::argList args(argc, argv)
fileName path() const
Return path.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
List< cell > cellList
list of cells
wordList selectRegionNames(const argList &args, const Time &runTime)
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
IOList< label > labelIOList
Label container classes.