1818#include < deal.II/dofs/dof_handler.h>
1919#include < deal.II/dofs/dof_tools.h>
2020
21+ #include < deal.II/fe/fe_q.h>
2122#include < deal.II/fe/fe_q_iso_q1.h>
23+ #include < deal.II/fe/mapping_q1.h>
2224
2325#include < deal.II/grid/grid_generator.h>
2426#include < deal.II/grid/tria.h>
@@ -45,12 +47,56 @@ test(const unsigned int n_subdivisions = 1)
4547 GridGenerator::hyper_cube (triangulation);
4648 dof_handler.distribute_dofs (fe);
4749
48- DynamicSparsityPattern dsp (dof_handler.n_dofs ());
49- DoFTools::make_sparsity_pattern (dof_handler, dsp);
50- sparsity_pattern.copy_from (dsp);
51-
52- dsp.print (deallog.get_file_stream ());
53- deallog << std::endl;
50+ Triangulation<dim> triangulation_q1;
51+ DoFHandler<dim> dof_handler_q1 (triangulation_q1);
52+ SparsityPattern sparsity_pattern_q1;
53+ FE_Q<dim> fe_q1 (1 );
54+ GridGenerator::subdivided_hyper_cube (triangulation_q1, n_subdivisions);
55+ dof_handler_q1.distribute_dofs (fe_q1);
56+
57+ std::vector<Point<dim>> support_points (dof_handler.n_dofs ());
58+ DoFTools::map_dofs_to_support_points (StaticMappingQ1<dim>::mapping,
59+ dof_handler,
60+ support_points);
61+
62+
63+ std::vector<Point<dim>> support_points_q1 (dof_handler_q1.n_dofs ());
64+ DoFTools::map_dofs_to_support_points (StaticMappingQ1<dim>::mapping,
65+ dof_handler_q1,
66+ support_points_q1);
67+
68+ AssertDimension (support_points.size (), support_points_q1.size ());
69+
70+ std::vector<types::global_dof_index> new_numbers (dof_handler_q1.n_dofs ());
71+
72+ for (unsigned int i = 0 ; i < support_points_q1.size (); ++i)
73+ {
74+ const Point<dim> &p = support_points_q1[i];
75+ for (unsigned int j = 0 ; j < support_points.size (); ++j)
76+ {
77+ if (p.distance (support_points[j]) < 1e-10 )
78+ {
79+ new_numbers[i] = j;
80+ break ;
81+ }
82+ }
83+ }
84+ dof_handler_q1.renumber_dofs (new_numbers);
85+
86+ {
87+ DynamicSparsityPattern dsp (dof_handler.n_dofs ());
88+ DoFTools::make_sparsity_pattern (dof_handler, dsp);
89+ dsp.print (deallog.get_file_stream ());
90+ deallog << std::endl;
91+ }
92+
93+ {
94+ DynamicSparsityPattern dsp (dof_handler_q1.n_dofs ());
95+ DoFTools::make_sparsity_pattern (dof_handler_q1, dsp);
96+ sparsity_pattern_q1.copy_from (dsp);
97+ // dsp.print(deallog.get_file_stream());
98+ // deallog << std::endl;
99+ }
54100}
55101
56102
0 commit comments