From 950b9c4748aa9c15b5aeaaa93b50f5977c64bfed Mon Sep 17 00:00:00 2001 From: Zhi Date: Wed, 18 Sep 2024 19:50:47 -0400 Subject: [PATCH 1/6] update cfl_violation and timestep for spherical2d --- Source/driver/timestep.cpp | 23 ++++++++++++++++++++++- Source/hydro/Castro_hydro.cpp | 5 +++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/Source/driver/timestep.cpp b/Source/driver/timestep.cpp index a7b5936e4e..c345d99a4f 100644 --- a/Source/driver/timestep.cpp +++ b/Source/driver/timestep.cpp @@ -82,6 +82,11 @@ Castro::estdt_cfl (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(c + std::abs(uy)); + if (geom.IsSPHERICAL) { + // dx[1] in Spherical2D is just dtheta, need rdtheta for physical length + // so just multiply by the smallest r + dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; + } #else dt2 = dt1; #endif @@ -206,6 +211,9 @@ Castro::estdt_mhd (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(cy + std::abs(uy)); + if (geom.IsSPHERICAL) { + dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; + } #else dt2 = dt1; #endif @@ -287,6 +295,10 @@ Castro::estdt_temp_diffusion (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = 0.5_rt * dx[1]*dx[1] / D; + if (geom.IsSPHERICAL) { + Real r = geom.ProbLo(0) + 0.5_rt * dx[0]; + dt2 *= r * r; + } #else dt2 = dt1; #endif @@ -368,7 +380,13 @@ Castro::estdt_burning (int is_new) #if AMREX_SPACEDIM == 1 burn_state.dx = dx[0]; #else - burn_state.dx = amrex::min(AMREX_D_DECL(dx[0], dx[1], dx[2])); + Real r = 1.0_rt; +#if AMREX_SPACEDIM >= 2 + if (geom.IsSPHERICAL) { + r = geom.ProbLo(0) + 0.5_rt * dx[0]; + } +#endif + burn_state.dx = amrex::min(AMREX_D_DECL(dx[0], r * dx[1], dx[2])); #endif burn_state.rho = S(i,j,k,URHO); @@ -523,6 +541,9 @@ Castro::estdt_rad (int is_new) Real dt1 = dx[0] / (c + std::abs(ux)); #if AMREX_SPACEDIM >= 2 Real dt2 = dx[1] / (c + std::abs(uy)); + if (geom.IsSPHERICAL) { + dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; + } #else Real dt2 = std::numeric_limits::max(); #endif diff --git a/Source/hydro/Castro_hydro.cpp b/Source/hydro/Castro_hydro.cpp index 0dedbc17aa..9cbeb1febb 100644 --- a/Source/hydro/Castro_hydro.cpp +++ b/Source/hydro/Castro_hydro.cpp @@ -243,6 +243,11 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) Real dtdy = 0.0_rt; if (AMREX_SPACEDIM >= 2) { dtdy = dt / dx[1]; + if (geom.IsSPHERICAL) { + // dx[1] in Spherical2D is just rdtheta, need rdtheta for physical length + // Just choose to divide by the smallest r + dtdy /= geom.ProbLo(0) + 0.5_rt * dx[0]; + } } Real dtdz = 0.0_rt; From 058febb7f2827965889d0108cbdb46caf0087e55 Mon Sep 17 00:00:00 2001 From: Zhi Date: Wed, 18 Sep 2024 20:31:47 -0400 Subject: [PATCH 2/6] fix --- Source/driver/timestep.cpp | 10 +++++----- Source/hydro/Castro_hydro.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Source/driver/timestep.cpp b/Source/driver/timestep.cpp index c345d99a4f..345e0c52b7 100644 --- a/Source/driver/timestep.cpp +++ b/Source/driver/timestep.cpp @@ -82,7 +82,7 @@ Castro::estdt_cfl (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(c + std::abs(uy)); - if (geom.IsSPHERICAL) { + if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just dtheta, need rdtheta for physical length // so just multiply by the smallest r dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; @@ -211,7 +211,7 @@ Castro::estdt_mhd (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(cy + std::abs(uy)); - if (geom.IsSPHERICAL) { + if (geom.IsSPHERICAL()) { dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; } #else @@ -295,7 +295,7 @@ Castro::estdt_temp_diffusion (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = 0.5_rt * dx[1]*dx[1] / D; - if (geom.IsSPHERICAL) { + if (geom.IsSPHERICAL()) { Real r = geom.ProbLo(0) + 0.5_rt * dx[0]; dt2 *= r * r; } @@ -382,7 +382,7 @@ Castro::estdt_burning (int is_new) #else Real r = 1.0_rt; #if AMREX_SPACEDIM >= 2 - if (geom.IsSPHERICAL) { + if (geom.IsSPHERICAL()) { r = geom.ProbLo(0) + 0.5_rt * dx[0]; } #endif @@ -541,7 +541,7 @@ Castro::estdt_rad (int is_new) Real dt1 = dx[0] / (c + std::abs(ux)); #if AMREX_SPACEDIM >= 2 Real dt2 = dx[1] / (c + std::abs(uy)); - if (geom.IsSPHERICAL) { + if (geom.IsSPHERICAL()) { dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; } #else diff --git a/Source/hydro/Castro_hydro.cpp b/Source/hydro/Castro_hydro.cpp index 9cbeb1febb..e7ed8cac6c 100644 --- a/Source/hydro/Castro_hydro.cpp +++ b/Source/hydro/Castro_hydro.cpp @@ -243,7 +243,7 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) Real dtdy = 0.0_rt; if (AMREX_SPACEDIM >= 2) { dtdy = dt / dx[1]; - if (geom.IsSPHERICAL) { + if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just rdtheta, need rdtheta for physical length // Just choose to divide by the smallest r dtdy /= geom.ProbLo(0) + 0.5_rt * dx[0]; From dc707fd82508e1f5d96da9709515db7b6e45cdf0 Mon Sep 17 00:00:00 2001 From: Zhi Date: Wed, 18 Sep 2024 20:46:51 -0400 Subject: [PATCH 3/6] try fix gpu compilation again --- Source/driver/timestep.cpp | 15 ++++++++++----- Source/hydro/Castro_hydro.cpp | 3 ++- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/driver/timestep.cpp b/Source/driver/timestep.cpp index 345e0c52b7..e7c14ad379 100644 --- a/Source/driver/timestep.cpp +++ b/Source/driver/timestep.cpp @@ -35,6 +35,7 @@ Castro::estdt_cfl (int is_new) // Courant-condition limited timestep const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -85,7 +86,7 @@ Castro::estdt_cfl (int is_new) if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just dtheta, need rdtheta for physical length // so just multiply by the smallest r - dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; + dt2 *= problo[0] + 0.5_rt * dx[0]; } #else dt2 = dt1; @@ -132,6 +133,7 @@ Castro::estdt_mhd (int is_new) // MHD timestep limiter const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); const MultiFab& U_state = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -212,7 +214,7 @@ Castro::estdt_mhd (int is_new) #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(cy + std::abs(uy)); if (geom.IsSPHERICAL()) { - dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; + dt2 *= problo[0] + 0.5_rt * dx[0]; } #else dt2 = dt1; @@ -246,6 +248,7 @@ Castro::estdt_temp_diffusion (int is_new) // where D = k/(rho c_v), and k is the conductivity const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -296,7 +299,7 @@ Castro::estdt_temp_diffusion (int is_new) #if AMREX_SPACEDIM >= 2 dt2 = 0.5_rt * dx[1]*dx[1] / D; if (geom.IsSPHERICAL()) { - Real r = geom.ProbLo(0) + 0.5_rt * dx[0]; + Real r = problo[0] + 0.5_rt * dx[0]; dt2 *= r * r; } #else @@ -332,6 +335,7 @@ Castro::estdt_burning (int is_new) } const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -383,7 +387,7 @@ Castro::estdt_burning (int is_new) Real r = 1.0_rt; #if AMREX_SPACEDIM >= 2 if (geom.IsSPHERICAL()) { - r = geom.ProbLo(0) + 0.5_rt * dx[0]; + r = problo[0] + 0.5_rt * dx[0]; } #endif burn_state.dx = amrex::min(AMREX_D_DECL(dx[0], r * dx[1], dx[2])); @@ -482,6 +486,7 @@ Real Castro::estdt_rad (int is_new) { auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); const MultiFab& radMF = is_new ? get_new_data(Rad_Type) : get_old_data(Rad_Type); @@ -542,7 +547,7 @@ Castro::estdt_rad (int is_new) #if AMREX_SPACEDIM >= 2 Real dt2 = dx[1] / (c + std::abs(uy)); if (geom.IsSPHERICAL()) { - dt2 *= geom.ProbLo(0) + 0.5_rt * dx[0]; + dt2 *= problo[0] + 0.5_rt * dx[0]; } #else Real dt2 = std::numeric_limits::max(); diff --git a/Source/hydro/Castro_hydro.cpp b/Source/hydro/Castro_hydro.cpp index e7ed8cac6c..9c5cc19644 100644 --- a/Source/hydro/Castro_hydro.cpp +++ b/Source/hydro/Castro_hydro.cpp @@ -237,6 +237,7 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) int cfl_violation = 0; auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); Real dtdx = dt / dx[0]; @@ -246,7 +247,7 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just rdtheta, need rdtheta for physical length // Just choose to divide by the smallest r - dtdy /= geom.ProbLo(0) + 0.5_rt * dx[0]; + dtdy /= problo[0] + 0.5_rt * dx[0]; } } From e187c15d1cdb21b5d8ac7e8ef5a9ba1fd6c1af5f Mon Sep 17 00:00:00 2001 From: Zhi Date: Wed, 18 Sep 2024 20:51:45 -0400 Subject: [PATCH 4/6] try again fix gpu --- Source/driver/timestep.cpp | 15 +++++---------- Source/hydro/Castro_hydro.cpp | 3 +-- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Source/driver/timestep.cpp b/Source/driver/timestep.cpp index e7c14ad379..a70a624381 100644 --- a/Source/driver/timestep.cpp +++ b/Source/driver/timestep.cpp @@ -35,7 +35,6 @@ Castro::estdt_cfl (int is_new) // Courant-condition limited timestep const auto dx = geom.CellSizeArray(); - const auto problo = geom.ProbLoArray(); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -86,7 +85,7 @@ Castro::estdt_cfl (int is_new) if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just dtheta, need rdtheta for physical length // so just multiply by the smallest r - dt2 *= problo[0] + 0.5_rt * dx[0]; + dt2 *= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; } #else dt2 = dt1; @@ -133,7 +132,6 @@ Castro::estdt_mhd (int is_new) // MHD timestep limiter const auto dx = geom.CellSizeArray(); - const auto problo = geom.ProbLoArray(); const MultiFab& U_state = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -214,7 +212,7 @@ Castro::estdt_mhd (int is_new) #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(cy + std::abs(uy)); if (geom.IsSPHERICAL()) { - dt2 *= problo[0] + 0.5_rt * dx[0]; + dt2 *= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; } #else dt2 = dt1; @@ -248,7 +246,6 @@ Castro::estdt_temp_diffusion (int is_new) // where D = k/(rho c_v), and k is the conductivity const auto dx = geom.CellSizeArray(); - const auto problo = geom.ProbLoArray(); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -299,7 +296,7 @@ Castro::estdt_temp_diffusion (int is_new) #if AMREX_SPACEDIM >= 2 dt2 = 0.5_rt * dx[1]*dx[1] / D; if (geom.IsSPHERICAL()) { - Real r = problo[0] + 0.5_rt * dx[0]; + Real r = geom.ProbLoArray()[0] + 0.5_rt * dx[0]; dt2 *= r * r; } #else @@ -335,7 +332,6 @@ Castro::estdt_burning (int is_new) } const auto dx = geom.CellSizeArray(); - const auto problo = geom.ProbLoArray(); MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -387,7 +383,7 @@ Castro::estdt_burning (int is_new) Real r = 1.0_rt; #if AMREX_SPACEDIM >= 2 if (geom.IsSPHERICAL()) { - r = problo[0] + 0.5_rt * dx[0]; + r = geom.ProbLoArray()[0] + 0.5_rt * dx[0]; } #endif burn_state.dx = amrex::min(AMREX_D_DECL(dx[0], r * dx[1], dx[2])); @@ -486,7 +482,6 @@ Real Castro::estdt_rad (int is_new) { auto dx = geom.CellSizeArray(); - const auto problo = geom.ProbLoArray(); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); const MultiFab& radMF = is_new ? get_new_data(Rad_Type) : get_old_data(Rad_Type); @@ -547,7 +542,7 @@ Castro::estdt_rad (int is_new) #if AMREX_SPACEDIM >= 2 Real dt2 = dx[1] / (c + std::abs(uy)); if (geom.IsSPHERICAL()) { - dt2 *= problo[0] + 0.5_rt * dx[0]; + dt2 *= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; } #else Real dt2 = std::numeric_limits::max(); diff --git a/Source/hydro/Castro_hydro.cpp b/Source/hydro/Castro_hydro.cpp index 9c5cc19644..9e3116b0b9 100644 --- a/Source/hydro/Castro_hydro.cpp +++ b/Source/hydro/Castro_hydro.cpp @@ -237,7 +237,6 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) int cfl_violation = 0; auto dx = geom.CellSizeArray(); - const auto problo = geom.ProbLoArray(); Real dtdx = dt / dx[0]; @@ -247,7 +246,7 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just rdtheta, need rdtheta for physical length // Just choose to divide by the smallest r - dtdy /= problo[0] + 0.5_rt * dx[0]; + dtdy /= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; } } From 98ced0b7d503f77ca9f62d1ae48c3c34e4199ea0 Mon Sep 17 00:00:00 2001 From: Zhi Date: Wed, 18 Sep 2024 21:01:30 -0400 Subject: [PATCH 5/6] fix gpu compilation again --- Source/driver/timestep.cpp | 20 +++++++++++++++----- Source/hydro/Castro_hydro.cpp | 4 +++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/Source/driver/timestep.cpp b/Source/driver/timestep.cpp index a70a624381..31144a7e9e 100644 --- a/Source/driver/timestep.cpp +++ b/Source/driver/timestep.cpp @@ -35,6 +35,8 @@ Castro::estdt_cfl (int is_new) // Courant-condition limited timestep const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); + amrex::ignore_unused(problo); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -85,7 +87,7 @@ Castro::estdt_cfl (int is_new) if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just dtheta, need rdtheta for physical length // so just multiply by the smallest r - dt2 *= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; + dt2 *= problo[0] + 0.5_rt * dx[0]; } #else dt2 = dt1; @@ -132,6 +134,8 @@ Castro::estdt_mhd (int is_new) // MHD timestep limiter const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); + amrex::ignore_unused(problo); const MultiFab& U_state = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -212,7 +216,7 @@ Castro::estdt_mhd (int is_new) #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(cy + std::abs(uy)); if (geom.IsSPHERICAL()) { - dt2 *= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; + dt2 *= problo[0] + 0.5_rt * dx[0]; } #else dt2 = dt1; @@ -246,6 +250,8 @@ Castro::estdt_temp_diffusion (int is_new) // where D = k/(rho c_v), and k is the conductivity const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); + amrex::ignore_unused(problo); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -296,7 +302,7 @@ Castro::estdt_temp_diffusion (int is_new) #if AMREX_SPACEDIM >= 2 dt2 = 0.5_rt * dx[1]*dx[1] / D; if (geom.IsSPHERICAL()) { - Real r = geom.ProbLoArray()[0] + 0.5_rt * dx[0]; + Real r = problo[0] + 0.5_rt * dx[0]; dt2 *= r * r; } #else @@ -332,6 +338,8 @@ Castro::estdt_burning (int is_new) } const auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); + amrex::ignore_unused(problo); MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -383,7 +391,7 @@ Castro::estdt_burning (int is_new) Real r = 1.0_rt; #if AMREX_SPACEDIM >= 2 if (geom.IsSPHERICAL()) { - r = geom.ProbLoArray()[0] + 0.5_rt * dx[0]; + r = problo[0] + 0.5_rt * dx[0]; } #endif burn_state.dx = amrex::min(AMREX_D_DECL(dx[0], r * dx[1], dx[2])); @@ -482,6 +490,8 @@ Real Castro::estdt_rad (int is_new) { auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); + amrex::ignore_unused(problo); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); const MultiFab& radMF = is_new ? get_new_data(Rad_Type) : get_old_data(Rad_Type); @@ -542,7 +552,7 @@ Castro::estdt_rad (int is_new) #if AMREX_SPACEDIM >= 2 Real dt2 = dx[1] / (c + std::abs(uy)); if (geom.IsSPHERICAL()) { - dt2 *= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; + dt2 *= problo[0] + 0.5_rt * dx[0]; } #else Real dt2 = std::numeric_limits::max(); diff --git a/Source/hydro/Castro_hydro.cpp b/Source/hydro/Castro_hydro.cpp index 9e3116b0b9..11dfe7fa72 100644 --- a/Source/hydro/Castro_hydro.cpp +++ b/Source/hydro/Castro_hydro.cpp @@ -237,6 +237,8 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) int cfl_violation = 0; auto dx = geom.CellSizeArray(); + const auto problo = geom.ProbLoArray(); + amrex::ignore_unused(problo); Real dtdx = dt / dx[0]; @@ -246,7 +248,7 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) if (geom.IsSPHERICAL()) { // dx[1] in Spherical2D is just rdtheta, need rdtheta for physical length // Just choose to divide by the smallest r - dtdy /= geom.ProbLoArray()[0] + 0.5_rt * dx[0]; + dtdy /= problo[0] + 0.5_rt * dx[0]; } } From 49cb4a02e55b67cc223c11cb97b9e49b64594575 Mon Sep 17 00:00:00 2001 From: Zhi Date: Wed, 18 Sep 2024 21:15:27 -0400 Subject: [PATCH 6/6] fix shadowing and clangtidy --- Source/driver/timestep.cpp | 31 ++++++++++++++++++------------- Source/hydro/Castro_hydro.cpp | 5 +++-- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Source/driver/timestep.cpp b/Source/driver/timestep.cpp index 31144a7e9e..fd7e029a4b 100644 --- a/Source/driver/timestep.cpp +++ b/Source/driver/timestep.cpp @@ -36,7 +36,8 @@ Castro::estdt_cfl (int is_new) const auto dx = geom.CellSizeArray(); const auto problo = geom.ProbLoArray(); - amrex::ignore_unused(problo); + const auto coord = geom.Coord(); + amrex::ignore_unused(problo, coord); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -84,7 +85,7 @@ Castro::estdt_cfl (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(c + std::abs(uy)); - if (geom.IsSPHERICAL()) { + if (coord == 2) { // dx[1] in Spherical2D is just dtheta, need rdtheta for physical length // so just multiply by the smallest r dt2 *= problo[0] + 0.5_rt * dx[0]; @@ -135,7 +136,8 @@ Castro::estdt_mhd (int is_new) // MHD timestep limiter const auto dx = geom.CellSizeArray(); const auto problo = geom.ProbLoArray(); - amrex::ignore_unused(problo); + const auto coord = geom.Coord(); + amrex::ignore_unused(problo, coord); const MultiFab& U_state = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -215,7 +217,7 @@ Castro::estdt_mhd (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = dx[1]/(cy + std::abs(uy)); - if (geom.IsSPHERICAL()) { + if (coord == 2) { dt2 *= problo[0] + 0.5_rt * dx[0]; } #else @@ -251,7 +253,8 @@ Castro::estdt_temp_diffusion (int is_new) const auto dx = geom.CellSizeArray(); const auto problo = geom.ProbLoArray(); - amrex::ignore_unused(problo); + const auto coord = geom.Coord(); + amrex::ignore_unused(problo, coord); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -301,7 +304,7 @@ Castro::estdt_temp_diffusion (int is_new) Real dt2; #if AMREX_SPACEDIM >= 2 dt2 = 0.5_rt * dx[1]*dx[1] / D; - if (geom.IsSPHERICAL()) { + if (coord == 2) { Real r = problo[0] + 0.5_rt * dx[0]; dt2 *= r * r; } @@ -339,7 +342,8 @@ Castro::estdt_burning (int is_new) const auto dx = geom.CellSizeArray(); const auto problo = geom.ProbLoArray(); - amrex::ignore_unused(problo); + const auto coord = geom.Coord(); + amrex::ignore_unused(problo, coord); MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); @@ -388,13 +392,13 @@ Castro::estdt_burning (int is_new) #if AMREX_SPACEDIM == 1 burn_state.dx = dx[0]; #else - Real r = 1.0_rt; + Real dx1 = dx[1]; #if AMREX_SPACEDIM >= 2 - if (geom.IsSPHERICAL()) { - r = problo[0] + 0.5_rt * dx[0]; + if (coord == 2) { + dx1 *= problo[0] + 0.5_rt * dx[0]; } #endif - burn_state.dx = amrex::min(AMREX_D_DECL(dx[0], r * dx[1], dx[2])); + burn_state.dx = amrex::min(AMREX_D_DECL(dx[0], dx1, dx[2])); #endif burn_state.rho = S(i,j,k,URHO); @@ -491,7 +495,8 @@ Castro::estdt_rad (int is_new) { auto dx = geom.CellSizeArray(); const auto problo = geom.ProbLoArray(); - amrex::ignore_unused(problo); + const auto coord = geom.Coord(); + amrex::ignore_unused(problo, coord); const MultiFab& stateMF = is_new ? get_new_data(State_Type) : get_old_data(State_Type); const MultiFab& radMF = is_new ? get_new_data(Rad_Type) : get_old_data(Rad_Type); @@ -551,7 +556,7 @@ Castro::estdt_rad (int is_new) Real dt1 = dx[0] / (c + std::abs(ux)); #if AMREX_SPACEDIM >= 2 Real dt2 = dx[1] / (c + std::abs(uy)); - if (geom.IsSPHERICAL()) { + if (coord == 2) { dt2 *= problo[0] + 0.5_rt * dx[0]; } #else diff --git a/Source/hydro/Castro_hydro.cpp b/Source/hydro/Castro_hydro.cpp index 11dfe7fa72..0e2250ed20 100644 --- a/Source/hydro/Castro_hydro.cpp +++ b/Source/hydro/Castro_hydro.cpp @@ -238,14 +238,15 @@ Castro::check_for_cfl_violation(const MultiFab& State, const Real dt) auto dx = geom.CellSizeArray(); const auto problo = geom.ProbLoArray(); - amrex::ignore_unused(problo); + const auto coord = geom.Coord(); + amrex::ignore_unused(problo, coord); Real dtdx = dt / dx[0]; Real dtdy = 0.0_rt; if (AMREX_SPACEDIM >= 2) { dtdy = dt / dx[1]; - if (geom.IsSPHERICAL()) { + if (coord == 2) { // dx[1] in Spherical2D is just rdtheta, need rdtheta for physical length // Just choose to divide by the smallest r dtdy /= problo[0] + 0.5_rt * dx[0];