<h1>Results</h1>

The program has, after having been run, produced two sparsity
patterns. We can visualize them by opening the <code>.svg</code> files in a web browser.

The results then look like this (every point denotes an entry which
might be nonzero; of course the fact whether the entry actually is
zero or not depends on the equation under consideration, but the
indicated positions in the matrix tell us which shape functions can
and which can't couple when discretizing a local, i.e. differential,
equation):
<table style="width:60%" align="center">
  <tr>
    <td><img src="https://www.dealii.org/images/steps/developer/step-2.sparsity-1.svg" alt=""></td>
    <td><img src="https://www.dealii.org/images/steps/developer/step-2.sparsity-2.svg" alt=""></td>
  </tr>
</table>

The different regions in the left picture, indicated by kinks in the lines and
single dots on the left and top, represent the degrees of
freedom on the different refinement levels of the triangulation.  As
can be seen in the right picture, the sparsity pattern is much better
clustered around the main diagonal of the matrix after
renumbering. Although this might not be apparent, the number of
nonzero entries is the same in both pictures, of course.



<h3> Possibilities for extensions </h3>

Just as with step-1, you may want to play with the program a bit to
familiarize yourself with deal.II. For example, in the
<code>distribute_dofs</code> function, we use linear finite elements
(that's what the argument "1" to the FE_Q object is). Explore how the
sparsity pattern changes if you use higher order elements, for example
cubic or quintic ones (by using 3 and 5 as the respective arguments).

You could also explore how the sparsity pattern changes by refining
the mesh. You will see that not only the size of the matrix
changes, but also its bandwidth (the distance from the diagonal of
those nonzero elements of the matrix that are farthest away from the
diagonal), though the ratio of bandwidth to size typically shrinks,
i.e. the matrix clusters more around the diagonal.

Another idea of experiments would be to try other renumbering
strategies than Cuthill-McKee from the DoFRenumbering namespace and see how
they affect the sparsity pattern.

You can also visualize the output using <a
href="http://www.gnuplot.info/">GNUPLOT</a> (one of the simpler visualization
programs; maybe not the easiest to use since it is command line driven, but
also universally available on all Linux and other Unix-like systems) by changing from <code>print_svg()</code> to <code>print_gnuplot()</code> in <code>distribute_dofs()</code> and <code>renumber_dofs()</code>:
@code
examples/\step-2> gnuplot

        G N U P L O T
        Version 3.7 patchlevel 3
        last modified Thu Dec 12 13:00:00 GMT 2002
        System: Linux 2.6.11.4-21.10-default

        Copyright(C) 1986 - 1993, 1998 - 2002
        Thomas Williams, Colin Kelley and many others

        Type `help` to access the on-line reference manual
        The gnuplot FAQ is available from
        http://www.gnuplot.info/gnuplot-faq.html

        Send comments and requests for help to <info-gnuplot@dartmouth.edu>
        Send bugs, suggestions and mods to <bug-gnuplot@dartmouth.edu>


Terminal type set to 'x11'
gnuplot> set style data points
gnuplot> plot "sparsity_pattern.1"
@endcode

Another practice based on
<a href="http://www.gnuplot.info/">GNUPLOT</a> is trying to
print out the mesh with locations and numbering of the support
points. For that, you need to include header files for GridOut and MappingQ1.
The code for this is:
@code
  std::ofstream out("gnuplot.gpl");
  out << "plot '-' using 1:2 with lines, "
      << "'-' with labels point pt 2 offset 1,1"
      << std::endl;
  GridOut().write_gnuplot (triangulation, out);
  out << "e" << std::endl;
  const int dim = 2;
  std::map<types::global_dof_index, Point<dim> > support_points;
  DoFTools::map_dofs_to_support_points (MappingQ1<dim>(),
                                        dof_handler,
                                        support_points);
  DoFTools::write_gnuplot_dof_support_point_info(out,
                                                 support_points);
  out << "e" << std::endl;
@endcode
After we run the code, we get a file called gnuplot.gpl. To view this
file, we can run the following code in the command line:
@code
gnuplot -p gnuplot.gpl
@endcode.
With that, you will get a picture similar to
@image html support_point_dofs1.png
depending on the mesh you are looking at. For more information, see DoFTools::write_gnuplot_dof_support_point_info.
