From: Malhar Tidke Date: Sun, 20 Dec 2020 19:35:19 +0000 (+0530) Subject: Modified the function to include conditions of dim < spacedim X-Git-Tag: v9.3.0-rc1~718^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9a6f0c7f1beeac3929407bfd9d20a3e32a49f02;p=dealii.git Modified the function to include conditions of dim < spacedim 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 --- diff --git a/doc/news/changes/minor/20201223MalharTidke b/doc/news/changes/minor/20201223MalharTidke new file mode 100644 index 0000000000..d4a6b07959 --- /dev/null +++ b/doc/news/changes/minor/20201223MalharTidke @@ -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. +
+(Malhar Tidke, 2020/12/23) diff --git a/tests/dofs/dof_tools_21.cc b/tests/dofs/dof_tools_21.cc index 4b7076a5ec..520c5fad61 100644 --- a/tests/dofs/dof_tools_21.cc +++ b/tests/dofs/dof_tools_21.cc @@ -45,9 +45,9 @@ -template +template void -check_this(const DoFHandler &dof_handler) +check_this(const DoFHandler &dof_handler) { Functions::CosineFunction test_func(dof_handler.get_fe().n_components()); diff --git a/tests/dofs/dof_tools_21_b.cc b/tests/dofs/dof_tools_21_b.cc index 5356e166a2..a0936b311d 100644 --- a/tests/dofs/dof_tools_21_b.cc +++ b/tests/dofs/dof_tools_21_b.cc @@ -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> vertices(&vertices_1[0], &vertices_1[8]); + + std::vector> 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 +template void -print_matching(DoFHandler &dof_handler, - bool constrain_only_velocity = false) +print_matching(DoFHandler &dof_handler, + bool constrain_only_velocity = false) { - const FiniteElement &fe = dof_handler.get_fe(); - MappingQ mapping(1); + const FiniteElement &fe = dof_handler.get_fe(); + MappingQ mapping(1); - AffineConstraints constraint_matrix; - AffineConstraints constraint_matrix_reverse; - std::vector> support_points(dof_handler.n_dofs()); - DoFTools::map_dofs_to_support_points(mapping, - dof_handler, - support_points); + AffineConstraints constraint_matrix; + AffineConstraints constraint_matrix_reverse; + std::vector> support_points(dof_handler.n_dofs()); + DoFTools::map_dofs_to_support_points(mapping, + dof_handler, + support_points); FEValuesExtractors::Vector v(0); FEValuesExtractors::Scalar v_1(0); @@ -211,9 +265,10 @@ print_matching(DoFHandler &dof_handler, velocity_mask = fe.component_mask(v); // Look for the two outermost faces: - typename DoFHandler::face_iterator face_1; - typename DoFHandler::face_iterator face_2; - for (typename DoFHandler::cell_iterator cell = dof_handler.begin(0); + typename DoFHandler::face_iterator face_1; + typename DoFHandler::face_iterator face_2; + for (typename DoFHandler::cell_iterator cell = + dof_handler.begin(0); cell != dof_handler.end(0); ++cell) { @@ -267,7 +322,7 @@ print_matching(DoFHandler &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) diff --git a/tests/dofs/dof_tools_21_b.output b/tests/dofs/dof_tools_21_b.output index 9815ffc899..d4e21c2cdb 100644 --- a/tests/dofs/dof_tools_21_b.output +++ b/tests/dofs/dof_tools_21_b.output @@ -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 diff --git a/tests/dofs/dof_tools_21_b_x.cc b/tests/dofs/dof_tools_21_b_x.cc index 2fd4055557..c61f253d10 100644 --- a/tests/dofs/dof_tools_21_b_x.cc +++ b/tests/dofs/dof_tools_21_b_x.cc @@ -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> vertices(&vertices_1[0], &vertices_1[8]); + + std::vector> 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 +template void -print_matching(DoFHandler &dof_handler) +print_matching(DoFHandler &dof_handler) { - const FiniteElement &fe = dof_handler.get_fe(); - MappingQ mapping(1); + const FiniteElement &fe = dof_handler.get_fe(); + MappingQ mapping(1); - AffineConstraints constraint_matrix; - std::vector> support_points(dof_handler.n_dofs()); - DoFTools::map_dofs_to_support_points(mapping, - dof_handler, - support_points); + AffineConstraints constraint_matrix; + std::vector> support_points(dof_handler.n_dofs()); + DoFTools::map_dofs_to_support_points(mapping, + dof_handler, + support_points); // Look for the two outermost faces: - typename DoFHandler::face_iterator face_1 = + typename DoFHandler::face_iterator face_1 = (++dof_handler.begin(0))->face(2); - typename DoFHandler::face_iterator face_2 = + typename DoFHandler::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; } diff --git a/tests/dofs/dof_tools_21_b_x.output b/tests/dofs/dof_tools_21_b_x.output index 0876ae0660..5f121b86e7 100644 --- a/tests/dofs/dof_tools_21_b_x.output +++ b/tests/dofs/dof_tools_21_b_x.output @@ -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: diff --git a/tests/dofs/dof_tools_21_b_x_q3.cc b/tests/dofs/dof_tools_21_b_x_q3.cc index 7402cc7365..6a3fb50f05 100644 --- a/tests/dofs/dof_tools_21_b_x_q3.cc +++ b/tests/dofs/dof_tools_21_b_x_q3.cc @@ -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> vertices(&vertices_1[0], &vertices_1[8]); + + std::vector> 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 +template void -print_matching(DoFHandler &dof_handler) +print_matching(DoFHandler &dof_handler) { - const FiniteElement &fe = dof_handler.get_fe(); - MappingQ mapping(1); + const FiniteElement &fe = dof_handler.get_fe(); + MappingQ mapping(1); - AffineConstraints constraint_matrix; - std::vector> support_points(dof_handler.n_dofs()); - DoFTools::map_dofs_to_support_points(mapping, - dof_handler, - support_points); + AffineConstraints constraint_matrix; + std::vector> support_points(dof_handler.n_dofs()); + DoFTools::map_dofs_to_support_points(mapping, + dof_handler, + support_points); // Look for the two outermost faces: - typename DoFHandler::face_iterator face_1 = + typename DoFHandler::face_iterator face_1 = (++dof_handler.begin(0))->face(2); - typename DoFHandler::face_iterator face_2 = + typename DoFHandler::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; } diff --git a/tests/dofs/dof_tools_21_b_x_q3.output b/tests/dofs/dof_tools_21_b_x_q3.output index 9d46160409..044e72ef83 100644 --- a/tests/dofs/dof_tools_21_b_x_q3.output +++ b/tests/dofs/dof_tools_21_b_x_q3.output @@ -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: diff --git a/tests/dofs/dof_tools_21_b_y.cc b/tests/dofs/dof_tools_21_b_y.cc index 5f0212ef09..454e23b41c 100644 --- a/tests/dofs/dof_tools_21_b_y.cc +++ b/tests/dofs/dof_tools_21_b_y.cc @@ -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> vertices(&vertices_1[0], &vertices_1[8]); + + std::vector> 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 +template void -print_matching(DoFHandler &dof_handler) +print_matching(DoFHandler &dof_handler) { - const FiniteElement &fe = dof_handler.get_fe(); - MappingQ mapping(1); + const FiniteElement &fe = dof_handler.get_fe(); + MappingQ mapping(1); - AffineConstraints constraint_matrix; - std::vector> support_points(dof_handler.n_dofs()); - DoFTools::map_dofs_to_support_points(mapping, - dof_handler, - support_points); + AffineConstraints constraint_matrix; + std::vector> support_points(dof_handler.n_dofs()); + DoFTools::map_dofs_to_support_points(mapping, + dof_handler, + support_points); // Look for the two outermost faces: - typename DoFHandler::face_iterator face_1 = + typename DoFHandler::face_iterator face_1 = (++dof_handler.begin(0))->face(2); - typename DoFHandler::face_iterator face_2 = + typename DoFHandler::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; } diff --git a/tests/dofs/dof_tools_21_b_y.output b/tests/dofs/dof_tools_21_b_y.output index 2a38ad58af..631cc17e20 100644 --- a/tests/dofs/dof_tools_21_b_y.output +++ b/tests/dofs/dof_tools_21_b_y.output @@ -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: diff --git a/tests/dofs/dof_tools_21_c.cc b/tests/dofs/dof_tools_21_c.cc index e8ee8db5c7..b5e0bfdc9b 100644 --- a/tests/dofs/dof_tools_21_c.cc +++ b/tests/dofs/dof_tools_21_c.cc @@ -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> vertices(&vertices_1[0], &vertices_1[8]); + + std::vector> 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 +template void -print_matching(DoFHandler &dof_handler, - bool constrain_only_velocity = false) +print_matching(DoFHandler &dof_handler, + bool constrain_only_velocity = false) { - const FiniteElement &fe = dof_handler.get_fe(); - MappingQ mapping(1); + const FiniteElement &fe = dof_handler.get_fe(); + MappingQ mapping(1); - AffineConstraints constraint_matrix; - AffineConstraints constraint_matrix_reverse; - std::vector> support_points(dof_handler.n_dofs()); - DoFTools::map_dofs_to_support_points(mapping, - dof_handler, - support_points); + AffineConstraints constraint_matrix; + AffineConstraints constraint_matrix_reverse; + std::vector> support_points(dof_handler.n_dofs()); + DoFTools::map_dofs_to_support_points(mapping, + dof_handler, + support_points); FEValuesExtractors::Vector v(0); FEValuesExtractors::Scalar v_1(0); @@ -216,9 +271,10 @@ print_matching(DoFHandler &dof_handler, velocity_mask = fe.component_mask(v); // Look for the two outermost faces: - typename DoFHandler::face_iterator face_1; - typename DoFHandler::face_iterator face_2; - for (typename DoFHandler::cell_iterator cell = dof_handler.begin(0); + typename DoFHandler::face_iterator face_1; + typename DoFHandler::face_iterator face_2; + for (typename DoFHandler::cell_iterator cell = + dof_handler.begin(0); cell != dof_handler.end(0); ++cell) { @@ -272,7 +328,7 @@ print_matching(DoFHandler &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) diff --git a/tests/dofs/dof_tools_21_c.output b/tests/dofs/dof_tools_21_c.output index 0f304ca708..badceef9da 100644 --- a/tests/dofs/dof_tools_21_c.output +++ b/tests/dofs/dof_tools_21_c.output @@ -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 diff --git a/tests/dofs/dof_tools_23.cc b/tests/dofs/dof_tools_23.cc index 84990bd2a9..8575f6b01f 100644 --- a/tests/dofs/dof_tools_23.cc +++ b/tests/dofs/dof_tools_23.cc @@ -46,9 +46,9 @@ -template +template void -check_this(const DoFHandler &dof_handler) +check_this(const DoFHandler &dof_handler) { Functions::CosineFunction test_func(dof_handler.get_fe().n_components()); diff --git a/tests/dofs/dof_tools_periodic.h b/tests/dofs/dof_tools_periodic.h index e6411336c1..eca78f2f9a 100644 --- a/tests/dofs/dof_tools_periodic.h +++ b/tests/dofs/dof_tools_periodic.h @@ -44,9 +44,9 @@ // forward declaration of the function that must be provided in the // .cc files -template +template void -check_this(const DoFHandler &dof_handler); +check_this(const DoFHandler &dof_handler);