From 8011eb46791a9f6264bd53db4eea23d1c3f2215b Mon Sep 17 00:00:00 2001 From: lkotipal Date: Wed, 9 Oct 2024 14:25:44 +0300 Subject: [PATCH 1/5] oops --- grid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grid.cpp b/grid.cpp index dde04f0bb..afed605cd 100644 --- a/grid.cpp +++ b/grid.cpp @@ -1467,7 +1467,7 @@ bool adaptRefinement(dccrg::Dccrg& mpiGri initTimer.stop(); refines = mpiGrid.get_local_cells_to_refine().size(); - double coarsens = mpiGrid.get_local_cells_to_unrefine().size(); + int coarsens {mpiGrid.get_local_cells_to_unrefine().size()}; MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(MPI_IN_PLACE, &coarsens, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); ratio_refines = static_cast(refines) / static_cast(cells); From 2b699b08bb963e9ac4a4a93a9c4dc046fbb43984 Mon Sep 17 00:00:00 2001 From: lkotipal Date: Wed, 9 Oct 2024 14:32:50 +0300 Subject: [PATCH 2/5] More correct typing --- grid.cpp | 8 ++++---- projects/project.cpp | 4 ++-- projects/project.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/grid.cpp b/grid.cpp index afed605cd..2ada8c6f7 100644 --- a/grid.cpp +++ b/grid.cpp @@ -1440,7 +1440,7 @@ void mapRefinement(dccrg::Dccrg& mpiGrid, bool adaptRefinement(dccrg::Dccrg& mpiGrid, FsGrid & technicalGrid, SysBoundary& sysBoundaries, Project& project, int useStatic) { phiprof::Timer amrTimer {"Re-refine spatial cells"}; - int refines {0}; + uint64_t refines {0}; if (useStatic > -1) { project.forceRefinement(mpiGrid, useStatic); } else { @@ -1454,7 +1454,7 @@ bool adaptRefinement(dccrg::Dccrg& mpiGri refines = project.adaptRefinement(mpiGrid); } - int cells = getLocalCells().size(); + uint64_t cells = getLocalCells().size(); MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(MPI_IN_PLACE, &cells, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); double ratio_refines = static_cast(refines) / static_cast(cells); @@ -1468,8 +1468,8 @@ bool adaptRefinement(dccrg::Dccrg& mpiGri refines = mpiGrid.get_local_cells_to_refine().size(); int coarsens {mpiGrid.get_local_cells_to_unrefine().size()}; - MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(MPI_IN_PLACE, &coarsens, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &coarsens, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); ratio_refines = static_cast(refines) / static_cast(cells); double ratio_coarsens = static_cast(coarsens) / static_cast(cells); logFile << "(AMR) Refining " << refines << " cells after induces, " << 100.0 * ratio_refines << "% of grid" << std::endl; diff --git a/projects/project.cpp b/projects/project.cpp index a4b174fec..11d21c052 100644 --- a/projects/project.cpp +++ b/projects/project.cpp @@ -563,12 +563,12 @@ namespace projects { return cell->sysBoundaryFlag == sysboundarytype::NOT_SYSBOUNDARY && (cell->sysBoundaryLayer == 0 || cell->sysBoundaryLayer > 2); } - int Project::adaptRefinement( dccrg::Dccrg& mpiGrid ) const { + uint64_t Project::adaptRefinement( dccrg::Dccrg& mpiGrid ) const { phiprof::Timer refinesTimer {"Set refines"}; int myRank; MPI_Comm_rank(MPI_COMM_WORLD,&myRank); - int refines {0}; + uint64_t refines {0}; if (!P::useAlpha1 && !P::useAlpha2) { if (myRank == MASTER_RANK) { std::cout << "WARNING All refinement indices disabled" << std::endl; diff --git a/projects/project.h b/projects/project.h index 0e7f44dc3..2980b8c3e 100644 --- a/projects/project.h +++ b/projects/project.h @@ -91,7 +91,7 @@ namespace projects { * \param mpiGrid grid to refine * @return The amount of cells set to refine */ - virtual int adaptRefinement( dccrg::Dccrg& mpiGrid ) const; + virtual uint64_t adaptRefinement( dccrg::Dccrg& mpiGrid ) const; /*!\brief Refine/unrefine spatial cells one level to the static criteria in the config From 667c37c143584af5bf3cda08f1d6598f57925c63 Mon Sep 17 00:00:00 2001 From: lkotipal Date: Wed, 9 Oct 2024 14:36:30 +0300 Subject: [PATCH 3/5] oops x2 --- grid.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grid.cpp b/grid.cpp index 2ada8c6f7..5bc701770 100644 --- a/grid.cpp +++ b/grid.cpp @@ -1467,7 +1467,7 @@ bool adaptRefinement(dccrg::Dccrg& mpiGri initTimer.stop(); refines = mpiGrid.get_local_cells_to_refine().size(); - int coarsens {mpiGrid.get_local_cells_to_unrefine().size()}; + uint64_t coarsens {mpiGrid.get_local_cells_to_unrefine().size()}; MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); MPI_Allreduce(MPI_IN_PLACE, &coarsens, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); ratio_refines = static_cast(refines) / static_cast(cells); From 17f8f8dcbe4c6603def643ac53b9eadc5c450c8f Mon Sep 17 00:00:00 2001 From: lkotipal Date: Wed, 9 Oct 2024 15:07:26 +0300 Subject: [PATCH 4/5] Fix more type issues in MPI_SUM --- grid.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/grid.cpp b/grid.cpp index 5bc701770..f4ffefdfb 100644 --- a/grid.cpp +++ b/grid.cpp @@ -1454,9 +1454,9 @@ bool adaptRefinement(dccrg::Dccrg& mpiGri refines = project.adaptRefinement(mpiGrid); } - uint64_t cells = getLocalCells().size(); - MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(MPI_IN_PLACE, &cells, 1, MPI_INT, MPI_SUM, MPI_COMM_WORLD); + uint64_t cells {getLocalCells().size()}; + MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); + MPI_Allreduce(MPI_IN_PLACE, &cells, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); double ratio_refines = static_cast(refines) / static_cast(cells); logFile << "(AMR) Refining " << refines << " cells, " << 100.0 * ratio_refines << "% of grid" << std::endl; From 8586311742486760e31e6187f45248ac09088e69 Mon Sep 17 00:00:00 2001 From: lkotipal Date: Tue, 22 Oct 2024 13:39:03 +0300 Subject: [PATCH 5/5] Get counts directly --- grid.cpp | 6 ++---- submodules/dccrg | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/grid.cpp b/grid.cpp index f4ffefdfb..26ad39c98 100644 --- a/grid.cpp +++ b/grid.cpp @@ -1466,10 +1466,8 @@ bool adaptRefinement(dccrg::Dccrg& mpiGri mpiGrid.initialize_refines(); initTimer.stop(); - refines = mpiGrid.get_local_cells_to_refine().size(); - uint64_t coarsens {mpiGrid.get_local_cells_to_unrefine().size()}; - MPI_Allreduce(MPI_IN_PLACE, &refines, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); - MPI_Allreduce(MPI_IN_PLACE, &coarsens, 1, MPI_UINT64_T, MPI_SUM, MPI_COMM_WORLD); + refines = mpiGrid.get_cells_to_refine_count(); + uint64_t coarsens {mpiGrid.get_cells_to_unrefine_count()}; ratio_refines = static_cast(refines) / static_cast(cells); double ratio_coarsens = static_cast(coarsens) / static_cast(cells); logFile << "(AMR) Refining " << refines << " cells after induces, " << 100.0 * ratio_refines << "% of grid" << std::endl; diff --git a/submodules/dccrg b/submodules/dccrg index cad44660c..26efea4b6 160000 --- a/submodules/dccrg +++ b/submodules/dccrg @@ -1 +1 @@ -Subproject commit cad44660c86a904ecf35061c92cc744e9ad4f37e +Subproject commit 26efea4b6287ba83b212e4ebaa093e30d37309bc