From 6d693b5b34f79a30d611555fddc98084902c40b0 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Wed, 7 Feb 2018 14:44:18 +0000 Subject: [PATCH 01/45] Refactor decomposition/reconstruction tools --- .../decomposePar/Make/files | 9 - .../decomposePar/Make/options | 2 + .../decomposePar/decomposePar.C | 37 +- .../decomposePar/domainDecomposition.C | 694 ------------------ .../decomposePar/readFields.C | 4 +- .../reconstructPar/Make/files | 6 - .../reconstructPar/Make/options | 7 +- .../fvFieldReconstructorReconstructFields.C | 526 ------------- .../reconstructParMesh/Make/files | 11 - .../reconstructParMesh/Make/options | 4 + .../reconstructParMesh/faFieldReconstructor.C | 47 -- .../reconstructParMesh/faFieldReconstructor.H | 197 ----- .../faFieldReconstructorReconstructFields.C | 640 ---------------- .../reconstructParMesh/fvFieldReconstructor.C | 47 -- .../reconstructParMesh/fvFieldReconstructor.H | 196 ----- .../pointFieldReconstructor.C | 104 --- .../pointFieldReconstructor.H | 173 ----- ...pointFieldReconstructorReconstructFields.C | 178 ----- .../reconstructParMesh/processorFaMeshes.C | 258 ------- .../reconstructParMesh/processorFaMeshes.H | 140 ---- .../reconstructLagrangian.H | 94 --- .../reconstructLagrangianFields.C | 125 ---- .../reconstructLagrangianPositions.C | 75 -- .../tetPointFieldReconstructor.C | 163 ---- .../tetPointFieldReconstructor.H | 217 ------ ...PointFieldReconstructorReconstructFields.C | 372 ---------- .../decomposeReconstruct/Make/files | 20 + .../decomposeReconstruct/Make/options | 15 + .../finiteArea}/faFieldDecomposer.C | 0 .../finiteArea}/faFieldDecomposer.H | 0 .../faFieldDecomposerDecomposeFields.C | 0 .../finiteArea}/faMeshDecomposition.C | 0 .../finiteArea}/faMeshDecomposition.H | 0 .../finiteVolume}/decomposeMesh.C | 23 +- .../finiteVolume}/distributeCells.C | 19 +- .../finiteVolume/domainDecomposition.C | 687 +++++++++++++++++ .../finiteVolume}/domainDecomposition.H | 93 ++- .../finiteVolume}/fvFieldDecomposer.C | 0 .../finiteVolume}/fvFieldDecomposer.H | 1 + .../fvFieldDecomposerDecomposeFields.C | 0 .../lagrangian}/lagrangianFieldDecomposer.C | 0 .../lagrangian}/lagrangianFieldDecomposer.H | 0 ...lagrangianFieldDecomposerDecomposeFields.C | 0 .../point}/pointFieldDecomposer.C | 0 .../point}/pointFieldDecomposer.H | 0 .../pointFieldDecomposerDecomposeFields.C | 0 .../tetPointFieldDecomposer.C | 0 .../tetPointFieldDecomposer.H | 0 .../tetPointFieldDecomposerDecomposeFields.C | 0 .../finiteArea}/faFieldReconstructor.C | 0 .../finiteArea}/faFieldReconstructor.H | 0 .../faFieldReconstructorReconstructFields.C | 0 .../finiteArea}/processorFaMeshes.C | 0 .../finiteArea}/processorFaMeshes.H | 0 .../finiteVolume}/fvFieldReconstructor.C | 0 .../finiteVolume}/fvFieldReconstructor.H | 12 +- .../fvFieldReconstructorReconstructFields.C | 333 +++++---- .../finiteVolume}/processorMeshesRebuild.C | 0 .../processorMeshesReconstructor.C | 0 .../processorMeshesReconstructor.H | 3 +- .../lagrangian}/reconstructLagrangian.H | 0 .../lagrangian}/reconstructLagrangianFields.C | 0 .../reconstructLagrangianPositions.C | 0 .../point}/pointFieldReconstructor.C | 0 .../point}/pointFieldReconstructor.H | 0 ...pointFieldReconstructorReconstructFields.C | 0 .../tetPointFieldReconstructor.C | 0 .../tetPointFieldReconstructor.H | 0 ...PointFieldReconstructorReconstructFields.C | 0 69 files changed, 1058 insertions(+), 4474 deletions(-) delete mode 100644 applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C delete mode 100644 applications/utilities/parallelProcessing/reconstructPar/fvFieldReconstructorReconstructFields.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/faFieldReconstructor.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/faFieldReconstructor.H delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/faFieldReconstructorReconstructFields.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/fvFieldReconstructor.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/fvFieldReconstructor.H delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/pointFieldReconstructor.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/pointFieldReconstructor.H delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/pointFieldReconstructorReconstructFields.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/processorFaMeshes.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/processorFaMeshes.H delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/reconstructLagrangian.H delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/reconstructLagrangianFields.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/reconstructLagrangianPositions.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/tetPointFieldReconstructor.C delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/tetPointFieldReconstructor.H delete mode 100644 applications/utilities/parallelProcessing/reconstructParMesh/tetPointFieldReconstructorReconstructFields.C create mode 100644 src/decompositionMethods/decomposeReconstruct/Make/files create mode 100644 src/decompositionMethods/decomposeReconstruct/Make/options rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteArea}/faFieldDecomposer.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteArea}/faFieldDecomposer.H (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteArea}/faFieldDecomposerDecomposeFields.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteArea}/faMeshDecomposition.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteArea}/faMeshDecomposition.H (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume}/decomposeMesh.C (98%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume}/distributeCells.C (91%) create mode 100644 src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume}/domainDecomposition.H (71%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume}/fvFieldDecomposer.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume}/fvFieldDecomposer.H (99%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume}/fvFieldDecomposerDecomposeFields.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/lagrangian}/lagrangianFieldDecomposer.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/lagrangian}/lagrangianFieldDecomposer.H (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/lagrangian}/lagrangianFieldDecomposerDecomposeFields.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/point}/pointFieldDecomposer.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/point}/pointFieldDecomposer.H (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/point}/pointFieldDecomposerDecomposeFields.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/tetFiniteElement}/tetPointFieldDecomposer.C (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/tetFiniteElement}/tetPointFieldDecomposer.H (100%) rename {applications/utilities/parallelProcessing/decomposePar => src/decompositionMethods/decomposeReconstruct/decomposeTools/tetFiniteElement}/tetPointFieldDecomposerDecomposeFields.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteArea}/faFieldReconstructor.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteArea}/faFieldReconstructor.H (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteArea}/faFieldReconstructorReconstructFields.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteArea}/processorFaMeshes.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteArea}/processorFaMeshes.H (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume}/fvFieldReconstructor.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume}/fvFieldReconstructor.H (92%) rename {applications/utilities/parallelProcessing/reconstructParMesh => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume}/fvFieldReconstructorReconstructFields.C (91%) rename {applications/utilities/parallelProcessing/reconstructParMesh => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume}/processorMeshesRebuild.C (100%) rename {applications/utilities/parallelProcessing/reconstructParMesh => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume}/processorMeshesReconstructor.C (100%) rename {applications/utilities/parallelProcessing/reconstructParMesh => src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume}/processorMeshesReconstructor.H (97%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/lagrangian}/reconstructLagrangian.H (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/lagrangian}/reconstructLagrangianFields.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/lagrangian}/reconstructLagrangianPositions.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/point}/pointFieldReconstructor.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/point}/pointFieldReconstructor.H (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/point}/pointFieldReconstructorReconstructFields.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/tetFiniteElement}/tetPointFieldReconstructor.C (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/tetFiniteElement}/tetPointFieldReconstructor.H (100%) rename {applications/utilities/parallelProcessing/reconstructPar => src/decompositionMethods/decomposeReconstruct/reconstructTools/tetFiniteElement}/tetPointFieldReconstructorReconstructFields.C (100%) diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/files b/applications/utilities/parallelProcessing/decomposePar/Make/files index a86648f25..8e29865cd 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/files +++ b/applications/utilities/parallelProcessing/decomposePar/Make/files @@ -1,12 +1,3 @@ -decomposeMesh.C decomposePar.C -domainDecomposition.C -distributeCells.C -faMeshDecomposition.C -fvFieldDecomposer.C -faFieldDecomposer.C -pointFieldDecomposer.C -tetPointFieldDecomposer.C -lagrangianFieldDecomposer.C EXE = $(FOAM_APPBIN)/decomposePar diff --git a/applications/utilities/parallelProcessing/decomposePar/Make/options b/applications/utilities/parallelProcessing/decomposePar/Make/options index 682187cd5..eb2754920 100644 --- a/applications/utilities/parallelProcessing/decomposePar/Make/options +++ b/applications/utilities/parallelProcessing/decomposePar/Make/options @@ -1,5 +1,6 @@ EXE_INC = \ -I$(LIB_SRC)/decompositionMethods/decompositionMethods/lnInclude \ + -I$(LIB_SRC)/decompositionMethods/decomposeReconstruct/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteArea/lnInclude \ @@ -8,6 +9,7 @@ EXE_INC = \ EXE_LIBS = \ -ldecompositionMethods \ + -ldecomposeReconstruct \ -lmeshTools \ -lfiniteVolume \ -lfiniteArea \ diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C index 06ba968ae..6d7430682 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposePar/decomposePar.C @@ -235,26 +235,45 @@ int main(int argc, char *argv[]) } Info<< "Create mesh for region " << regionName << endl; - domainDecomposition mesh + fvMesh mesh ( IOobject ( regionName, runTime.timeName(), - runTime + runTime, + IOobject::MUST_READ, + IOobject::NO_WRITE ) ); + domainDecomposition meshDecomp + ( + mesh, + IOdictionary + ( + IOobject + ( + "decomposeParDict", + runTime.system(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ) + ); + + // Decompose the mesh if (!decomposeFieldsOnly) { - mesh.decomposeMesh(filterPatches); + meshDecomp.decomposeMesh(filterPatches); - mesh.writeDecomposition(); + meshDecomp.writeDecomposition(); if (writeCellDist) { - const labelList& procIds = mesh.cellToProc(); + const labelList& procIds = meshDecomp.cellToProc(); // Write the decomposition as labelList for use with 'manual' // decomposition method. @@ -345,7 +364,7 @@ int main(int argc, char *argv[]) // Construct the point fields // ~~~~~~~~~~~~~~~~~~~~~~~~~~ - pointMesh pMesh(mesh); + const pointMesh& pMesh = pointMesh::New(mesh); PtrList pointScalarFields; readFields(pMesh, objects, pointScalarFields); @@ -595,7 +614,7 @@ int main(int argc, char *argv[]) Info<< endl; // Split the fields over processors - for (label procI = 0; procI < mesh.nProcs(); procI++) + for (label procI = 0; procI < meshDecomp.nProcs(); procI++) { Info<< "Processor " << procI << ": field transfer" << endl; @@ -872,7 +891,7 @@ int main(int argc, char *argv[]) { const fileName timePath = processorDb.timePath(); - if (copyUniform || mesh.distributed()) + if (copyUniform || meshDecomp.distributed()) { cp ( @@ -962,7 +981,7 @@ int main(int argc, char *argv[]) Info << endl; // Split the fields over processors - for (label procI = 0; procI < mesh.nProcs(); procI++) + for (label procI = 0; procI < meshDecomp.nProcs(); procI++) { Info<< "Processor " << procI << ": finite area field transfer" << endl; diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C deleted file mode 100644 index 015761d1b..000000000 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ /dev/null @@ -1,694 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | foam-extend: Open Source CFD - \\ / O peration | Version: 4.0 - \\ / A nd | Web: http://www.foam-extend.org - \\/ M anipulation | For copyright notice see file Copyright -------------------------------------------------------------------------------- -License - This file is part of foam-extend. - - foam-extend is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by the - Free Software Foundation, either version 3 of the License, or (at your - option) any later version. - - foam-extend is distributed in the hope that it will be useful, but - WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public License - along with foam-extend. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "domainDecomposition.H" -#include "foamTime.H" -#include "dictionary.H" -#include "labelIOList.H" -#include "processorPolyPatch.H" -#include "fvMesh.H" -#include "OSspecific.H" -#include "Map.H" -#include "globalMeshData.H" -#include "DynamicList.H" - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -domainDecomposition::domainDecomposition(const IOobject& io) -: - fvMesh(io), - decompositionDict_ - ( - IOobject - ( - "decomposeParDict", - time().system(), - *this, - IOobject::MUST_READ, - IOobject::NO_WRITE - ) - ), - nProcs_(readInt(decompositionDict_.lookup("numberOfSubdomains"))), - distributed_(false), - cellToProc_(nCells()), - procPointAddressing_(nProcs_), - procFaceAddressing_(nProcs_), - nInternalProcFaces_(nProcs_), - nLiveProcFaces_(nProcs_), - procCellAddressing_(nProcs_), - procBoundaryAddressing_(nProcs_), - procPatchSize_(nProcs_), - procPatchStartIndex_(nProcs_), - procNeighbourProcessors_(nProcs_), - procProcessorPatchSize_(nProcs_), - procProcessorPatchStartIndex_(nProcs_), - globallySharedPoints_(0), - cyclicParallel_(false) -{ - if (decompositionDict_.found("distributed")) - { - distributed_ = Switch(decompositionDict_.lookup("distributed")); - } -} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -domainDecomposition::~domainDecomposition() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -bool domainDecomposition::writeDecomposition() -{ - Info<< "\nConstructing processor meshes" << endl; - - // Make a lookup map for globally shared points - Map