Skip to content

Commit

Permalink
CarpetX: Implement minmod prolongation operator
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Oct 25, 2024
1 parent 1380ea6 commit 901bc9e
Show file tree
Hide file tree
Showing 7 changed files with 382 additions and 93 deletions.
3 changes: 2 additions & 1 deletion CarpetX/param.ccl
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,8 @@ KEYWORD prolongation_type "Prolongation type"
"interpolate" :: "interpolate between data points"
"conservative" :: "interpolate cell averages, ensuring conservation"
"ddf" :: "interpolate in vertex centred and conserve (with one order lower) in cell centred directions"
"eno" :: "interpolate in vertex centred and ENO-conserve in cell centred directions"
"eno" :: "interpolate in vertex centred and minmod-conserve in cell centred directions"
"minmod" :: "interpolate in vertex centred and ENO-conserve in cell centred directions"
"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"
Expand Down
72 changes: 72 additions & 0 deletions CarpetX/src/driver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,7 @@ amrex::Interpolater *get_interpolator(const std::array<int, dim> indextype) {
conservative,
ddf,
eno,
minmod,
hermite,
natural,
poly_cons3lfb,
Expand All @@ -555,6 +556,8 @@ amrex::Interpolater *get_interpolator(const std::array<int, dim> indextype) {
return interp_t::ddf;
else if (CCTK_EQUALS(prolongation_type, "eno"))
return interp_t::eno;
else if (CCTK_EQUALS(prolongation_type, "minmod"))
return interp_t::minmod;
else if (CCTK_EQUALS(prolongation_type, "hermite"))
return interp_t::hermite;
else if (CCTK_EQUALS(prolongation_type, "natural"))
Expand Down Expand Up @@ -894,6 +897,75 @@ amrex::Interpolater *get_interpolator(const std::array<int, dim> indextype) {
}
break;

case interp_t::minmod:

switch (prolongation_order) {

case 1:
switch ((indextype[0] << 2) | (indextype[1] << 1) | (indextype[2] << 0)) {
case 0b000:
return &prolongate_minmod_3d_rf2_c000_o1;
case 0b001:
return &prolongate_minmod_3d_rf2_c001_o1;
case 0b010:
return &prolongate_minmod_3d_rf2_c010_o1;
case 0b011:
return &prolongate_minmod_3d_rf2_c011_o1;
case 0b100:
return &prolongate_minmod_3d_rf2_c100_o1;
case 0b101:
return &prolongate_minmod_3d_rf2_c101_o1;
case 0b110:
return &prolongate_minmod_3d_rf2_c110_o1;
case 0b111:
return &prolongate_minmod_3d_rf2_c111_o1;
}
break;

case 3:
switch ((indextype[0] << 2) | (indextype[1] << 1) | (indextype[2] << 0)) {
case 0b000:
return &prolongate_minmod_3d_rf2_c000_o3;
case 0b001:
return &prolongate_minmod_3d_rf2_c001_o3;
case 0b010:
return &prolongate_minmod_3d_rf2_c010_o3;
case 0b011:
return &prolongate_minmod_3d_rf2_c011_o3;
case 0b100:
return &prolongate_minmod_3d_rf2_c100_o3;
case 0b101:
return &prolongate_minmod_3d_rf2_c101_o3;
case 0b110:
return &prolongate_minmod_3d_rf2_c110_o3;
case 0b111:
return &prolongate_minmod_3d_rf2_c111_o3;
}
break;

case 5:
switch ((indextype[0] << 2) | (indextype[1] << 1) | (indextype[2] << 0)) {
case 0b000:
return &prolongate_minmod_3d_rf2_c000_o5;
case 0b001:
return &prolongate_minmod_3d_rf2_c001_o5;
case 0b010:
return &prolongate_minmod_3d_rf2_c010_o5;
case 0b011:
return &prolongate_minmod_3d_rf2_c011_o5;
case 0b100:
return &prolongate_minmod_3d_rf2_c100_o5;
case 0b101:
return &prolongate_minmod_3d_rf2_c101_o5;
case 0b110:
return &prolongate_minmod_3d_rf2_c110_o5;
case 0b111:
return &prolongate_minmod_3d_rf2_c111_o5;
}
break;
}
break;

case interp_t::hermite:

switch (prolongation_order) {
Expand Down
1 change: 1 addition & 0 deletions CarpetX/src/make.code.defn
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ SRCS = \
prolongate_3d_rf2_impl_ddf.cxx \
prolongate_3d_rf2_impl_eno.cxx \
prolongate_3d_rf2_impl_hermite.cxx \
prolongate_3d_rf2_impl_minmod.cxx \
prolongate_3d_rf2_impl_natural.cxx \
prolongate_3d_rf2_impl_poly.cxx \
prolongate_3d_rf2_impl_poly_cons3lfb.cxx \
Expand Down
2 changes: 2 additions & 0 deletions CarpetX/src/prolongate_3d_rf2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ std::ostream &operator<<(std::ostream &os, const interpolation_t intp) {
return os << "cons";
case interpolation_t::eno:
return os << "eno";
case interpolation_t::minmod:
return os << "minmod";
}
assert(false);
}
Expand Down
67 changes: 63 additions & 4 deletions CarpetX/src/prolongate_3d_rf2.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ std::ostream &operator<<(std::ostream &os, centering_t cent);
constexpr auto VC = centering_t::vertex;
constexpr auto CC = centering_t::cell;

enum class interpolation_t { poly, hermite, cons, eno };
enum class interpolation_t { poly, hermite, cons, eno, minmod };
std::ostream &operator<<(std::ostream &os, interpolation_t cent);
constexpr auto POLY = interpolation_t::poly;
constexpr auto HERMITE = interpolation_t::hermite;
constexpr auto CONS = interpolation_t::cons;
constexpr auto ENO = interpolation_t::eno;
constexpr auto MINMOD = interpolation_t::minmod;

enum class fallback_t { none, linear };
std::ostream &operator<<(std::ostream &os, fallback_t fb);
Expand All @@ -39,17 +40,22 @@ class prolongate_3d_rf2 final : public amrex::Interpolater {

// Conservative must be one of the possible choices
static_assert(INTPI == POLY || INTPI == HERMITE || INTPI == CONS ||
INTPI == ENO);
INTPI == ENO || INTPI == MINMOD);
static_assert(INTPJ == POLY || INTPJ == HERMITE || INTPJ == CONS ||
INTPJ == ENO);
INTPJ == ENO || INTPJ == MINMOD);
static_assert(INTPK == POLY || INTPK == HERMITE || INTPK == CONS ||
INTPK == ENO);
INTPK == ENO || INTPK == MINMOD);

// Order must be nonnegative
static_assert(ORDERI >= 0);
static_assert(ORDERJ >= 0);
static_assert(ORDERK >= 0);

// Minmod is always linear
static_assert(INTPI == MINMOD ? ORDERI == 1 : true);
static_assert(INTPJ == MINMOD ? ORDERJ == 1 : true);
static_assert(INTPK == MINMOD ? ORDERK == 1 : true);

// Fallback must be one of the possible choices
static_assert(FB == FB_NONE || FB == FB_LINEAR);

Expand Down Expand Up @@ -401,6 +407,59 @@ extern prolongate_3d_rf2<CC, CC, VC, ENO, ENO, POLY, 2, 2, 5, FB_NONE>
extern prolongate_3d_rf2<CC, CC, CC, ENO, ENO, ENO, 2, 2, 2, FB_NONE>
prolongate_eno_3d_rf2_c111_o5;

// Minmod (tensor product) interpolation

extern prolongate_3d_rf2<VC, VC, VC, POLY, POLY, POLY, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c000_o1;
extern prolongate_3d_rf2<VC, VC, CC, POLY, POLY, MINMOD, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c001_o1;
extern prolongate_3d_rf2<VC, CC, VC, POLY, MINMOD, POLY, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c010_o1;
extern prolongate_3d_rf2<VC, CC, CC, POLY, MINMOD, MINMOD, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c011_o1;
extern prolongate_3d_rf2<CC, VC, VC, MINMOD, POLY, POLY, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c100_o1;
extern prolongate_3d_rf2<CC, VC, CC, MINMOD, POLY, MINMOD, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c101_o1;
extern prolongate_3d_rf2<CC, CC, VC, MINMOD, MINMOD, POLY, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c110_o1;
extern prolongate_3d_rf2<CC, CC, CC, MINMOD, MINMOD, MINMOD, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c111_o1;

extern prolongate_3d_rf2<VC, VC, VC, POLY, POLY, POLY, 3, 3, 3, FB_NONE>
prolongate_minmod_3d_rf2_c000_o3;
extern prolongate_3d_rf2<VC, VC, CC, POLY, POLY, MINMOD, 3, 3, 1, FB_NONE>
prolongate_minmod_3d_rf2_c001_o3;
extern prolongate_3d_rf2<VC, CC, VC, POLY, MINMOD, POLY, 3, 1, 3, FB_NONE>
prolongate_minmod_3d_rf2_c010_o3;
extern prolongate_3d_rf2<VC, CC, CC, POLY, MINMOD, MINMOD, 3, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c011_o3;
extern prolongate_3d_rf2<CC, VC, VC, MINMOD, POLY, POLY, 1, 3, 3, FB_NONE>
prolongate_minmod_3d_rf2_c100_o3;
extern prolongate_3d_rf2<CC, VC, CC, MINMOD, POLY, MINMOD, 1, 3, 1, FB_NONE>
prolongate_minmod_3d_rf2_c101_o3;
extern prolongate_3d_rf2<CC, CC, VC, MINMOD, MINMOD, POLY, 1, 1, 3, FB_NONE>
prolongate_minmod_3d_rf2_c110_o3;
extern prolongate_3d_rf2<CC, CC, CC, MINMOD, MINMOD, MINMOD, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c111_o3;

extern prolongate_3d_rf2<VC, VC, VC, POLY, POLY, POLY, 5, 5, 5, FB_NONE>
prolongate_minmod_3d_rf2_c000_o5;
extern prolongate_3d_rf2<VC, VC, CC, POLY, POLY, MINMOD, 5, 5, 1, FB_NONE>
prolongate_minmod_3d_rf2_c001_o5;
extern prolongate_3d_rf2<VC, CC, VC, POLY, MINMOD, POLY, 5, 1, 5, FB_NONE>
prolongate_minmod_3d_rf2_c010_o5;
extern prolongate_3d_rf2<VC, CC, CC, POLY, MINMOD, MINMOD, 5, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c011_o5;
extern prolongate_3d_rf2<CC, VC, VC, MINMOD, POLY, POLY, 1, 5, 5, FB_NONE>
prolongate_minmod_3d_rf2_c100_o5;
extern prolongate_3d_rf2<CC, VC, CC, MINMOD, POLY, MINMOD, 1, 5, 1, FB_NONE>
prolongate_minmod_3d_rf2_c101_o5;
extern prolongate_3d_rf2<CC, CC, VC, MINMOD, MINMOD, POLY, 1, 1, 5, FB_NONE>
prolongate_minmod_3d_rf2_c110_o5;
extern prolongate_3d_rf2<CC, CC, CC, MINMOD, MINMOD, MINMOD, 1, 1, 1, FB_NONE>
prolongate_minmod_3d_rf2_c111_o5;

// Hermite interpolation

extern prolongate_3d_rf2<VC, VC, VC, HERMITE, HERMITE, HERMITE, 1, 1, 1,
Expand Down
Loading

0 comments on commit 901bc9e

Please sign in to comment.