From 0e01e530a84e9fb8b677be155ec6500981586560 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 3 May 2022 17:37:12 +0200 Subject: [PATCH] ENH: add optional agglomeration coefficent to random decomposition - specifies the number of consecutive cells to assign to the same randomly chosen processor. Can be used to have a less extremely random distribution for testing possible breaking points. Eg, method random; coeffs { agglom 4; } - Add finiteArea cellID (actually face ids) / faceLabel and procID for foamToVTK with -write-ids. Useful when this type of information is needed. --- .../foamToVTK/convertAreaFields.H | 29 ++++++++++++-- .../randomDecomp/randomDecomp.C | 39 ++++++++++++++++--- .../randomDecomp/randomDecomp.H | 25 ++++++++++-- 3 files changed, 79 insertions(+), 14 deletions(-) diff --git a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H index ddcebf63e4..64c13eebb0 100644 --- a/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H +++ b/applications/utilities/postProcessing/dataConversion/foamToVTK/convertAreaFields.H @@ -49,8 +49,10 @@ if (doFiniteArea) faMeshPtr = faMesh::TryNew(meshProxy.baseMesh()); } - if (faMeshPtr && nAreaFields) + if (faMeshPtr && (nAreaFields || withMeshIds)) { + const faMesh& areaMesh = faMeshPtr(); + reportFields::area(Info, objects); const auto& pp = faMeshPtr->patch(); @@ -66,17 +68,36 @@ if (doFiniteArea) Pstream::parRun() ); - writer.beginFile(faMeshPtr->name()); + writer.beginFile(areaMesh.name()); writer.writeTimeValue(timeValue); writer.writeGeometry(); - writer.beginCellData(nAreaFields); + // Optionally with (cellID, faceLabels, procID) fields + writer.beginCellData + ( + (withMeshIds ? 2 + (writer.parallel() ? 1 : 0) : 0) + + nAreaFields + ); + + if (withMeshIds) + { + const globalIndex procAddr(areaMesh.nFaces()); + + // Use global indexed values for the 'cell' ids + writer.writeCellData("cellID", identity(procAddr.range())); + + // Use proc-local data for faceLabels + // (confusing enough already without renumbering) + writer.writeCellData("faceLabels", areaMesh.faceLabels()); + + writer.writeProcIDs(); // parallel only + } writeAllAreaFields ( writer, - *faMeshPtr, + areaMesh, objects, true // syncPar ); diff --git a/src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C b/src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C index 2ab2fe85a3..625d2cbcb7 100644 --- a/src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C +++ b/src/parallel/decompose/decompositionMethods/randomDecomp/randomDecomp.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2021 OpenCFD Ltd. + Copyright (C) 2019-2022 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -51,9 +51,29 @@ Foam::labelList Foam::randomDecomp::randomMap(const label nCells) const labelList finalDecomp(nCells); - for (label& val : finalDecomp) + if (agglom_ > 1) { - val = rndGen.position