<a name="Intro"></a>
<h1>Introduction</h1>

@dealiiVideoLecture{15,16,17}

The main emphasis in this example is the handling of locally refined
grids. The approach to adaptivity chosen in deal.II is to use grids in which
neighboring cells may be refined a different number of times. This then
results in nodes on the interfaces of cells which belong to one
side, but are unbalanced on the other. The common term for these is
&ldquo;hanging nodes&rdquo;.

To guarantee that the global solution is continuous at these nodes as well, we
have to state some additional constraints on the values of the solution at
these nodes. In the program below, we will show how we can get these
constraints from the library, and how to use them in the solution of the
linear system of equations. Before going over the details of the program
below, you may want to take a look at the @ref constraints documentation
module that explains how these constraints can be computed and what classes in
deal.II work on them.

The locally refined grids are produced using an error estimator class
which estimates the energy error with respect to the Laplace
operator. This error estimator, although developed for Laplace's
equation has proven to be a suitable tool to generate locally refined
meshes for a wide range of equations, not restricted to elliptic
problems. Although it will create non-optimal meshes for other
equations, it is often a good way to quickly produce meshes that are
well adapted to the features of solutions, such as regions of great
variation or discontinuities. Since it was developed by Kelly and
co-workers, we often refer to it as the &ldquo;Kelly refinement
indicator&rdquo; in the library, documentation, and mailing list. The
class that implements it is called
KellyErrorEstimator. Although the error estimator (and
its
implementation in the deal.II library) is capable of handling variable
coefficients in the equation, we will not use this feature since we
are only interested in a quick and simple way to generate locally
refined grids.



Since the concepts used for locally refined grids are so important,
we do not show much additional new stuff in this example. The most
important exception is that we show how to use biquadratic elements
instead of the bilinear ones which we have used in all previous
examples. In fact, The use of higher order elements is accomplished by
only replacing three lines of the program, namely the declaration of
the <code>fe</code> variable, and the use of an appropriate quadrature formula
in two places. The rest of the program is unchanged.



The only other new thing is a method to catch exceptions in the
<code>main</code> function in order to output some information in case the
program crashes for some reason.


<h3>The ConstraintMatrix</h3>

As explained above, we are going to use an object called ConstraintMatrix
that will store the constraints at the hanging nodes to insure the solution
is continuous at these nodes. We could first assemble the system as normal
and then condense out the degrees of freedom that need to be constrained.
This is also explained  @ref constraints documentation
module. Instead we will go the more efficient route and eliminate the
constrained entries while we are copying from the local to the global system.
Because boundary conditions can be treated in the same way, we will
incorporate the them as constraints in the same ConstraintMatrix object.
This way, we don't need to apply the boundary conditions after assembly 
(like we did in the earlier steps).
 
