diff --git a/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C b/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C index bb34931e9a..a31468da21 100644 --- a/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C +++ b/applications/utilities/finiteArea/checkFaMesh/checkFaMesh.C @@ -95,7 +95,8 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; - #include "printMeshSummary.H" + // Mesh information (verbose) + faMeshTools::printMeshChecks(aMesh); if (args.found("write-vtk")) { diff --git a/applications/utilities/finiteArea/makeFaMesh/decomposeFaFields.H b/applications/utilities/finiteArea/makeFaMesh/decomposeFaFields.H index 00068a1dea..27d1f4d0f0 100644 --- a/applications/utilities/finiteArea/makeFaMesh/decomposeFaFields.H +++ b/applications/utilities/finiteArea/makeFaMesh/decomposeFaFields.H @@ -30,44 +30,63 @@ do break; } - reconstructor.writeAddressing(); + reconstructor.writeMesh(); // Writes on master only + reconstructor.writeAddressing(); // Writes per-proc - Info<< "Wrote proc-addressing" << nl << endl; + Info<< "Wrote proc-addressing and serial mesh" << nl << endl; // Handle area fields // ------------------ faFieldDecomposer::fieldsCache areaFieldsCache; - const faMesh& fullMesh = reconstructor.mesh(); + const faMesh& serialMesh = reconstructor.mesh(); + if (doDecompFields) { - // Use uncollated (or master uncollated) file handler here. - // - each processor is reading in the identical serial fields. - // - nothing should be parallel-coordinated. + // The serial finite-area mesh exists and is identical on all + // processors, but its fields can only reliably be read on the + // master (eg, running with distributed roots). + // + // - mark mesh fields as readable on master only (haveMeshOnProc) + // - 'subset' entire serial mesh so that a full copy will be + // broadcast to other ranks (subsetterPtr) + // - scan available IOobjects on the master only - // Similarly, if we write the serial finite-area mesh, this is only - // done from one processor! + bitSet haveMeshOnProc; + std::unique_ptr subsetter; + IOobjectList objects(0); - reconstructor.writeMesh(); + const bool oldDistributed = fileHandler().distributed(); + auto oldHandler = fileHandler(fileOperation::NewUncollated()); + fileHandler().distributed(true); - if (doDecompFields) + if (Pstream::master()) { - const bool oldDistributed = fileHandler().distributed(); - auto oldHandler = fileHandler(fileOperation::NewUncollated()); - fileHandler().distributed(true); + haveMeshOnProc.set(Pstream::myProcNo()); + subsetter.reset(new faMeshSubset(serialMesh)); - IOobjectList objects(fullMesh.time(), runTime.timeName()); + const bool oldParRun = Pstream::parRun(false); - areaFieldsCache.readAllFields(fullMesh, objects); + objects = IOobjectList(serialMesh.time(), runTime.timeName()); - // Restore old settings - if (oldHandler) - { - fileHandler(std::move(oldHandler)); - } - fileHandler().distributed(oldDistributed); + Pstream::parRun(oldParRun); } + + // Restore old settings + if (oldHandler) + { + fileHandler(std::move(oldHandler)); + } + fileHandler().distributed(oldDistributed); + + areaFieldsCache.readAllFields + ( + haveMeshOnProc, + subsetter.get(), + serialMesh, + objects + ); } const label nAreaFields = areaFieldsCache.size(); @@ -78,7 +97,7 @@ do faFieldDecomposer fieldDecomposer ( - fullMesh, + serialMesh, aMesh, reconstructor.edgeProcAddressing(), reconstructor.faceProcAddressing(), diff --git a/applications/utilities/finiteArea/makeFaMesh/makeFaMesh.C b/applications/utilities/finiteArea/makeFaMesh/makeFaMesh.C index ca6c56eca3..9fcd6e5c0e 100644 --- a/applications/utilities/finiteArea/makeFaMesh/makeFaMesh.C +++ b/applications/utilities/finiteArea/makeFaMesh/makeFaMesh.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 Wikki Ltd - Copyright (C) 2021 OpenCFD Ltd. + Copyright (C) 2021-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -42,13 +42,14 @@ Original Authors #include "argList.H" #include "OSspecific.H" #include "faMesh.H" +#include "faMeshTools.H" #include "IOdictionary.H" #include "IOobjectList.H" - #include "areaFields.H" #include "edgeFields.H" #include "faFieldDecomposer.H" #include "faMeshReconstructor.H" +#include "faMeshSubset.H" #include "PtrListOps.H" #include "foamVtkIndPatchWriter.H" #include "OBJstream.H" @@ -131,8 +132,8 @@ int main(int argc, char *argv[]) // Create faMesh aMesh(mesh, meshDefDict); - // Mesh information - #include "printMeshSummary.H" + // Mesh information (less verbose) + faMeshTools::printMeshChecks(aMesh, 0); if (args.found("write-edges-obj")) { diff --git a/applications/utilities/finiteArea/makeFaMesh/printMeshSummary.H b/applications/utilities/finiteArea/makeFaMesh/printMeshSummary.H deleted file mode 100644 index 084759849f..0000000000 --- a/applications/utilities/finiteArea/makeFaMesh/printMeshSummary.H +++ /dev/null @@ -1,104 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2021-2022 OpenCFD Ltd. -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM, distributed under GPL-3.0-or-later. - -Description - Summary of faMesh information - -\*---------------------------------------------------------------------------*/ - -{ - const faBoundaryMesh& patches = aMesh.boundary(); - const label nNonProcessor = patches.nNonProcessor(); - const label nPatches = patches.size(); - - Info<< "----------------" << nl - << "Mesh Information" << nl - << "----------------" << nl - << " " << "boundingBox: " << boundBox(aMesh.points()) << nl - << " " << "nFaces: " << returnReduce(aMesh.nFaces(), sumOp