From 1217e8a2541fd2ec7ec9c7b52d57512e0c9bf406 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 10 Sep 2024 18:11:35 -0400 Subject: [PATCH 1/2] make const_grav in the r direction for 2D r-theta --- Source/gravity/Gravity.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Source/gravity/Gravity.cpp b/Source/gravity/Gravity.cpp index c5f7bac162..cad22c3a83 100644 --- a/Source/gravity/Gravity.cpp +++ b/Source/gravity/Gravity.cpp @@ -883,9 +883,13 @@ Gravity::get_old_grav_vector(int level, MultiFab& grav_vector, Real time) if (gravity::gravity_type == "ConstantGrav") { - // Set to constant value in the AMREX_SPACEDIM direction and zero in all others. - - grav.setVal(gravity::const_grav,AMREX_SPACEDIM-1,1,ng); + if (AMREX_SPACEDIM == 2 && geom.Coord() == 2) { + // 2D spherical r-theta, we want g in the radial direction + grav.setVal(gravity::const_grav, 0, 1, ng); + } else { + // Set to constant value in the AMREX_SPACEDIM direction and zero in all others. + grav.setVal(gravity::const_grav, AMREX_SPACEDIM-1, 1, ng); + } } else if (gravity::gravity_type == "MonopoleGrav") { @@ -955,8 +959,13 @@ Gravity::get_new_grav_vector(int level, MultiFab& grav_vector, Real time) if (gravity::gravity_type == "ConstantGrav") { - // Set to constant value in the AMREX_SPACEDIM direction - grav.setVal(gravity::const_grav,AMREX_SPACEDIM-1,1,ng); + if (AMREX_SPACEDIM == 2 && geom.Coord() == 2) { + // 2D spherical r-theta, we want g in the radial direction + grav.setVal(gravity::const_grav, 0, 1, ng); + } else { + // Set to constant value in the AMREX_SPACEDIM direction + grav.setVal(gravity::const_grav, AMREX_SPACEDIM-1, 1, ng); + } } else if (gravity::gravity_type == "MonopoleGrav") { From cef267502698c9d98cd41336ab3835421406dcdb Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 10 Sep 2024 18:27:31 -0400 Subject: [PATCH 2/2] fix compilation --- Source/gravity/Gravity.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Source/gravity/Gravity.cpp b/Source/gravity/Gravity.cpp index cad22c3a83..edeb7359d2 100644 --- a/Source/gravity/Gravity.cpp +++ b/Source/gravity/Gravity.cpp @@ -881,6 +881,8 @@ Gravity::get_old_grav_vector(int level, MultiFab& grav_vector, Real time) MultiFab grav(grids[level], dmap[level], AMREX_SPACEDIM, ng); grav.setVal(0.0,ng); + const Geometry& geom = parent->Geom(level); + if (gravity::gravity_type == "ConstantGrav") { if (AMREX_SPACEDIM == 2 && geom.Coord() == 2) { @@ -899,7 +901,6 @@ Gravity::get_old_grav_vector(int level, MultiFab& grav_vector, Real time) } else if (gravity::gravity_type == "PoissonGrav") { - const Geometry& geom = parent->Geom(level); amrex::average_face_to_cellcenter(grav, amrex::GetVecOfConstPtrs(grad_phi_prev[level]), geom); grav.mult(-1.0, ng); // g = - grad(phi) @@ -956,6 +957,7 @@ Gravity::get_new_grav_vector(int level, MultiFab& grav_vector, Real time) MultiFab grav(grids[level],dmap[level],AMREX_SPACEDIM,ng); grav.setVal(0.0,ng); + const Geometry& geom = parent->Geom(level); if (gravity::gravity_type == "ConstantGrav") { @@ -976,7 +978,6 @@ Gravity::get_new_grav_vector(int level, MultiFab& grav_vector, Real time) } else if (gravity::gravity_type == "PoissonGrav") { - const Geometry& geom = parent->Geom(level); amrex::average_face_to_cellcenter(grav, amrex::GetVecOfConstPtrs(grad_phi_curr[level]), geom); grav.mult(-1.0, ng); // g = - grad(phi)