From 0b61ef547200284c33278eaaa2f08c2eca894dba Mon Sep 17 00:00:00 2001 From: teseoch Date: Fri, 13 Dec 2024 09:17:58 -0800 Subject: [PATCH 1/3] fixed writer --- src/wmtk/io/ParaviewWriter.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wmtk/io/ParaviewWriter.cpp b/src/wmtk/io/ParaviewWriter.cpp index 074ffe0930..5030cf47be 100644 --- a/src/wmtk/io/ParaviewWriter.cpp +++ b/src/wmtk/io/ParaviewWriter.cpp @@ -219,12 +219,12 @@ void ParaviewWriter::write_internal( for (int i = 0; i < m_writers.size(); ++i) { if (m_enabled[i]) m_writers[i].vertices() = V; } - } else if (m_enabled[type]) { - m_writers[type].write(name, stride, val, true); } else if (type == 0) { // vertex attrs are always written for (size_t i = 0; i < m_writers.size(); ++i) { if (m_enabled[i]) m_writers[i].write(name, stride, val, false); } + } else if (m_enabled[type]) { + m_writers[type].write(name, stride, val, true); } } From 22a380266012eca9ae10b967096b0031d3c683f8 Mon Sep 17 00:00:00 2001 From: teseoch Date: Fri, 13 Dec 2024 09:23:38 -0800 Subject: [PATCH 2/3] added check no throw --- tests/io/test_io.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/io/test_io.cpp b/tests/io/test_io.cpp index ea87a5cabe..c1dae7af7f 100644 --- a/tests/io/test_io.cpp +++ b/tests/io/test_io.cpp @@ -89,17 +89,17 @@ TEST_CASE("paraview_2d", "[io]") auto mesh = read_mesh(WMTK_DATA_DIR "/fan.msh"); ParaviewWriter writer("paraview_2d", "vertices", *mesh, true, true, true, false); - mesh->serialize(writer); + CHECK_NOTHROW(mesh->serialize(writer)); } -TEST_CASE("paraview_2d_vtag", "[io.]") +TEST_CASE("paraview_2d_vtag", "[io]") { auto mesh = read_mesh(WMTK_DATA_DIR "/fan.msh"); mesh->register_attribute("tag", PrimitiveType::Triangle, 1); mesh->register_attribute("tag1", PrimitiveType::Vertex, 1); - ParaviewWriter writer("paraview_2d_vtag", "vertices", *mesh, false, false, true, false); - mesh->serialize(writer); + ParaviewWriter writer("paraview_2d_vtag", "vertices", *mesh, true, true, true, false); + CHECK_NOTHROW(mesh->serialize(writer)); } TEST_CASE("hdf5_3d", "[io]") @@ -110,7 +110,7 @@ TEST_CASE("hdf5_3d", "[io]") mesh.initialize(T); HDF5Writer writer("hdf5_3d.hdf5"); - mesh.serialize(writer); + CHECK_NOTHROW(mesh.serialize(writer)); } TEST_CASE("hdf5_multimesh", "[io]") @@ -157,7 +157,7 @@ TEST_CASE("paraview_3d", "[io]") mesh_utils::set_matrix_attribute(V, "vertices", PrimitiveType::Vertex, mesh); ParaviewWriter writer("paraview_3d", "vertices", mesh, true, true, true, true); - mesh.serialize(writer); + CHECK_NOTHROW(mesh.serialize(writer)); } TEST_CASE("msh_3d", "[io]") @@ -303,5 +303,5 @@ TEST_CASE("attribute_after_split", "[io][.]") // attribute_after_split_edges.hdf contains a 1 in the "test_attribute" ParaviewWriter writer("attribute_after_split", "vertices", m, true, true, true, false); - m.serialize(writer); + CHECK_NOTHROW(m.serialize(writer)); } From f710d788e4d546e59b7084fd683a5b38653e5dc8 Mon Sep 17 00:00:00 2001 From: teseoch Date: Fri, 13 Dec 2024 09:29:25 -0800 Subject: [PATCH 3/3] export vtm too --- src/wmtk/io/ParaviewWriter.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/wmtk/io/ParaviewWriter.cpp b/src/wmtk/io/ParaviewWriter.cpp index 5030cf47be..38e60386a1 100644 --- a/src/wmtk/io/ParaviewWriter.cpp +++ b/src/wmtk/io/ParaviewWriter.cpp @@ -5,7 +5,9 @@ #include #include +#include #include + // #include #include @@ -147,6 +149,14 @@ ParaviewWriter::ParaviewWriter( m_writers[1].init(filename.string() + "_edges.vtu", vertices_name, cells[1], m_enabled[1]); m_writers[2].init(filename.string() + "_faces.vtu", vertices_name, cells[2], m_enabled[2]); m_writers[3].init(filename.string() + "_tets.vtu", vertices_name, cells[3], m_enabled[3]); + + paraviewo::VTMWriter vtm; + if (m_enabled[0]) vtm.add_dataset("verts", "mesh", filename.string() + "_verts.vtu"); + if (m_enabled[1]) vtm.add_dataset("edges", "mesh", filename.string() + "_edges.vtu"); + if (m_enabled[2]) vtm.add_dataset("faces", "mesh", filename.string() + "_faces.vtu"); + if (m_enabled[3]) vtm.add_dataset("tets", "mesh", filename.string() + "_tets.vtu"); + + vtm.save(filename.string() + ".vtm"); } void ParaviewWriter::write(