Loading README.md +5 −9 Original line number Diff line number Diff line Loading @@ -9,18 +9,14 @@ This has the MFIX-Exa repo as a submodule in order to test against existing ``in ## Build > python3 pip install cmake # if CMake not installed > cmake -S. -Bbuild > cmake --build build > cd build > ctest > python3 pip install meson ninja > meson build > ninja -C build ## Run Tests > cmake --build build --target unit_tests > ./build/src/tests/unit_tests > meson test -C build ## Run on inputs file > cmake --build build --target mfix-parser > ./build/mfix-parser subprojects/mfix/benchmarks/01-HCS/Size0001/inputs && echo "Parsing succeeded." > ./build/src/mfix-parser subprojects/mfix/benchmarks/01-HCS/Size0001/inputs && echo "Parsing succeeded." src/inputs_file.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -27,10 +27,9 @@ solver_settings::SolverSettings InputsFile::load() { // for (auto it = inputinfo.begin(); it != inputinfo.end(); ++it) { // std::visit( // overloaded{ // [](std::string ss) { std::cout << ss << std::endl; }, // [](parser::NumberArray aa) { std::cout << aa.size() << std::endl; // [it](parser::NumberArray aa) { std::cout << it->first << " nums " << aa.size() << std::endl; // }, // [](parser::StringArray aa) { std::cout << aa.size() << std::endl; // [it](parser::StringArray aa) { std::cout << it->first << " strings " << aa.size() << std::endl; // }, // }, // it->second); Loading src/solver.cpp +32 −9 Original line number Diff line number Diff line Loading @@ -5,21 +5,44 @@ namespace { void require(parser::InputInfo ii, std::string key) { if (!ii.count(key)) { void require(std::string key) { std::cout << "missing required key: " << key << std::endl; } } std::optional<solver_settings::SolverSettings> do_make_solver(parser::InputInfo ii) { solver_settings::SolverSettings ss; require(ii, "geometry.prob_lo"); require(ii, "geometry.prob_hi"); require(ii, "geometry.is_periodic"); auto lows = std::get<parser::NumberArray>(ii["geometry.prob_lo"]); auto highs = std::get<parser::NumberArray>(ii["geometry.prob_hi"]); auto is_periodic = std::get<parser::NumberArray>(ii["geometry.is_periodic"]); 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; } if (!ii.count(PROB_HI)) { require(PROB_HI); return std::nullopt; } if (!ii.count(PERIODIC)) { require(PERIODIC); return std::nullopt; } auto lows = std::get<parser::NumberArray>(ii[PROB_LO]); auto highs = std::get<parser::NumberArray>(ii[PROB_HI]); auto is_periodic = std::get<parser::NumberArray>(ii[PERIODIC]); if (lows.size() != 3) { std::cout << "prob_lo needs 3 elements " << std::endl; return std::nullopt; } if (highs.size() != 3) { std::cout << "prob_hi needs 3 elements " << std::endl; return std::nullopt; } if (is_periodic.size() != 3) { std::cout << "periodic needs 3 elements " << std::endl; return std::nullopt; } std::get<0>(ss.geometry.axes).high = highs[0]; std::get<0>(ss.geometry.axes).low = lows[0]; std::get<0>(ss.geometry.axes).periodic = is_periodic[0]; Loading tests/meson.build +9 −2 Original line number Diff line number Diff line unit_exe = executable('unit_tests', 'inputs.t.cpp', 'parser.t.cpp', 'solver.t.cpp', 'main.cpp', include_directories: [parser_inc, catch2_inc], link_with: lib_parser ) test('unit_test', unit_exe) functional_test = executable('functional_tests', 'inputs.t.cpp', 'main.cpp', include_directories: [parser_inc, catch2_inc], link_with: lib_parser ) test('functional_test', functional_test) tests/solver.t.cpp +19 −6 Original line number Diff line number Diff line Loading @@ -4,11 +4,24 @@ #include <inputs.hpp> std::string PROB_LO("geometry.prob_lo"); std::string PROB_HI("geometry.prob_hi"); std::string PERIODIC("geometry.is_periodic"); TEST_CASE("empty (invalid) map", "[]") { parser::InputInfo ii; auto maybe_sv = solver_settings::make_solver(ii); CHECK_FALSE(maybe_sv.has_value()); } TEST_CASE("from_origin", "[]") { parser::InputInfo ii; ii["geometry.prob_lo"] = parser::NumberArray({0, 0, 0}); ii["geometry.prob_hi"] = parser::NumberArray({0.004, 0.001, 0.001}); ii["geometry.is_periodic"] = parser::NumberArray({0, 0, 0}); ii[PROB_LO] = parser::NumberArray({0, 0, 0}); ii[PROB_HI] = parser::NumberArray({0.004, 0.001, 0.001}); ii[PERIODIC] = parser::NumberArray({0, 0, 0}); CHECK(ii.count(PROB_LO)); CHECK(ii.count(PROB_HI)); CHECK(ii.count(PERIODIC)); auto maybe_sv = solver_settings::make_solver(ii); REQUIRE(maybe_sv.has_value()); Loading @@ -27,9 +40,9 @@ TEST_CASE("from_origin", "[]") { TEST_CASE("negative_positive", "[]") { parser::InputInfo ii; ii["geometry.prob_lo"] = std::vector<double>({-4, -5, -6}); ii["geometry.prob_hi"] = std::vector<double>({11.1, 22.2, 33.3}); ii["geometry.is_periodic"] = parser::NumberArray({1, 0, 1}); ii[PROB_LO] = std::vector<double>({-4, -5, -6}); ii[PROB_HI] = std::vector<double>({11.1, 22.2, 33.3}); ii[PERIODIC] = parser::NumberArray({1, 0, 1}); auto maybe_sv = solver_settings::make_solver(ii); Loading Loading
README.md +5 −9 Original line number Diff line number Diff line Loading @@ -9,18 +9,14 @@ This has the MFIX-Exa repo as a submodule in order to test against existing ``in ## Build > python3 pip install cmake # if CMake not installed > cmake -S. -Bbuild > cmake --build build > cd build > ctest > python3 pip install meson ninja > meson build > ninja -C build ## Run Tests > cmake --build build --target unit_tests > ./build/src/tests/unit_tests > meson test -C build ## Run on inputs file > cmake --build build --target mfix-parser > ./build/mfix-parser subprojects/mfix/benchmarks/01-HCS/Size0001/inputs && echo "Parsing succeeded." > ./build/src/mfix-parser subprojects/mfix/benchmarks/01-HCS/Size0001/inputs && echo "Parsing succeeded."
src/inputs_file.cpp +2 −3 Original line number Diff line number Diff line Loading @@ -27,10 +27,9 @@ solver_settings::SolverSettings InputsFile::load() { // for (auto it = inputinfo.begin(); it != inputinfo.end(); ++it) { // std::visit( // overloaded{ // [](std::string ss) { std::cout << ss << std::endl; }, // [](parser::NumberArray aa) { std::cout << aa.size() << std::endl; // [it](parser::NumberArray aa) { std::cout << it->first << " nums " << aa.size() << std::endl; // }, // [](parser::StringArray aa) { std::cout << aa.size() << std::endl; // [it](parser::StringArray aa) { std::cout << it->first << " strings " << aa.size() << std::endl; // }, // }, // it->second); Loading
src/solver.cpp +32 −9 Original line number Diff line number Diff line Loading @@ -5,21 +5,44 @@ namespace { void require(parser::InputInfo ii, std::string key) { if (!ii.count(key)) { void require(std::string key) { std::cout << "missing required key: " << key << std::endl; } } std::optional<solver_settings::SolverSettings> do_make_solver(parser::InputInfo ii) { solver_settings::SolverSettings ss; require(ii, "geometry.prob_lo"); require(ii, "geometry.prob_hi"); require(ii, "geometry.is_periodic"); auto lows = std::get<parser::NumberArray>(ii["geometry.prob_lo"]); auto highs = std::get<parser::NumberArray>(ii["geometry.prob_hi"]); auto is_periodic = std::get<parser::NumberArray>(ii["geometry.is_periodic"]); 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; } if (!ii.count(PROB_HI)) { require(PROB_HI); return std::nullopt; } if (!ii.count(PERIODIC)) { require(PERIODIC); return std::nullopt; } auto lows = std::get<parser::NumberArray>(ii[PROB_LO]); auto highs = std::get<parser::NumberArray>(ii[PROB_HI]); auto is_periodic = std::get<parser::NumberArray>(ii[PERIODIC]); if (lows.size() != 3) { std::cout << "prob_lo needs 3 elements " << std::endl; return std::nullopt; } if (highs.size() != 3) { std::cout << "prob_hi needs 3 elements " << std::endl; return std::nullopt; } if (is_periodic.size() != 3) { std::cout << "periodic needs 3 elements " << std::endl; return std::nullopt; } std::get<0>(ss.geometry.axes).high = highs[0]; std::get<0>(ss.geometry.axes).low = lows[0]; std::get<0>(ss.geometry.axes).periodic = is_periodic[0]; Loading
tests/meson.build +9 −2 Original line number Diff line number Diff line unit_exe = executable('unit_tests', 'inputs.t.cpp', 'parser.t.cpp', 'solver.t.cpp', 'main.cpp', include_directories: [parser_inc, catch2_inc], link_with: lib_parser ) test('unit_test', unit_exe) functional_test = executable('functional_tests', 'inputs.t.cpp', 'main.cpp', include_directories: [parser_inc, catch2_inc], link_with: lib_parser ) test('functional_test', functional_test)
tests/solver.t.cpp +19 −6 Original line number Diff line number Diff line Loading @@ -4,11 +4,24 @@ #include <inputs.hpp> std::string PROB_LO("geometry.prob_lo"); std::string PROB_HI("geometry.prob_hi"); std::string PERIODIC("geometry.is_periodic"); TEST_CASE("empty (invalid) map", "[]") { parser::InputInfo ii; auto maybe_sv = solver_settings::make_solver(ii); CHECK_FALSE(maybe_sv.has_value()); } TEST_CASE("from_origin", "[]") { parser::InputInfo ii; ii["geometry.prob_lo"] = parser::NumberArray({0, 0, 0}); ii["geometry.prob_hi"] = parser::NumberArray({0.004, 0.001, 0.001}); ii["geometry.is_periodic"] = parser::NumberArray({0, 0, 0}); ii[PROB_LO] = parser::NumberArray({0, 0, 0}); ii[PROB_HI] = parser::NumberArray({0.004, 0.001, 0.001}); ii[PERIODIC] = parser::NumberArray({0, 0, 0}); CHECK(ii.count(PROB_LO)); CHECK(ii.count(PROB_HI)); CHECK(ii.count(PERIODIC)); auto maybe_sv = solver_settings::make_solver(ii); REQUIRE(maybe_sv.has_value()); Loading @@ -27,9 +40,9 @@ TEST_CASE("from_origin", "[]") { TEST_CASE("negative_positive", "[]") { parser::InputInfo ii; ii["geometry.prob_lo"] = std::vector<double>({-4, -5, -6}); ii["geometry.prob_hi"] = std::vector<double>({11.1, 22.2, 33.3}); ii["geometry.is_periodic"] = parser::NumberArray({1, 0, 1}); ii[PROB_LO] = std::vector<double>({-4, -5, -6}); ii[PROB_HI] = std::vector<double>({11.1, 22.2, 33.3}); ii[PERIODIC] = parser::NumberArray({1, 0, 1}); auto maybe_sv = solver_settings::make_solver(ii); Loading