Commit a742b366 authored by Mark Meredith's avatar Mark Meredith
Browse files

Add time fields

parent 38211678
Loading
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -34,10 +34,13 @@ struct MeshSettings {
  std::array<MeshAxis, 3> axes;
};
struct TimeSettings {
  unsigned int max_step;
  bool fixed_dt;
  double cfl;
  double dt_max;
  double dt_min;
  double tcoll_ratio;
  double tstop;
  unsigned int max_step;
};
struct SolverSettings {
  GeometrySettings geometry;
+25 −0
Original line number Diff line number Diff line
@@ -11,6 +11,9 @@ std::optional<solver::TimeSettings> make_time(solver::InputInfo ii) {
  std::string DT_MIN("mfix.dt_min");
  std::string MAXSTEP("mfix.max_step");
  std::string TSTOP("mfix.stop_time");
  std::string FIXED_DT("mfix.fixed_dt");
  std::string CFL("mfix.cfl");
  std::string TCOLL_RATIO("mfix.tcoll_ratio");

  auto dt_max = std::get<solver::NumberArray>(ii[DT_MAX]);
  if (dt_max.size() != 1) {
@@ -44,6 +47,28 @@ std::optional<solver::TimeSettings> make_time(solver::InputInfo ii) {
    time.tstop = tstop[0];
  }

  auto fixed_dt = std::get<solver::NumberArray>(ii[FIXED_DT]);
  if (fixed_dt.size() != 1) {
    std::cout << "fixed_dt is a scalar" << std::endl;
  } else {
    time.fixed_dt = (fixed_dt[0] != 0);
  }

  auto cfl = std::get<solver::NumberArray>(ii[CFL]);
  if (cfl.size() != 1) {
    std::cout << "cfl is a scalar" << std::endl;
  } else {
    time.cfl = cfl[0];
  }

  auto tcoll_ratio = std::get<solver::NumberArray>(ii[TCOLL_RATIO]);
  if (tcoll_ratio.size() != 1) {
    std::cout << "tcoll_ratio is a scalar" << std::endl;
  } else {
    time.tcoll_ratio = tcoll_ratio[0];
  }


  return time;
}
} // namespace solver
+10 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

#include <solver.hpp>

std::string BLOCKING_FACTOR("amr.blocking_factor");
std::string DT_MAX("mfix.dt_max");
std::string DT_MIN("mfix.dt_min");
std::string MAXSTEP("mfix.max_step");
@@ -12,7 +13,9 @@ std::string PERIODIC("geometry.is_periodic");
std::string PROB_HI("geometry.prob_hi");
std::string PROB_LO("geometry.prob_lo");
std::string TSTOP("mfix.stop_time");
std::string BLOCKING_FACTOR("amr.blocking_factor");
std::string FIXED_DT("mfix.fixed_dt");
std::string CFL("mfix.cfl");
std::string TCOLL_RATIO("mfix.tcoll_ratio");

TEST_CASE("empty (invalid) map", "[]") {
  solver::InputInfo ii;
@@ -31,6 +34,9 @@ TEST_CASE("from_origin", "[]") {
  ii[MAXSTEP] = solver::NumberArray({39});
  ii[TSTOP] = solver::NumberArray({3.14});
  ii[BLOCKING_FACTOR] = solver::NumberArray({222});
  ii[FIXED_DT] = solver::NumberArray({1});
  ii[CFL] = solver::NumberArray({0.77});
  ii[TCOLL_RATIO] = solver::NumberArray({49.2});
  CHECK(ii.count(PROB_LO));
  CHECK(ii.count(PROB_HI));
  CHECK(ii.count(PERIODIC));
@@ -59,6 +65,9 @@ TEST_CASE("from_origin", "[]") {
  CHECK(sv.time.max_step == 39);
  CHECK(sv.time.tstop == 3.14);
  CHECK(sv.mesh.blocking_factor == 222);
  CHECK(sv.time.fixed_dt);
  CHECK(sv.time.cfl == 0.77);
  CHECK(sv.time.tcoll_ratio == 49.2);
}

TEST_CASE("negative_positive", "[]") {