]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Enabling mixed meshes in GridIn::read_vkt() amd read_msh() 11501/head
authorPeter Munch <peterrmuench@gmail.com>
Sun, 10 Jan 2021 21:44:15 +0000 (22:44 +0100)
committerPeter Munch <peterrmuench@gmail.com>
Sun, 10 Jan 2021 21:48:02 +0000 (22:48 +0100)
source/grid/grid_in.cc
source/grid/tria.cc

index 50d432be0f66f3f7f578ec647a005ed8fc8d0248..2eec0e3195837ba696f7a72c8a842462caf7863c 100644 (file)
@@ -529,17 +529,12 @@ GridIn<dim, spacedim>::read_vtk(std::istream &in)
       Assert(subcelldata.check_consistency(dim), ExcInternalError());
 
 
-      // make sure that only either simplex or hypercube cells are available
-      //
       // TODO: the functions below (GridTools::delete_unused_vertices(),
       // GridTools::invert_all_cells_of_negative_grid(),
-      // GridReordering::reorder_cells(),
-      // Triangulation::create_triangulation_compatibility()) need to be
-      // revisited for simplex meshes
-      AssertThrow(dim == 1 || (is_tria_or_tet_mesh ^ is_quad_or_hex_mesh),
-                  ExcNotImplemented());
+      // GridReordering::reorder_cells()) need to be
+      // revisited for simplex/mixed meshes
 
-      if (dim == 1 || is_quad_or_hex_mesh)
+      if (dim == 1 || (is_quad_or_hex_mesh && !is_tria_or_tet_mesh))
         {
           GridTools::delete_unused_vertices(vertices, cells, subcelldata);
 
@@ -556,7 +551,10 @@ GridIn<dim, spacedim>::read_vtk(std::istream &in)
         }
       else
         {
-          tria->create_triangulation(vertices, cells, subcelldata);
+          // simplex or mixed mesh
+          tria->create_triangulation_compatibility(vertices,
+                                                   cells,
+                                                   subcelldata);
         }
     }
   else
@@ -2150,17 +2148,12 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
   // check that we actually read some cells.
   AssertThrow(cells.size() > 0, ExcGmshNoCellInformation());
 
-  // make sure that only either simplex or hypercube cells are available
-  //
   // TODO: the functions below (GridTools::delete_unused_vertices(),
   // GridTools::invert_all_cells_of_negative_grid(),
-  // GridReordering::reorder_cells(),
-  // Triangulation::create_triangulation_compatibility()) need to be revisited
-  // for simplex meshes
-  AssertThrow(dim == 1 || (is_tria_or_tet_mesh ^ is_quad_or_hex_mesh),
-              ExcNotImplemented());
+  // GridReordering::reorder_cells()) need to be revisited
+  // for simplex/mixed meshes
 
-  if (dim == 1 || is_quad_or_hex_mesh)
+  if (dim == 1 || (is_quad_or_hex_mesh && !is_tria_or_tet_mesh))
     {
       // do some clean-up on vertices...
       GridTools::delete_unused_vertices(vertices, cells, subcelldata);
@@ -2173,7 +2166,8 @@ GridIn<dim, spacedim>::read_msh(std::istream &in)
     }
   else
     {
-      tria->create_triangulation(vertices, cells, subcelldata);
+      // simplex or mixed mesh
+      tria->create_triangulation_compatibility(vertices, cells, subcelldata);
     }
 
   // in 1d, we also have to attach boundary ids to vertices, which does not
index 964bb3b598dcc0ef88f198eac9a0b30d1569ef6e..dc48caea96cb057e84bfecc7e27e0e5ccb30b3c0 100644 (file)
@@ -481,7 +481,8 @@ namespace
                              const SubCellData &)
   {
     for (auto &cell : cells)
-      std::swap(cell.vertices[2], cell.vertices[3]);
+      if (cell.vertices.size() == GeometryInfo<2>::vertices_per_cell)
+        std::swap(cell.vertices[2], cell.vertices[3]);
   }
 
 
@@ -490,21 +491,18 @@ namespace
   {
     unsigned int tmp[GeometryInfo<3>::vertices_per_cell];
     for (auto &cell : cells)
-      {
-        for (const unsigned int i : GeometryInfo<3>::vertex_indices())
-          tmp[i] = cell.vertices[i];
-        for (const unsigned int i : GeometryInfo<3>::vertex_indices())
-          cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i];
-      }
+      if (cell.vertices.size() == GeometryInfo<3>::vertices_per_cell)
+        {
+          for (const unsigned int i : GeometryInfo<3>::vertex_indices())
+            tmp[i] = cell.vertices[i];
+          for (const unsigned int i : GeometryInfo<3>::vertex_indices())
+            cell.vertices[GeometryInfo<3>::ucd_to_deal[i]] = tmp[i];
+        }
 
     // now points in boundary quads
-    std::vector<CellData<2>>::iterator boundary_quad =
-      subcelldata.boundary_quads.begin();
-    std::vector<CellData<2>>::iterator end_quad =
-      subcelldata.boundary_quads.end();
-    for (unsigned int quad_no = 0; boundary_quad != end_quad;
-         ++boundary_quad, ++quad_no)
-      std::swap(boundary_quad->vertices[2], boundary_quad->vertices[3]);
+    for (auto &boundary_quad : subcelldata.boundary_quads)
+      if (boundary_quad.vertices.size() == GeometryInfo<2>::vertices_per_cell)
+        std::swap(boundary_quad.vertices[2], boundary_quad.vertices[3]);
   }
 
 

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.