1 #include <fmt/ranges.h>
2 #include <catch2/catch_test_macros.hpp>
3 #include <nlohmann/json.hpp>
18 TEST_CASE(
"named_multimesh_parse",
"[components][multimesh]")
27 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
28 CHECK(m == named_mm.
root().shared_from_this());
29 CHECK(m == named_mm.
get_mesh(
"roo").shared_from_this());
42 js[
"roo"] = nlohmann::json::array({
"child"});
43 named_mm.set_names(js);
45 CHECK(std::vector<int64_t>{} == named_mm.get_id(
"roo"));
46 CHECK(std::vector<int64_t>{0} == named_mm.get_id(
"roo.child"));
47 CHECK(m == named_mm.root().shared_from_this());
48 CHECK(m == named_mm.get_mesh(
"roo").shared_from_this());
50 m->get_multi_mesh_child_mesh({0}).shared_from_this() ==
51 named_mm.get_mesh(
"roo.child").shared_from_this());
58 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
59 CHECK(std::vector<int64_t>{0} == named_mm.
get_id(
"roo.child"));
64 js[
"roo"][
"child"] = {};
66 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
67 CHECK(std::vector<int64_t>{0} == named_mm.
get_id(
"roo.child"));
82 js[
"roo"][
"c"][
"d"][
"e"] = {};
83 js[
"roo"][
"child"] = nlohmann::json::array({
"c1",
"c2"});
86 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
87 CHECK(std::vector<int64_t>{0, 0, 0} == named_mm.
get_id(
"roo.c.d.e"));
88 CHECK(std::vector<int64_t>{1} == named_mm.
get_id(
"roo.child"));
89 CHECK(std::vector<int64_t>{1, 0} == named_mm.
get_id(
"roo.child.c1"));
90 CHECK(std::vector<int64_t>{1, 1} == named_mm.
get_id(
"roo.child.c2"));
92 m->get_multi_mesh_child_mesh({0, 0, 0}).shared_from_this() ==
93 named_mm.
get_mesh(
"roo.c.d.e").shared_from_this());
95 m->get_multi_mesh_child_mesh({1, 1}).shared_from_this() ==
96 named_mm.
get_mesh(
"roo.child.c2").shared_from_this());
99 m->get_multi_mesh_child_mesh({0, 0, 0}).shared_from_this() ==
100 named_mm.
get_mesh(
".c.d.e").shared_from_this());
102 m->get_multi_mesh_child_mesh({1, 1}).shared_from_this() ==
103 named_mm.
get_mesh(
".child.c2").shared_from_this());
std::vector< int64_t > get_id(const std::string_view &path) const
void set_mesh(Mesh &m)
Navigates to the root of the multimesh.
Mesh & get_mesh(const std::string_view &path) const
void set_names(const nlohmann::json &js)
void set_name(const std::string_view &root_name="")
sets just the name of the root mesh, keeping child names the same
TEST_CASE("named_multimesh_parse", "[components][multimesh]")
auto make_child(wmtk::Mesh &m, const std::vector< int64_t > &path) -> std::vector< std::shared_ptr< wmtk::Mesh >>
std::shared_ptr< wmtk::Mesh > make_mesh()