From 63d733d5fea05f8722157213d8341edec2b99fac Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 15 Nov 2021 17:46:59 -0700 Subject: [PATCH] Add the ability to output tet meshes in gnuplot format. --- source/grid/grid_out.cc | 115 ++++++++++++++++++++++++---------------- 1 file changed, 70 insertions(+), 45 deletions(-) diff --git a/source/grid/grid_out.cc b/source/grid/grid_out.cc index 92362ce53a..287364b001 100644 --- a/source/grid/grid_out.cc +++ b/source/grid/grid_out.cc @@ -4411,55 +4411,80 @@ namespace internal (!cell->has_boundary_lines() && !gnuplot_flags.curved_inner_cells)) { - // front face - out << cell->vertex(0) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(1) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(5) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(4) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(0) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << '\n'; - // back face - out << cell->vertex(2) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(3) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(7) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(6) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(2) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << '\n'; + if (cell->reference_cell() == ReferenceCells::Hexahedron) + { + // front face + out << cell->vertex(0) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(1) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(5) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(4) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(0) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << '\n'; + // back face + out << cell->vertex(2) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(3) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(7) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(6) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(2) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << '\n'; + + // now for the four connecting lines + out << cell->vertex(0) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(2) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << '\n'; + out << cell->vertex(1) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(3) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << '\n'; + out << cell->vertex(5) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(7) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << '\n'; + out << cell->vertex(4) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << cell->vertex(6) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n' + << '\n'; + } + else if (cell->reference_cell() == ReferenceCells::Tetrahedron) + { + // Draw the tetrahedron as a two collections of lines. + for (const unsigned int v : {0, 1, 2, 0, 3, 2}) + { + out << cell->vertex(v) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n'; + } + out << '\n'; // end of first line - // now for the four connecting lines - out << cell->vertex(0) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(2) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << '\n'; - out << cell->vertex(1) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(3) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << '\n'; - out << cell->vertex(5) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(7) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << '\n'; - out << cell->vertex(4) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << cell->vertex(6) << ' ' << cell->level() << ' ' - << cell->material_id() << '\n' - << '\n'; + for (const unsigned int v : {3, 1}) + { + out << cell->vertex(v) << ' ' << cell->level() << ' ' + << cell->material_id() << '\n'; + } + out << '\n'; // end of second line + } + else + Assert(false, ExcNotImplemented()); } else { + Assert(cell->reference_cell() == ReferenceCells::Hexahedron, + ExcNotImplemented()); + for (const unsigned int face_no : GeometryInfo::face_indices()) { -- 2.39.5