1 #include <catch2/catch_test_macros.hpp>
2 #include <nlohmann/json.hpp>
3 #include <tools/DEBUG_TetMesh.hpp>
4 #include <tools/DEBUG_TriMesh.hpp>
5 #include <tools/TetMesh_examples.hpp>
6 #include <tools/TriMesh_examples.hpp>
10 #include <wmtk/components/fusion/fusion.hpp>
12 #include <wmtk/components/utils/Paths.hpp>
21 using namespace wmtk::tests_3d;
25 const std::filesystem::path
data_dir = WMTK_DATA_DIR;
34 V.row(0) << 1.0, 0.0, 0.0;
35 V.row(1) << 1.25, 0.0, 0.0;
36 V.row(2) << 1.5, 0.0, 0.0;
37 V.row(3) << 1.75, 0.0, 0.0;
38 V.row(4) << 2.0, 0.0, 0.0;
39 V.row(5) << 1.0, 1.0, 0.0;
40 V.row(6) << 1.25, 1.0, 0.0;
41 V.row(7) << 1.5, 1.0, 0.0;
42 V.row(8) << 1.75, 1.0, 0.0;
43 V.row(9) << 2.0, 1.0, 0.0;
44 V.row(10) << 1.0, 2.0, 0.0;
45 V.row(11) << 1.25, 2.0, 0.0;
46 V.row(12) << 1.5, 2.0, 0.0;
47 V.row(13) << 1.75, 2.0, 0.0;
48 V.row(14) << 2.0, 2.0, 0.0;
61 F.row(9) << 5, 11, 10;
62 F.row(10) << 6, 7, 12;
63 F.row(11) << 6, 12, 11;
64 F.row(12) << 7, 8, 13;
65 F.row(13) << 7, 13, 12;
66 F.row(14) << 8, 9, 14;
67 F.row(15) << 8, 14, 13;
86 wmtk::components::fusion(Paths(), input, cache);
89 DEBUG_TriMesh& periodic_mesh =
static_cast<DEBUG_TriMesh&
>(*p_mesh);
92 periodic_mesh.serialize(writer);
97 std::cout << F_p << std::endl << std::endl;
99 auto childs = periodic_mesh.get_child_meshes();
100 CHECK(childs.size() == 1);
108 childs[0]->serialize(writer_child);
115 std::cout << V_child << std::endl << std::endl;
116 std::cout << FV_child << std::endl << std::endl;
122 "input": "test_mesh",
129 wmtk::components::fusion(Paths(), input, cache);
132 DEBUG_TriMesh& periodic_mesh =
static_cast<DEBUG_TriMesh&
>(*p_mesh);
135 periodic_mesh.serialize(writer);
145 auto childs = periodic_mesh.get_child_meshes();
146 CHECK(childs.size() == 1);
155 "input": "test_mesh",
162 wmtk::components::fusion(Paths(), input, cache);
165 DEBUG_TriMesh& periodic_mesh =
static_cast<DEBUG_TriMesh&
>(*p_mesh);
168 periodic_mesh.serialize(writer);
177 auto childs = periodic_mesh.get_child_meshes();
178 CHECK(childs.size() == 1);
185 TEST_CASE(
"fusion_3d",
"[components][fusion][.]")
191 V.row(0) << 1.0, 1.0, 1.0;
192 V.row(1) << 3.0, 1.0, 1.0;
193 V.row(2) << 3.0, 1.5, 1.0;
194 V.row(3) << 1.0, 1.5, 1.0;
195 V.row(4) << 1.0, 1.0, 4.0;
196 V.row(5) << 3.0, 1.0, 4.0;
197 V.row(6) << 3.0, 1.5, 4.0;
198 V.row(7) << 1.0, 1.5, 4.0;
202 T.row(0) << 0, 1, 2, 3;
203 T.row(1) << 5, 2, 6, 7;
204 T.row(2) << 4, 1, 5, 3;
205 T.row(3) << 4, 3, 7, 5;
206 T.row(4) << 3, 1, 5, 2;
207 T.row(5) << 2, 3, 7, 5;
219 "input": "test_mesh",
226 wmtk::components::fusion(Paths(), input, cache);
229 DEBUG_TetMesh& periodic_mesh =
static_cast<DEBUG_TetMesh&
>(*p_mesh);
232 periodic_mesh.serialize(writer);
241 auto childs = periodic_mesh.get_child_meshes();
242 CHECK(childs.size() == 1);
249 childs[0]->serialize(writer_child);
256 std::cout << V_child << std::endl << std::endl;
257 std::cout << TV_child << std::endl << std::endl;
264 "input": "test_mesh",
271 wmtk::components::fusion(Paths(), input, cache);
274 DEBUG_TetMesh& periodic_mesh =
static_cast<DEBUG_TetMesh&
>(*p_mesh);
277 periodic_mesh.serialize(writer);
286 auto childs = periodic_mesh.get_child_meshes();
287 CHECK(childs.size() == 1);
298 "input": "test_mesh",
305 wmtk::components::fusion(Paths(), input, cache);
308 DEBUG_TetMesh& periodic_mesh =
static_cast<DEBUG_TetMesh&
>(*p_mesh);
311 periodic_mesh.serialize(writer);
320 auto childs = periodic_mesh.get_child_meshes();
321 CHECK(childs.size() == 1);
void write_mesh(const Mesh &m, const std::string &name, const std::map< std::string, std::vector< int64_t >> &multimesh_names={})
Write a mesh to cache.
std::shared_ptr< Mesh > read_mesh(const std::string &name) const
Load a mesh from cache.
void get_position_matrix(MatrixX< double > &matrix)
void get_TV_matrix(MatrixX< int64_t > &matrix)
void get_FV_matrix(MatrixX< int64_t > &matrix)
attribute::MeshAttributeHandle set_matrix_attribute(const Mat &data, const std::string &name, const PrimitiveType &type, Mesh &mesh)
RowVectors< int64_t, 3 > RowVectors3l
RowVectors< int64_t, 4 > RowVectors4l
RowVectors< double, 3 > RowVectors3d
Eigen::Matrix< T, Eigen::Dynamic, Eigen::Dynamic > MatrixX
const std::filesystem::path data_dir
TEST_CASE("fusion_2d", "[components][fusion][.]")