1 #include <fmt/ranges.h>
2 #include <catch2/catch_test_macros.hpp>
3 #include <nlohmann/json.hpp>
22 auto make_AD = [](
const std::string_view& name,
23 const std::optional<uint8_t>& dim,
24 const std::optional<AT>& at) {
return AD{name, dim, at}; };
28 TEST_CASE(
"multimesh_attribute_description_json",
"[components][multimesh]")
33 auto check = [](
const AD& ad,
const JS& js) {
35 auto ad2 = js.get<
AD>();
37 CHECK(ad == js.get<
AD>());
40 AD ad{
"double_test", 0, AT::Double};
41 JS js{{
"path",
"double_test"}, {
"dimension", 0}, {
"type",
"double"}};
46 JS js{{
"path",
"rational_test"}, {
"dimension", 0}, {
"type",
"rational"}};
50 AD ad{
"int_test", 0, AT::Int64};
51 JS js{{
"path",
"int_test"}, {
"dimension", 0}, {
"type",
"int"}};
55 AD ad{
"char_test", 0, AT::Char};
56 JS js{{
"path",
"char_test"}, {
"dimension", 0}, {
"type",
"char"}};
60 AD ad{
"double_test", 1, AT::Double};
61 JS js{{
"path",
"double_test"}, {
"dimension", 1}, {
"type",
"double"}};
65 AD ad{
"double_test", 2, AT::Double};
66 JS js{{
"path",
"double_test"}, {
"dimension", 2}, {
"type",
"double"}};
71 auto ad = make_AD(
"double_test", {}, AT::Double);
72 JS js{{
"path",
"double_test"}, {
"type",
"double"}};
76 auto ad = make_AD(
"double_test", 2, {});
77 JS js{{
"path",
"double_test"}, {
"dimension", 2}};
81 auto ad = make_AD(
"double_test", {}, {});
82 JS js{{
"path",
"double_test"}};
87 TEST_CASE(
"named_multimesh_parse_attributes",
"[components][multimesh]")
95 auto double_test_handle =
97 auto char_test_handle =
99 auto int_test_handle =
101 auto rational_test_handle =
105 std::vector<AD> double_ads;
106 double_ads.emplace_back(make_AD(
"double_test", 0, AT::Double));
107 double_ads.emplace_back(make_AD(
"/double_test", 0, AT::Double));
108 double_ads.emplace_back(make_AD(
"roo/double_test", 0, AT::Double));
109 double_ads.emplace_back(make_AD(
"double_test", {}, AT::Double));
110 double_ads.emplace_back(make_AD(
"/double_test", 0, {}));
111 double_ads.emplace_back(make_AD(
"roo/double_test", {}, {}));
114 for (
const auto& ad : double_ads) {
116 CHECK(double_test_handle == h);
119 CHECK(double_test_handle == h2);
122 CHECK(double_test_handle == h3);
133 AD{
"int_test", 0, AT::Int64}));
137 AD{
"char_test", 0, AT::Char}));
148 make_AD(
"double_test_e", 1, AT::Double)));
152 make_AD(
"double_test_f", 2, AT::Double)));
156 make_AD(
"double_test_f", {}, AT::Double)));
160 make_AD(
"double_test_f", {}, AT::Double)));
164 make_AD(
"double_test_f", {}, {})));
168 make_AD(
"double_test_e", {}, {})));
175 AD{
"doub2r2le_test_e", 2, AT::Double}),
180 AD{
"double_test_e", 2, AT::Double}),
185 AD{
"double_test_f", 1, AT::Double}),
188 auto double_test_handle =
193 make_AD(
"double_test", {}, AT::Double)),
203 REQUIRE(children.size() == 1);
204 auto child = children[0];
211 js[
"roo"] = nlohmann::json::array({
"child"});
214 CHECK(std::vector<int64_t>{} == named_mm.
get_id(
"roo"));
215 CHECK(std::vector<int64_t>{0} == named_mm.
get_id(
"roo.child"));
218 auto child_attr_handle =
224 AD{
"double_test", 0, AT::Double}));
228 AD{
"/double_test", 0, AT::Double}));
232 AD{
"roo/double_test", 0, AT::Double}));
236 AD{
"roo.child/double_test", 0, AT::Double}));
240 AD{
".child/double_test", 0, AT::Double}));
NamedMultiMesh & emplace_mesh(Args &&... args)
std::vector< int64_t > get_id(const std::string_view &path) const
void set_mesh(Mesh &m)
Navigates to the root of the multimesh.
void set_names(const nlohmann::json &js)
TEST_CASE("multimesh_attribute_description_json", "[components][multimesh]")
wmtk::attribute::MeshAttributeHandle get_attribute(const NamedMultiMesh &mesh, const AttributeDescription &description)
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()