Skip to content

Commit

Permalink
CarpetX: add prolongation_type 'amrex-interp'
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Oct 6, 2024
1 parent e20789f commit f5cea50
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
1 change: 1 addition & 0 deletions CarpetX/param.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ KEYWORD prolongation_type "Prolongation type"
"hermite" :: "Hermite-interpolate in vertex centred and conserve in cell centred directions"
"natural" :: "interpolate in vertex centred and conserve in cell centred directions, using the same order"
"poly-cons3lfb" :: "interpolate polynomially in vertex centred directions and conserve with 3rd order accuracy and a linear fallback in cell centred directions"
"amrex-interp" :: "using amrex interpolation operator"
} "natural"

CCTK_INT prolongation_order "Prolongation order"
Expand Down
25 changes: 24 additions & 1 deletion CarpetX/src/driver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <AMReX.H>
#include <AMReX_BCRec.H>
#include <AMReX_Interpolater.H>
#include <AMReX_ParmParse.H>

#include <omp.h>
Expand Down Expand Up @@ -542,7 +543,7 @@ amrex::Interpolater *get_interpolator(const std::array<int, dim> indextype) {
hermite,
natural,
poly_cons3lfb,
poly_eno3lfb,
amrex_interp,
};
static interp_t interp = [&]() {
if (CCTK_EQUALS(prolongation_type, "interpolate"))
Expand All @@ -559,11 +560,33 @@ amrex::Interpolater *get_interpolator(const std::array<int, dim> indextype) {
return interp_t::natural;
else if (CCTK_EQUALS(prolongation_type, "poly-cons3lfb"))
return interp_t::poly_cons3lfb;
else if (CCTK_EQUALS(prolongation_type, "amrex-interp"))
return interp_t::amrex_interp;
else
assert(0);
}();

switch (interp) {
case interp_t::amrex_interp:

switch ((indextype[0] << 2) | (indextype[1] << 1) | (indextype[2] << 0)) {
case 0b000:
return &amrex::node_bilinear_interp;
break;
case 0b111:
return &amrex::cell_bilinear_interp;
break;
case 0b001:
case 0b010:
case 0b011:
case 0b100:
case 0b101:
case 0b110:
return &amrex::face_linear_interp;
break;
}
break;

case interp_t::interpolate:

switch ((indextype[0] << 2) | (indextype[1] << 1) | (indextype[2] << 0)) {
Expand Down

0 comments on commit f5cea50

Please sign in to comment.