]> https://gitweb.dealii.org/ - dealii.git/blob - tests/simplex/wedge_01.cc
Introduce FE_Wedge
[dealii.git] / tests / simplex / wedge_01.cc
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2020 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15
16
17 // Distribute Simplex::FE_Wedge on a DoFHandler.
18
19 #include <deal.II/dofs/dof_handler.h>
20
21 #include <deal.II/grid/grid_out.h>
22 #include <deal.II/grid/tria.h>
23
24 #include <deal.II/simplex/fe_lib.h>
25
26 #include "../tests.h"
27
28 using namespace dealii;
29
30 void
31 test_3()
32 {
33   const int dim      = 3;
34   const int spacedim = 3;
35
36   std::vector<Point<spacedim>> vertices;
37   std::vector<CellData<dim>>   cells;
38
39 #if true
40   vertices.emplace_back(0.0, 0.0, 0.0);
41   vertices.emplace_back(1.0, 0.0, 0.0);
42   vertices.emplace_back(0.0, 1.0, 0.0);
43   vertices.emplace_back(0.0, 0.0, 1.0);
44   vertices.emplace_back(1.0, 0.0, 1.0);
45   vertices.emplace_back(0.0, 1.0, 1.0);
46
47   {
48     CellData<dim> cell;
49     cell.vertices = {0, 1, 2, 3, 4, 5};
50     cells.push_back(cell);
51   }
52 #else
53   vertices.emplace_back(0.0, 0.0, 0.0);
54   vertices.emplace_back(1.0, 0.0, 0.0);
55   vertices.emplace_back(0.0, 1.0, 0.0);
56   vertices.emplace_back(1.0, 1.0, 0.0);
57   vertices.emplace_back(0.0, 0.0, 1.0);
58   vertices.emplace_back(1.0, 0.0, 1.0);
59   vertices.emplace_back(0.0, 1.0, 1.0);
60   vertices.emplace_back(1.0, 1.0, 1.0);
61
62   {
63     CellData<dim> cell;
64     cell.vertices = {0, 1, 2, 4, 5, 6};
65     cells.push_back(cell);
66   }
67   {
68     CellData<dim> cell;
69     cell.vertices = {2, 1, 3, 6, 5, 7};
70     cells.push_back(cell);
71   }
72 #endif
73
74   Triangulation<dim, spacedim> tria;
75   tria.create_triangulation(vertices, cells, SubCellData());
76
77   GridOut       grid_out;
78   std::ofstream out("mesh.vtk");
79   grid_out.write_vtk(tria, out);
80
81   Simplex::FE_WedgeP<dim, spacedim> fe(2);
82
83   DoFHandler<dim, spacedim> dof_handler(tria);
84   dof_handler.distribute_dofs(fe);
85
86   deallog << dof_handler.n_dofs() << std::endl;
87
88   std::vector<types::global_dof_index> dof_indices;
89   for (const auto &cell : dof_handler.active_cell_iterators())
90     {
91       for (const auto face : cell->face_indices())
92         {
93 #if false
94           dof_indices.resize(face <= 1 ? 3 : 4);
95 #else
96           dof_indices.resize(fe.n_dofs_per_face(face));
97 #endif
98           cell->face(face)->get_dof_indices(dof_indices);
99
100           for (const auto i : dof_indices)
101             deallog << i << " ";
102           deallog << std::endl;
103         }
104     }
105 }
106
107 int
108 main()
109 {
110   initlog();
111
112   test_3();
113 }

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.