]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make ExodusII work with line types. 14745/head
authorDavid Wells <drwells@email.unc.edu>
Fri, 27 Jan 2023 22:28:09 +0000 (17:28 -0500)
committerDavid Wells <drwells@email.unc.edu>
Sat, 28 Jan 2023 14:44:20 +0000 (09:44 -0500)
This is useful for loading codim 1 and codim 2 meshes.

source/grid/grid_in.cc
tests/grid/grid_in_exodusii.cc
tests/grid/grid_in_exodusii.with_trilinos_with_seacas=on.output
tests/grid/grids/exodusii/lines.e [new file with mode: 0644]

index 312400bc28833f90df8ad25eba1c100a6aba2dfe..10aba0dfaee591e7929912fc2b7df7aa4f460917 100644 (file)
@@ -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<dim, spacedim>::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
index 74d88a00aae963c1d9ed182e58f759ffa09c2991..69f43292051374eaa802fa6f945bcc56c4c04167 100644 (file)
@@ -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;
 }
index b1b43d02d4b5101089ae9ee34e38b5acb171b07b..a0775a462e98a4029839fbc657dca86c3f5565cc 100644 (file)
@@ -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 (file)
index 0000000..84901e0
Binary files /dev/null and b/tests/grid/grids/exodusii/lines.e differ

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.