From 80dd4bc6a8eaf99ca0f882999d7f90063506c399 Mon Sep 17 00:00:00 2001 From: David Wells Date: Fri, 27 Jan 2023 17:28:09 -0500 Subject: [PATCH] Make ExodusII work with line types. This is useful for loading codim 1 and codim 2 meshes. --- source/grid/grid_in.cc | 13 +++- tests/grid/grid_in_exodusii.cc | 29 +++++---- ...odusii.with_trilinos_with_seacas=on.output | 56 ++++++++++++++++++ tests/grid/grids/exodusii/lines.e | Bin 0 -> 1868 bytes 4 files changed, 85 insertions(+), 13 deletions(-) create mode 100644 tests/grid/grids/exodusii/lines.e diff --git a/source/grid/grid_in.cc b/source/grid/grid_in.cc index 312400bc28..10aba0dfae 100644 --- a/source/grid/grid_in.cc +++ b/source/grid/grid_in.cc @@ -3517,7 +3517,11 @@ namespace numbers.end()), type_name_2.end()); - if (type_name_2 == "TRI" || type_name_2 == "TRIANGLE") + // The manual specifies BAR, BEAM, and TRUSS: in practice people use EDGE + if (type_name_2 == "BAR" || type_name_2 == "BEAM" || + type_name_2 == "EDGE" || type_name_2 == "TRUSS") + return ReferenceCells::Line; + else if (type_name_2 == "TRI" || type_name_2 == "TRIANGLE") return ReferenceCells::Triangle; else if (type_name_2 == "QUAD" || type_name_2 == "QUADRILATERAL") return ReferenceCells::Quadrilateral; @@ -3813,6 +3817,13 @@ GridIn::read_exodusii( AssertThrowExodusII(ierr); const ReferenceCell type = exodusii_name_to_type(string_temp.data(), n_nodes_per_element); + AssertThrow(type.get_dimension() == dim, + ExcMessage( + "The ExodusII block " + std::to_string(element_block_id) + + " with element type " + std::string(string_temp.data()) + + " has dimension " + std::to_string(type.get_dimension()) + + ", which does not match the topological mesh dimension " + + std::to_string(dim) + ".")); // The number of nodes per element may be larger than what we want to // read - for example, if the Exodus file contains a QUAD9 element, we diff --git a/tests/grid/grid_in_exodusii.cc b/tests/grid/grid_in_exodusii.cc index 74d88a00aa..69f4329205 100644 --- a/tests/grid/grid_in_exodusii.cc +++ b/tests/grid/grid_in_exodusii.cc @@ -45,18 +45,19 @@ read_and_print(const std::string &filename, deallog << std::endl; } - for (const auto &face : tria.active_face_iterators()) - { - if (face->at_boundary()) - { - deallog << "face center = " << face->center(); - if (read_as_manifolds) - deallog << " face manifold id = " << face->manifold_id(); - else - deallog << " face boundary id = " << face->boundary_id(); - deallog << std::endl; - } - } + if (dim > 1) + for (const auto &face : tria.active_face_iterators()) + { + if (face->at_boundary()) + { + deallog << "face center = " << face->center(); + if (read_as_manifolds) + deallog << " face manifold id = " << face->manifold_id(); + else + deallog << " face boundary id = " << face->boundary_id(); + deallog << std::endl; + } + } deallog << "Number of vertices: " << tria.get_vertices().size() << std::endl; deallog << "Number of cells: " << tria.n_cells() << std::endl; @@ -106,6 +107,10 @@ main() deallog << "--------------------------------------" << std::endl; read_and_print<3>(SOURCE_DIR "/grids/exodusii/four-sidesets.e", true); + deallog << "-------------" << std::endl; + deallog << "codim 1 lines" << std::endl; + deallog << "-------------" << std::endl; + read_and_print<1, 2>(SOURCE_DIR "/grids/exodusii/lines.e"); deallog << "OK" << std::endl; } diff --git a/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output b/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output index b1b43d02d4..a0775a462e 100644 --- a/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output +++ b/tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output @@ -415,4 +415,60 @@ LOOKUP_TABLE default -1 -1 -1 -1 1 2 5 3 4 1 5 1 4 3 1 4 6 3 +DEAL::------------- +DEAL::codim 1 lines +DEAL::------------- +DEAL::boundary id = 0 sideset ids = +DEAL::Number of vertices: 9 +DEAL::Number of cells: 8 +DEAL::cell 0 type = Line volume = 3.50000 +DEAL::cell 1 type = Line volume = 7.00000 +DEAL::cell 2 type = Line volume = 2.82843 +DEAL::cell 3 type = Line volume = 3.00000 +DEAL::cell 4 type = Line volume = 7.00000 +DEAL::cell 5 type = Line volume = 2.82843 +DEAL::cell 6 type = Line volume = 7.00000 +DEAL::cell 7 type = Line volume = 2.82843 +# vtk DataFile Version 3.0 +Triangulation generated with deal.II +ASCII +DATASET UNSTRUCTURED_GRID +POINTS 9 double +0.0 0.0 0 +7.0 0.0 0 +5.0 2.0 0 +2.0 2.0 0 +2.0 5.0 0 +0.0 7.0 0 +5.0 5.0 0 +7.0 3.5 0 +7.0 7.0 0 + +CELLS 8 24 +2 7 1 +2 1 0 +2 0 3 +2 3 2 +2 0 5 +2 5 4 +2 5 8 +2 8 6 + +CELL_TYPES 8 +3 3 3 3 3 3 3 3 + + + +CELL_DATA 8 +SCALARS MaterialID int 1 +LOOKUP_TABLE default +1 1 1 1 1 1 1 1 + + + +SCALARS ManifoldID int 1 +LOOKUP_TABLE default +-1 -1 -1 -1 -1 -1 -1 -1 + + DEAL::OK diff --git a/tests/grid/grids/exodusii/lines.e b/tests/grid/grids/exodusii/lines.e new file mode 100644 index 0000000000000000000000000000000000000000..84901e0429a222999ffeec0b4b0708a1bf65eb7b GIT binary patch literal 1868 zcmeHI%TB{E5KL)H9w0ctfddDA0SR#q0wIt%bG1TiiiKlGtqT-!<d;X7Tv#PpPqoQDlAEd%!Zqcg9(-kLU^96UiFzR#?YeW`}x6lK(0#_*@QzJ zB)!2S*LUBGAtsi5h;V%>WEk+sfN$o$A*q5Tuk=Upy|;TCUSA*+d!_#c@#e&XIeM{Y z*n087y=KVd&mPw9}}NVymNXI$QcVfCx3@BE9dWAg;lfmZpV5$>%x}*5_m`|J+k4XJdBlc zzq8RKWoO0ob-{O5>SD{z>8;F_K8d*#h^!x@|K~pgf0hB>tNgyH{649?`>4FT81vhw M@_wS_e;qab0zV6YmjD0& literal 0 HcmV?d00001 -- 2.39.5