From 1217e8a2541fd2ec7ec9c7b52d57512e0c9bf406 Mon Sep 17 00:00:00 2001 From: Michael Zingale Date: Tue, 10 Sep 2024 18:11:35 -0400 Subject: [PATCH] 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") {