Wildmeshing Toolkit
Loading...
Searching...
No Matches
MapValidator.cpp
Go to the documentation of this file.
1
2#include "MapValidator.hpp"
3#include <wmtk/Mesh.hpp>
10
12 : m_mesh(m)
13{}
15{
16 bool ok = true;
19 if (!ok) {
20 return ok;
21 }
23
24 return ok;
25}
26
28{
29 bool ok = true;
30 for (const auto& [cptr, attr] : m_mesh.m_multi_mesh_manager.m_children) {
31 const auto& child = *cptr;
32 auto map_accessor = m_mesh.create_const_accessor(attr);
33
34 for (int64_t j = 0; j < child.top_cell_dimension(); ++j) {
36
37 for (const auto& pt : m_mesh.get_all(prim_type)) {
38 wmtk::simplex::Simplex s(m_mesh, prim_type, pt);
39
41
42 for (const auto& source_tuple : tups) {
43 const auto [source_mesh_base_tuple, target_mesh_base_tuple] =
44 multimesh::utils::read_tuple_map_attribute(map_accessor, source_tuple);
45 if (source_mesh_base_tuple.is_null() || target_mesh_base_tuple.is_null()) {
46 if (source_mesh_base_tuple.is_null() && target_mesh_base_tuple.is_null()) {
47 ok = false;
48 wmtk::logger().error(
49 "Map from parent {} to child {} on tuple {} (dim {}) fails on {} "
50 "or "
51 "{} null",
52 fmt::join(m_mesh.absolute_multi_mesh_id(), ","),
53 fmt::join(child.absolute_multi_mesh_id(), ","),
54 j,
55 pt.as_string(),
56 source_mesh_base_tuple.as_string(),
57 target_mesh_base_tuple.as_string()
58
59 );
60 }
61 } else if (!child.is_valid(target_mesh_base_tuple)) {
62 wmtk::logger().error(
63 "Map from parent {} to child {} on tuple {} (dim {}) fails on {} -> "
64 "{}",
65 fmt::join(m_mesh.absolute_multi_mesh_id(), ","),
66 fmt::join(child.absolute_multi_mesh_id(), ","),
67 j,
68 pt.as_string(),
69 source_mesh_base_tuple.as_string(),
70 target_mesh_base_tuple.as_string()
71
72 );
73 ok = false;
74 }
75 }
76 }
77 }
78 }
79 return ok;
80}
81
83{
84 bool ok = true;
85 const auto& parent_ptr = m_mesh.m_multi_mesh_manager.m_parent;
86 if (parent_ptr == nullptr) {
87 return true;
88 }
90 const auto& parent = *parent_ptr;
91 auto map_accessor = m_mesh.create_const_accessor(attr);
92
94
95 for (const auto& source_tuple : m_mesh.get_all(prim_type)) {
96 const auto [source_mesh_base_tuple, target_mesh_base_tuple] =
97 multimesh::utils::read_tuple_map_attribute(map_accessor, source_tuple);
98 if (source_mesh_base_tuple.is_null() || target_mesh_base_tuple.is_null()) {
99 wmtk::logger().error(
100 "Map from child {} to parent {} on tuple {} (dim {}) has null entry {} -> "
101 "{}",
102 fmt::join(m_mesh.absolute_multi_mesh_id(), ","),
103 fmt::join(parent.absolute_multi_mesh_id(), ","),
105 source_tuple.as_string(),
106 source_mesh_base_tuple.as_string(),
107 target_mesh_base_tuple.as_string()
108
109 );
110 ok = false;
111 } else if (!parent.is_valid(target_mesh_base_tuple)) {
112 wmtk::logger().error(
113 "Map from child {} to parent {} on tuple {} (dim {}) fails on {} -> "
114 "{}",
115 fmt::join(m_mesh.absolute_multi_mesh_id(), ","),
116 fmt::join(parent.absolute_multi_mesh_id(), ","),
118 source_tuple.as_string(),
119 source_mesh_base_tuple.as_string(),
120 target_mesh_base_tuple.as_string()
121
122 );
123 ok = false;
124 }
125 }
126 return ok;
127}
128
129
131{
132 bool ok = true;
133 for (const auto& cptr : m_mesh.get_child_meshes()) {
135 }
136 return ok;
137}
139{
140 assert(child.m_multi_mesh_manager.m_parent == &m_mesh);
141 bool ok = true;
143 auto tups = child.get_all(pt);
144 for (const wmtk::Tuple& t : tups) {
145 wmtk::simplex::Simplex s(child, pt, t);
146
147 wmtk::Tuple parent_tuple = child.map_to_parent_tuple(s);
149 // skip switches over boundaries
150 if (spt == pt &&
151 child.is_boundary(wmtk::PrimitiveType(child.top_cell_dimension() - 1), t)) {
152 continue;
153 }
154
155 wmtk::simplex::Simplex switched_simplex(child, pt, m_mesh.switch_tuple(t, pt));
156 wmtk::Tuple switch_map = child.map_to_parent_tuple(switched_simplex);
157 wmtk::Tuple map_switch = m_mesh.switch_tuple(parent_tuple, pt);
160 m_mesh,
161 my_pt,
162 switch_map,
163 map_switch);
164 if (!worked) {
165 wmtk::logger().error(
166 "Map from child {0} to parent {1} on tuple {2} (dim {3}) fails on "
167 "switch(map({2}),{4}) = {5} != "
168 "map(switch({2},{4})) = {6} (dim {7} id {8} != {9})",
169 fmt::join(child.absolute_multi_mesh_id(), ","), // 0
170 fmt::join(m_mesh.absolute_multi_mesh_id(), ","), // 1
171 t.as_string(), // 2
172 child.top_cell_dimension(), // 3
173 primitive_type_name(pt), // 4
174 map_switch.as_string(), // 5
175 switch_map.as_string(), // 6
176 primitive_type_name(my_pt), // 7
177 m_mesh.id(map_switch, my_pt), // 8
178 m_mesh.id(switch_map, my_pt) // 9
179 );
180 ok = false;
181 }
182 }
183 }
184 }
185 }
186 return ok;
187}
188
189
190} // namespace wmtk::multimesh::utils
std::vector< int64_t > absolute_multi_mesh_id() const
returns a unique identifier for this mesh within a single multimesh structure
const attribute::Accessor< T, Mesh, D > create_const_accessor(const attribute::MeshAttributeHandle &handle) const
int64_t id(const Tuple &tuple, PrimitiveType type) const
return the global id of the Tuple of the given dimension
Definition Mesh.hpp:1006
bool is_boundary(const simplex::Simplex &tuple) const
check if a simplex lies on a boundary or not
Definition Mesh.cpp:107
std::vector< Tuple > get_all(PrimitiveType type) const
Generate a vector of Tuples from global vertex/edge/triangle/tetrahedron index.
Definition Mesh.cpp:18
multimesh::MultiMeshManager m_multi_mesh_manager
Definition Mesh.hpp:827
int64_t top_cell_dimension() const
Definition Mesh.hpp:978
virtual Tuple switch_tuple(const Tuple &tuple, PrimitiveType type) const =0
switch the orientation of the Tuple of the given dimension
Tuple map_to_parent_tuple(const simplex::Simplex &my_simplex) const
optimized map from a simplex from this mesh to its direct parent
PrimitiveType top_simplex_type() const
Definition Mesh.hpp:982
std::vector< std::shared_ptr< Mesh > > get_child_meshes() const
returns the direct multimesh child meshes for the current mesh
The Tuple is the basic navigation tool in our mesh data structure.
Definition Tuple.hpp:19
std::string as_string() const
Definition Tuple.cpp:7
std::vector< ChildData > m_children
TypedAttributeHandle< int64_t > map_to_parent_handle
bool check_child_switch_homomorphism(const Mesh &child) const
static bool equal(const Mesh &m, const Simplex &s0, const Simplex &s1)
std::tuple< Tuple, Tuple > read_tuple_map_attribute(const wmtk::attribute::Accessor< int64_t, MeshType > &accessor, const Tuple &source_tuple)
void top_dimension_cofaces_tuples(const PointMesh &mesh, const Simplex &simplex, SimplexCollection &collection)
std::string_view primitive_type_name(PrimitiveType t)
spdlog::logger & logger()
Retrieves the current logger.
Definition Logger.cpp:58