Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make const_grav in the r direction for 2D r-theta #2957

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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