Go to the documentation of this file.
67 static const scalar defaultMergeTol = 1
e-7;
80 elems[i] = map[elems[i]];
93 const label masterMeshProcStart,
94 const label masterMeshProcEnd,
96 const label meshToAddProcStart,
97 const label meshToAddProcEnd,
99 const scalar mergeDist
102 if (fullMatch || masterMesh.
nCells() == 0)
127 forAll(masterPatches, patchi)
129 const polyPatch& pp = masterPatches[patchi];
131 if (isA<processorPolyPatch>(pp))
135 label proci=meshToAddProcStart;
136 proci<meshToAddProcEnd;
140 const string toProcString(
"to" +
name(proci));
142 pp.
name().rfind(toProcString)
143 == (pp.
name().size()-toProcString.size())
146 label meshFacei = pp.
start();
149 masterFaces.append(meshFacei++);
157 masterFaces.shrink();
171 forAll(addPatches, patchi)
173 const polyPatch& pp = addPatches[patchi];
175 if (isA<processorPolyPatch>(pp))
177 bool isConnected =
false;
181 label mergedProci=masterMeshProcStart;
182 !isConnected && (mergedProci < masterMeshProcEnd);
188 label proci = meshToAddProcStart;
189 proci < meshToAddProcEnd;
193 const word fromProcString
198 if (pp.
name() == fromProcString)
208 label meshFacei = pp.
start();
211 addFaces.append(meshFacei++);
236 const scalar mergeDist,
252 Info<<
"mergeSharedPoints : detected " << pointToMaster.size()
253 <<
" points that are to be merged." <<
endl;
274 forAll(pointProcAddressing, proci)
276 labelList& constructMap = pointProcAddressing[proci];
280 label oldPointi = constructMap[i];
283 label
newPointi = map().reversePointMap()[oldPointi];
296 <<
"Problem. oldPointi:" << oldPointi
310 const word& regionDir
319 databases[proci].findInstance
326 if (pointsInstance != databases[proci].
timeName())
329 <<
"Your time was specified as " << databases[proci].timeName()
330 <<
" but there is no polyMesh/points in that time." <<
endl
331 <<
"(there is a points file in " << pointsInstance
333 <<
"Please rerun with the correct time specified"
334 <<
" (through the -constant, -time or -latestTime "
335 <<
"(at your option)."
339 Info<<
"Reading points from "
340 << databases[proci].caseName()
341 <<
" for time = " << databases[proci].timeName()
349 databases[proci].findInstance
369 void writeCellDistance
393 forAll(cellProcAddressing, proci)
395 const labelList& pCells = cellProcAddressing[proci];
399 cellDecomposition.write();
401 Info<<
nl <<
"Wrote decomposition to "
402 << cellDecomposition.objectPath()
403 <<
" for use in manual decomposition." <<
endl;
428 extrapolatedCalculatedFvPatchScalarField::typeName
431 forAll(cellDecomposition, celli)
433 cellDist[celli] = cellDecomposition[celli];
435 cellDist.correctBoundaryConditions();
439 Info<<
nl <<
"Wrote decomposition as volScalarField to "
440 << cellDist.name() <<
" for use in postprocessing."
449 int main(
int argc,
char *argv[])
453 "Reconstruct a mesh using geometric information only"
465 "The merge distance relative to the bounding box size (default 1e-7)"
470 "Do (slower) geometric matching on all boundary faces"
475 "Write cell distribution as a labelList - for use with 'manual' "
476 "decomposition method or as a volScalarField for post-processing."
483 Info<<
"This is an experimental tool which tries to merge"
484 <<
" individual processor" <<
nl
485 <<
"meshes back into one master mesh. Use it if the original"
486 <<
" master mesh has" <<
nl
487 <<
"been deleted or if the processor meshes have been modified"
488 <<
" (topology change)." <<
nl
489 <<
"This tool will write the resulting mesh to a new time step"
490 <<
" and construct" <<
nl
491 <<
"xxxxProcAddressing files in the processor meshes so"
492 <<
" reconstructPar can be" <<
nl
493 <<
"used to regenerate the fields on the master mesh." <<
nl
495 <<
"Not well tested & use at your own risk!" <<
nl
512 const scalar mergeTol =
517 Info<<
"Merge tolerance : " << mergeTol <<
nl
518 <<
"Write tolerance : " << writeTol <<
endl;
523 <<
"Your current settings specify ASCII writing with "
525 <<
"Your merging tolerance (" << mergeTol <<
") is finer than this."
527 <<
"Please change your writeFormat to binary"
528 <<
" or increase the writePrecision" <<
endl
529 <<
"or adjust the merge tolerance (-mergeTol)."
534 const bool fullMatch =
args.
found(
"fullMatch");
535 const bool writeCellDist =
args.
found(
"cellDist");
539 Info<<
"Doing geometric matching on all boundary faces." <<
nl <<
endl;
543 Info<<
"Doing geometric matching on correct procBoundaries only."
544 <<
nl <<
"This assumes a correct decomposition." <<
endl;
549 Info<<
"Found " << nProcs <<
" processor directories" <<
nl <<
endl;
556 Info<<
"Reading database "
576 databases[0].times(),
591 databases[proci].setTime(timeDirs[timeI], timeI);
618 const boundBox bb = procBounds(
args, databases, regionDir);
619 const scalar mergeDist = mergeTol*bb.
mag();
621 Info<<
"Overall mesh bounding box : " << bb <<
nl
622 <<
"Relative tolerance : " << mergeTol <<
nl
623 <<
"Absolute matching distance : " << mergeDist <<
nl
634 label masterInternalFaces;
644 for (label proci=0; proci<nProcs; proci++)
676 boundaryProcAddressing[proci] =
701 renumber(map().addedCellMap(), cellProcAddressing[proci]);
703 renumber(map().addedPointMap(), pointProcAddressing[proci]);
704 renumber(map().addedPatchMap(), boundaryProcAddressing[proci]);
706 for (label step=2; step<nProcs*2; step*=2)
708 for (label proci=0; proci<nProcs; proci+=step)
710 label next = proci + step/2;
716 Info<<
"Merging mesh " << proci <<
" with " << next <<
endl;
740 for (label mergedI=proci; mergedI<next; mergedI++)
745 cellProcAddressing[mergedI]
757 pointProcAddressing[mergedI]
764 boundaryProcAddressing[mergedI]
772 addedI<
min(proci+step, nProcs);
778 map().addedCellMap(),
779 cellProcAddressing[addedI]
784 map().addedFaceMap(),
790 map().addedPointMap(),
791 pointProcAddressing[addedI]
796 map().addedPatchMap(),
797 boundaryProcAddressing[addedI]
801 masterMesh.
set(next,
nullptr);
805 for (label proci=0; proci<nProcs; proci++)
807 Info<<
"Reading mesh to add from "
808 << databases[proci].caseName()
809 <<
" for time = " << databases[proci].timeName()
815 mergeSharedPoints(mergeDist, masterMesh[0], pointProcAddressing);
822 Info<<
"\nWriting merged mesh to "
826 if (!masterMesh[0].
write())
829 <<
"Failed writing polyMesh."
848 Info<<
"Reconstructing the addressing from the processor meshes"
849 <<
" to the newly reconstructed mesh" <<
nl <<
endl;
853 Info<<
"Reading processor " << proci <<
" mesh from "
854 << databases[proci].caseName() <<
endl;
869 Info<<
"Writing pointProcAddressing to "
870 << databases[proci].caseName()
871 /procMesh.facesInstance()
879 "pointProcAddressing",
880 procMesh.facesInstance(),
887 pointProcAddressing[proci]
893 Info<<
"Writing faceProcAddressing to "
894 << databases[proci].caseName()
895 /procMesh.facesInstance()
903 "faceProcAddressing",
904 procMesh.facesInstance(),
916 forAll(faceProcAddr, procFacei)
918 const label masterFacei = faceProcAddr[procFacei];
922 !procMesh.isInternalFace(procFacei)
923 && masterFacei < masterInternalFaces
929 label procOwn = procMesh.faceOwner()[procFacei];
930 label masterOwn = masterOwner[masterFacei];
932 if (cellProcAddressing[proci][procOwn] == masterOwn)
935 faceProcAddr[procFacei]++;
940 faceProcAddr[procFacei] =
941 -1 - faceProcAddr[procFacei];
947 faceProcAddr[procFacei]++;
951 faceProcAddr.write();
956 Info<<
"Writing cellProcAddressing to "
957 << databases[proci].caseName()
958 /procMesh.facesInstance()
966 "cellProcAddressing",
967 procMesh.facesInstance(),
974 cellProcAddressing[proci]
981 Info<<
"Writing boundaryProcAddressing to "
982 << databases[proci].caseName()
983 /procMesh.facesInstance()
991 "boundaryProcAddressing",
992 procMesh.facesInstance(),
999 boundaryProcAddressing[proci]
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
PtrList< labelIOList > & faceProcAddressing
scalar mag() const
The magnitude of the bounding box span.
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Dimensionless.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
A class for handling words, derived from Foam::string.
A class for handling file names.
A primitive field of type <T> with automated input and output.
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.
static word defaultRegion
Return the default region name.
T getOrDefault(const word &optName, const T &deflt) const
Get a value from the named option if present, or return default.
static constexpr const zero Zero
Global zero (0)
label nInternalFaces() const
Number of internal faces.
IOstream::streamFormat writeFormat() const
The write stream format.
label nFaces() const
Number of mesh faces.
static const boundBox invertedBox
A large inverted boundBox: min/max == +/- ROOTVGREAT.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
static word timeName(const scalar t, const int precision=precision_)
Direct mesh changes based on v1.3 polyTopoChange syntax.
Info<< "Creating field kinetic energy K\n"<< endl;volScalarField K("K", 0.5 *magSqr(U));if(U.nOldTimes()){ volVectorField *Uold=&U.oldTime();volScalarField *Kold=&K.oldTime();*Kold==0.5 *magSqr(*Uold);while(Uold->nOldTimes()) { Uold=&Uold-> oldTime()
static void addNote(const string ¬e)
Add extra notes for the usage information.
instantList select(const instantList ×) const
Select a list of Time values that are within the ranges.
const fileName & facesInstance() const
Return the current instance directory for faces.
Extract command arguments and options from the supplied argc and argv parameters.
const fileOperation & fileHandler()
Get current file handler.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const Type & value() const
Return const reference to value.
IOList< label > labelIOList
Label container classes.
static word controlDictName
The default control dictionary name (normally "controlDict")
bool readIfPresent(const word &optName, T &val) const
Read a value from the named option if present.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
const fileName & rootPath() const
Return root path.
Mesh consisting of general polyhedral cells.
#define forAll(list, i)
Loop across all elements in list.
static autoPtr< mapAddedPolyMesh > add(fvMesh &mesh0, const fvMesh &mesh1, const faceCoupleInfo &coupleInfo, const bool validBoundary=true, const bool fullyMapped=false)
Inplace add mesh to fvMesh. Maps all stored fields. Returns map.
label nCells() const
Number of mesh cells.
virtual bool write(const bool valid=true) const
Write using setting from DB.
messageStream Info
Information stream (uses stdout - output is on the master only)
A patch is a list of labels that address the faces in the global face list.
word name(const complex &c)
Return string representation of complex.
virtual label nProcs(const fileName &dir, const fileName &local="") const
Get number of processor directories/results. Used for e.g.
virtual const labelList & faceOwner() const
Return face owner.
virtual void updateMesh(const mapPolyMesh &mpm)
Update mesh corresponding to the given map.
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
fileName path() const
Return the full path to the (processor local) case.
Mesh data needed to do the Finite Volume discretisation.
errorManip< error > abort(error &err)
const T * set(const label i) const
Return const pointer to element (if set) or nullptr.
label start() const
Return start label of this patch in the polyMesh face list.
static Map< label > findSharedPoints(const polyMesh &, const scalar mergeTol)
Find topologically and geometrically shared points.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
IntListType renumber(const labelUList &oldToNew, const IntListType &input)
Renumber the values (not the indices) of a list.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
fileName path() const
Return path.
static unsigned int defaultPrecision()
Return the default precision.
static void addOptions(const bool constant=true, const bool withZero=false)
Add timeSelector options to argList::validOptions.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
virtual void setTime(const Time &t)
Reset the time and time-index to those of the given time.
const dimensionedScalar e
Elementary charge.
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)
static const word null
An empty word.
bool set(const Key &key, const T &obj)
Copy assign a new entry, overwriting existing entries.
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
A bounding box defined in terms of min/max extrema points.
const fileName & caseName() const
Return case name (parallel run) or global case (serial run)
label timeIndex() const
Return current time index.
static void noParallel()
Remove the parallel options.
const word & constant() const
Return constant name.
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)
static void removeFiles(const polyMesh &)
Helper: remove all sets files from mesh instance.
const word & name() const
The patch name.
static void mergePoints(const polyMesh &, const Map< label > &pointToMaster, polyTopoChange &meshMod)
Helper: Merge points.
bool found(const word &optName) const
Return true if the named option is found.
void add(const boundBox &bb)
Extend to include the second box.
UIndirectList< label > labelUIndList
UIndirectList of labels.