From fdf5a86c24a65a9359f0e4bf74f9c42cfd60bd3f Mon Sep 17 00:00:00 2001 From: Avirup Sircar Date: Thu, 28 Nov 2024 09:37:15 -0500 Subject: [PATCH] Printing num enrich ids in a cell in processor in src/basis/EnrichmentClassicalInterfaceSpherical.t.cpp --- ...nrichmentClassicalInterfaceSpherical.t.cpp | 90 ++++++++++++++++++- 1 file changed, 88 insertions(+), 2 deletions(-) diff --git a/src/basis/EnrichmentClassicalInterfaceSpherical.t.cpp b/src/basis/EnrichmentClassicalInterfaceSpherical.t.cpp index 067a53df..dd107b99 100644 --- a/src/basis/EnrichmentClassicalInterfaceSpherical.t.cpp +++ b/src/basis/EnrichmentClassicalInterfaceSpherical.t.cpp @@ -74,6 +74,9 @@ namespace dftefe utils::ConditionalOStream rootCout(std::cout); rootCout.setCondition(rank == 0); + int numProcs; + utils::mpi::MPICommSize(comm, &numProcs); + if (dim != 3) utils::throwException( false, "Dimension should be 3 for Spherical Enrichment Dofs."); @@ -161,6 +164,47 @@ namespace dftefe d_overlappingEnrichmentIdsInCells = d_enrichmentIdsPartition->overlappingEnrichmentIdsInCells(); + global_size_type maxEnrich = 0; + global_size_type avgEnrich = 0; + size_type cellIndex = 0; + cell = d_triangulation->beginLocal(); + for (; cell != endc; cell++) + { + global_size_type numEnrichInCell = + d_overlappingEnrichmentIdsInCells[cellIndex].size(); + if (maxEnrich < numEnrichInCell) + maxEnrich = numEnrichInCell; + avgEnrich += numEnrichInCell; + cellIndex++; + } + + avgEnrich /= d_cfeBasisDofHandler->nLocallyOwnedCells(); + + utils::mpi::MPIAllreduce( + utils::mpi::MPIInPlace, + &maxEnrich, + 1, + utils::mpi::Types::getMPIDatatype(), + utils::mpi::MPIMax, + comm); + + utils::mpi::MPIAllreduce( + utils::mpi::MPIInPlace, + &avgEnrich, + 1, + utils::mpi::Types::getMPIDatatype(), + utils::mpi::MPISum, + comm); + + avgEnrich /= numProcs; + + rootCout << "Maximum " << fieldName + << " Enrichment Ids In a Cell in Processor: " << maxEnrich + << "\n"; + rootCout << "Average " << fieldName + << " Enrichment Ids In a Cell In Processor: " << avgEnrich + << "\n"; + // For Non-Periodic BC, a sparse vector d_i with hanging with homogenous // BC will be formed which will be solved by Md = // integrateWithBasisValues( homogeneous BC). Form quadRuleContainer for @@ -209,8 +253,8 @@ namespace dftefe d_cfeBasisDofHandler->nLocallyOwnedCells(); std::vector nQuadPointsInCell(0); nQuadPointsInCell.resize(numLocallyOwnedCells, 0); - size_type cellIndex = 0; - auto locallyOwnedCellIter = + cellIndex = 0; + auto locallyOwnedCellIter = d_cfeBasisDofHandler->beginLocallyOwnedCells(); for (; locallyOwnedCellIter != d_cfeBasisDofHandler->endLocallyOwnedCells(); @@ -470,6 +514,9 @@ namespace dftefe utils::ConditionalOStream rootCout(std::cout); rootCout.setCondition(rank == 0); + int numProcs; + utils::mpi::MPICommSize(comm, &numProcs); + if (dim != 3) utils::throwException( false, "Dimension should be 3 for Spherical Enrichment Dofs."); @@ -539,6 +586,45 @@ namespace dftefe d_overlappingEnrichmentIdsInCells = d_enrichmentIdsPartition->overlappingEnrichmentIdsInCells(); + global_size_type maxEnrich = 0; + global_size_type avgEnrich = 0; + size_type cellIndex = 0; + cell = d_triangulation->beginLocal(); + for (; cell != endc; cell++) + { + global_size_type numEnrichInCell = + d_overlappingEnrichmentIdsInCells[cellIndex].size(); + if (maxEnrich < numEnrichInCell) + maxEnrich = numEnrichInCell; + avgEnrich += numEnrichInCell; + cellIndex++; + } + + avgEnrich /= d_cfeBasisDofHandler->nLocallyOwnedCells(); + + utils::mpi::MPIAllreduce( + utils::mpi::MPIInPlace, + &maxEnrich, + 1, + utils::mpi::Types::getMPIDatatype(), + utils::mpi::MPIMax, + comm); + + utils::mpi::MPIAllreduce( + utils::mpi::MPIInPlace, + &avgEnrich, + 1, + utils::mpi::Types::getMPIDatatype(), + utils::mpi::MPISum, + comm); + + avgEnrich /= numProcs; + + rootCout << "Maximum " << fieldName + << " Enrichment Ids In a Processor: " << maxEnrich << "\n"; + rootCout << "Average " << fieldName + << " Enrichment Ids In a Processor: " << avgEnrich << "\n"; + rootCout << "Completed creating Pristine EnrichmentClassicalInterfaceSpherical for " << d_enrichmentIdsPartition->nTotalEnrichmentIds() << " " << fieldName