Loading src/geometry.cpp +0 −13 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { std::string PROB_LO("geometry.prob_lo"); std::string PROB_HI("geometry.prob_hi"); std::string PERIODIC("geometry.is_periodic"); std::string N_CELL("amr.n_cell"); if (!ii.count(PROB_LO)) { require(PROB_LO); return std::nullopt; Loading @@ -22,14 +21,9 @@ std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { require(PERIODIC); return std::nullopt; } if (!ii.count(N_CELL)) { require(N_CELL); return std::nullopt; } auto lows = std::get<solver::NumberArray>(ii[PROB_LO]); auto highs = std::get<solver::NumberArray>(ii[PROB_HI]); auto is_periodic = std::get<solver::NumberArray>(ii[PERIODIC]); auto n_cell = std::get<solver::NumberArray>(ii[N_CELL]); if (lows.size() != 3) { std::cout << "prob_lo needs 3 elements " << std::endl; return std::nullopt; Loading @@ -42,23 +36,16 @@ std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { std::cout << "periodic needs 3 elements " << std::endl; return std::nullopt; } if (n_cell.size() != 3) { std::cout << "n_cell needs 3 elements " << std::endl; return std::nullopt; } 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]; std::get<0>(geo.axes).n_cell = n_cell[0]; std::get<1>(geo.axes).high = highs[1]; std::get<1>(geo.axes).low = lows[1]; std::get<1>(geo.axes).periodic = is_periodic[1]; std::get<1>(geo.axes).n_cell = n_cell[1]; std::get<2>(geo.axes).high = highs[2]; std::get<2>(geo.axes).low = lows[2]; std::get<2>(geo.axes).periodic = is_periodic[2]; std::get<2>(geo.axes).n_cell = n_cell[2]; return geo; } } // namespace solver src/mesh.cpp 0 → 100644 +40 −0 Original line number Diff line number Diff line #include <iostream> #include "solver.hpp" 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; 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 bf = std::get<solver::NumberArray>(ii[BLOCKING_FACTOR]); if (bf.size() != 1) { std::cout << "amr.blocking_factor is a scalar" << std::endl; } else { mesh.blocking_factor = bf[0]; } return mesh; } } // namespace solver src/meson.build +1 −0 Original line number Diff line number Diff line lib_parser = static_library('mfix-parser', 'geometry.cpp', 'mesh.cpp', 'parser.cpp', 'solver.cpp', 'time.cpp', Loading src/solver.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,11 @@ std::optional<solver::SolverSettings> do_make_solver(solver::InputInfo ii) { std::cout << "Problem making geometry" << std::endl; return std::nullopt; } auto new_mesh = make_mesh(ii); if (!new_mesh.has_value()) { std::cout << "Problem making mesh" << std::endl; return std::nullopt; } auto new_time = make_time(ii); if (!new_time.has_value()) { std::cout << "Problem making time" << std::endl; Loading @@ -24,6 +29,7 @@ std::optional<solver::SolverSettings> do_make_solver(solver::InputInfo ii) { } ss.geometry = new_geo.value(); ss.time = new_time.value(); ss.mesh = new_mesh.value(); return ss; } Loading @@ -47,8 +53,10 @@ std::string serialize(solver::SolverSettings settings) { << zz.low << std::endl; buffer << " geometry.prob_hi = " << xx.high << " " << yy.high << " " << zz.high << std::endl; buffer << " amr.n_cell = " << xx.n_cell << " " << yy.n_cell << " " << zz.n_cell; auto [mx, my, mz] = settings.mesh.axes; buffer << " amr.n_cell = " << mx.n_cell << " " << my.n_cell << " " << mz.n_cell; return buffer.str(); } Loading src/solver.hpp +11 −1 Original line number Diff line number Diff line Loading @@ -20,11 +20,19 @@ struct GeometryAxis { double low; double high; bool periodic; unsigned int n_cell; }; struct GeometrySettings { std::array<GeometryAxis, 3> axes; }; struct MeshAxis { unsigned int n_cell; }; struct MeshSettings { int blocking_factor; std::array<MeshAxis, 3> axes; }; struct TimeSettings { unsigned int max_step; double dt_max; Loading @@ -33,11 +41,13 @@ struct TimeSettings { }; struct SolverSettings { GeometrySettings geometry; MeshSettings mesh; TimeSettings time; }; std::optional<SolverSettings> make_solver(solver::InputInfo); std::optional<GeometrySettings> make_geometry(solver::InputInfo); std::optional<MeshSettings> make_mesh(solver::InputInfo); std::optional<TimeSettings> make_time(solver::InputInfo); std::string serialize(solver::SolverSettings); Loading Loading
src/geometry.cpp +0 −13 Original line number Diff line number Diff line Loading @@ -9,7 +9,6 @@ std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { std::string PROB_LO("geometry.prob_lo"); std::string PROB_HI("geometry.prob_hi"); std::string PERIODIC("geometry.is_periodic"); std::string N_CELL("amr.n_cell"); if (!ii.count(PROB_LO)) { require(PROB_LO); return std::nullopt; Loading @@ -22,14 +21,9 @@ std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { require(PERIODIC); return std::nullopt; } if (!ii.count(N_CELL)) { require(N_CELL); return std::nullopt; } auto lows = std::get<solver::NumberArray>(ii[PROB_LO]); auto highs = std::get<solver::NumberArray>(ii[PROB_HI]); auto is_periodic = std::get<solver::NumberArray>(ii[PERIODIC]); auto n_cell = std::get<solver::NumberArray>(ii[N_CELL]); if (lows.size() != 3) { std::cout << "prob_lo needs 3 elements " << std::endl; return std::nullopt; Loading @@ -42,23 +36,16 @@ std::optional<solver::GeometrySettings> make_geometry(solver::InputInfo ii) { std::cout << "periodic needs 3 elements " << std::endl; return std::nullopt; } if (n_cell.size() != 3) { std::cout << "n_cell needs 3 elements " << std::endl; return std::nullopt; } 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]; std::get<0>(geo.axes).n_cell = n_cell[0]; std::get<1>(geo.axes).high = highs[1]; std::get<1>(geo.axes).low = lows[1]; std::get<1>(geo.axes).periodic = is_periodic[1]; std::get<1>(geo.axes).n_cell = n_cell[1]; std::get<2>(geo.axes).high = highs[2]; std::get<2>(geo.axes).low = lows[2]; std::get<2>(geo.axes).periodic = is_periodic[2]; std::get<2>(geo.axes).n_cell = n_cell[2]; return geo; } } // namespace solver
src/mesh.cpp 0 → 100644 +40 −0 Original line number Diff line number Diff line #include <iostream> #include "solver.hpp" 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; 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 bf = std::get<solver::NumberArray>(ii[BLOCKING_FACTOR]); if (bf.size() != 1) { std::cout << "amr.blocking_factor is a scalar" << std::endl; } else { mesh.blocking_factor = bf[0]; } return mesh; } } // namespace solver
src/meson.build +1 −0 Original line number Diff line number Diff line lib_parser = static_library('mfix-parser', 'geometry.cpp', 'mesh.cpp', 'parser.cpp', 'solver.cpp', 'time.cpp', Loading
src/solver.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -17,6 +17,11 @@ std::optional<solver::SolverSettings> do_make_solver(solver::InputInfo ii) { std::cout << "Problem making geometry" << std::endl; return std::nullopt; } auto new_mesh = make_mesh(ii); if (!new_mesh.has_value()) { std::cout << "Problem making mesh" << std::endl; return std::nullopt; } auto new_time = make_time(ii); if (!new_time.has_value()) { std::cout << "Problem making time" << std::endl; Loading @@ -24,6 +29,7 @@ std::optional<solver::SolverSettings> do_make_solver(solver::InputInfo ii) { } ss.geometry = new_geo.value(); ss.time = new_time.value(); ss.mesh = new_mesh.value(); return ss; } Loading @@ -47,8 +53,10 @@ std::string serialize(solver::SolverSettings settings) { << zz.low << std::endl; buffer << " geometry.prob_hi = " << xx.high << " " << yy.high << " " << zz.high << std::endl; buffer << " amr.n_cell = " << xx.n_cell << " " << yy.n_cell << " " << zz.n_cell; auto [mx, my, mz] = settings.mesh.axes; buffer << " amr.n_cell = " << mx.n_cell << " " << my.n_cell << " " << mz.n_cell; return buffer.str(); } Loading
src/solver.hpp +11 −1 Original line number Diff line number Diff line Loading @@ -20,11 +20,19 @@ struct GeometryAxis { double low; double high; bool periodic; unsigned int n_cell; }; struct GeometrySettings { std::array<GeometryAxis, 3> axes; }; struct MeshAxis { unsigned int n_cell; }; struct MeshSettings { int blocking_factor; std::array<MeshAxis, 3> axes; }; struct TimeSettings { unsigned int max_step; double dt_max; Loading @@ -33,11 +41,13 @@ struct TimeSettings { }; struct SolverSettings { GeometrySettings geometry; MeshSettings mesh; TimeSettings time; }; std::optional<SolverSettings> make_solver(solver::InputInfo); std::optional<GeometrySettings> make_geometry(solver::InputInfo); std::optional<MeshSettings> make_mesh(solver::InputInfo); std::optional<TimeSettings> make_time(solver::InputInfo); std::string serialize(solver::SolverSettings); Loading