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

Merge branch 'mwm/add_csgtree_to_inputs' into 'master'

Add mfix.geometry_filename to inputs parsing

See merge request exa/mfix-parser!17
parents f0203616 805f0532
Loading
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -47,6 +47,7 @@ private:
  std::unique_ptr<Impl> m_pimpl;
};

std::shared_ptr<csg::Tree> get_csgtree_from_filename(std::string);
std::unique_ptr<CsgIF> get_csgif_from_filename(std::string geom_file);

} // namespace csg
+6 −3
Original line number Diff line number Diff line
@@ -54,14 +54,17 @@ double CsgIF::operator()(double xx, double yy, double zz) const noexcept {
  return m_pimpl->call_signed_distance(m_state, xx, yy, zz);
}

std::unique_ptr<CsgIF> get_csgif_from_filename(std::string geom_file) {

std::shared_ptr<csg::Tree> get_csgtree_from_filename(std::string geom_file) {
  auto csg_str = read_csg(geom_file);
  if (!csg_str) {
    std::cout << "Unable to read .csg file:  " << geom_file << std::endl;
    return nullptr;
  }
  auto csg_obj = csg::parse_csg(csg_str.value());
  return csg::parse_csg(csg_str.value());
}

std::unique_ptr<CsgIF> get_csgif_from_filename(std::string geom_file) {
  auto csg_obj = get_csgtree_from_filename(geom_file);

  if (!csg_obj) {
    std::cout << "Failed to parse .csg file:  " << geom_file << std::endl;
+12 −0
Original line number Diff line number Diff line
@@ -6,6 +6,17 @@ namespace solver {

std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) {
  solver::GeometrySettings geo;

  if (!ii.count(CSG_FILENAME)) {
    require(CSG_FILENAME);
    return std::nullopt;
  }
  auto csg_filename = std::get<solver::StringArray>(ii[CSG_FILENAME]);
  if (csg_filename.size() != 1) {
    std::cout << CSG_FILENAME << " should only have 1 element" << std::endl;
    return std::nullopt;
  }

  if (!ii.count(PROB_LO)) {
    require(PROB_LO);
    return std::nullopt;
@@ -34,6 +45,7 @@ std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) {
    return std::nullopt;
  }

  geo.csg_filename = csg_filename[0];
  std::get<0>(geo.axes).high = highs[0];
  std::get<0>(geo.axes).low = lows[0];
  std::get<0>(geo.axes).periodic = is_periodic[0];
+1 −0
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ static const std::string DT_MIN("mfix.dt_min");
static const std::string PERIODIC("geometry.is_periodic");
static const std::string PROB_HI("geometry.prob_hi");
static const std::string PROB_LO("geometry.prob_lo");
static const std::string CSG_FILENAME("mfix.geometry_filename");

// Mesh
static const std::string BLOCKING_FACTOR("amr.blocking_factor");
+1 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ struct GeometryAxis {
};
struct GeometrySettings {
  std::array<GeometryAxis, 3> axes;
  std::string csg_filename;
};

struct MeshAxis {
Loading