]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Modified the function to include conditions of dim < spacedim 11259/head
authorMalhar Tidke <malhar.tidke@gmail.com>
Sun, 20 Dec 2020 19:35:19 +0000 (01:05 +0530)
committerMalhar Tidke <malhar.tidke@gmail.com>
Wed, 23 Dec 2020 09:29:20 +0000 (14:59 +0530)
Added a test case for dim < spacedim

Added a output for test case when dim < spacedim

Added separate template parameters of dim and spacedim for check function

Fixed instantiation of DoFTools::make_periodicity_constraints

14 files changed:
doc/news/changes/minor/20201223MalharTidke [new file with mode: 0644]
tests/dofs/dof_tools_21.cc
tests/dofs/dof_tools_21_b.cc
tests/dofs/dof_tools_21_b.output
tests/dofs/dof_tools_21_b_x.cc
tests/dofs/dof_tools_21_b_x.output
tests/dofs/dof_tools_21_b_x_q3.cc
tests/dofs/dof_tools_21_b_x_q3.output
tests/dofs/dof_tools_21_b_y.cc
tests/dofs/dof_tools_21_b_y.output
tests/dofs/dof_tools_21_c.cc
tests/dofs/dof_tools_21_c.output
tests/dofs/dof_tools_23.cc
tests/dofs/dof_tools_periodic.h

diff --git a/doc/news/changes/minor/20201223MalharTidke b/doc/news/changes/minor/20201223MalharTidke
new file mode 100644 (file)
index 0000000..d4a6b07
--- /dev/null
@@ -0,0 +1,3 @@
+Fixed: DoFTools::make_periodicity_constraints() was not instantiated for condition 'dim < spacedim'. The instantiation was corrected and a test was added to verify that the function works for such condition.     
+<br>
+(Malhar Tidke, 2020/12/23)
index 4b7076a5ec55a6e723e6ee5f55ff5dd2aedae47c..520c5fad61a6baedfcaf19ca6bb29bb3498f635a 100644 (file)
@@ -45,9 +45,9 @@
 
 
 
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-check_this(const DoFHandler<dim> &dof_handler)
+check_this(const DoFHandler<dim, spacedim> &dof_handler)
 {
   Functions::CosineFunction<dim> test_func(dof_handler.get_fe().n_components());
 
index 5356e166a251aec17d6bc61092dd0b52693c9ad7..a0936b311dc08ec2d9f76fa26aeae626cf24ac5b 100644 (file)
@@ -110,6 +110,60 @@ void generate_grid(Triangulation<2> &triangulation, int orientation)
   triangulation.refine_global(0);
 }
 
+/* The 2D in 3D case */
+void generate_grid(Triangulation<2, 3> &triangulation, int orientation)
+{
+  Point<3> vertices_1[] = {
+    Point<3>(-1., -3., 0.),
+    Point<3>(+1., -3., 0.),
+    Point<3>(-1., -1., 0.),
+    Point<3>(+1., -1., 0.),
+    Point<3>(-1., +1., 0.),
+    Point<3>(+1., +1., 0.),
+    Point<3>(-1., +3., 0.),
+    Point<3>(+1., +3., 0.),
+  };
+  std::vector<Point<3>> vertices(&vertices_1[0], &vertices_1[8]);
+
+  std::vector<CellData<2>> cells(2, CellData<2>());
+
+  /* cell 0 */
+  int cell_vertices_0[GeometryInfo<2>::vertices_per_cell] = {0, 1, 2, 3};
+
+  /* cell 1 */
+  int cell_vertices_1[2][GeometryInfo<2>::vertices_per_cell] = {
+    {4, 5, 6, 7},
+    {7, 6, 5, 4},
+  };
+
+  for (const unsigned int j : GeometryInfo<2>::vertex_indices())
+    {
+      cells[0].vertices[j] = cell_vertices_0[j];
+      cells[1].vertices[j] = cell_vertices_1[orientation][j];
+    }
+  cells[0].material_id = 0;
+  cells[1].material_id = 0;
+
+  triangulation.create_triangulation(vertices, cells, SubCellData());
+
+  Triangulation<2, 3>::cell_iterator cell_1 = triangulation.begin();
+  Triangulation<2, 3>::cell_iterator cell_2 = cell_1++;
+  Triangulation<2, 3>::face_iterator face_1;
+  Triangulation<2, 3>::face_iterator face_2;
+
+  // Look for the two outermost faces:
+  for (const unsigned int j : GeometryInfo<2>::face_indices())
+    {
+      if (cell_1->face(j)->center()(1) > 2.9)
+        face_1 = cell_1->face(j);
+      if (cell_2->face(j)->center()(1) < -2.9)
+        face_2 = cell_2->face(j);
+    }
+  face_1->set_boundary_id(42);
+  face_2->set_boundary_id(43);
+
+  triangulation.refine_global(0);
+}
 
 /* The 3D case */
 void generate_grid(Triangulation<3> &triangulation, int orientation)
@@ -185,20 +239,20 @@ void generate_grid(Triangulation<3> &triangulation, int orientation)
  * Print out all face DoFs and support points as well as the actual
  * matching via make_periodicity_constraints
  */
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-print_matching(DoFHandler<dim> &dof_handler,
-               bool             constrain_only_velocity = false)
+print_matching(DoFHandler<dim, spacedim> &dof_handler,
+               bool                       constrain_only_velocity = false)
 {
-  const FiniteElement<dim> &fe = dof_handler.get_fe();
-  MappingQ<dim>             mapping(1);
+  const FiniteElement<dim, spacedim> &fe = dof_handler.get_fe();
+  MappingQ<dim, spacedim>             mapping(1);
 
-  AffineConstraints<double> constraint_matrix;
-  AffineConstraints<double> constraint_matrix_reverse;
-  std::vector<Point<dim>>   support_points(dof_handler.n_dofs());
-  DoFTools::map_dofs_to_support_points<dim>(mapping,
-                                            dof_handler,
-                                            support_points);
+  AffineConstraints<double>    constraint_matrix;
+  AffineConstraints<double>    constraint_matrix_reverse;
+  std::vector<Point<spacedim>> support_points(dof_handler.n_dofs());
+  DoFTools::map_dofs_to_support_points<dim, spacedim>(mapping,
+                                                      dof_handler,
+                                                      support_points);
 
   FEValuesExtractors::Vector v(0);
   FEValuesExtractors::Scalar v_1(0);
@@ -211,9 +265,10 @@ print_matching(DoFHandler<dim> &dof_handler,
     velocity_mask = fe.component_mask(v);
 
   // Look for the two outermost faces:
-  typename DoFHandler<dim>::face_iterator face_1;
-  typename DoFHandler<dim>::face_iterator face_2;
-  for (typename DoFHandler<dim>::cell_iterator cell = dof_handler.begin(0);
+  typename DoFHandler<dim, spacedim>::face_iterator face_1;
+  typename DoFHandler<dim, spacedim>::face_iterator face_2;
+  for (typename DoFHandler<dim, spacedim>::cell_iterator cell =
+         dof_handler.begin(0);
        cell != dof_handler.end(0);
        ++cell)
     {
@@ -267,7 +322,7 @@ print_matching(DoFHandler<dim> &dof_handler,
                                          face_1,
                                          face_2,
                                          dim == 2 ? 1 : 2,
-                                         dealii::Tensor<1, dim>()))
+                                         dealii::Tensor<1, spacedim>()))
     std::cerr << " not match! oh noze!! " << std::endl;
   deallog << "Orientation: " << orientation[0] << orientation[1]
           << orientation[2] << std::endl;
@@ -323,6 +378,22 @@ main()
       print_matching(dof_handler);
     }
 
+  deallog << "Test for 2D in 3D, Q1:" << std::endl << std::endl;
+
+  for (int i = 0; i < 2; ++i)
+    {
+      // Generate a triangulation and match:
+      Triangulation<2, 3> triangulation;
+      FE_Q<2, 3>          fe(1);
+      DoFHandler<2, 3>    dof_handler(triangulation);
+
+      deallog << "Triangulation:" << i << std::endl;
+
+      generate_grid(triangulation, i);
+      dof_handler.distribute_dofs(fe);
+      print_matching(dof_handler);
+    }
+
   deallog << "Test for 3D, Q1:" << std::endl << std::endl;
 
   for (int i = 0; i < 8; ++i)
index 9815ffc899735df7cd11260314a2020c26947671..d4e21c2cdbf8623a810e3a6b6ce3ce6efc644f99 100644 (file)
@@ -19,6 +19,32 @@ DEAL:: component 0: (4 - 1.000 3.000) (5 - -1.000 3.000)
 DEAL::DoFs of face_2:
 DEAL:: component 0: (0 - -1.000 -3.000) (1 - 1.000 -3.000)
 DEAL::Orientation: 110
+DEAL::Matching:
+    4 1:  1.000
+    5 0:  1.000
+DEAL::Reverse Matching:
+    5 0:  1.000
+    4 1:  1.000
+DEAL::Test for 2D in 3D, Q1:
+DEAL::
+DEAL::Triangulation:0
+DEAL::DoFs of face_1:
+DEAL:: component 0: (6 - -1.000 3.000 0.000) (7 - 1.000 3.000 0.000)
+DEAL::DoFs of face_2:
+DEAL:: component 0: (0 - -1.000 -3.000 0.000) (1 - 1.000 -3.000 0.000)
+DEAL::Orientation: 100
+DEAL::Matching:
+    6 0:  1.000
+    7 1:  1.000
+DEAL::Reverse Matching:
+    6 0:  1.000
+    7 1:  1.000
+DEAL::Triangulation:1
+DEAL::DoFs of face_1:
+DEAL:: component 0: (4 - 1.000 3.000 0.000) (5 - -1.000 3.000 0.000)
+DEAL::DoFs of face_2:
+DEAL:: component 0: (0 - -1.000 -3.000 0.000) (1 - 1.000 -3.000 0.000)
+DEAL::Orientation: 110
 DEAL::Matching:
     4 1:  1.000
     5 0:  1.000
index 2fd40555572c3be9018e48aad9ffae0f8b489c04..c61f253d102f9081ad11c71c46d6587aee9800ce 100644 (file)
@@ -107,28 +107,78 @@ void generate_grid(Triangulation<2> &triangulation)
   face_2->set_boundary_id(43);
 }
 
+/* The 2D in 3D case */
+void generate_grid(Triangulation<2, 3> &triangulation)
+{
+  Point<3> vertices_1[] = {
+    Point<3>(-1., -3., 0.),
+    Point<3>(+1., -3., 0.),
+    Point<3>(-1., -1., 0.),
+    Point<3>(+1., -1., 0.),
+    Point<3>(-1., +1., 0.),
+    Point<3>(+1., +1., 0.),
+    Point<3>(-1., +3., 0.),
+    Point<3>(+1., +3., 0.),
+  };
+  std::vector<Point<3>> vertices(&vertices_1[0], &vertices_1[8]);
+
+  std::vector<CellData<2>> cells(2, CellData<2>());
+
+  /* cell 0 */
+  int cell_vertices_0[GeometryInfo<2>::vertices_per_cell] = {0, 1, 2, 3};
+
+  /* cell 1 */
+  int cell_vertices_1[GeometryInfo<2>::vertices_per_cell] = {7, 6, 5, 4};
+
+  for (const unsigned int j : GeometryInfo<2>::vertex_indices())
+    {
+      cells[0].vertices[j] = cell_vertices_0[j];
+      cells[1].vertices[j] = cell_vertices_1[j];
+    }
+  cells[0].material_id = 0;
+  cells[1].material_id = 0;
+
+  triangulation.create_triangulation(vertices, cells, SubCellData());
+
+  Triangulation<2, 3>::cell_iterator cell_1 = triangulation.begin();
+  Triangulation<2, 3>::cell_iterator cell_2 = cell_1++;
+  Triangulation<2, 3>::face_iterator face_1;
+  Triangulation<2, 3>::face_iterator face_2;
+
+  // Look for the two outermost faces:
+  for (const unsigned int j : GeometryInfo<2>::face_indices())
+    {
+      if (cell_1->face(j)->center()(1) > 2.9)
+        face_1 = cell_1->face(j);
+      if (cell_2->face(j)->center()(1) < -2.9)
+        face_2 = cell_2->face(j);
+    }
+  face_1->set_boundary_id(42);
+  face_2->set_boundary_id(43);
+}
+
 
 /*
  * Print out all face DoFs and support points as well as the actual
  * matching via make_periodicity_constraints
  */
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-print_matching(DoFHandler<dim> &dof_handler)
+print_matching(DoFHandler<dim, spacedim> &dof_handler)
 {
-  const FiniteElement<dim> &fe = dof_handler.get_fe();
-  MappingQ<dim>             mapping(1);
+  const FiniteElement<dim, spacedim> &fe = dof_handler.get_fe();
+  MappingQ<dim, spacedim>             mapping(1);
 
-  AffineConstraints<double> constraint_matrix;
-  std::vector<Point<dim>>   support_points(dof_handler.n_dofs());
-  DoFTools::map_dofs_to_support_points<dim>(mapping,
-                                            dof_handler,
-                                            support_points);
+  AffineConstraints<double>    constraint_matrix;
+  std::vector<Point<spacedim>> support_points(dof_handler.n_dofs());
+  DoFTools::map_dofs_to_support_points<dim, spacedim>(mapping,
+                                                      dof_handler,
+                                                      support_points);
 
   // Look for the two outermost faces:
-  typename DoFHandler<dim>::face_iterator face_1 =
+  typename DoFHandler<dim, spacedim>::face_iterator face_1 =
     (++dof_handler.begin(0))->face(2);
-  typename DoFHandler<dim>::face_iterator face_2 =
+  typename DoFHandler<dim, spacedim>::face_iterator face_2 =
     dof_handler.begin(0)->face(2);
 
   // Determine the orientation of the two faces:
@@ -175,14 +225,27 @@ main()
   logfile << std::setprecision(4);
   deallog.attach(logfile);
 
-  // Generate a triangulation and match:
-  Triangulation<2> triangulation;
-  FE_Q<2>          fe(1);
-  DoFHandler<2>    dof_handler(triangulation);
-
-  generate_grid(triangulation);
-  dof_handler.distribute_dofs(fe);
-  print_matching(dof_handler);
+  {
+    // Generate a triangulation and match:
+    Triangulation<2> triangulation;
+    FE_Q<2>          fe(1);
+    DoFHandler<2>    dof_handler(triangulation);
+
+    generate_grid(triangulation);
+    dof_handler.distribute_dofs(fe);
+    print_matching(dof_handler);
+  }
+
+  {
+    // Generate a triangulation and match:
+    Triangulation<2, 3> triangulation;
+    FE_Q<2, 3>          fe(1);
+    DoFHandler<2, 3>    dof_handler(triangulation);
+
+    generate_grid(triangulation);
+    dof_handler.distribute_dofs(fe);
+    print_matching(dof_handler);
+  }
 
   return 0;
 }
index 0876ae066094ce86d90124d0634288ea1096f84f..5f121b86e7d9b69736778ef161e3d8780888fcf5 100644 (file)
@@ -8,3 +8,12 @@ DEAL::1 is located at 1.000 -3.000
     4 1:  1.000
     5 0:  1.000
 DEAL::Matching:
+DEAL::DoFs of face_1:
+DEAL::4 is located at 1.000 3.000 0.000
+DEAL::5 is located at -1.000 3.000 0.000
+DEAL::DoFs of face_2:
+DEAL::0 is located at -1.000 -3.000 0.000
+DEAL::1 is located at 1.000 -3.000 0.000
+    4 1:  1.000
+    5 0:  1.000
+DEAL::Matching:
index 7402cc73656bb39f71e48981a4c168c99ca20f6f..6a3fb50f056c043077b74fb7601802d7cb49e60f 100644 (file)
@@ -141,28 +141,78 @@ void generate_grid(Triangulation<2> &triangulation)
   face_2->set_boundary_id(43);
 }
 
+/* The 2D in 3D case */
+void generate_grid(Triangulation<2, 3> &triangulation)
+{
+  Point<3> vertices_1[] = {
+    Point<3>(-1., -3., 0.),
+    Point<3>(+1., -3., 0.),
+    Point<3>(-1., -1., 0.),
+    Point<3>(+1., -1., 0.),
+    Point<3>(-1., +1., 0.),
+    Point<3>(+1., +1., 0.),
+    Point<3>(-1., +3., 0.),
+    Point<3>(+1., +3., 0.),
+  };
+  std::vector<Point<3>> vertices(&vertices_1[0], &vertices_1[8]);
+
+  std::vector<CellData<2>> cells(2, CellData<2>());
+
+  /* cell 0 */
+  int cell_vertices_0[GeometryInfo<2>::vertices_per_cell] = {0, 1, 2, 3};
+
+  /* cell 1 */
+  int cell_vertices_1[GeometryInfo<2>::vertices_per_cell] = {7, 6, 5, 4};
+
+  for (const unsigned int j : GeometryInfo<2>::vertex_indices())
+    {
+      cells[0].vertices[j] = cell_vertices_0[j];
+      cells[1].vertices[j] = cell_vertices_1[j];
+    }
+  cells[0].material_id = 0;
+  cells[1].material_id = 0;
+
+  triangulation.create_triangulation(vertices, cells, SubCellData());
+
+  Triangulation<2, 3>::cell_iterator cell_1 = triangulation.begin();
+  Triangulation<2, 3>::cell_iterator cell_2 = cell_1++;
+  Triangulation<2, 3>::face_iterator face_1;
+  Triangulation<2, 3>::face_iterator face_2;
+
+  // Look for the two outermost faces:
+  for (const unsigned int j : GeometryInfo<2>::face_indices())
+    {
+      if (cell_1->face(j)->center()(1) > 2.9)
+        face_1 = cell_1->face(j);
+      if (cell_2->face(j)->center()(1) < -2.9)
+        face_2 = cell_2->face(j);
+    }
+  face_1->set_boundary_id(42);
+  face_2->set_boundary_id(43);
+}
+
 
 /*
  * Print out all face DoFs and support points as well as the actual
  * matching via make_periodicity_constraints
  */
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-print_matching(DoFHandler<dim> &dof_handler)
+print_matching(DoFHandler<dim, spacedim> &dof_handler)
 {
-  const FiniteElement<dim> &fe = dof_handler.get_fe();
-  MappingQ<dim>             mapping(1);
+  const FiniteElement<dim, spacedim> &fe = dof_handler.get_fe();
+  MappingQ<dim, spacedim>             mapping(1);
 
-  AffineConstraints<double> constraint_matrix;
-  std::vector<Point<dim>>   support_points(dof_handler.n_dofs());
-  DoFTools::map_dofs_to_support_points<dim>(mapping,
-                                            dof_handler,
-                                            support_points);
+  AffineConstraints<double>    constraint_matrix;
+  std::vector<Point<spacedim>> support_points(dof_handler.n_dofs());
+  DoFTools::map_dofs_to_support_points<dim, spacedim>(mapping,
+                                                      dof_handler,
+                                                      support_points);
 
   // Look for the two outermost faces:
-  typename DoFHandler<dim>::face_iterator face_1 =
+  typename DoFHandler<dim, spacedim>::face_iterator face_1 =
     (++dof_handler.begin(0))->face(2);
-  typename DoFHandler<dim>::face_iterator face_2 =
+  typename DoFHandler<dim, spacedim>::face_iterator face_2 =
     dof_handler.begin(0)->face(2);
 
   // Determine the orientation of the two faces:
@@ -209,14 +259,28 @@ main()
   logfile << std::setprecision(4);
   deallog.attach(logfile);
 
-  // Generate a triangulation and match:
-  Triangulation<2> triangulation;
-  FE_Q<2>          fe(3);
-  DoFHandler<2>    dof_handler(triangulation);
+  {
+    // Generate a triangulation and match:
+    Triangulation<2> triangulation;
+    FE_Q<2>          fe(3);
+    DoFHandler<2>    dof_handler(triangulation);
+
+    generate_grid(triangulation);
+    dof_handler.distribute_dofs(fe);
+    print_matching(dof_handler);
+  }
+
+  {
+    // Generate a triangulation and match:
+    Triangulation<2, 3> triangulation;
+    FE_Q<2, 3>          fe(3);
+    DoFHandler<2, 3>    dof_handler(triangulation);
+
+    generate_grid(triangulation);
+    dof_handler.distribute_dofs(fe);
+    print_matching(dof_handler);
+  }
 
-  generate_grid(triangulation);
-  dof_handler.distribute_dofs(fe);
-  print_matching(dof_handler);
 
   return 0;
 }
index 9d46160409d6a79ec8bd5edfe5306621e2fdb42a..044e72ef8329a5538347ac99799fa0dd2787117c 100644 (file)
@@ -14,3 +14,18 @@ DEAL::9 is located at 0.4472 -3.000
     24 9:  1.000
     25 8:  1.000
 DEAL::Matching:
+DEAL::DoFs of face_1:
+DEAL::16 is located at 1.000 3.000 0.000
+DEAL::17 is located at -1.000 3.000 0.000
+DEAL::24 is located at 0.4472 3.000 0.000
+DEAL::25 is located at -0.4472 3.000 0.000
+DEAL::DoFs of face_2:
+DEAL::0 is located at -1.000 -3.000 0.000
+DEAL::1 is located at 1.000 -3.000 0.000
+DEAL::8 is located at -0.4472 -3.000 0.000
+DEAL::9 is located at 0.4472 -3.000 0.000
+    16 1:  1.000
+    17 0:  1.000
+    24 9:  1.000
+    25 8:  1.000
+DEAL::Matching:
index 5f0212ef093db16b38ef69aefe9aaf4329ad263b..454e23b41c3ab5366488f886b0faeb4791361f65 100644 (file)
@@ -106,28 +106,79 @@ void generate_grid(Triangulation<2> &triangulation)
   face_2->set_boundary_id(43);
 }
 
+/* The 2D in 3D case */
+void generate_grid(Triangulation<2, 3> &triangulation)
+{
+  Point<3> vertices_1[] = {
+    Point<3>(-1., -3., 0.),
+    Point<3>(+1., -3., 0.),
+    Point<3>(-1., -1., 0.),
+    Point<3>(+1., -1., 0.),
+    Point<3>(-1., +1., 0.),
+    Point<3>(+1., +1., 0.),
+    Point<3>(-1., +3., 0.),
+    Point<3>(+1., +3., 0.),
+  };
+  std::vector<Point<3>> vertices(&vertices_1[0], &vertices_1[8]);
+
+  std::vector<CellData<2>> cells(2, CellData<2>());
+
+  /* cell 0 */
+  int cell_vertices_0[GeometryInfo<2>::vertices_per_cell] = {0, 1, 2, 3};
+
+  /* cell 1 */
+  int cell_vertices_1[GeometryInfo<2>::vertices_per_cell] = {7, 6, 5, 4};
+
+  for (const unsigned int j : GeometryInfo<2>::vertex_indices())
+    {
+      cells[0].vertices[j] = cell_vertices_0[j];
+      cells[1].vertices[j] = cell_vertices_1[j];
+    }
+  cells[0].material_id = 0;
+  cells[1].material_id = 0;
+
+  triangulation.create_triangulation(vertices, cells, SubCellData());
+  triangulation.refine_global(1);
+
+  Triangulation<2, 3>::cell_iterator cell_1 = triangulation.begin();
+  Triangulation<2, 3>::cell_iterator cell_2 = cell_1++;
+  Triangulation<2, 3>::face_iterator face_1;
+  Triangulation<2, 3>::face_iterator face_2;
+
+  // Look for the two outermost faces:
+  for (const unsigned int j : GeometryInfo<2>::face_indices())
+    {
+      if (cell_1->face(j)->center()(1) > 2.9)
+        face_1 = cell_1->face(j);
+      if (cell_2->face(j)->center()(1) < -2.9)
+        face_2 = cell_2->face(j);
+    }
+  face_1->set_boundary_id(42);
+  face_2->set_boundary_id(43);
+}
+
 
 /*
  * Print out all face DoFs and support points as well as the actual
  * matching via make_periodicity_constraints
  */
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-print_matching(DoFHandler<dim> &dof_handler)
+print_matching(DoFHandler<dim, spacedim> &dof_handler)
 {
-  const FiniteElement<dim> &fe = dof_handler.get_fe();
-  MappingQ<dim>             mapping(1);
+  const FiniteElement<dim, spacedim> &fe = dof_handler.get_fe();
+  MappingQ<dim, spacedim>             mapping(1);
 
-  AffineConstraints<double> constraint_matrix;
-  std::vector<Point<dim>>   support_points(dof_handler.n_dofs());
-  DoFTools::map_dofs_to_support_points<dim>(mapping,
-                                            dof_handler,
-                                            support_points);
+  AffineConstraints<double>    constraint_matrix;
+  std::vector<Point<spacedim>> support_points(dof_handler.n_dofs());
+  DoFTools::map_dofs_to_support_points<dim, spacedim>(mapping,
+                                                      dof_handler,
+                                                      support_points);
 
   // Look for the two outermost faces:
-  typename DoFHandler<dim>::face_iterator face_1 =
+  typename DoFHandler<dim, spacedim>::face_iterator face_1 =
     (++dof_handler.begin(0))->face(2);
-  typename DoFHandler<dim>::face_iterator face_2 =
+  typename DoFHandler<dim, spacedim>::face_iterator face_2 =
     dof_handler.begin(0)->face(2);
 
   // Determine the orientation of the two faces:
@@ -174,14 +225,27 @@ main()
   logfile << std::setprecision(4);
   deallog.attach(logfile);
 
-  // Generate a triangulation and match:
-  Triangulation<2> triangulation;
-  FE_Q<2>          fe(1);
-  DoFHandler<2>    dof_handler(triangulation);
+  {
+    // Generate a triangulation and match:
+    Triangulation<2> triangulation;
+    FE_Q<2>          fe(1);
+    DoFHandler<2>    dof_handler(triangulation);
+
+    generate_grid(triangulation);
+    dof_handler.distribute_dofs(fe);
+    print_matching(dof_handler);
+  }
+
+  {
+    Triangulation<2, 3> triangulation;
+    FE_Q<2, 3>          fe(1);
+    DoFHandler<2, 3>    dof_handler(triangulation);
+
+    generate_grid(triangulation);
+    dof_handler.distribute_dofs(fe);
+    print_matching(dof_handler);
+  }
 
-  generate_grid(triangulation);
-  dof_handler.distribute_dofs(fe);
-  print_matching(dof_handler);
 
   return 0;
 }
index 2a38ad58afd614a0755f8a3041821884583b4b1b..631cc17e20f291142a6216ccde7760aa0bf2a2ca 100644 (file)
@@ -9,3 +9,13 @@ DEAL::4 is located at 1.000 -3.000
     10 1:  1.000
     13 0:  1.000
 DEAL::Matching:
+DEAL::DoFs of face_1:
+DEAL::9 is located at 1.000 3.000 0.000
+DEAL::13 is located at -1.000 3.000 0.000
+DEAL::DoFs of face_2:
+DEAL::0 is located at -1.000 -3.000 0.000
+DEAL::4 is located at 1.000 -3.000 0.000
+    9 4:  1.000
+    10 1:  1.000
+    13 0:  1.000
+DEAL::Matching:
index e8ee8db5c756dae2b558362f15d2d71f063df901..b5e0bfdc9b8e1da531245c93aa48b1b634cc7d7a 100644 (file)
@@ -114,6 +114,61 @@ void generate_grid(Triangulation<2> &triangulation, int orientation)
   triangulation.execute_coarsening_and_refinement();
 }
 
+/* The 2D in 3D case */
+void generate_grid(Triangulation<2, 3> &triangulation, int orientation)
+{
+  Point<3> vertices_1[] = {
+    Point<3>(-1., -3., 0.),
+    Point<3>(+1., -3., 0.),
+    Point<3>(-1., -1., 0.),
+    Point<3>(+1., -1., 0.),
+    Point<3>(-1., +1., 0.),
+    Point<3>(+1., +1., 0.),
+    Point<3>(-1., +3., 0.),
+    Point<3>(+1., +3., 0.),
+  };
+  std::vector<Point<3>> vertices(&vertices_1[0], &vertices_1[8]);
+
+  std::vector<CellData<2>> cells(2, CellData<2>());
+
+  /* cell 0 */
+  int cell_vertices_0[GeometryInfo<2>::vertices_per_cell] = {0, 1, 2, 3};
+
+  /* cell 1 */
+  int cell_vertices_1[2][GeometryInfo<2>::vertices_per_cell] = {
+    {4, 5, 6, 7},
+    {7, 6, 5, 4},
+  };
+
+  for (const unsigned int j : GeometryInfo<2>::vertex_indices())
+    {
+      cells[0].vertices[j] = cell_vertices_0[j];
+      cells[1].vertices[j] = cell_vertices_1[orientation][j];
+    }
+  cells[0].material_id = 0;
+  cells[1].material_id = 0;
+
+  triangulation.create_triangulation(vertices, cells, SubCellData());
+
+  Triangulation<2, 3>::cell_iterator cell_1 = triangulation.begin();
+  Triangulation<2, 3>::cell_iterator cell_2 = cell_1++;
+  Triangulation<2, 3>::face_iterator face_1;
+  Triangulation<2, 3>::face_iterator face_2;
+
+  // Look for the two outermost faces:
+  for (const unsigned int j : GeometryInfo<2>::face_indices())
+    {
+      if (cell_1->face(j)->center()(1) > 2.9)
+        face_1 = cell_1->face(j);
+      if (cell_2->face(j)->center()(1) < -2.9)
+        face_2 = cell_2->face(j);
+    }
+  face_1->set_boundary_id(42);
+  face_2->set_boundary_id(43);
+
+  cell_2->set_refine_flag();
+  triangulation.execute_coarsening_and_refinement();
+}
 
 /* The 3D case */
 void generate_grid(Triangulation<3> &triangulation, int orientation)
@@ -190,20 +245,20 @@ void generate_grid(Triangulation<3> &triangulation, int orientation)
  * Print out all face DoFs and support points as well as the actual
  * matching via make_periodicity_constraints
  */
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-print_matching(DoFHandler<dim> &dof_handler,
-               bool             constrain_only_velocity = false)
+print_matching(DoFHandler<dim, spacedim> &dof_handler,
+               bool                       constrain_only_velocity = false)
 {
-  const FiniteElement<dim> &fe = dof_handler.get_fe();
-  MappingQ<dim>             mapping(1);
+  const FiniteElement<dim, spacedim> &fe = dof_handler.get_fe();
+  MappingQ<dim, spacedim>             mapping(1);
 
-  AffineConstraints<double> constraint_matrix;
-  AffineConstraints<double> constraint_matrix_reverse;
-  std::vector<Point<dim>>   support_points(dof_handler.n_dofs());
-  DoFTools::map_dofs_to_support_points<dim>(mapping,
-                                            dof_handler,
-                                            support_points);
+  AffineConstraints<double>    constraint_matrix;
+  AffineConstraints<double>    constraint_matrix_reverse;
+  std::vector<Point<spacedim>> support_points(dof_handler.n_dofs());
+  DoFTools::map_dofs_to_support_points<dim, spacedim>(mapping,
+                                                      dof_handler,
+                                                      support_points);
 
   FEValuesExtractors::Vector v(0);
   FEValuesExtractors::Scalar v_1(0);
@@ -216,9 +271,10 @@ print_matching(DoFHandler<dim> &dof_handler,
     velocity_mask = fe.component_mask(v);
 
   // Look for the two outermost faces:
-  typename DoFHandler<dim>::face_iterator face_1;
-  typename DoFHandler<dim>::face_iterator face_2;
-  for (typename DoFHandler<dim>::cell_iterator cell = dof_handler.begin(0);
+  typename DoFHandler<dim, spacedim>::face_iterator face_1;
+  typename DoFHandler<dim, spacedim>::face_iterator face_2;
+  for (typename DoFHandler<dim, spacedim>::cell_iterator cell =
+         dof_handler.begin(0);
        cell != dof_handler.end(0);
        ++cell)
     {
@@ -272,7 +328,7 @@ print_matching(DoFHandler<dim> &dof_handler,
                                          face_1,
                                          face_2,
                                          dim == 2 ? 1 : 2,
-                                         dealii::Tensor<1, dim>()))
+                                         dealii::Tensor<1, spacedim>()))
     std::cerr << " not match! oh noze!! " << std::endl;
   deallog << "Orientation: " << orientation[0] << orientation[1]
           << orientation[2] << std::endl;
@@ -328,6 +384,22 @@ main()
       print_matching(dof_handler);
     }
 
+  deallog << "Test for 2D in 3D, Q1:" << std::endl << std::endl;
+
+  for (int i = 0; i < 2; ++i)
+    {
+      // Generate a triangulation and match:
+      Triangulation<2, 3> triangulation;
+      FE_Q<2, 3>          fe(1);
+      DoFHandler<2, 3>    dof_handler(triangulation);
+
+      deallog << "Triangulation:" << i << std::endl;
+
+      generate_grid(triangulation, i);
+      dof_handler.distribute_dofs(fe);
+      print_matching(dof_handler);
+    }
+
   deallog << "Test for 3D, Q1:" << std::endl << std::endl;
 
   for (int i = 0; i < 8; ++i)
index 0f304ca708cd476e470df865c0eb20f1a0eab2b2..badceef9dac9a4a75e6bc381b0d1aa64ef58a977 100644 (file)
@@ -23,6 +23,40 @@ DEAL:: component 0: (0 - 1.000 3.000) (1 - -1.000 3.000)
 DEAL::DoFs of face_2:
 DEAL:: component 0: (4 - -1.000 -3.000) (8 - 1.000 -3.000)
 DEAL::Orientation: 110
+DEAL::Matching:
+    4 1:  1.000
+    5 1:  0.5000
+    5 0:  0.5000
+    8 0:  1.000
+DEAL::Reverse Matching:
+    4 1:  1.000
+    5 1:  0.5000
+    5 0:  0.5000
+    8 0:  1.000
+DEAL::Test for 2D in 3D, Q1:
+DEAL::
+DEAL::Triangulation:0
+DEAL::DoFs of face_1:
+DEAL:: component 0: (2 - -1.000 3.000 0.000) (3 - 1.000 3.000 0.000)
+DEAL::DoFs of face_2:
+DEAL:: component 0: (4 - -1.000 -3.000 0.000) (8 - 1.000 -3.000 0.000)
+DEAL::Orientation: 100
+DEAL::Matching:
+    4 2:  1.000
+    5 2:  0.5000
+    5 3:  0.5000
+    8 3:  1.000
+DEAL::Reverse Matching:
+    4 2:  1.000
+    5 2:  0.5000
+    5 3:  0.5000
+    8 3:  1.000
+DEAL::Triangulation:1
+DEAL::DoFs of face_1:
+DEAL:: component 0: (0 - 1.000 3.000 0.000) (1 - -1.000 3.000 0.000)
+DEAL::DoFs of face_2:
+DEAL:: component 0: (4 - -1.000 -3.000 0.000) (8 - 1.000 -3.000 0.000)
+DEAL::Orientation: 110
 DEAL::Matching:
     4 1:  1.000
     5 1:  0.5000
index 84990bd2a91af1119807e5d15f4ca141126d52f6..8575f6b01f70337de202a8f1d271d143623c662b 100644 (file)
@@ -46,9 +46,9 @@
 
 
 
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-check_this(const DoFHandler<dim> &dof_handler)
+check_this(const DoFHandler<dim, spacedim> &dof_handler)
 {
   Functions::CosineFunction<dim> test_func(dof_handler.get_fe().n_components());
 
index e6411336c105a0936bce76ba57739b49df61e840..eca78f2f9a5e3fa5465e63b52bac9e614f0cb993 100644 (file)
@@ -44,9 +44,9 @@
 
 // forward declaration of the function that must be provided in the
 // .cc files
-template <int dim>
+template <int dim, int spacedim = dim>
 void
-check_this(const DoFHandler<dim> &dof_handler);
+check_this(const DoFHandler<dim, spacedim> &dof_handler);
 
 
 

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.