From 40ac293b066283402024c5044e2178f003e2b876 Mon Sep 17 00:00:00 2001 From: vincentcasseau Date: Sat, 29 May 2021 09:46:55 -0400 Subject: [PATCH] dsmcFoam+: load balancing #76: adjustments to the decomposeDSMCLoadBalancePar application to detele balanceParDict and only use loadBalanceDict for domain repartitioning --- .../decomposePar.C | 4 +- .../domainDecomposition.C | 62 +++++++++++++------ 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/decomposePar.C b/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/decomposePar.C index 9e8fcfef..f6445825 100644 --- a/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/decomposePar.C +++ b/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/decomposePar.C @@ -266,7 +266,7 @@ int main(int argc, char *argv[]) ( IOobject ( - "balanceParDict", + "decomposeParDict", runTime.time().system(), regionDir, // use region if non-standard runTime, @@ -287,7 +287,7 @@ int main(int argc, char *argv[]) << nProcs << " domains" << nl << "instead of " << nDomains - << " domains as specified in balanceParDict" + << " domains as specified in decomposeParDict" << nl << exit(FatalError); } diff --git a/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/domainDecomposition.C index fcdd5896..2fb09e23 100644 --- a/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposeDSMCLoadBalancePar/domainDecomposition.C @@ -95,28 +95,51 @@ Foam::domainDecomposition::domainDecomposition(const IOobject& io) ( IOobject ( - "balanceParDict", + "loadBalanceDict", time().system(), *this, IOobject::MUST_READ_IF_MODIFIED, IOobject::NO_WRITE ) ), - nProcs_(readInt(decompositionDict_.lookup("numberOfSubdomains"))), distributed_(false), - cellToProc_(nCells()), - procPointAddressing_(nProcs_), - procFaceAddressing_(nProcs_), - procCellAddressing_(nProcs_), - procPatchSize_(nProcs_), - procPatchStartIndex_(nProcs_), - procNeighbourProcessors_(nProcs_), - procProcessorPatchSize_(nProcs_), - procProcessorPatchStartIndex_(nProcs_), - procProcessorPatchSubPatchIDs_(nProcs_), - procProcessorPatchSubPatchStarts_(nProcs_) + cellToProc_(nCells()) { - decompositionDict_.readIfPresent("distributed", distributed_); + word method = word::null; + + { + IOdictionary decomposeParDict + ( + IOobject + ( + "decomposeParDict", + time().system(), + *this, + IOobject::MUST_READ_IF_MODIFIED, + IOobject::NO_WRITE, + false + ) + ); + + nProcs_ = readLabel(decomposeParDict.lookup("numberOfSubdomains")); + method = word(decomposeParDict.lookup("method")); + decomposeParDict.readIfPresent("distributed", distributed_); + } + + procPointAddressing_.setSize(nProcs_); + procFaceAddressing_.setSize(nProcs_); + procCellAddressing_.setSize(nProcs_); + procPatchSize_.setSize(nProcs_); + procPatchStartIndex_.setSize(nProcs_); + procNeighbourProcessors_.setSize(nProcs_); + procProcessorPatchSize_.setSize(nProcs_); + procProcessorPatchStartIndex_.setSize(nProcs_); + procProcessorPatchSubPatchIDs_.setSize(nProcs_); + procProcessorPatchSubPatchStarts_.setSize(nProcs_); + + decompositionDict_.add("numberOfSubdomains", nProcs_); + decompositionDict_.add("method", method); + decompositionDict_.add("distributed", distributed_); } @@ -207,8 +230,7 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets) IOobject::MUST_READ, IOobject::NO_WRITE ); - //if (io.headerOk()) - if (io.typeHeaderOk()) // NEW VINCENT + if (io.typeHeaderOk()) { Info<< "Reading hexRef8 data : " << io.name() << endl; cellLevelPtr.reset(new labelIOList(io)); @@ -225,8 +247,8 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets) IOobject::MUST_READ, IOobject::NO_WRITE ); - //if (io.headerOk()) - if (io.typeHeaderOk()) // NEW VINCENT + + if (io.typeHeaderOk()) { Info<< "Reading hexRef8 data : " << io.name() << endl; pointLevelPtr.reset(new labelIOList(io)); @@ -243,8 +265,8 @@ bool Foam::domainDecomposition::writeDecomposition(const bool decomposeSets) IOobject::MUST_READ, IOobject::NO_WRITE ); - //if (io.headerOk()) - if (io.typeHeaderOk()) // NEW VINCENT + + if (io.typeHeaderOk()) { Info<< "Reading hexRef8 data : " << io.name() << endl; level0EdgePtr.reset(new uniformDimensionedScalarField(io));