Loading src/geometry.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -6,9 +6,6 @@ namespace solver { std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { solver::GeometrySettings geo; std::string PROB_LO("geometry.prob_lo"); std::string PROB_HI("geometry.prob_hi"); std::string PERIODIC("geometry.is_periodic"); if (!ii.count(PROB_LO)) { require(PROB_LO); return std::nullopt; Loading src/inputs.hpp 0 → 100644 +28 −0 Original line number Diff line number Diff line #ifndef INPUTS_H_ #define INPUTS_H_ // Geometry static const std::string DT_MAX("mfix.dt_max"); 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"); // Mesh static const std::string SMALL_VOLFRAC("eb2.small_volfrac"); static const std::string BLOCKING_FACTOR("amr.blocking_factor"); static const std::string FABARRAY_TILE_SZ("fabarray.mfiter_tile_size"); static const std::string GRID_SIZE_X("amr.max_grid_size_x"); static const std::string GRID_SIZE_Y("amr.max_grid_size_y"); static const std::string GRID_SIZE_Z("amr.max_grid_size_z"); static const std::string N_CELL("amr.n_cell"); static const std::string PARTICLE_TILE_SZ("particles.tile_size"); // Time static const std::string CFL("mfix.cfl"); static const std::string FIXED_DT("mfix.fixed_dt"); static const std::string MAXSTEP("mfix.max_step"); static const std::string TCOLL_RATIO("mfix.tcoll_ratio"); static const std::string TSTOP("mfix.stop_time"); #endif src/mesh.cpp +54 −13 Original line number Diff line number Diff line Loading @@ -6,35 +6,76 @@ namespace solver { std::optional<solver::MeshSettings> make_mesh(solver::InputInfo ii) { solver::MeshSettings mesh; std::string N_CELL("amr.n_cell"); std::string BLOCKING_FACTOR("amr.blocking_factor"); if (!ii.count(N_CELL)) { require(N_CELL); return std::nullopt; } if (!ii.count(N_CELL)) { require(N_CELL); return std::nullopt; } auto n_cell = std::get<solver::NumberArray>(ii[N_CELL]); if (n_cell.size() != 3) { std::cout << "n_cell needs 3 elements " << std::endl; std::cout << N_CELL << " needs 3 elements " << std::endl; return std::nullopt; } std::get<0>(mesh.axes).n_cell = n_cell[0]; std::get<1>(mesh.axes).n_cell = n_cell[1]; std::get<2>(mesh.axes).n_cell = n_cell[2]; auto [mx, my, mz] = mesh.axes; mx.n_cell = n_cell[0]; my.n_cell = n_cell[1]; mz.n_cell = n_cell[2]; auto fabarray_size = std::get<solver::NumberArray>(ii[FABARRAY_TILE_SZ]); if (fabarray_size.size() != 3) { std::cout << FABARRAY_TILE_SZ << " needs 3 elements " << std::endl; } else { mx.fab_tile_size = fabarray_size[0]; my.fab_tile_size = fabarray_size[1]; mz.fab_tile_size = fabarray_size[2]; } auto part_grid_size = std::get<solver::NumberArray>(ii[PARTICLE_TILE_SZ]); if (part_grid_size.size() != 3) { std::cout << PARTICLE_TILE_SZ << " needs 3 elements " << std::endl; } else { mx.particle_tile_size = part_grid_size[0]; my.particle_tile_size = part_grid_size[1]; mz.particle_tile_size = part_grid_size[2]; } auto grid_size_x = std::get<solver::NumberArray>(ii[GRID_SIZE_X]); if (grid_size_x.size() != 1) { std::cout << GRID_SIZE_X << " is a scalar " << std::endl; } else { mx.grid_size = grid_size_x[0]; } auto grid_size_y = std::get<solver::NumberArray>(ii[GRID_SIZE_Y]); if (grid_size_y.size() != 1) { std::cout << GRID_SIZE_Y << " is a scalar " << std::endl; } else { my.grid_size = grid_size_y[0]; } auto grid_size_z = std::get<solver::NumberArray>(ii[GRID_SIZE_Z]); if (grid_size_z.size() != 1) { std::cout << GRID_SIZE_Z << " is a scalar " << std::endl; } else { mz.grid_size = grid_size_z[0]; } auto bf = std::get<solver::NumberArray>(ii[BLOCKING_FACTOR]); if (bf.size() != 1) { std::cout << "amr.blocking_factor is a scalar" << std::endl; std::cout << BLOCKING_FACTOR << " is a scalar" << std::endl; } else { mesh.blocking_factor = bf[0]; } auto volfrac = std::get<solver::NumberArray>(ii[SMALL_VOLFRAC]); if (volfrac.size() != 1) { std::cout << SMALL_VOLFRAC << " is a scalar" << std::endl; } else { mesh.small_volfrac = volfrac[0]; } mesh.axes[0] = mx; mesh.axes[1] = my; mesh.axes[2] = mz; return mesh; } } // namespace solver src/solver.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ #include <variant> #include <vector> #include <inputs.hpp> namespace solver { using NumberArray = std::vector<double>; Loading @@ -26,11 +28,15 @@ struct GeometrySettings { }; struct MeshAxis { unsigned int fab_tile_size; unsigned int grid_size; unsigned int n_cell; unsigned int particle_tile_size; }; struct MeshSettings { int blocking_factor; double small_volfrac; std::array<MeshAxis, 3> axes; }; struct TimeSettings { Loading src/time.cpp +0 −9 Original line number Diff line number Diff line Loading @@ -7,14 +7,6 @@ namespace solver { std::optional<solver::TimeSettings> make_time(solver::InputInfo ii) { solver::TimeSettings time; std::string DT_MAX("mfix.dt_max"); 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) { std::cout << "dt_max is a scalar: " << dt_max.size() << std::endl; Loading Loading @@ -68,7 +60,6 @@ std::optional<solver::TimeSettings> make_time(solver::InputInfo ii) { time.tcoll_ratio = tcoll_ratio[0]; } return time; } } // namespace solver Loading
src/geometry.cpp +0 −3 Original line number Diff line number Diff line Loading @@ -6,9 +6,6 @@ namespace solver { std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { solver::GeometrySettings geo; std::string PROB_LO("geometry.prob_lo"); std::string PROB_HI("geometry.prob_hi"); std::string PERIODIC("geometry.is_periodic"); if (!ii.count(PROB_LO)) { require(PROB_LO); return std::nullopt; Loading
src/inputs.hpp 0 → 100644 +28 −0 Original line number Diff line number Diff line #ifndef INPUTS_H_ #define INPUTS_H_ // Geometry static const std::string DT_MAX("mfix.dt_max"); 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"); // Mesh static const std::string SMALL_VOLFRAC("eb2.small_volfrac"); static const std::string BLOCKING_FACTOR("amr.blocking_factor"); static const std::string FABARRAY_TILE_SZ("fabarray.mfiter_tile_size"); static const std::string GRID_SIZE_X("amr.max_grid_size_x"); static const std::string GRID_SIZE_Y("amr.max_grid_size_y"); static const std::string GRID_SIZE_Z("amr.max_grid_size_z"); static const std::string N_CELL("amr.n_cell"); static const std::string PARTICLE_TILE_SZ("particles.tile_size"); // Time static const std::string CFL("mfix.cfl"); static const std::string FIXED_DT("mfix.fixed_dt"); static const std::string MAXSTEP("mfix.max_step"); static const std::string TCOLL_RATIO("mfix.tcoll_ratio"); static const std::string TSTOP("mfix.stop_time"); #endif
src/mesh.cpp +54 −13 Original line number Diff line number Diff line Loading @@ -6,35 +6,76 @@ namespace solver { std::optional<solver::MeshSettings> make_mesh(solver::InputInfo ii) { solver::MeshSettings mesh; std::string N_CELL("amr.n_cell"); std::string BLOCKING_FACTOR("amr.blocking_factor"); if (!ii.count(N_CELL)) { require(N_CELL); return std::nullopt; } if (!ii.count(N_CELL)) { require(N_CELL); return std::nullopt; } auto n_cell = std::get<solver::NumberArray>(ii[N_CELL]); if (n_cell.size() != 3) { std::cout << "n_cell needs 3 elements " << std::endl; std::cout << N_CELL << " needs 3 elements " << std::endl; return std::nullopt; } std::get<0>(mesh.axes).n_cell = n_cell[0]; std::get<1>(mesh.axes).n_cell = n_cell[1]; std::get<2>(mesh.axes).n_cell = n_cell[2]; auto [mx, my, mz] = mesh.axes; mx.n_cell = n_cell[0]; my.n_cell = n_cell[1]; mz.n_cell = n_cell[2]; auto fabarray_size = std::get<solver::NumberArray>(ii[FABARRAY_TILE_SZ]); if (fabarray_size.size() != 3) { std::cout << FABARRAY_TILE_SZ << " needs 3 elements " << std::endl; } else { mx.fab_tile_size = fabarray_size[0]; my.fab_tile_size = fabarray_size[1]; mz.fab_tile_size = fabarray_size[2]; } auto part_grid_size = std::get<solver::NumberArray>(ii[PARTICLE_TILE_SZ]); if (part_grid_size.size() != 3) { std::cout << PARTICLE_TILE_SZ << " needs 3 elements " << std::endl; } else { mx.particle_tile_size = part_grid_size[0]; my.particle_tile_size = part_grid_size[1]; mz.particle_tile_size = part_grid_size[2]; } auto grid_size_x = std::get<solver::NumberArray>(ii[GRID_SIZE_X]); if (grid_size_x.size() != 1) { std::cout << GRID_SIZE_X << " is a scalar " << std::endl; } else { mx.grid_size = grid_size_x[0]; } auto grid_size_y = std::get<solver::NumberArray>(ii[GRID_SIZE_Y]); if (grid_size_y.size() != 1) { std::cout << GRID_SIZE_Y << " is a scalar " << std::endl; } else { my.grid_size = grid_size_y[0]; } auto grid_size_z = std::get<solver::NumberArray>(ii[GRID_SIZE_Z]); if (grid_size_z.size() != 1) { std::cout << GRID_SIZE_Z << " is a scalar " << std::endl; } else { mz.grid_size = grid_size_z[0]; } auto bf = std::get<solver::NumberArray>(ii[BLOCKING_FACTOR]); if (bf.size() != 1) { std::cout << "amr.blocking_factor is a scalar" << std::endl; std::cout << BLOCKING_FACTOR << " is a scalar" << std::endl; } else { mesh.blocking_factor = bf[0]; } auto volfrac = std::get<solver::NumberArray>(ii[SMALL_VOLFRAC]); if (volfrac.size() != 1) { std::cout << SMALL_VOLFRAC << " is a scalar" << std::endl; } else { mesh.small_volfrac = volfrac[0]; } mesh.axes[0] = mx; mesh.axes[1] = my; mesh.axes[2] = mz; return mesh; } } // namespace solver
src/solver.hpp +6 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,8 @@ #include <variant> #include <vector> #include <inputs.hpp> namespace solver { using NumberArray = std::vector<double>; Loading @@ -26,11 +28,15 @@ struct GeometrySettings { }; struct MeshAxis { unsigned int fab_tile_size; unsigned int grid_size; unsigned int n_cell; unsigned int particle_tile_size; }; struct MeshSettings { int blocking_factor; double small_volfrac; std::array<MeshAxis, 3> axes; }; struct TimeSettings { Loading
src/time.cpp +0 −9 Original line number Diff line number Diff line Loading @@ -7,14 +7,6 @@ namespace solver { std::optional<solver::TimeSettings> make_time(solver::InputInfo ii) { solver::TimeSettings time; std::string DT_MAX("mfix.dt_max"); 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) { std::cout << "dt_max is a scalar: " << dt_max.size() << std::endl; Loading Loading @@ -68,7 +60,6 @@ std::optional<solver::TimeSettings> make_time(solver::InputInfo ii) { time.tcoll_ratio = tcoll_ratio[0]; } return time; } } // namespace solver