Skip to content

Commit

Permalink
make const_grav in the r direction for 2D r-theta (#2957)
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale authored Sep 10, 2024
1 parent 916a2ec commit 7059f8b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions Source/gravity/Gravity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -881,11 +881,17 @@ 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);

if (gravity::gravity_type == "ConstantGrav") {
const Geometry& geom = parent->Geom(level);

// Set to constant value in the AMREX_SPACEDIM direction and zero in all others.
if (gravity::gravity_type == "ConstantGrav") {

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") {

Expand All @@ -895,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)

Expand Down Expand Up @@ -952,11 +957,17 @@ 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") {

// 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") {

Expand All @@ -967,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)

Expand Down

0 comments on commit 7059f8b

Please sign in to comment.