[cig-commits] r1392 - in branches/s-wang: cookbooks doc/manual for_deal.II/examples/step-32 for_deal.II/include/deal.II/lac for_deal.II/source/lac

s-wang at dealii.org s-wang at dealii.org
Wed Nov 28 11:03:50 PST 2012


Author: s-wang
Date: 2012-11-28 12:03:50 -0700 (Wed, 28 Nov 2012)
New Revision: 1392

Added:
   branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_sparse_matrix.h
   branches/s-wang/for_deal.II/source/lac/petsc_solver.cc
Modified:
   branches/s-wang/cookbooks/convection-box.prm
   branches/s-wang/doc/manual/manual.bib
   branches/s-wang/doc/manual/manual.tex
   branches/s-wang/for_deal.II/examples/step-32/test-step-32.cc
   branches/s-wang/for_deal.II/include/deal.II/lac/petsc_matrix_base.h
   branches/s-wang/for_deal.II/include/deal.II/lac/petsc_parallel_block_vector.h
   branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_vector_base.h
   branches/s-wang/for_deal.II/source/lac/constraint_matrix.cc
   branches/s-wang/for_deal.II/source/lac/petsc_matrix_base.cc
   branches/s-wang/for_deal.II/source/lac/trilinos_sparse_matrix.cc
   branches/s-wang/for_deal.II/source/lac/trilinos_vector_base.cc
Log:
updated files under for_deal.II with deal.II svn

Modified: branches/s-wang/cookbooks/convection-box.prm
===================================================================
--- branches/s-wang/cookbooks/convection-box.prm	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/cookbooks/convection-box.prm	2012-11-28 19:03:50 UTC (rev 1392)
@@ -118,7 +118,7 @@
   set Model name = vertical
 
   subsection Vertical
-    set Magnitude = 1e14   # = Thermal expansion coefficient * Ra
+    set Magnitude = 1e14   # = Ra / Thermal expansion coefficient
   end
 end
 

Modified: branches/s-wang/doc/manual/manual.bib
===================================================================
--- branches/s-wang/doc/manual/manual.bib	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/doc/manual/manual.bib	2012-11-28 19:03:50 UTC (rev 1392)
@@ -5059,7 +5059,7 @@
   year = 	 1998,
   editor =	 {H. G. Bock and F. Brezzi and R.
                   Glowinsky and G. Kanschat and Y. A. Kuznetsov
-                  and J. Périaux and R. Rannacher},
+                  and J. P�riaux and R. Rannacher},
   address =	 {Singapore},
   publisher =	 {World Scientific}
 }
@@ -9613,7 +9613,7 @@
 }
 
 @Article{BD80,
-  author = 	 {Garth A. Baker and Vassilios A. Dougalis},
+  author = 	 {G. A. Baker and V. A. Dougalis},
   title = 	 {On the $L^\infty$-convergence of {G}alerkin approximations
                   for second-order hyperbolic equations},
   journal = 	 {Math. Comput.},
@@ -9624,7 +9624,7 @@
 
 
 @TechReport{BIK01,
-  author = 	 {J{\"o}rn Behrens and Armin Iske and Martin K{\"a}ser},
+  author = 	 {J. Behrens and A. Iske and M. K{\"a}ser},
   title = 	 {Adaptive meshfree method of backward characteristics for
                   nonlinear transport equations},
   institution =  {Technical University Munich, Faculty of Mathematics},
@@ -10728,7 +10728,7 @@
   year = 	 {2012}}
 
 @Article{KHB12,
-  author = 	 {Martin Kronbichler and Timo Heister and Wolfgang Bangerth},
+  author = 	 {M. Kronbichler and T. Heister and W. Bangerth},
   title = 	 {High Accuracy Mantle Convection Simulation through Modern Numerical Methods},
   journal = 	 {Geophysics Journal International},
   year = 	 2012,
@@ -10773,7 +10773,7 @@
 
 @Article{SP03,
   title={Analytical solutions for deformable elliptical inclusions in general shear},
-  author={Schmid, D.W. and Podladchikov, Y.Y.},
+  author={Schmid, D. W. and Podladchikov, Y. Y.},
   journal={Geophysical Journal International},
   volume={155},
   number={1},

Modified: branches/s-wang/doc/manual/manual.tex
===================================================================
--- branches/s-wang/doc/manual/manual.tex	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/doc/manual/manual.tex	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,6 +1,7 @@
 \documentclass{article}
 \usepackage[pdftex]{graphicx,color}
 \usepackage{amsmath}
+\usepackage{amsfonts}
 \usepackage{subfigure}
 
 % use a larger page size; otherwise, it is difficult to have complete
@@ -27,11 +28,14 @@
   \end{center}
 }}
 
-% use the listings package for code snippets
+% use the listings package for code snippets. define keywords for prm files
+% and for gnuplot
 \usepackage{listings}
 \lstset{language=C++,basicstyle=\footnotesize}
 \lstdefinelanguage{prmfile}{morekeywords={set,subsection,end},
                             morecomment=[l]{\#},}
+\lstdefinelanguage{gnuplot}{morekeywords={plot,using,title,with,set,replot},
+                            morecomment=[l]{\#},}
 
 % use the hyperref package; set the base for relative links to
 % the top-level aspect directory so that we can link to
@@ -217,7 +221,8 @@
 material in Schubert, Turcotte and Olson \cite{STO01}.
 
 Specifically, we consider the following set of equations for velocity $\mathbf
-u$, pressure $p$ and temperature $T$:
+u$, pressure $p$ and temperature $T$, as well as a set of advected quantities
+$c_i$ that we call \textit{compositional fields}:
 \marginpar{To be finished}
 \marginpar{Wouldn't the last term need to have a minus sign? drho/dT
   is negative...}
@@ -254,6 +259,14 @@
   & \quad
   & \textrm{in $\Omega$},
   \notag
+  \\
+  \label{eq:compositional}
+  \frac{\partial c_i}{\partial t} + \mathbf u\cdot\nabla T
+  &=
+  0
+  & \quad
+  & \textrm{in $\Omega$},
+  i=1\ldots C
 \end{align}
 where $\varepsilon(\mathbf u) = \frac{1}{2}(\nabla \mathbf u + \nabla\mathbf
 u^T)$ is the symmetric gradient of the velocity (often called the
@@ -282,6 +295,19 @@
 The equations \aspect{} currently solves do not include phase change terms,
 see Section~\ref{sec:future}.
 
+The final set equations, \eqref{eq:compositional}, describes the motion of
+a set of advected quantities $c_i(\mathbf x,t),i=1\ldots C$. We call these
+\textit{compositional fields} because we think of them as spatially and
+temporally varying concentrations of different elements, minerals, or other
+constituents of the composition of the material that convects. As such, these
+fields participate actively in determining the values of the various
+coefficients of these equations. On the other hand, \aspect{} also allows the
+definition of material models that are independent of these compositional
+fields, making them passively advected quantities. Several of the cookbooks in
+Section~\ref{sec:cookbooks} consider compositional fields in this way, i.e.,
+essentially as tracer quantities that only keep track of where material came
+from.
+
 These equations are
 augmented by boundary conditions that can either be of Dirichlet-, Neumann, or
 tangential type on subsets of the boundary $\Gamma=\partial\Omega$:
@@ -295,6 +321,10 @@
   \\
   \mathbf n \cdot k\nabla T &= 0
    & \qquad &\textrm{on $\Gamma_{N,T}$}.
+  \\
+  c_i &= 0
+   & \qquad &\textrm{on $\Gamma_\textit{in}=\{\mathbf x: \mathbf
+   u\cdot\mathbf n<0\}$}.
 \end{align}
 Here,
 $\Gamma_{0,\mathbf u}$ corresponds to parts of the boundary on which the
@@ -309,13 +339,16 @@
 simulated). We require that one of these boundary conditions hold at each
 point for both velocity and temperature, i.e.,
 $\Gamma_{0,\mathbf u}\cup\Gamma_{\parallel,\mathbf u}=\Gamma$ and
-$\Gamma_{D,T}\cup\Gamma_{N,T}=\Gamma$.
+$\Gamma_{D,T}\cup\Gamma_{N,T}=\Gamma$. No boundary conditions have to be posed
+for the compositional fields at those parts of the boundary where flow is either
+tangential to the boundary or points outward.
 
 \aspect{} solves these equations in essentially the form stated. In
 particular, the form given in \eqref{eq:stokes-1} implies that the pressure
 $p$ we compute is in fact the \textit{total pressure}, i.e., the sum of
 hydrostatic pressure and dynamic pressure (however, see
-Section~\ref{sec:pressure-static-dyn} for more information on this).
+Section~\ref{sec:pressure-static-dyn} for more information on this, as well as
+the extensive discussion of this issue in \cite{KHB12}).
 Consequently, it allows the direct use of this pressure when looking up
 pressure dependent material parameters.
 
@@ -327,8 +360,11 @@
 discuss in the following. In the most general form, many of these coefficients
 depend nonlinearly on the solution variables pressure $p$, temperature $T$
 and, in the case of the viscosity, on the strain rate $\varepsilon(\mathbf
-u)$. Alternatively, they may be parameterized as a function of the spatial
-variable $\mathbf x$. \aspect{} allows both kinds of parameterizations.
+u)$. If compositional fields $\mathfrak c=\{c_1,\ldots,c_C\}$ are present (i.e.,
+if $C>0$), coefficients may also depend on them. Alternatively, they may be
+parameterized as a function
+of the spatial variable $\mathbf x$. \aspect{} allows both kinds of
+parameterizations.
 
 \note{One of the next versions of \aspect{} will actually iterate out
   nonlinearities in the material description. However, in the current version,
@@ -347,8 +383,8 @@
 
 Concretely, we consider the following coefficients and dependencies:
 \begin{itemize}
-\item \textit{The viscosity $\eta=\eta(p,T,\varepsilon(\mathbf u),\mathbf
-    x)$:} Units $\textrm{Pa}\cdot \textrm{s} =
+\item \textit{The viscosity $\eta=\eta(p,T,\varepsilon(\mathbf u),\mathfrak
+c,\mathbf x)$:} Units $\textrm{Pa}\cdot \textrm{s} =
   \textrm{kg}\frac{1}{\textrm{m}\cdot\textrm{s}}$.
 
   The viscosity is the proportionality factor that relates total forces
@@ -361,7 +397,7 @@
   difficult to quantify, one modeling approach is to make $\eta$ spatially
   dependent.
 
-\item \textit{The density $\rho=\rho(p,T,\mathbf x)$:} Units
+\item \textit{The density $\rho=\rho(p,T,\mathfrak c,\mathbf x)$:} Units
   $\frac{\textrm{kg}}{\textrm{m}^3}$.
 
   In general, the density depends on pressure and temperature, both through
@@ -393,8 +429,8 @@
   that changes as a function of time. Such a model is not currently
   implemented.
 
-\item \textit{The specific heat capacity $C_p=C_p(p,T,\mathbf x)$:} Units
-  $\frac{\textrm{J}}{\textrm{kg}\cdot\textrm{K}} =
+\item \textit{The specific heat capacity $C_p=C_p(p,T,\mathfrak c,\mathbf x)$:}
+Units $\frac{\textrm{J}}{\textrm{kg}\cdot\textrm{K}} =
   \frac{\textrm{m}^2}{\textrm{s}^2\cdot\textrm{K}}$.
 
   The specific heat capacity denotes the amount of energy needed to increase
@@ -406,7 +442,7 @@
   suggested by the literature.
 
 
-\item \textit{The thermal conductivity $k=k(p,T,\mathbf x)$:} Units
+\item \textit{The thermal conductivity $k=k(p,T,\mathfrak c,\mathbf x)$:} Units
   $\frac{\textrm{W}}{\textrm{m}\cdot\textrm{K}}=\frac{\textrm{kg}\cdot\textrm{m}}{\textrm{s}^3\cdot\textrm{K}}$.
 
   The thermal conductivity denotes the amount of thermal energy flowing
@@ -470,7 +506,7 @@
   than in non-dimensionalized form, see below.}
 
 That said, in reality, \aspect{} has no preferred system of
-units as long as every material constant, geometry, time, etc., is all
+units as long as every material constant, geometry, time, etc., are all
 expressed in the same system. In other words, it is entirely legitimate to
 implement geometry and material models in which the dimension of the domain is
 one, density and viscosity are one, and the density variation as a function of
@@ -515,7 +551,7 @@
   \footnote{To illustrate this, consider convection in the Earth as a
   back-of-the-envelope example.
   With the length scale of the mantle $L=3\cdot 10^6\;m$, viscosity
-  $\eta=10^24 \; kg/m/s$, density $\rho=3\cdot 10^3 \; kg/m^3$ and a typical
+  $\eta=10^{24} \; kg/m/s$, density $\rho=3\cdot 10^3 \; kg/m^3$ and a typical
   velocity of $U=0.1\;m/year=3\cdot 10^{-9}\; m/s$, we get that the friction
   term in \eqref{eq:stokes-1} has size $\eta U/L^2 \approx 3\cdot 10^2 \;
   kg/m/s^3$. On the other hand, the term $\nabla\cdot(\rho u)$ in the
@@ -671,12 +707,19 @@
 of a static density was simple.
 
 On the other hand, we intend \aspect{} to be a code that can solve more
-general models for which this definition is not as simple.
+general models for which this definition is not as simple. As a consequence, we
+have chosen to solve the equations as stated originally -- i.e., we solve for
+the \textit{full} pressure rather than just its \textit{dynamic} component. With
+most traditional methods, this would lead to a catastrophic loss of accuracy in the
+dynamic pressure since it is many orders of magnitude smaller than the total
+pressure at the bottom of the earth mantle. We avoid this problem in \aspect{}
+by using a cleverly chosen iterative solver that ensures that the full pressure
+we compute is accurate enough so that the dynamic pressure can be extracted from
+it with the same accuracy one would get if one were to solve for only the 
+dynamic component. The methods that ensure this are described in detail in
+\cite{KHB12} and in particular in the appendix of that paper.
 
-\textbf{Rest to be written; we have a scheme in mind but haven't implemented
-  it yet.}
 
-
 \subsection{Pressure normalization}
 \label{sec:pressure}
 
@@ -1074,10 +1117,10 @@
   \href{http://trilinos.sandia.gov/download/trilinos-10.4.html}{http://trilinos.sandia.gov/}. At
   the current time we recommend Trilinos Version 10.4.x.%
   \footnote{There are newer versions of Trilinos, but at least Trilinos 10.6.x
-  and 10.8.x have bugs that make these versions unusable for our purpose.}
-  For installation instructions see
-  \href{http://www.dealii.org/developer/readme-petsc-trilinos.html}{the
-    deal.II README file on installing Trilinos and PETSc}. Note that you have
+  and 10.8.x have bugs that make these versions unusable for our purpose. The
+  \dealii{} ReadMe file provides a list of versions that are known to work
+  without bugs with \dealii{}.} For installation instructions see
+  \href{http://www.dealii.org/developer/readme-petsc-trilinos.html}{the deal.II README file on installing Trilinos and PETSc}. Note that you have
   to configure with MPI by using
 \begin{verbatim}
  TPL_ENABLE_MPI:BOOL=ON
@@ -1410,6 +1453,8 @@
 \note{As noted in Section~\ref{sec:equations}, \aspect{} can be thought to compute
   in the meter-kilogram-second (MKS, or SI) system. Unless otherwise noted,
   the quantities in the output file are therefore also in MKS units.}
+  
+  A simple way to plot the contents of this file is shown in Section~\ref{sec:viz-stat}.
 
 \item \textit{Depth average statistics:} Similar to the
   \texttt{output/statistics} file, Aspect can generate depth-average
@@ -1584,17 +1629,17 @@
   \phantom{.}
   \hfill
   \subfigure[]{
-    \includegraphics[width=0.24\textwidth]{visit-1}
+    \includegraphics[width=0.24\textwidth]{viz/visit/visit-1}
     \label{fig:visit-1:a}
   }
   \hfill
   \subfigure[]{
-    \includegraphics[width=0.24\textwidth]{visit-2}
+    \includegraphics[width=0.24\textwidth]{viz/visit/visit-2}
     \label{fig:visit-1:b}
   }
   \hfill
   \subfigure[]{
-    \includegraphics[width=0.24\textwidth]{visit-3}
+    \includegraphics[width=0.24\textwidth]{viz/visit/visit-3}
     \label{fig:visit-1:c}
   }
   \hfill
@@ -1608,12 +1653,12 @@
   \phantom{.}
   \hfill
   \subfigure[]{
-    \includegraphics[width=0.48\textwidth]{visit-4}
+    \includegraphics[width=0.48\textwidth]{viz/visit/visit-4}
     \label{fig:visit-2:a}
   }
   \hfill
   \subfigure[]{
-    \includegraphics[width=0.48\textwidth]{visit-5}
+    \includegraphics[width=0.48\textwidth]{viz/visit/visit-5}
     \label{fig:visit-2:b}
   }
   \hfill
@@ -1692,12 +1737,193 @@
 More information on all of these topis can be found in the Visit
 documentation, see \url{http://www.llnl.gov/visit/}.
 
+
 \subsubsection{Visualizing statistical data}
 \label{sec:viz-stat}
 
-\marginpar{To be written}
+In addition to the graphical outputdiscussed above, \aspect{} produces a 
+statistics file that collects information produced during each time step.
+For the remainder of this section, let us assume that we have run \aspect{}
+with the input file discussed in Section~\ref{sec:cookbooks-simple-box},
+simulating convection in a box. After running \aspect{}, you will find
+a file called \texttt{statistics} in the output directory that, at the time
+of writing this, looked like this:
+This file has a structure that looks like this:
+  \begin{lstlisting}[frame=single,language=ksh]
+# 1: Time step number
+# 2: Time (seconds)
+# 3: Number of mesh cells
+# 4: Number of Stokes degrees of freedom
+# 5: Number of temperature degrees of freedom
+# 6: Iterations for temperature solver
+# 7: Iterations for Stokes solver
+# 8: Time step size (seconds)
+# 9: RMS velocity (m/s)
+# 10: Max. velocity (m/s)
+# 11: Minimal temperature (K)
+# 12: Average temperature (K)
+# 13: Maximal temperature (K)
+# 14: Average nondimensional temperature (K)
+# 15: Outward heat flux through boundary with indicator 0 (W)
+# 16: Outward heat flux through boundary with indicator 1 (W)
+# 17: Outward heat flux through boundary with indicator 2 (W)
+# 18: Outward heat flux through boundary with indicator 3 (W)
+# 19: Visualization file name
+   0 0.0000e+00 256 2467 1089  1 22 1.2225e-02 1.79038621e+00 2.54812273e+00 ...
+   1 1.2225e-02 256 2467 1089 40 16 3.7409e-03 5.88727814e+00 8.34299267e+00 ...
+   2 1.5966e-02 256 2467 1089 25 15 2.0249e-03 1.08925316e+01 1.54185045e+01 ...
+   3 1.7991e-02 256 2467 1089 19 15 1.3658e-03 1.61586242e+01 2.28690070e+01 ...
+   4 1.9357e-02 256 2467 1089 16 14 1.0291e-03 2.14311381e+01 3.03519178e+01 ...
+   5 2.0386e-02 256 2467 1089 14 14 8.2853e-04 2.65966688e+01 3.76989179e+01 ... 
+  \end{lstlisting}
+  
+In other words, it first lists what the individual columns mean with a hash
+mark at the beginning of the line and then has one line for each time step
+in which the individual columns list what has been explained above. In the
+example shown here, the first time step appears twice because we use a mesh
+that starts out globally refined and we then start the entire computation
+over again on a once adaptively refined mesh (see the parameters in 
+Section~\ref{parameters:Mesh_20refinement} for how to do that).
 
+This file is easy to visualize. For example, one can import it as a whitespace
+separated file into a spreadsheet such as Microsoft Excel or OpenOffice/LibreOffice
+Calc and then generate graphs of one column against another. Or, maybe simpler,
+there is a multitude of simple graphing programs that do not need the overhead
+of a full fledged spreadsheet engine and simply plot graphs. One that is 
+particularly simple to use and available on every major platform is \texttt{Gnuplot}.
+It is extensively documented at \url{http://www.gnuplot.info/}.
 
+\texttt{Gnuplot} is a command line program in which you enter commands that
+plot data or modify the way data is plotted. When you call it, you will first
+get a screen that looks like this:
+\begin{lstlisting}[frame=single]
+/home/user/aspect/output$ gnuplot
+
+        G N U P L O T
+        Version 4.6 patchlevel 0    last modified 2012-03-04 
+        Build System: Linux x86_64
+
+        Copyright (C) 1986-1993, 1998, 2004, 2007-2012
+        Thomas Williams, Colin Kelley and many others
+
+        gnuplot home:     http://www.gnuplot.info
+        faq, bugs, etc:   type "help FAQ"
+        immediate help:   type "help"  (plot window: hit 'h')
+
+Terminal type set to 'qt'
+gnuplot>
+\end{lstlisting}
+At the prompt on the last line, you can then enter commands. Given the
+description of the individual columns given above, let us first try to 
+plot the heat flux through boundary 2 (which in this case is the bottom
+boundary of the box), i.e., column 17, as a function of time (column 2).
+This can be achieved using the following command:
+\begin{lstlisting}[frame=single,language=gnuplot]
+  plot "statistics" using 2:17
+\end{lstlisting}
+The left panel of Fig.~\ref{fig:viz-gnuplot-1} shows what \texttt{Gnuplot}
+will display in its output window. There are many things one can
+configure in these plots (see the \texttt{Gnuplot} manual referenced above).
+For example, let us assume that we want to add labels to the $x$- and $y$-axes,
+use not just points but lines and points for the curves,
+restrict the time axis to the range $[0,0.2]$ and the heat flux axis to
+$[-10:10]$,
+plot not only the flux through the bottom but also through the top boundary
+(column 18) and finally add a key to the figure, then the following 
+commands achieve this:
+\begin{lstlisting}[frame=single,language=gnuplot]
+  set xlabel "Time"
+  set ylabel "Heat flux"
+  set style data linespoints
+  plot [0:0.2][-10:10] "statistics" using 2:17 title "Bottom boundary", \
+                       "statistics" using 2:18 title "Top boundary"
+\end{lstlisting}
+If a line gets too long, you can continue it by ending it in a backslash as
+above. This is rarely used on the command line but useful when writing the
+commands above into a script file, see below. We have done it here to get
+the entire command into the width of the page.
+
+\begin{figure}
+  \centering
+  \phantom.
+  \hfill
+  \includegraphics[width=0.4\textwidth]{viz/statistics/1}
+  \hfill
+  \includegraphics[width=0.4\textwidth]{viz/statistics/2}
+  \hfill
+  \phantom.
+  \caption{\it Visualizing the statistics file obtained from the example in 
+    Section~\ref{sec:cookbooks-simple-box} using \texttt{Gnuplot}: Output
+    using simple commands.}
+  \label{fig:viz-gnuplot-1}
+\end{figure}
+
+For those who are lazy, \texttt{Gnuplot} allows to abbreviate things in many
+different ways. For example, one can abbreviate most commands. Furthermore,
+one does not need to repeat the name of an input file if it is the same
+as the previous one in a plot command. Thus, instead of the commands above,
+the following abbreviated form would have achieved the same effect:
+\begin{lstlisting}[frame=single,language=gnuplot]
+  se xl "Time"
+  se yl "Heat flux"
+  se sty da lp
+  pl [:0.2][-10:10] "statistics" us 2:17 t "Bottom boundary", "" us 2:18 t "Top boundary"
+\end{lstlisting}
+This is of course unreadable at first but becomes useful once you become
+more familiar with the command offered by this program.
+
+Once you have gotten the commands that create the plot you want right, you probably
+want to save it into a file. \texttt{Gnuplot} can write output in many
+different formats. For inclusion in publications, either \texttt{eps} or
+\texttt{png} are the most common. In the latter case, the commands to
+achieve this are
+\begin{lstlisting}[frame=single,language=gnuplot]
+  set terminal png
+  set output "heatflux.png"
+  replot
+\end{lstlisting}
+The last command will simply generate the same plot again but this time
+into the given file. The result is a graphics file similar to the one
+shown in Fig.~\ref{fig:convection-box-stats} on page \pageref{fig:convection-box-stats}.
+
+\note{After setting output to a file, \textit{all} following plot commands will
+	want to write to this file. Thus, if you want to create more plots after
+	the one just created, you need to reset output back to the screen. On linux,
+	this is done using the command \texttt{set terminal X11}. You can then
+	continue experimenting with plots and when you have the next plot ready,
+	switch back to output to a file.}
+
+What makes \texttt{Gnuplot} so useful is that it doesn't just allow entering
+all these commands at the prompt. Rather, one can write them all into a file,
+say \texttt{plot-heatflux.gnuplot}, and then, on the command line, call
+\begin{lstlisting}[frame=single,language=ksh]
+  gnuplot plot-heatflux.gnuplot
+\end{lstlisting}
+to generate the \texttt{heatflux.png} file. This comes in handy if one wants
+to create the same plot for multiple simulations while playing with parameters
+of the physical setup. It is also a very useful tool if one wants to generate
+the same kind of plot again later with a different data set, for example when
+a reviewer requested additional computations to be made for a paper or if one
+realizes that one has forgotten or misspelled an axis label in a plot.%
+\footnote{In my own work, I usually save the \aspect{} input file, the 
+  \texttt{statistics} output file and the \texttt{Gnuplot} script along with
+  the actual figure I want to include in a paper. This way, it is easy to
+  either re-run an entire simulation, or just tweak the graphic at a later
+  time. Speaking from experience, you will not believe how often one wants
+  to tweak a figure long after it was first created. In such situations it is
+  outstandingly helpful if one still has both the actual data as well as the script
+  that generated the graphic.}
+
+\texttt{Gnuplot} has many many more features we have not even touched upon. For
+example, it is equally happy to produce three-dimensional graphics, and it also
+has statistics modules that can do things like curve fits, statistical regression,
+and many more operations on the data you provide in the columns of an input file.
+We will not try to cover them here but instead refer to the manual at
+\url{http://www.gnuplot.info/}. You can also get a good amount of information
+by typing \texttt{help} at the prompt, or a command like \texttt{help plot} to
+get help on the \texttt{plot} command.
+
+
 \subsubsection{Large data issues for parallel computations}
 \label{sec:viz-data}
 
@@ -1915,19 +2141,19 @@
   together with the sections in which their parameters are declared:
   \begin{itemize}
   \item The material model:
-    Sections~\ref{parameters:Material_20model}, \ref{parameters:Material_20model/Simple_20model}.
+    Sections~\ref{parameters:Material_20model} and following.
   \item The geometry:
-    Sections~\ref{parameters:Geometry_20model}, \ref{parameters:Geometry_20model/Spherical_20shell}.
+    Sections~\ref{parameters:Geometry_20model} and following.
   \item The gravity description:
-    Sections~\ref{parameters:Gravity_20model}, \ref{parameters:Gravity_20model/Radial_20constant}.
+    Sections~\ref{parameters:Gravity_20model} and following.
   \item Initial conditions for the temperature:
-    Sections~\ref{parameters:Initial_20conditions},
-    \ref{parameters:Initial_20conditions/Spherical_20gaussian_20perturbation}.
+    Sections~\ref{parameters:Initial_20conditions} and following.
   \item Temperature boundary conditions:
-    Sections~\ref{parameters:Boundary_20temperature_20model},
-    \ref{parameters:Boundary_20temperature_20model/Spherical_20constant}.
+    Sections~\ref{parameters:Boundary_20temperature_20model} and following.
   \item Postprocessors:
-    Sections~\ref{parameters:Postprocess}, \ref{parameters:Postprocess/Visualization}.
+    Sections~\ref{parameters:Postprocess} and following for most postprocessors,
+    section \ref{parameters:Postprocess/Visualization} and following for
+    postprocessors related to visualization.
   \end{itemize}
 \end{itemize}
 
@@ -2182,7 +2408,7 @@
   set Model name = vertical % \index[prmindex]{Model name} \index[prmindexfull]{Gravity model!Model name} %
 
   subsection Vertical
-    set Magnitude = 1e14   # = Thermal expansion coefficient * Ra % \index[prmindex]{Magnitude} \index[prmindexfull]{Gravity model!Vertical!Magnitude} %
+    set Magnitude = 1e14   # = Ra / Thermal expansion coefficient % \index[prmindex]{Magnitude} \index[prmindexfull]{Gravity model!Vertical!Magnitude} %
   end
 end
 
@@ -2377,7 +2603,8 @@
 Fig.~\ref{fig:convection-box-stats} shows the results of visualizing the data
 that can be found in columns 2 (the time) plotted against columns 9 and 10
 (root mean square and maximal velocities). Plots of this kind can be generated with
-\texttt{gnuplot} by typing:
+\texttt{Gnuplot} by typing (see Section~\ref{sec:viz-stat} for a more thorough
+discussion):
 \begin{verbatim}
   plot "output/statistics" using 2:9 with lines
 \end{verbatim}
@@ -2508,7 +2735,7 @@
 \begin{lstlisting}[frame=single,language=prmfile,escapechar=\%]
 subsection Gravity model
   subsection Vertical
-    set Magnitude = 1e16   # = Thermal expansion coefficient * Ra % \index[prmindex]{Magnitude} \index[prmindexfull]{Gravity model!Vertical!Magnitude} %
+    set Magnitude = 1e16   # = Ra / Thermal expansion coefficient % \index[prmindex]{Magnitude} \index[prmindexfull]{Gravity model!Vertical!Magnitude} %
   end
 end
 \end{lstlisting}

Modified: branches/s-wang/for_deal.II/examples/step-32/test-step-32.cc
===================================================================
--- branches/s-wang/for_deal.II/examples/step-32/test-step-32.cc	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/examples/step-32/test-step-32.cc	2012-11-28 19:03:50 UTC (rev 1392)
@@ -2325,7 +2325,7 @@
 				     // elements. In other words, the
 				     // assignment here requires communication
 				     // between processors:
-    CIG::reduce_accuracy(solution);
+//    CIG::reduce_accuracy(solution);
 
     temperature_solution = solution;
     old_temperature_solution = solution;
@@ -4456,8 +4456,8 @@
 
     do
       {
-    	if(timestep_number==3)
-    		break;
+//    	if(timestep_number==3)
+//    		break;
 
         pcout << "Timestep " << timestep_number
               << ":  t=" << time/EquationData::year_in_seconds
@@ -4643,5 +4643,7 @@
   dealii::GrowingVectorMemory<dealii::PETScWrappers::Vector>::release_unused_memory ();
   PetscFinalize();
 
+//  dealii::TrilinosWrappers::BlockVector vec;
+
   return 0;
 }

Modified: branches/s-wang/for_deal.II/include/deal.II/lac/petsc_matrix_base.h
===================================================================
--- branches/s-wang/for_deal.II/include/deal.II/lac/petsc_matrix_base.h	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/include/deal.II/lac/petsc_matrix_base.h	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,5 +1,5 @@
 //---------------------------------------------------------------------------
-//    $Id: petsc_matrix_base.h 26045 2012-08-21 09:38:15Z young $
+//    $Id: petsc_matrix_base.h 27628 2012-11-20 22:49:26Z heister $
 //
 //    Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
 //
@@ -35,1264 +35,1264 @@
 
 namespace PETScWrappers
 {
-                                   // forward declarations
+  // forward declarations
   class VectorBase;
   class MatrixBase;
 
   namespace MatrixIterators
   {
-/**
- * STL conforming iterator. This class acts as an iterator walking over the
- * elements of PETSc matrices. Since PETSc offers a uniform interface for all
- * types of matrices, this iterator can be used to access both sparse and full
- * matrices.
- *
- * Note that PETSc does not give any guarantees as to the order of elements
- * within each row. Note also that accessing the elements of a full matrix
- * surprisingly only shows the nonzero elements of the matrix, not all
- * elements.
- *
- * @ingroup PETScWrappers
- * @author Guido Kanschat, Roy Stogner, Wolfgang Bangerth, 2004
- */
+    /**
+     * STL conforming iterator. This class acts as an iterator walking over the
+     * elements of PETSc matrices. Since PETSc offers a uniform interface for all
+     * types of matrices, this iterator can be used to access both sparse and full
+     * matrices.
+     *
+     * Note that PETSc does not give any guarantees as to the order of elements
+     * within each row. Note also that accessing the elements of a full matrix
+     * surprisingly only shows the nonzero elements of the matrix, not all
+     * elements.
+     *
+     * @ingroup PETScWrappers
+     * @author Guido Kanschat, Roy Stogner, Wolfgang Bangerth, 2004
+     */
     class const_iterator
     {
-      private:
-                                         /**
-                                          * Accessor class for iterators
-                                          */
-        class Accessor
-        {
-          public:
-                                             /**
-                                              * Constructor. Since we use
-                                              * accessors only for read
-                                              * access, a const matrix
-                                              * pointer is sufficient.
-                                              */
-            Accessor (const MatrixBase    *matrix,
-                      const unsigned int   row,
-                      const unsigned int   index);
+    private:
+      /**
+       * Accessor class for iterators
+       */
+      class Accessor
+      {
+      public:
+        /**
+         * Constructor. Since we use
+         * accessors only for read
+         * access, a const matrix
+         * pointer is sufficient.
+         */
+        Accessor (const MatrixBase    *matrix,
+                  const unsigned int   row,
+                  const unsigned int   index);
 
-                                             /**
-                                              * Row number of the element
-                                              * represented by this
-                                              * object.
-                                              */
-            unsigned int row() const;
+        /**
+         * Row number of the element
+         * represented by this
+         * object.
+         */
+        unsigned int row() const;
 
-                                             /**
-                                              * Index in row of the element
-                                              * represented by this
-                                              * object.
-                                              */
-            unsigned int index() const;
+        /**
+         * Index in row of the element
+         * represented by this
+         * object.
+         */
+        unsigned int index() const;
 
-                                             /**
-                                              * Column number of the
-                                              * element represented by
-                                              * this object.
-                                              */
-            unsigned int column() const;
+        /**
+         * Column number of the
+         * element represented by
+         * this object.
+         */
+        unsigned int column() const;
 
-                                             /**
-                                              * Value of this matrix entry.
-                                              */
-            PetscScalar value() const;
+        /**
+         * Value of this matrix entry.
+         */
+        PetscScalar value() const;
 
-                                             /**
-                                              * Exception
-                                              */
-            DeclException0 (ExcBeyondEndOfMatrix);
-                                             /**
-                                              * Exception
-                                              */
-            DeclException3 (ExcAccessToNonlocalRow,
-                            int, int, int,
-                            << "You tried to access row " << arg1
-                            << " of a distributed matrix, but only rows "
-                            << arg2 << " through " << arg3
-                            << " are stored locally and can be accessed.");
+        /**
+         * Exception
+         */
+        DeclException0 (ExcBeyondEndOfMatrix);
+        /**
+         * Exception
+         */
+        DeclException3 (ExcAccessToNonlocalRow,
+                        int, int, int,
+                        << "You tried to access row " << arg1
+                        << " of a distributed matrix, but only rows "
+                        << arg2 << " through " << arg3
+                        << " are stored locally and can be accessed.");
 
-          private:
-                                             /**
-                                              * The matrix accessed.
-                                              */
-            mutable MatrixBase *matrix;
+      private:
+        /**
+         * The matrix accessed.
+         */
+        mutable MatrixBase *matrix;
 
-                                             /**
-                                              * Current row number.
-                                              */
-            unsigned int a_row;
+        /**
+         * Current row number.
+         */
+        unsigned int a_row;
 
-                                             /**
-                                              * Current index in row.
-                                              */
-            unsigned int a_index;
+        /**
+         * Current index in row.
+         */
+        unsigned int a_index;
 
-                                             /**
-                                              * Cache where we store the
-                                              * column indices of the present
-                                              * row. This is necessary, since
-                                              * PETSc makes access to the
-                                              * elements of its matrices
-                                              * rather hard, and it is much
-                                              * more efficient to copy all
-                                              * column entries of a row once
-                                              * when we enter it than
-                                              * repeatedly asking PETSc for
-                                              * individual ones. This also
-                                              * makes some sense since it is
-                                              * likely that we will access
-                                              * them sequentially anyway.
-                                              *
-                                              * In order to make copying of
-                                              * iterators/accessor of
-                                              * acceptable performance, we
-                                              * keep a shared pointer to these
-                                              * entries so that more than one
-                                              * accessor can access this data
-                                              * if necessary.
-                                              */
-            std_cxx1x::shared_ptr<const std::vector<unsigned int> > colnum_cache;
+        /**
+         * Cache where we store the
+         * column indices of the present
+         * row. This is necessary, since
+         * PETSc makes access to the
+         * elements of its matrices
+         * rather hard, and it is much
+         * more efficient to copy all
+         * column entries of a row once
+         * when we enter it than
+         * repeatedly asking PETSc for
+         * individual ones. This also
+         * makes some sense since it is
+         * likely that we will access
+         * them sequentially anyway.
+         *
+         * In order to make copying of
+         * iterators/accessor of
+         * acceptable performance, we
+         * keep a shared pointer to these
+         * entries so that more than one
+         * accessor can access this data
+         * if necessary.
+         */
+        std_cxx1x::shared_ptr<const std::vector<unsigned int> > colnum_cache;
 
-                                             /**
-                                              * Similar cache for the values
-                                              * of this row.
-                                              */
-            std_cxx1x::shared_ptr<const std::vector<PetscScalar> > value_cache;
+        /**
+         * Similar cache for the values
+         * of this row.
+         */
+        std_cxx1x::shared_ptr<const std::vector<PetscScalar> > value_cache;
 
-                                             /**
-                                              * Discard the old row caches
-                                              * (they may still be used by
-                                              * other accessors) and generate
-                                              * new ones for the row pointed
-                                              * to presently by this accessor.
-                                              */
-            void visit_present_row ();
+        /**
+         * Discard the old row caches
+         * (they may still be used by
+         * other accessors) and generate
+         * new ones for the row pointed
+         * to presently by this accessor.
+         */
+        void visit_present_row ();
 
-                                             /**
-                                              * Make enclosing class a
-                                              * friend.
-                                              */
-            friend class const_iterator;
-        };
+        /**
+         * Make enclosing class a
+         * friend.
+         */
+        friend class const_iterator;
+      };
 
-      public:
+    public:
 
-                                         /**
-                                          * Constructor. Create an iterator
-                                          * into the matrix @p matrix for the
-                                          * given row and the index within it.
-                                          */
-        const_iterator (const MatrixBase   *matrix,
-                        const unsigned int  row,
-                        const unsigned int  index);
+      /**
+       * Constructor. Create an iterator
+       * into the matrix @p matrix for the
+       * given row and the index within it.
+       */
+      const_iterator (const MatrixBase   *matrix,
+                      const unsigned int  row,
+                      const unsigned int  index);
 
-                                         /**
-                                          * Prefix increment.
-                                          */
-        const_iterator& operator++ ();
+      /**
+       * Prefix increment.
+       */
+      const_iterator &operator++ ();
 
-                                         /**
-                                          * Postfix increment.
-                                          */
-        const_iterator operator++ (int);
+      /**
+       * Postfix increment.
+       */
+      const_iterator operator++ (int);
 
-                                         /**
-                                          * Dereferencing operator.
-                                          */
-        const Accessor& operator* () const;
+      /**
+       * Dereferencing operator.
+       */
+      const Accessor &operator* () const;
 
-                                         /**
-                                          * Dereferencing operator.
-                                          */
-        const Accessor* operator-> () const;
+      /**
+       * Dereferencing operator.
+       */
+      const Accessor *operator-> () const;
 
-                                         /**
-                                          * Comparison. True, if
-                                          * both iterators point to
-                                          * the same matrix
-                                          * position.
-                                          */
-        bool operator == (const const_iterator&) const;
-                                         /**
-                                          * Inverse of <tt>==</tt>.
-                                          */
-        bool operator != (const const_iterator&) const;
+      /**
+       * Comparison. True, if
+       * both iterators point to
+       * the same matrix
+       * position.
+       */
+      bool operator == (const const_iterator &) const;
+      /**
+       * Inverse of <tt>==</tt>.
+       */
+      bool operator != (const const_iterator &) const;
 
-                                         /**
-                                          * Comparison
-                                          * operator. Result is true
-                                          * if either the first row
-                                          * number is smaller or if
-                                          * the row numbers are
-                                          * equal and the first
-                                          * index is smaller.
-                                          */
-        bool operator < (const const_iterator&) const;
+      /**
+       * Comparison
+       * operator. Result is true
+       * if either the first row
+       * number is smaller or if
+       * the row numbers are
+       * equal and the first
+       * index is smaller.
+       */
+      bool operator < (const const_iterator &) const;
 
-                                         /**
-                                          * Exception
-                                          */
-        DeclException2 (ExcInvalidIndexWithinRow,
-                        int, int,
-                        << "Attempt to access element " << arg2
-                        << " of row " << arg1
-                        << " which doesn't have that many elements.");
+      /**
+       * Exception
+       */
+      DeclException2 (ExcInvalidIndexWithinRow,
+                      int, int,
+                      << "Attempt to access element " << arg2
+                      << " of row " << arg1
+                      << " which doesn't have that many elements.");
 
-      private:
-                                         /**
-                                          * Store an object of the
-                                          * accessor class.
-                                          */
-        Accessor accessor;
+    private:
+      /**
+       * Store an object of the
+       * accessor class.
+       */
+      Accessor accessor;
     };
 
   }
 
 
-/**
- * Base class for all matrix classes that are implemented on top of the PETSc
- * matrix types. Since in PETSc all matrix types (i.e. sequential and
- * parallel, sparse, blocked, etc.)  are built by filling the contents of an
- * abstract object that is only referenced through a pointer of a type that is
- * independent of the actual matrix type, we can implement almost all
- * functionality of matrices in this base class. Derived classes will then only
- * have to provide the functionality to create one or the other kind of
- * matrix.
- *
- * The interface of this class is modeled after the existing
- * SparseMatrix class in deal.II. It has almost the same member
- * functions, and is often exchangable. However, since PETSc only supports a
- * single scalar type (either double, float, or a complex data type), it is
- * not templated, and only works with whatever your PETSc installation has
- * defined the data type PetscScalar to.
- *
- * Note that PETSc only guarantees that operations do what you expect if the
- * functions @p MatAssemblyBegin and @p MatAssemblyEnd have been called
- * after matrix assembly. Therefore, you need to call
- * SparseMatrix::compress() before you actually use the matrix. This also
- * calls @p MatCompress that compresses the storage format for sparse
- * matrices by discarding unused elements. PETSc allows to continue with
- * assembling the matrix after calls to these functions, but since there are
- * no more free entries available after that any more, it is better to only
- * call SparseMatrix::compress() once at the end of the assembly stage and
- * before the matrix is actively used.
- *
- * @ingroup PETScWrappers
- * @ingroup Matrix1
- * @author Wolfgang Bangerth, 2004
- */
+  /**
+   * Base class for all matrix classes that are implemented on top of the PETSc
+   * matrix types. Since in PETSc all matrix types (i.e. sequential and
+   * parallel, sparse, blocked, etc.)  are built by filling the contents of an
+   * abstract object that is only referenced through a pointer of a type that is
+   * independent of the actual matrix type, we can implement almost all
+   * functionality of matrices in this base class. Derived classes will then only
+   * have to provide the functionality to create one or the other kind of
+   * matrix.
+   *
+   * The interface of this class is modeled after the existing
+   * SparseMatrix class in deal.II. It has almost the same member
+   * functions, and is often exchangable. However, since PETSc only supports a
+   * single scalar type (either double, float, or a complex data type), it is
+   * not templated, and only works with whatever your PETSc installation has
+   * defined the data type PetscScalar to.
+   *
+   * Note that PETSc only guarantees that operations do what you expect if the
+   * functions @p MatAssemblyBegin and @p MatAssemblyEnd have been called
+   * after matrix assembly. Therefore, you need to call
+   * SparseMatrix::compress() before you actually use the matrix. This also
+   * calls @p MatCompress that compresses the storage format for sparse
+   * matrices by discarding unused elements. PETSc allows to continue with
+   * assembling the matrix after calls to these functions, but since there are
+   * no more free entries available after that any more, it is better to only
+   * call SparseMatrix::compress() once at the end of the assembly stage and
+   * before the matrix is actively used.
+   *
+   * @ingroup PETScWrappers
+   * @ingroup Matrix1
+   * @author Wolfgang Bangerth, 2004
+   */
   class MatrixBase : public Subscriptor
   {
-    public:
-                                       /**
-                                        * Declare a typedef for the iterator
-                                        * class.
-                                        */
-      typedef MatrixIterators::const_iterator const_iterator;
+  public:
+    /**
+     * Declare a typedef for the iterator
+     * class.
+     */
+    typedef MatrixIterators::const_iterator const_iterator;
 
-                                       /**
-                                        * Declare a typedef in analogy to all
-                                        * the other container classes.
-                                        */
-      typedef PetscScalar value_type;
+    /**
+     * Declare a typedef in analogy to all
+     * the other container classes.
+     */
+    typedef PetscScalar value_type;
 
-                                       /**
-                                        * Default constructor.
-                                        */
-      MatrixBase ();
+    /**
+     * Default constructor.
+     */
+    MatrixBase ();
 
-                                       /**
-                                        * Destructor. Made virtual so that one
-                                        * can use pointers to this class.
-                                        */
-      virtual ~MatrixBase ();
+    /**
+     * Destructor. Made virtual so that one
+     * can use pointers to this class.
+     */
+    virtual ~MatrixBase ();
 
-                                       /**
-                                        * This operator assigns a scalar to a
-                                        * matrix. Since this does usually not
-                                        * make much sense (should we set all
-                                        * matrix entries to this value? Only
-                                        * the nonzero entries of the sparsity
-                                        * pattern?), this operation is only
-                                        * allowed if the actual value to be
-                                        * assigned is zero. This operator only
-                                        * exists to allow for the obvious
-                                        * notation <tt>matrix=0</tt>, which
-                                        * sets all elements of the matrix to
-                                        * zero, but keeps the sparsity pattern
-                                        * previously used.
-                                        */
-      MatrixBase &
-      operator = (const value_type d);
-                                       /**
-                                        * Release all memory and return
-                                        * to a state just like after
-                                        * having called the default
-                                        * constructor.
-                                        */
-      void clear ();
+    /**
+     * This operator assigns a scalar to a
+     * matrix. Since this does usually not
+     * make much sense (should we set all
+     * matrix entries to this value? Only
+     * the nonzero entries of the sparsity
+     * pattern?), this operation is only
+     * allowed if the actual value to be
+     * assigned is zero. This operator only
+     * exists to allow for the obvious
+     * notation <tt>matrix=0</tt>, which
+     * sets all elements of the matrix to
+     * zero, but keeps the sparsity pattern
+     * previously used.
+     */
+    MatrixBase &
+    operator = (const value_type d);
+    /**
+     * Release all memory and return
+     * to a state just like after
+     * having called the default
+     * constructor.
+     */
+    void clear ();
 
-                                       /**
-                                        * Set the element (<i>i,j</i>) to @p
-                                        * value.
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds a new entry to the
-                                        * matrix if it didn't exist before,
-                                        * very much in contrast to the
-                                        * SparseMatrix class which throws an
-                                        * error if the entry does not exist.
-                                        * If <tt>value</tt> is not a finite
-                                        * number an exception is thrown.
-                                        */
-      void set (const unsigned int i,
-                const unsigned int j,
-                const PetscScalar value);
+    /**
+     * Set the element (<i>i,j</i>) to @p
+     * value.
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds a new entry to the
+     * matrix if it didn't exist before,
+     * very much in contrast to the
+     * SparseMatrix class which throws an
+     * error if the entry does not exist.
+     * If <tt>value</tt> is not a finite
+     * number an exception is thrown.
+     */
+    void set (const unsigned int i,
+              const unsigned int j,
+              const PetscScalar value);
 
-                                       /**
-                                        * Set all elements given in a
-                                        * FullMatrix<double> into the sparse
-                                        * matrix locations given by
-                                        * <tt>indices</tt>. In other words,
-                                        * this function writes the elements
-                                        * in <tt>full_matrix</tt> into the
-                                        * calling matrix, using the
-                                        * local-to-global indexing specified
-                                        * by <tt>indices</tt> for both the
-                                        * rows and the columns of the
-                                        * matrix. This function assumes a
-                                        * quadratic sparse matrix and a
-                                        * quadratic full_matrix, the usual
-                                        * situation in FE calculations.
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds some new entries to
-                                        * the matrix if they didn't exist
-                                        * before, very much in contrast to
-                                        * the SparseMatrix class which
-                                        * throws an error if the entry does
-                                        * not exist.
-                                        *
-                                        * The optional parameter
-                                        * <tt>elide_zero_values</tt> can be
-                                        * used to specify whether zero
-                                        * values should be inserted anyway
-                                        * or they should be filtered
-                                        * away. The default value is
-                                        * <tt>false</tt>, i.e., even zero
-                                        * values are inserted/replaced.
-                                        */
-      void set (const std::vector<unsigned int> &indices,
-                const FullMatrix<PetscScalar>   &full_matrix,
-                const bool                       elide_zero_values = false);
+    /**
+     * Set all elements given in a
+     * FullMatrix<double> into the sparse
+     * matrix locations given by
+     * <tt>indices</tt>. In other words,
+     * this function writes the elements
+     * in <tt>full_matrix</tt> into the
+     * calling matrix, using the
+     * local-to-global indexing specified
+     * by <tt>indices</tt> for both the
+     * rows and the columns of the
+     * matrix. This function assumes a
+     * quadratic sparse matrix and a
+     * quadratic full_matrix, the usual
+     * situation in FE calculations.
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds some new entries to
+     * the matrix if they didn't exist
+     * before, very much in contrast to
+     * the SparseMatrix class which
+     * throws an error if the entry does
+     * not exist.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be inserted anyway
+     * or they should be filtered
+     * away. The default value is
+     * <tt>false</tt>, i.e., even zero
+     * values are inserted/replaced.
+     */
+    void set (const std::vector<unsigned int> &indices,
+              const FullMatrix<PetscScalar>   &full_matrix,
+              const bool                       elide_zero_values = false);
 
-                                       /**
-                                        * Same function as before, but now
-                                        * including the possibility to use
-                                        * rectangular full_matrices and
-                                        * different local-to-global indexing
-                                        * on rows and columns, respectively.
-                                        */
-      void set (const std::vector<unsigned int> &row_indices,
-                const std::vector<unsigned int> &col_indices,
-                const FullMatrix<PetscScalar>   &full_matrix,
-                const bool                       elide_zero_values = false);
+    /**
+     * Same function as before, but now
+     * including the possibility to use
+     * rectangular full_matrices and
+     * different local-to-global indexing
+     * on rows and columns, respectively.
+     */
+    void set (const std::vector<unsigned int> &row_indices,
+              const std::vector<unsigned int> &col_indices,
+              const FullMatrix<PetscScalar>   &full_matrix,
+              const bool                       elide_zero_values = false);
 
-                                       /**
-                                        * Set several elements in the
-                                        * specified row of the matrix with
-                                        * column indices as given by
-                                        * <tt>col_indices</tt> to the
-                                        * respective value.
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds some new entries to
-                                        * the matrix if they didn't exist
-                                        * before, very much in contrast to
-                                        * the SparseMatrix class which
-                                        * throws an error if the entry does
-                                        * not exist.
-                                        *
-                                        * The optional parameter
-                                        * <tt>elide_zero_values</tt> can be
-                                        * used to specify whether zero
-                                        * values should be inserted anyway
-                                        * or they should be filtered
-                                        * away. The default value is
-                                        * <tt>false</tt>, i.e., even zero
-                                        * values are inserted/replaced.
-                                        */
-      void set (const unsigned int               row,
-                const std::vector<unsigned int> &col_indices,
-                const std::vector<PetscScalar>  &values,
-                const bool                       elide_zero_values = false);
+    /**
+     * Set several elements in the
+     * specified row of the matrix with
+     * column indices as given by
+     * <tt>col_indices</tt> to the
+     * respective value.
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds some new entries to
+     * the matrix if they didn't exist
+     * before, very much in contrast to
+     * the SparseMatrix class which
+     * throws an error if the entry does
+     * not exist.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be inserted anyway
+     * or they should be filtered
+     * away. The default value is
+     * <tt>false</tt>, i.e., even zero
+     * values are inserted/replaced.
+     */
+    void set (const unsigned int               row,
+              const std::vector<unsigned int> &col_indices,
+              const std::vector<PetscScalar> &values,
+              const bool                       elide_zero_values = false);
 
-                                       /**
-                                        * Set several elements to values
-                                        * given by <tt>values</tt> in a
-                                        * given row in columns given by
-                                        * col_indices into the sparse
-                                        * matrix.
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds some new entries to
-                                        * the matrix if they didn't exist
-                                        * before, very much in contrast to
-                                        * the SparseMatrix class which
-                                        * throws an error if the entry does
-                                        * not exist.
-                                        *
-                                        * The optional parameter
-                                        * <tt>elide_zero_values</tt> can be
-                                        * used to specify whether zero
-                                        * values should be inserted anyway
-                                        * or they should be filtered
-                                        * away. The default value is
-                                        * <tt>false</tt>, i.e., even zero
-                                        * values are inserted/replaced.
-                                        */
-      void set (const unsigned int  row,
-                const unsigned int  n_cols,
-                const unsigned int *col_indices,
-                const PetscScalar  *values,
-                const bool          elide_zero_values = false);
+    /**
+     * Set several elements to values
+     * given by <tt>values</tt> in a
+     * given row in columns given by
+     * col_indices into the sparse
+     * matrix.
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds some new entries to
+     * the matrix if they didn't exist
+     * before, very much in contrast to
+     * the SparseMatrix class which
+     * throws an error if the entry does
+     * not exist.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be inserted anyway
+     * or they should be filtered
+     * away. The default value is
+     * <tt>false</tt>, i.e., even zero
+     * values are inserted/replaced.
+     */
+    void set (const unsigned int  row,
+              const unsigned int  n_cols,
+              const unsigned int *col_indices,
+              const PetscScalar *values,
+              const bool          elide_zero_values = false);
 
-                                       /**
-                                        * Add @p value to the element
-                                        * (<i>i,j</i>).
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds a new entry to the
-                                        * matrix if it didn't exist before,
-                                        * very much in contrast to the
-                                        * SparseMatrix class which throws an
-                                        * error if the entry does not exist.
-                                        * If <tt>value</tt> is not a finite
-                                        * number an exception is thrown.
-                                        */
-      void add (const unsigned int i,
-                const unsigned int j,
-                const PetscScalar value);
+    /**
+     * Add @p value to the element
+     * (<i>i,j</i>).
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds a new entry to the
+     * matrix if it didn't exist before,
+     * very much in contrast to the
+     * SparseMatrix class which throws an
+     * error if the entry does not exist.
+     * If <tt>value</tt> is not a finite
+     * number an exception is thrown.
+     */
+    void add (const unsigned int i,
+              const unsigned int j,
+              const PetscScalar value);
 
-                                       /**
-                                        * Add all elements given in a
-                                        * FullMatrix<double> into sparse
-                                        * matrix locations given by
-                                        * <tt>indices</tt>. In other words,
-                                        * this function adds the elements in
-                                        * <tt>full_matrix</tt> to the
-                                        * respective entries in calling
-                                        * matrix, using the local-to-global
-                                        * indexing specified by
-                                        * <tt>indices</tt> for both the rows
-                                        * and the columns of the
-                                        * matrix. This function assumes a
-                                        * quadratic sparse matrix and a
-                                        * quadratic full_matrix, the usual
-                                        * situation in FE calculations.
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds some new entries to
-                                        * the matrix if they didn't exist
-                                        * before, very much in contrast to
-                                        * the SparseMatrix class which
-                                        * throws an error if the entry does
-                                        * not exist.
-                                        *
-                                        * The optional parameter
-                                        * <tt>elide_zero_values</tt> can be
-                                        * used to specify whether zero
-                                        * values should be added anyway or
-                                        * these should be filtered away and
-                                        * only non-zero data is added. The
-                                        * default value is <tt>true</tt>,
-                                        * i.e., zero values won't be added
-                                        * into the matrix.
-                                        */
-      void add (const std::vector<unsigned int> &indices,
-                const FullMatrix<PetscScalar>   &full_matrix,
-                const bool                       elide_zero_values = true);
+    /**
+     * Add all elements given in a
+     * FullMatrix<double> into sparse
+     * matrix locations given by
+     * <tt>indices</tt>. In other words,
+     * this function adds the elements in
+     * <tt>full_matrix</tt> to the
+     * respective entries in calling
+     * matrix, using the local-to-global
+     * indexing specified by
+     * <tt>indices</tt> for both the rows
+     * and the columns of the
+     * matrix. This function assumes a
+     * quadratic sparse matrix and a
+     * quadratic full_matrix, the usual
+     * situation in FE calculations.
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds some new entries to
+     * the matrix if they didn't exist
+     * before, very much in contrast to
+     * the SparseMatrix class which
+     * throws an error if the entry does
+     * not exist.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be added anyway or
+     * these should be filtered away and
+     * only non-zero data is added. The
+     * default value is <tt>true</tt>,
+     * i.e., zero values won't be added
+     * into the matrix.
+     */
+    void add (const std::vector<unsigned int> &indices,
+              const FullMatrix<PetscScalar>   &full_matrix,
+              const bool                       elide_zero_values = true);
 
-                                       /**
-                                        * Same function as before, but now
-                                        * including the possibility to use
-                                        * rectangular full_matrices and
-                                        * different local-to-global indexing
-                                        * on rows and columns, respectively.
-                                        */
-      void add (const std::vector<unsigned int> &row_indices,
-                const std::vector<unsigned int> &col_indices,
-                const FullMatrix<PetscScalar>   &full_matrix,
-                const bool                       elide_zero_values = true);
+    /**
+     * Same function as before, but now
+     * including the possibility to use
+     * rectangular full_matrices and
+     * different local-to-global indexing
+     * on rows and columns, respectively.
+     */
+    void add (const std::vector<unsigned int> &row_indices,
+              const std::vector<unsigned int> &col_indices,
+              const FullMatrix<PetscScalar>   &full_matrix,
+              const bool                       elide_zero_values = true);
 
-                                       /**
-                                        * Set several elements in the
-                                        * specified row of the matrix with
-                                        * column indices as given by
-                                        * <tt>col_indices</tt> to the
-                                        * respective value.
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds some new entries to
-                                        * the matrix if they didn't exist
-                                        * before, very much in contrast to
-                                        * the SparseMatrix class which
-                                        * throws an error if the entry does
-                                        * not exist.
-                                        *
-                                        * The optional parameter
-                                        * <tt>elide_zero_values</tt> can be
-                                        * used to specify whether zero
-                                        * values should be added anyway or
-                                        * these should be filtered away and
-                                        * only non-zero data is added. The
-                                        * default value is <tt>true</tt>,
-                                        * i.e., zero values won't be added
-                                        * into the matrix.
-                                        */
-      void add (const unsigned int               row,
-                const std::vector<unsigned int> &col_indices,
-                const std::vector<PetscScalar>  &values,
-                const bool                       elide_zero_values = true);
+    /**
+     * Set several elements in the
+     * specified row of the matrix with
+     * column indices as given by
+     * <tt>col_indices</tt> to the
+     * respective value.
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds some new entries to
+     * the matrix if they didn't exist
+     * before, very much in contrast to
+     * the SparseMatrix class which
+     * throws an error if the entry does
+     * not exist.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be added anyway or
+     * these should be filtered away and
+     * only non-zero data is added. The
+     * default value is <tt>true</tt>,
+     * i.e., zero values won't be added
+     * into the matrix.
+     */
+    void add (const unsigned int               row,
+              const std::vector<unsigned int> &col_indices,
+              const std::vector<PetscScalar> &values,
+              const bool                       elide_zero_values = true);
 
-                                       /**
-                                        * Add an array of values given by
-                                        * <tt>values</tt> in the given
-                                        * global matrix row at columns
-                                        * specified by col_indices in the
-                                        * sparse matrix.
-                                        *
-                                        * If the present object (from a
-                                        * derived class of this one) happens
-                                        * to be a sparse matrix, then this
-                                        * function adds some new entries to
-                                        * the matrix if they didn't exist
-                                        * before, very much in contrast to
-                                        * the SparseMatrix class which
-                                        * throws an error if the entry does
-                                        * not exist.
-                                        *
-                                        * The optional parameter
-                                        * <tt>elide_zero_values</tt> can be
-                                        * used to specify whether zero
-                                        * values should be added anyway or
-                                        * these should be filtered away and
-                                        * only non-zero data is added. The
-                                        * default value is <tt>true</tt>,
-                                        * i.e., zero values won't be added
-                                        * into the matrix.
-                                        */
-      void add (const unsigned int  row,
-                const unsigned int  n_cols,
-                const unsigned int *col_indices,
-                const PetscScalar  *values,
-                const bool          elide_zero_values = true,
-                const bool          col_indices_are_sorted = false);
+    /**
+     * Add an array of values given by
+     * <tt>values</tt> in the given
+     * global matrix row at columns
+     * specified by col_indices in the
+     * sparse matrix.
+     *
+     * If the present object (from a
+     * derived class of this one) happens
+     * to be a sparse matrix, then this
+     * function adds some new entries to
+     * the matrix if they didn't exist
+     * before, very much in contrast to
+     * the SparseMatrix class which
+     * throws an error if the entry does
+     * not exist.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be added anyway or
+     * these should be filtered away and
+     * only non-zero data is added. The
+     * default value is <tt>true</tt>,
+     * i.e., zero values won't be added
+     * into the matrix.
+     */
+    void add (const unsigned int  row,
+              const unsigned int  n_cols,
+              const unsigned int *col_indices,
+              const PetscScalar *values,
+              const bool          elide_zero_values = true,
+              const bool          col_indices_are_sorted = false);
 
-                                       /**
-                                        * Remove all elements from
-                                        * this <tt>row</tt> by setting
-                                        * them to zero. The function
-                                        * does not modify the number
-                                        * of allocated nonzero
-                                        * entries, it only sets some
-                                        * entries to zero. It may drop
-                                        * them from the sparsity
-                                        * pattern, though (but retains
-                                        * the allocated memory in case
-                                        * new entries are again added
-                                        * later).
-                                        *
-                                        * This operation is used in
-                                        * eliminating constraints (e.g. due to
-                                        * hanging nodes) and makes sure that
-                                        * we can write this modification to
-                                        * the matrix without having to read
-                                        * entries (such as the locations of
-                                        * non-zero elements) from it --
-                                        * without this operation, removing
-                                        * constraints on parallel matrices is
-                                        * a rather complicated procedure.
-                                        *
-                                        * The second parameter can be used to
-                                        * set the diagonal entry of this row
-                                        * to a value different from zero. The
-                                        * default is to set it to zero.
-                                        */
-      void clear_row (const unsigned int row,
-                      const PetscScalar  new_diag_value = 0);
+    /**
+     * Remove all elements from
+     * this <tt>row</tt> by setting
+     * them to zero. The function
+     * does not modify the number
+     * of allocated nonzero
+     * entries, it only sets some
+     * entries to zero. It may drop
+     * them from the sparsity
+     * pattern, though (but retains
+     * the allocated memory in case
+     * new entries are again added
+     * later).
+     *
+     * This operation is used in
+     * eliminating constraints (e.g. due to
+     * hanging nodes) and makes sure that
+     * we can write this modification to
+     * the matrix without having to read
+     * entries (such as the locations of
+     * non-zero elements) from it --
+     * without this operation, removing
+     * constraints on parallel matrices is
+     * a rather complicated procedure.
+     *
+     * The second parameter can be used to
+     * set the diagonal entry of this row
+     * to a value different from zero. The
+     * default is to set it to zero.
+     */
+    void clear_row (const unsigned int row,
+                    const PetscScalar  new_diag_value = 0);
 
-                                       /**
-                                        * Same as clear_row(), except that it
-                                        * works on a number of rows at once.
-                                        *
-                                        * The second parameter can be used to
-                                        * set the diagonal entries of all
-                                        * cleared rows to something different
-                                        * from zero. Note that all of these
-                                        * diagonal entries get the same value
-                                        * -- if you want different values for
-                                        * the diagonal entries, you have to
-                                        * set them by hand.
-                                        */
-      void clear_rows (const std::vector<unsigned int> &rows,
-                       const PetscScalar                new_diag_value = 0);
+    /**
+     * Same as clear_row(), except that it
+     * works on a number of rows at once.
+     *
+     * The second parameter can be used to
+     * set the diagonal entries of all
+     * cleared rows to something different
+     * from zero. Note that all of these
+     * diagonal entries get the same value
+     * -- if you want different values for
+     * the diagonal entries, you have to
+     * set them by hand.
+     */
+    void clear_rows (const std::vector<unsigned int> &rows,
+                     const PetscScalar                new_diag_value = 0);
 
-                                       /**
-                                        * PETSc matrices store their own
-                                        * sparsity patterns. So, in analogy to
-                                        * our own SparsityPattern class,
-                                        * this function compresses the
-                                        * sparsity pattern and allows the
-                                        * resulting matrix to be used in all
-                                        * other operations where before only
-                                        * assembly functions were
-                                        * allowed. This function must
-                                        * therefore be called once you have
-                                        * assembled the matrix.
-                                        *
-                                        * See @ref GlossCompress "Compressing distributed objects"
-                                        * for more information.
-                                        * more information.
-                                        */
-      void compress (::dealii::VectorOperation::values operation
-		     =::dealii::VectorOperation::unknown);
-                                       /**
-                                        * Return the value of the entry
-                                        * (<i>i,j</i>).  This may be an
-                                        * expensive operation and you should
-                                        * always take care where to call this
-                                        * function. In contrast to the
-                                        * respective function in the
-                                        * @p MatrixBase class, we don't
-                                        * throw an exception if the respective
-                                        * entry doesn't exist in the sparsity
-                                        * pattern of this class, since PETSc
-                                        * does not transmit this information.
-                                        *
-                                        * This function is therefore exactly
-                                        * equivalent to the <tt>el()</tt> function.
-                                        */
-      PetscScalar operator () (const unsigned int i,
-                               const unsigned int j) const;
+    /**
+     * PETSc matrices store their own
+     * sparsity patterns. So, in analogy to
+     * our own SparsityPattern class,
+     * this function compresses the
+     * sparsity pattern and allows the
+     * resulting matrix to be used in all
+     * other operations where before only
+     * assembly functions were
+     * allowed. This function must
+     * therefore be called once you have
+     * assembled the matrix.
+     *
+     * See @ref GlossCompress "Compressing distributed objects"
+     * for more information.
+     * more information.
+     */
+    void compress (::dealii::VectorOperation::values operation
+                   =::dealii::VectorOperation::unknown);
+    /**
+     * Return the value of the entry
+     * (<i>i,j</i>).  This may be an
+     * expensive operation and you should
+     * always take care where to call this
+     * function. In contrast to the
+     * respective function in the
+     * @p MatrixBase class, we don't
+     * throw an exception if the respective
+     * entry doesn't exist in the sparsity
+     * pattern of this class, since PETSc
+     * does not transmit this information.
+     *
+     * This function is therefore exactly
+     * equivalent to the <tt>el()</tt> function.
+     */
+    PetscScalar operator () (const unsigned int i,
+                             const unsigned int j) const;
 
-                                       /**
-                                        * Return the value of the matrix entry
-                                        * (<i>i,j</i>). If this entry does not
-                                        * exist in the sparsity pattern, then
-                                        * zero is returned. While this may be
-                                        * convenient in some cases, note that
-                                        * it is simple to write algorithms
-                                        * that are slow compared to an optimal
-                                        * solution, since the sparsity of the
-                                        * matrix is not used.
-                                        */
-      PetscScalar el (const unsigned int i,
-                      const unsigned int j) const;
+    /**
+     * Return the value of the matrix entry
+     * (<i>i,j</i>). If this entry does not
+     * exist in the sparsity pattern, then
+     * zero is returned. While this may be
+     * convenient in some cases, note that
+     * it is simple to write algorithms
+     * that are slow compared to an optimal
+     * solution, since the sparsity of the
+     * matrix is not used.
+     */
+    PetscScalar el (const unsigned int i,
+                    const unsigned int j) const;
 
-                                       /**
-                                        * Return the main diagonal
-                                        * element in the <i>i</i>th
-                                        * row. This function throws an
-                                        * error if the matrix is not
-                                        * quadratic.
-                                        *
-                                        * Since we do not have direct access
-                                        * to the underlying data structure,
-                                        * this function is no faster than the
-                                        * elementwise access using the el()
-                                        * function. However, we provide this
-                                        * function for compatibility with the
-                                        * SparseMatrix class.
-                                        */
-      PetscScalar diag_element (const unsigned int i) const;
+    /**
+     * Return the main diagonal
+     * element in the <i>i</i>th
+     * row. This function throws an
+     * error if the matrix is not
+     * quadratic.
+     *
+     * Since we do not have direct access
+     * to the underlying data structure,
+     * this function is no faster than the
+     * elementwise access using the el()
+     * function. However, we provide this
+     * function for compatibility with the
+     * SparseMatrix class.
+     */
+    PetscScalar diag_element (const unsigned int i) const;
 
-                                       /**
-                                        * Return the number of rows in this
-                                        * matrix.
-                                        */
-      unsigned int m () const;
+    /**
+     * Return the number of rows in this
+     * matrix.
+     */
+    unsigned int m () const;
 
-                                       /**
-                                        * Return the number of columns in this
-                                        * matrix.
-                                        */
-      unsigned int n () const;
+    /**
+     * Return the number of columns in this
+     * matrix.
+     */
+    unsigned int n () const;
 
-                                       /**
-                                        * Return the local dimension of the
-                                        * matrix, i.e. the number of rows
-                                        * stored on the present MPI
-                                        * process. For sequential matrices,
-                                        * this number is the same as m(),
-                                        * but for parallel matrices it may be
-                                        * smaller.
-                                        *
-                                        * To figure out which elements
-                                        * exactly are stored locally,
-                                        * use local_range().
-                                        */
-      unsigned int local_size () const;
+    /**
+     * Return the local dimension of the
+     * matrix, i.e. the number of rows
+     * stored on the present MPI
+     * process. For sequential matrices,
+     * this number is the same as m(),
+     * but for parallel matrices it may be
+     * smaller.
+     *
+     * To figure out which elements
+     * exactly are stored locally,
+     * use local_range().
+     */
+    unsigned int local_size () const;
 
-                                       /**
-                                        * Return a pair of indices
-                                        * indicating which rows of
-                                        * this matrix are stored
-                                        * locally. The first number is
-                                        * the index of the first
-                                        * row stored, the second
-                                        * the index of the one past
-                                        * the last one that is stored
-                                        * locally. If this is a
-                                        * sequential matrix, then the
-                                        * result will be the pair
-                                        * (0,m()), otherwise it will be
-                                        * a pair (i,i+n), where
-                                        * <tt>n=local_size()</tt>.
-                                        */
-      std::pair<unsigned int, unsigned int>
-      local_range () const;
+    /**
+     * Return a pair of indices
+     * indicating which rows of
+     * this matrix are stored
+     * locally. The first number is
+     * the index of the first
+     * row stored, the second
+     * the index of the one past
+     * the last one that is stored
+     * locally. If this is a
+     * sequential matrix, then the
+     * result will be the pair
+     * (0,m()), otherwise it will be
+     * a pair (i,i+n), where
+     * <tt>n=local_size()</tt>.
+     */
+    std::pair<unsigned int, unsigned int>
+    local_range () const;
 
-                                       /**
-                                        * Return whether @p index is
-                                        * in the local range or not,
-                                        * see also local_range().
-                                        */
-      bool in_local_range (const unsigned int index) const;
+    /**
+     * Return whether @p index is
+     * in the local range or not,
+     * see also local_range().
+     */
+    bool in_local_range (const unsigned int index) const;
 
-                                       /**
-                                        * Return a reference to the MPI
-                                        * communicator object in use with this
-                                        * matrix. This function has to be
-                                        * implemented in derived classes.
-                                        */
-      virtual const MPI_Comm & get_mpi_communicator () const = 0;
+    /**
+     * Return a reference to the MPI
+     * communicator object in use with this
+     * matrix. This function has to be
+     * implemented in derived classes.
+     */
+    virtual const MPI_Comm &get_mpi_communicator () const = 0;
 
-                                       /**
-                                        * Return the number of nonzero
-                                        * elements of this
-                                        * matrix. Actually, it returns
-                                        * the number of entries in the
-                                        * sparsity pattern; if any of
-                                        * the entries should happen to
-                                        * be zero, it is counted anyway.
-                                        */
-      unsigned int n_nonzero_elements () const;
+    /**
+     * Return the number of nonzero
+     * elements of this
+     * matrix. Actually, it returns
+     * the number of entries in the
+     * sparsity pattern; if any of
+     * the entries should happen to
+     * be zero, it is counted anyway.
+     */
+    unsigned int n_nonzero_elements () const;
 
-                                       /**
-                                        * Number of entries in a specific row.
-                                        */
-      unsigned int row_length (const unsigned int row) const;
+    /**
+     * Number of entries in a specific row.
+     */
+    unsigned int row_length (const unsigned int row) const;
 
-                                       /**
-                                        * Return the l1-norm of the matrix, that is
-                                        * $|M|_1=max_{all columns j}\sum_{all
-                                        * rows i} |M_ij|$,
-                                        * (max. sum of columns).
-                                        * This is the
-                                        * natural matrix norm that is compatible
-                                        * to the l1-norm for vectors, i.e.
-                                        * $|Mv|_1\leq |M|_1 |v|_1$.
-                                        * (cf. Haemmerlin-Hoffmann:
-                                        * Numerische Mathematik)
-                                        */
-      PetscReal l1_norm () const;
+    /**
+     * Return the l1-norm of the matrix, that is
+     * $|M|_1=max_{all columns j}\sum_{all
+     * rows i} |M_ij|$,
+     * (max. sum of columns).
+     * This is the
+     * natural matrix norm that is compatible
+     * to the l1-norm for vectors, i.e.
+     * $|Mv|_1\leq |M|_1 |v|_1$.
+     * (cf. Haemmerlin-Hoffmann:
+     * Numerische Mathematik)
+     */
+    PetscReal l1_norm () const;
 
-                                       /**
-                                        * Return the linfty-norm of the
-                                        * matrix, that is
-                                        * $|M|_infty=max_{all rows i}\sum_{all
-                                        * columns j} |M_ij|$,
-                                        * (max. sum of rows).
-                                        * This is the
-                                        * natural matrix norm that is compatible
-                                        * to the linfty-norm of vectors, i.e.
-                                        * $|Mv|_infty \leq |M|_infty |v|_infty$.
-                                        * (cf. Haemmerlin-Hoffmann:
-                                        * Numerische Mathematik)
-                                        */
-      PetscReal linfty_norm () const;
+    /**
+     * Return the linfty-norm of the
+     * matrix, that is
+     * $|M|_infty=max_{all rows i}\sum_{all
+     * columns j} |M_ij|$,
+     * (max. sum of rows).
+     * This is the
+     * natural matrix norm that is compatible
+     * to the linfty-norm of vectors, i.e.
+     * $|Mv|_infty \leq |M|_infty |v|_infty$.
+     * (cf. Haemmerlin-Hoffmann:
+     * Numerische Mathematik)
+     */
+    PetscReal linfty_norm () const;
 
-                                       /**
-                                        * Return the frobenius norm of the
-                                        * matrix, i.e. the square root of the
-                                        * sum of squares of all entries in the
-                                        * matrix.
-                                        */
-      PetscReal frobenius_norm () const;
+    /**
+     * Return the frobenius norm of the
+     * matrix, i.e. the square root of the
+     * sum of squares of all entries in the
+     * matrix.
+     */
+    PetscReal frobenius_norm () const;
 
 
-                                       /**
-                                        * Return the square of the norm
-                                        * of the vector $v$ with respect
-                                        * to the norm induced by this
-                                        * matrix,
-                                        * i.e. $\left(v,Mv\right)$. This
-                                        * is useful, e.g. in the finite
-                                        * element context, where the
-                                        * $L_2$ norm of a function
-                                        * equals the matrix norm with
-                                        * respect to the mass matrix of
-                                        * the vector representing the
-                                        * nodal values of the finite
-                                        * element function.
-                                        *
-                                        * Obviously, the matrix needs to
-                                        * be quadratic for this operation.
-                                        *
-                                        * The implementation of this function
-                                        * is not as efficient as the one in
-                                        * the @p MatrixBase class used in
-                                        * deal.II (i.e. the original one, not
-                                        * the PETSc wrapper class) since PETSc
-                                        * doesn't support this operation and
-                                        * needs a temporary vector.
-                                        *
-                                        * Note that if the current object
-                                        * represents a parallel distributed
-                                        * matrix (of type
-                                        * PETScWrappers::MPI::SparseMatrix),
-                                        * then the given vector has to be
-                                        * a distributed vector as
-                                        * well. Conversely, if the matrix is
-                                        * not distributed, then neither
-                                        * may the vector be.
-                                        */
-      PetscScalar matrix_norm_square (const VectorBase &v) const;
+    /**
+     * Return the square of the norm
+     * of the vector $v$ with respect
+     * to the norm induced by this
+     * matrix,
+     * i.e. $\left(v,Mv\right)$. This
+     * is useful, e.g. in the finite
+     * element context, where the
+     * $L_2$ norm of a function
+     * equals the matrix norm with
+     * respect to the mass matrix of
+     * the vector representing the
+     * nodal values of the finite
+     * element function.
+     *
+     * Obviously, the matrix needs to
+     * be quadratic for this operation.
+     *
+     * The implementation of this function
+     * is not as efficient as the one in
+     * the @p MatrixBase class used in
+     * deal.II (i.e. the original one, not
+     * the PETSc wrapper class) since PETSc
+     * doesn't support this operation and
+     * needs a temporary vector.
+     *
+     * Note that if the current object
+     * represents a parallel distributed
+     * matrix (of type
+     * PETScWrappers::MPI::SparseMatrix),
+     * then the given vector has to be
+     * a distributed vector as
+     * well. Conversely, if the matrix is
+     * not distributed, then neither
+     * may the vector be.
+     */
+    PetscScalar matrix_norm_square (const VectorBase &v) const;
 
 
-                                       /**
-                                        * Compute the matrix scalar
-                                        * product $\left(u,Mv\right)$.
-                                        *
-                                        * The implementation of this function
-                                        * is not as efficient as the one in
-                                        * the @p MatrixBase class used in
-                                        * deal.II (i.e. the original one, not
-                                        * the PETSc wrapper class) since PETSc
-                                        * doesn't support this operation and
-                                        * needs a temporary vector.
-                                        *
-                                        * Note that if the current object
-                                        * represents a parallel distributed
-                                        * matrix (of type
-                                        * PETScWrappers::MPI::SparseMatrix),
-                                        * then both vectors have to be
-                                        * distributed vectors as
-                                        * well. Conversely, if the matrix is
-                                        * not distributed, then neither of the
-                                        * vectors may be.
-                                        */
-      PetscScalar matrix_scalar_product (const VectorBase &u,
-					 const VectorBase &v) const;
+    /**
+     * Compute the matrix scalar
+     * product $\left(u,Mv\right)$.
+     *
+     * The implementation of this function
+     * is not as efficient as the one in
+     * the @p MatrixBase class used in
+     * deal.II (i.e. the original one, not
+     * the PETSc wrapper class) since PETSc
+     * doesn't support this operation and
+     * needs a temporary vector.
+     *
+     * Note that if the current object
+     * represents a parallel distributed
+     * matrix (of type
+     * PETScWrappers::MPI::SparseMatrix),
+     * then both vectors have to be
+     * distributed vectors as
+     * well. Conversely, if the matrix is
+     * not distributed, then neither of the
+     * vectors may be.
+     */
+    PetscScalar matrix_scalar_product (const VectorBase &u,
+                                       const VectorBase &v) const;
 
 
 #if DEAL_II_PETSC_VERSION_GTE(3,1,0)
-                                       /**
-                                        * Return the trace of the
-                                        * matrix, i.e. the sum of all
-                                        * diagonal entries in the
-                                        * matrix.
-                                        */
-      PetscReal trace () const;
+    /**
+     * Return the trace of the
+     * matrix, i.e. the sum of all
+     * diagonal entries in the
+     * matrix.
+     */
+    PetscReal trace () const;
 #endif
 
-                                       /**
-                                        * Multiply the entire matrix by a
-                                        * fixed factor.
-                                        */
-      MatrixBase & operator *= (const PetscScalar factor);
+    /**
+     * Multiply the entire matrix by a
+     * fixed factor.
+     */
+    MatrixBase &operator *= (const PetscScalar factor);
 
-                                       /**
-                                        * Divide the entire matrix by a
-                                        * fixed factor.
-                                        */
-      MatrixBase & operator /= (const PetscScalar factor);
+    /**
+     * Divide the entire matrix by a
+     * fixed factor.
+     */
+    MatrixBase &operator /= (const PetscScalar factor);
 
-                                       /**
-                                        * Matrix-vector multiplication:
-                                        * let <i>dst = M*src</i> with
-                                        * <i>M</i> being this matrix.
-                                        *
-                                        * Source and destination must
-                                        * not be the same vector.
-                                        *
-                                        * Note that if the current object
-                                        * represents a parallel distributed
-                                        * matrix (of type
-                                        * PETScWrappers::MPI::SparseMatrix),
-                                        * then both vectors have to be
-                                        * distributed vectors as
-                                        * well. Conversely, if the matrix is
-                                        * not distributed, then neither of the
-                                        * vectors may be.
-                                        */
-      void vmult (VectorBase       &dst,
-                  const VectorBase &src) const;
+    /**
+     * Matrix-vector multiplication:
+     * let <i>dst = M*src</i> with
+     * <i>M</i> being this matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that if the current object
+     * represents a parallel distributed
+     * matrix (of type
+     * PETScWrappers::MPI::SparseMatrix),
+     * then both vectors have to be
+     * distributed vectors as
+     * well. Conversely, if the matrix is
+     * not distributed, then neither of the
+     * vectors may be.
+     */
+    void vmult (VectorBase       &dst,
+                const VectorBase &src) const;
 
-                                       /**
-                                        * Matrix-vector multiplication: let
-                                        * <i>dst = M<sup>T</sup>*src</i> with
-                                        * <i>M</i> being this matrix. This
-                                        * function does the same as vmult()
-                                        * but takes the transposed matrix.
-                                        *
-                                        * Source and destination must
-                                        * not be the same vector.
-                                        *
-                                        * Note that if the current object
-                                        * represents a parallel distributed
-                                        * matrix (of type
-                                        * PETScWrappers::MPI::SparseMatrix),
-                                        * then both vectors have to be
-                                        * distributed vectors as
-                                        * well. Conversely, if the matrix is
-                                        * not distributed, then neither of the
-                                        * vectors may be.
-                                        */
-      void Tvmult (VectorBase       &dst,
-                   const VectorBase &src) const;
+    /**
+     * Matrix-vector multiplication: let
+     * <i>dst = M<sup>T</sup>*src</i> with
+     * <i>M</i> being this matrix. This
+     * function does the same as vmult()
+     * but takes the transposed matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that if the current object
+     * represents a parallel distributed
+     * matrix (of type
+     * PETScWrappers::MPI::SparseMatrix),
+     * then both vectors have to be
+     * distributed vectors as
+     * well. Conversely, if the matrix is
+     * not distributed, then neither of the
+     * vectors may be.
+     */
+    void Tvmult (VectorBase       &dst,
+                 const VectorBase &src) const;
 
-                                       /**
-                                        * Adding Matrix-vector
-                                        * multiplication. Add
-                                        * <i>M*src</i> on <i>dst</i>
-                                        * with <i>M</i> being this
-                                        * matrix.
-                                        *
-                                        * Source and destination must
-                                        * not be the same vector.
-                                        *
-                                        * Note that if the current object
-                                        * represents a parallel distributed
-                                        * matrix (of type
-                                        * PETScWrappers::MPI::SparseMatrix),
-                                        * then both vectors have to be
-                                        * distributed vectors as
-                                        * well. Conversely, if the matrix is
-                                        * not distributed, then neither of the
-                                        * vectors may be.
-                                        */
-      void vmult_add (VectorBase       &dst,
-                      const VectorBase &src) const;
+    /**
+     * Adding Matrix-vector
+     * multiplication. Add
+     * <i>M*src</i> on <i>dst</i>
+     * with <i>M</i> being this
+     * matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that if the current object
+     * represents a parallel distributed
+     * matrix (of type
+     * PETScWrappers::MPI::SparseMatrix),
+     * then both vectors have to be
+     * distributed vectors as
+     * well. Conversely, if the matrix is
+     * not distributed, then neither of the
+     * vectors may be.
+     */
+    void vmult_add (VectorBase       &dst,
+                    const VectorBase &src) const;
 
-                                       /**
-                                        * Adding Matrix-vector
-                                        * multiplication. Add
-                                        * <i>M<sup>T</sup>*src</i> to
-                                        * <i>dst</i> with <i>M</i> being
-                                        * this matrix. This function
-                                        * does the same as vmult_add()
-                                        * but takes the transposed
-                                        * matrix.
-                                        *
-                                        * Source and destination must
-                                        * not be the same vector.
-                                        *
-                                        * Note that if the current object
-                                        * represents a parallel distributed
-                                        * matrix (of type
-                                        * PETScWrappers::MPI::SparseMatrix),
-                                        * then both vectors have to be
-                                        * distributed vectors as
-                                        * well. Conversely, if the matrix is
-                                        * not distributed, then neither of the
-                                        * vectors may be.
-                                        */
-      void Tvmult_add (VectorBase       &dst,
-                       const VectorBase &src) const;
+    /**
+     * Adding Matrix-vector
+     * multiplication. Add
+     * <i>M<sup>T</sup>*src</i> to
+     * <i>dst</i> with <i>M</i> being
+     * this matrix. This function
+     * does the same as vmult_add()
+     * but takes the transposed
+     * matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that if the current object
+     * represents a parallel distributed
+     * matrix (of type
+     * PETScWrappers::MPI::SparseMatrix),
+     * then both vectors have to be
+     * distributed vectors as
+     * well. Conversely, if the matrix is
+     * not distributed, then neither of the
+     * vectors may be.
+     */
+    void Tvmult_add (VectorBase       &dst,
+                     const VectorBase &src) const;
 
 
-                                       /**
-                                        * Compute the residual of an
-                                        * equation <i>Mx=b</i>, where
-                                        * the residual is defined to be
-                                        * <i>r=b-Mx</i>. Write the
-                                        * residual into
-                                        * @p dst. The
-                                        * <i>l<sub>2</sub></i> norm of
-                                        * the residual vector is
-                                        * returned.
-                                        *
-                                        * Source <i>x</i> and destination
-                                        * <i>dst</i> must not be the same
-                                        * vector.
-                                        *
-                                        * Note that if the current object
-                                        * represents a parallel distributed
-                                        * matrix (of type
-                                        * PETScWrappers::MPI::SparseMatrix),
-                                        * then all vectors have to be
-                                        * distributed vectors as
-                                        * well. Conversely, if the matrix is
-                                        * not distributed, then neither of the
-                                        * vectors may be.
-                                        */
-      PetscScalar residual (VectorBase       &dst,
-                            const VectorBase &x,
-                            const VectorBase &b) const;
+    /**
+     * Compute the residual of an
+     * equation <i>Mx=b</i>, where
+     * the residual is defined to be
+     * <i>r=b-Mx</i>. Write the
+     * residual into
+     * @p dst. The
+     * <i>l<sub>2</sub></i> norm of
+     * the residual vector is
+     * returned.
+     *
+     * Source <i>x</i> and destination
+     * <i>dst</i> must not be the same
+     * vector.
+     *
+     * Note that if the current object
+     * represents a parallel distributed
+     * matrix (of type
+     * PETScWrappers::MPI::SparseMatrix),
+     * then all vectors have to be
+     * distributed vectors as
+     * well. Conversely, if the matrix is
+     * not distributed, then neither of the
+     * vectors may be.
+     */
+    PetscScalar residual (VectorBase       &dst,
+                          const VectorBase &x,
+                          const VectorBase &b) const;
 
-                                       /**
-                                        * STL-like iterator with the
-                                        * first entry.
-                                        */
-      const_iterator begin () const;
+    /**
+     * STL-like iterator with the
+     * first entry.
+     */
+    const_iterator begin () const;
 
-                                       /**
-                                        * Final iterator.
-                                        */
-      const_iterator end () const;
+    /**
+     * Final iterator.
+     */
+    const_iterator end () const;
 
-                                       /**
-                                        * STL-like iterator with the
-                                        * first entry of row @p r.
-                                        *
-                                        * Note that if the given row is empty,
-                                        * i.e. does not contain any nonzero
-                                        * entries, then the iterator returned by
-                                        * this function equals
-                                        * <tt>end(r)</tt>. Note also that the
-                                        * iterator may not be dereferencable in
-                                        * that case.
-                                        */
-      const_iterator begin (const unsigned int r) const;
+    /**
+     * STL-like iterator with the
+     * first entry of row @p r.
+     *
+     * Note that if the given row is empty,
+     * i.e. does not contain any nonzero
+     * entries, then the iterator returned by
+     * this function equals
+     * <tt>end(r)</tt>. Note also that the
+     * iterator may not be dereferencable in
+     * that case.
+     */
+    const_iterator begin (const unsigned int r) const;
 
-                                       /**
-                                        * Final iterator of row <tt>r</tt>. It
-                                        * points to the first element past the
-                                        * end of line @p r, or past the end of
-                                        * the entire sparsity pattern.
-                                        *
-                                        * Note that the end iterator is not
-                                        * necessarily dereferencable. This is in
-                                        * particular the case if it is the end
-                                        * iterator for the last row of a matrix.
-                                        */
-      const_iterator end (const unsigned int r) const;
+    /**
+     * Final iterator of row <tt>r</tt>. It
+     * points to the first element past the
+     * end of line @p r, or past the end of
+     * the entire sparsity pattern.
+     *
+     * Note that the end iterator is not
+     * necessarily dereferencable. This is in
+     * particular the case if it is the end
+     * iterator for the last row of a matrix.
+     */
+    const_iterator end (const unsigned int r) const;
 
-                                       /**
-                                        * Conversion operator to gain access
-                                        * to the underlying PETSc type. If you
-                                        * do this, you cut this class off some
-                                        * information it may need, so this
-                                        * conversion operator should only be
-                                        * used if you know what you do. In
-                                        * particular, it should only be used
-                                        * for read-only operations into the
-                                        * matrix.
-                                        */
-      operator Mat () const;
+    /**
+     * Conversion operator to gain access
+     * to the underlying PETSc type. If you
+     * do this, you cut this class off some
+     * information it may need, so this
+     * conversion operator should only be
+     * used if you know what you do. In
+     * particular, it should only be used
+     * for read-only operations into the
+     * matrix.
+     */
+    operator Mat () const;
 
-                                        /**
-                                         * Make an in-place transpose of a
-                                         * matrix.
-                                         */
-      void transpose ();
+    /**
+     * Make an in-place transpose of a
+     * matrix.
+     */
+    void transpose ();
 
-                                        /**
-                                         * Test whether a matrix is
-                                         * symmetric.  Default
-                                         * tolerance is
-                                         * $1000\times32$-bit machine
-                                         * precision.
-                                         */
+    /**
+     * Test whether a matrix is
+     * symmetric.  Default
+     * tolerance is
+     * $1000\times32$-bit machine
+     * precision.
+     */
 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
-      PetscTruth
+    PetscTruth
 #else
-        PetscBool
+    PetscBool
 #endif
-        is_symmetric (const double tolerance = 1.e-12);
+    is_symmetric (const double tolerance = 1.e-12);
 
-                                        /**
-                                         * Test whether a matrix is
-                                         * Hermitian, i.e. it is the
-                                         * complex conjugate of its
-                                         * transpose. Default
-                                         * tolerance is
-                                         * $1000\times32$-bit machine
-                                         * precision.
-                                         */
+    /**
+     * Test whether a matrix is
+     * Hermitian, i.e. it is the
+     * complex conjugate of its
+     * transpose. Default
+     * tolerance is
+     * $1000\times32$-bit machine
+     * precision.
+     */
 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
-      PetscTruth
+    PetscTruth
 #else
-        PetscBool
+    PetscBool
 #endif
-        is_hermitian (const double tolerance = 1.e-12);
+    is_hermitian (const double tolerance = 1.e-12);
 
-                                        /**
-                                         * Abstract PETSc object that helps view
-                                         * in ASCII other PETSc objects. Currently
-                                         * this function simply writes non-zero
-                                         * elements of a matrix to the terminal.
-                                         */
-      void write_ascii () const;
+    /**
+     * Abstract PETSc object that helps view
+     * in ASCII other PETSc objects. Currently
+     * this function simply writes non-zero
+     * elements of a matrix to the terminal.
+     */
+      void write_ascii () const;		// shuqiangwang
 
-                                       /**
-                                        *  Returns the number bytes consumed
-                                        *  by this matrix on this CPU.
-                                        */
-      std::size_t memory_consumption() const;
+    /**
+     *  Returns the number bytes consumed
+     *  by this matrix on this CPU.
+     */
+    std::size_t memory_consumption() const;
 
-                                       /**
-                                        * Exception
-                                        */
-      DeclException1 (ExcPETScError,
-                      int,
-                      << "An error with error number " << arg1
-                      << " occurred while calling a PETSc function");
-                                       /**
-                                        * Exception
-                                        */
-      DeclException0 (ExcSourceEqualsDestination);
+    /**
+     * Exception
+     */
+    DeclException1 (ExcPETScError,
+                    int,
+                    << "An error with error number " << arg1
+                    << " occurred while calling a PETSc function");
+    /**
+     * Exception
+     */
+    DeclException0 (ExcSourceEqualsDestination);
 
-      /**
-        * Exception.
-        */
-      DeclException2 (ExcWrongMode,
-                      int, int,
-                      << "You tried to do a "
-                      << (arg1 == 1 ?
-                          "'set'" :
-                          (arg1 == 2 ?
-                           "'add'" : "???"))
-                      << " operation but the matrix is currently in "
-                      << (arg2 == 1 ?
-                          "'set'" :
-                          (arg2 == 2 ?
-                           "'add'" : "???"))
-                      << " mode. You first have to call 'compress()'.");
+    /**
+      * Exception.
+      */
+    DeclException2 (ExcWrongMode,
+                    int, int,
+                    << "You tried to do a "
+                    << (arg1 == 1 ?
+                        "'set'" :
+                        (arg1 == 2 ?
+                         "'add'" : "???"))
+                    << " operation but the matrix is currently in "
+                    << (arg2 == 1 ?
+                        "'set'" :
+                        (arg2 == 2 ?
+                         "'add'" : "???"))
+                    << " mode. You first have to call 'compress()'.");
 
-    protected:
-                                       /**
-                                        * A generic matrix object in
-                                        * PETSc. The actual type, a sparse
-                                        * matrix, is set in the constructor.
-                                        */
-      Mat matrix;
+  protected:
+    /**
+     * A generic matrix object in
+     * PETSc. The actual type, a sparse
+     * matrix, is set in the constructor.
+     */
+    Mat matrix;
 
-                                       /**
-                                        * PETSc doesn't allow to mix additions
-                                        * to matrix entries and overwriting
-                                        * them (to make synchronisation of
-                                        * parallel computations
-                                        * simpler). Since the interface of the
-                                        * existing classes don't support the
-                                        * notion of not interleaving things,
-                                        * we have to emulate this
-                                        * ourselves. The way we do it is to,
-                                        * for each access operation, store
-                                        * whether it is an insertion or an
-                                        * addition. If the previous one was of
-                                        * different type, then we first have
-                                        * to flush the PETSc buffers;
-                                        * otherwise, we can simply go on.
-                                        *
-                                        * The following structure and variable
-                                        * declare and store the previous
-                                        * state.
-                                        */
-      struct LastAction
-      {
-          enum Values { none, insert, add };
-      };
+    /**
+     * PETSc doesn't allow to mix additions
+     * to matrix entries and overwriting
+     * them (to make synchronisation of
+     * parallel computations
+     * simpler). Since the interface of the
+     * existing classes don't support the
+     * notion of not interleaving things,
+     * we have to emulate this
+     * ourselves. The way we do it is to,
+     * for each access operation, store
+     * whether it is an insertion or an
+     * addition. If the previous one was of
+     * different type, then we first have
+     * to flush the PETSc buffers;
+     * otherwise, we can simply go on.
+     *
+     * The following structure and variable
+     * declare and store the previous
+     * state.
+     */
+    struct LastAction
+    {
+      enum Values { none, insert, add };
+    };
 
-                                       /**
-                                        * Store whether the last action was a
-                                        * write or add operation.
-                                        */
-      LastAction::Values last_action;
+    /**
+     * Store whether the last action was a
+     * write or add operation.
+     */
+    LastAction::Values last_action;
 
-                                       /**
-                                        * Ensure that the add/set mode that
-                                        * is required for actions following
-                                        * this call is compatible with the
-                                        * current mode.
-                                        * Should be called from all internal
-                                        * functions accessing matrix elements.
-                                        */
-      void prepare_action(const LastAction::Values new_action);
+    /**
+     * Ensure that the add/set mode that
+     * is required for actions following
+     * this call is compatible with the
+     * current mode.
+     * Should be called from all internal
+     * functions accessing matrix elements.
+     */
+    void prepare_action(const LastAction::Values new_action);
 
-                                       /**
-                                        * For some matrix storage
-                                        * formats, in particular for the
-                                        * PETSc distributed blockmatrices,
-                                        * set and add operations on
-                                        * individual elements can not be
-                                        * freely mixed. Rather, one has
-                                        * to synchronize operations when
-                                        * one wants to switch from
-                                        * setting elements to adding to
-                                        * elements.
-                                        * BlockMatrixBase automatically
-                                        * synchronizes the access by
-                                        * calling this helper function
-                                        * for each block.
-                                        * This function ensures that the
-                                        * matrix is in a state that
-                                        * allows adding elements; if it
-                                        * previously already was in this
-                                        * state, the function does
-                                        * nothing.
-                                        */
-      void prepare_add();
-                                       /**
-                                        * Same as prepare_add() but
-                                        * prepare the matrix for setting
-                                        * elements if the representation
-                                        * of elements in this class
-                                        * requires such an operation.
-                                        */
-      void prepare_set();
+    /**
+     * For some matrix storage
+     * formats, in particular for the
+     * PETSc distributed blockmatrices,
+     * set and add operations on
+     * individual elements can not be
+     * freely mixed. Rather, one has
+     * to synchronize operations when
+     * one wants to switch from
+     * setting elements to adding to
+     * elements.
+     * BlockMatrixBase automatically
+     * synchronizes the access by
+     * calling this helper function
+     * for each block.
+     * This function ensures that the
+     * matrix is in a state that
+     * allows adding elements; if it
+     * previously already was in this
+     * state, the function does
+     * nothing.
+     */
+    void prepare_add();
+    /**
+     * Same as prepare_add() but
+     * prepare the matrix for setting
+     * elements if the representation
+     * of elements in this class
+     * requires such an operation.
+     */
+    void prepare_set();
 
 
 
-    private:
-                                       /**
-                                        * An internal array of integer
-                                        * values that is used to store the
-                                        * column indices when
-                                        * adding/inserting local data into
-                                        * the (large) sparse matrix.
-                                        */
+  private:
+    /**
+     * An internal array of integer
+     * values that is used to store the
+     * column indices when
+     * adding/inserting local data into
+     * the (large) sparse matrix.
+     */
 #ifdef PETSC_USE_64BIT_INDICES
-      std::vector<PetscInt> column_indices;
+    std::vector<PetscInt> column_indices;
 #else
-      std::vector<int> column_indices;
+    std::vector<int> column_indices;
 #endif
 
-                                       /**
-                                        * An internal array of double values
-                                        * that is used to store the column
-                                        * indices when adding/inserting
-                                        * local data into the (large) sparse
-                                        * matrix.
-                                        */
-      std::vector<PetscScalar> column_values;
+    /**
+     * An internal array of double values
+     * that is used to store the column
+     * indices when adding/inserting
+     * local data into the (large) sparse
+     * matrix.
+     */
+    std::vector<PetscScalar> column_values;
 
 
-                                       /**
-                                        *  To allow calling protected
-                                        *  prepare_add() and
-                                        *  prepare_set().
-                                        */
-      template <class> friend class dealii::BlockMatrixBase;
+    /**
+     *  To allow calling protected
+     *  prepare_add() and
+     *  prepare_set().
+     */
+    template <class> friend class dealii::BlockMatrixBase;
 
 
 public:	// added by shuqiangwang
@@ -1314,10 +1314,10 @@
     Accessor (const MatrixBase   *matrix,
               const unsigned int  row,
               const unsigned int  index)
-                    :
-                    matrix(const_cast<MatrixBase*>(matrix)),
-                    a_row(row),
-                    a_index(index)
+      :
+      matrix(const_cast<MatrixBase *>(matrix)),
+      a_row(row),
+      a_index(index)
     {
       visit_present_row ();
     }
@@ -1364,8 +1364,8 @@
     const_iterator(const MatrixBase   *matrix,
                    const unsigned int  row,
                    const unsigned int  index)
-                    :
-                    accessor(matrix, row, index)
+      :
+      accessor(matrix, row, index)
     {}
 
 
@@ -1378,9 +1378,9 @@
 
       ++accessor.a_index;
 
-                                       // if at end of line: do one step, then
-                                       // cycle until we find a row with a
-                                       // nonzero number of entries
+      // if at end of line: do one step, then
+      // cycle until we find a row with a
+      // nonzero number of entries
       if (accessor.a_index >= accessor.colnum_cache->size())
         {
           accessor.a_index = 0;
@@ -1426,7 +1426,7 @@
     inline
     bool
     const_iterator::
-    operator == (const const_iterator& other) const
+    operator == (const const_iterator &other) const
     {
       return (accessor.a_row == other.accessor.a_row &&
               accessor.a_index == other.accessor.a_index);
@@ -1436,7 +1436,7 @@
     inline
     bool
     const_iterator::
-    operator != (const const_iterator& other) const
+    operator != (const const_iterator &other) const
     {
       return ! (*this == other);
     }
@@ -1445,7 +1445,7 @@
     inline
     bool
     const_iterator::
-    operator < (const const_iterator& other) const
+    operator < (const const_iterator &other) const
     {
       return (accessor.row() < other.accessor.row() ||
               (accessor.row() == other.accessor.row() &&
@@ -1456,13 +1456,13 @@
 
 
 
-                                        // Inline the set() and add()
-                                        // functions, since they will be
-                                        // called frequently, and the
-                                        // compiler can optimize away
-                                        // some unnecessary loops when
-                                        // the sizes are given at
-                                        // compile time.
+  // Inline the set() and add()
+  // functions, since they will be
+  // called frequently, and the
+  // compiler can optimize away
+  // some unnecessary loops when
+  // the sizes are given at
+  // compile time.
   inline
   void
   MatrixBase::set (const unsigned int i,
@@ -1516,7 +1516,7 @@
   void
   MatrixBase::set (const unsigned int               row,
                    const std::vector<unsigned int> &col_indices,
-                   const std::vector<PetscScalar>  &values,
+                   const std::vector<PetscScalar> &values,
                    const bool                       elide_zero_values)
   {
     Assert (col_indices.size() == values.size(),
@@ -1533,35 +1533,35 @@
   MatrixBase::set (const unsigned int  row,
                    const unsigned int  n_cols,
                    const unsigned int *col_indices,
-                   const PetscScalar  *values,
+                   const PetscScalar *values,
                    const bool          elide_zero_values)
   {
     prepare_action(LastAction::insert);
 
 #ifdef PETSC_USE_64BIT_INDICES
     const PetscInt petsc_i = row;
-    PetscInt * col_index_ptr;
+    PetscInt *col_index_ptr;
 #else
     const int petsc_i = row;
-    int * col_index_ptr;
+    int *col_index_ptr;
 #endif
-    PetscScalar const* col_value_ptr;
+    PetscScalar const *col_value_ptr;
     int n_columns;
 
-                                   // If we don't elide zeros, the pointers
-                                   // are already available...
+    // If we don't elide zeros, the pointers
+    // are already available...
 #ifndef PETSC_USE_64BIT_INDICES
     if (elide_zero_values == false)
       {
-        col_index_ptr = (int*)col_indices;
+        col_index_ptr = (int *)col_indices;
         col_value_ptr = values;
         n_columns = n_cols;
       }
     else
 #endif
       {
-                                   // Otherwise, extract nonzero values in
-                                   // each row and get the respective index.
+        // Otherwise, extract nonzero values in
+        // each row and get the respective index.
         if (column_indices.size() < n_cols)
           {
             column_indices.resize(n_cols);
@@ -1605,16 +1605,16 @@
 
     if (value == PetscScalar())
       {
-                                  // we have to do checkings on Insert/Add
-                                  // in any case
-                                  // to be consistent with the MPI
-                                  // communication model (see the comments
-                                  // in the documentation of
-                                  // TrilinosWrappers::Vector), but we can
-                                  // save some work if the addend is
-                                  // zero. However, these actions are done
-                                  // in case we pass on to the other
-                                  // function.
+        // we have to do checkings on Insert/Add
+        // in any case
+        // to be consistent with the MPI
+        // communication model (see the comments
+        // in the documentation of
+        // TrilinosWrappers::Vector), but we can
+        // save some work if the addend is
+        // zero. However, these actions are done
+        // in case we pass on to the other
+        // function.
         prepare_action(LastAction::add);
 
         return;
@@ -1665,7 +1665,7 @@
   void
   MatrixBase::add (const unsigned int               row,
                    const std::vector<unsigned int> &col_indices,
-                   const std::vector<PetscScalar>  &values,
+                   const std::vector<PetscScalar> &values,
                    const bool                       elide_zero_values)
   {
     Assert (col_indices.size() == values.size(),
@@ -1682,7 +1682,7 @@
   MatrixBase::add (const unsigned int  row,
                    const unsigned int  n_cols,
                    const unsigned int *col_indices,
-                   const PetscScalar  *values,
+                   const PetscScalar *values,
                    const bool          elide_zero_values,
                    const bool          /*col_indices_are_sorted*/)
   {
@@ -1690,28 +1690,28 @@
 
 #ifdef PETSC_USE_64BIT_INDICES
     const PetscInt petsc_i = row;
-    PetscInt * col_index_ptr;
+    PetscInt *col_index_ptr;
 #else
     const int petsc_i = row;
-    int * col_index_ptr;
+    int *col_index_ptr;
 #endif
-    PetscScalar const* col_value_ptr;
+    PetscScalar const *col_value_ptr;
     int n_columns;
 
-                                   // If we don't elide zeros, the pointers
-                                   // are already available...
+    // If we don't elide zeros, the pointers
+    // are already available...
 #ifndef PETSC_USE_64BIT_INDICES
     if (elide_zero_values == false)
       {
-        col_index_ptr = (int*)col_indices;
+        col_index_ptr = (int *)col_indices;
         col_value_ptr = values;
         n_columns = n_cols;
       }
     else
 #endif
       {
-                                   // Otherwise, extract nonzero values in
-                                   // each row and get the respective index.
+        // Otherwise, extract nonzero values in
+        // each row and get the respective index.
         if (column_indices.size() < n_cols)
           {
             column_indices.resize(n_cols);
@@ -1791,15 +1791,15 @@
   {
     Assert (r < m(), ExcIndexRange(r, 0, m()));
 
-                                     // place the iterator on the first entry
-                                     // past this line, or at the end of the
-                                     // matrix
+    // place the iterator on the first entry
+    // past this line, or at the end of the
+    // matrix
     for (unsigned int i=r+1; i<m(); ++i)
       if (row_length(i) > 0)
         return const_iterator(this, i, 0);
 
-                                     // if there is no such line, then take the
-                                     // end iterator of the matrix
+    // if there is no such line, then take the
+    // end iterator of the matrix
     return end();
   }
 

Modified: branches/s-wang/for_deal.II/include/deal.II/lac/petsc_parallel_block_vector.h
===================================================================
--- branches/s-wang/for_deal.II/include/deal.II/lac/petsc_parallel_block_vector.h	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/include/deal.II/lac/petsc_parallel_block_vector.h	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,5 +1,5 @@
 //---------------------------------------------------------------------------
-//    $Id: petsc_parallel_block_vector.h 25345 2012-03-31 08:37:04Z bangerth $
+//    $Id: petsc_parallel_block_vector.h 27628 2012-11-20 22:49:26Z heister $
 //
 //    Copyright (C) 2004, 2005, 2006, 2007, 2009, 2010, 2012 by the deal.II authors
 //
@@ -27,307 +27,307 @@
 
 namespace PETScWrappers
 {
-                                   // forward declaration
+  // forward declaration
   class BlockVector;
 
   namespace MPI
   {
 
-/*! @addtogroup PETScWrappers
- *@{
- */
+    /*! @addtogroup PETScWrappers
+     *@{
+     */
 
-/**
- * An implementation of block vectors based on the parallel vector class
- * implemented in PETScWrappers. While the base class provides for most of the
- * interface, this class handles the actual allocation of vectors and provides
- * functions that are specific to the underlying vector type.
- *
- * The model of distribution of data is such that each of the blocks is
- * distributed across all MPI processes named in the MPI communicator. I.e. we
- * don't just distribute the whole vector, but each component. In the
- * constructors and reinit() functions, one therefore not only has to specify
- * the sizes of the individual blocks, but also the number of elements of each
- * of these blocks to be stored on the local process.
- *
- * @ingroup Vectors
- * @see @ref GlossBlockLA "Block (linear algebra)"
- * @author Wolfgang Bangerth, 2004
- */
+    /**
+     * An implementation of block vectors based on the parallel vector class
+     * implemented in PETScWrappers. While the base class provides for most of the
+     * interface, this class handles the actual allocation of vectors and provides
+     * functions that are specific to the underlying vector type.
+     *
+     * The model of distribution of data is such that each of the blocks is
+     * distributed across all MPI processes named in the MPI communicator. I.e. we
+     * don't just distribute the whole vector, but each component. In the
+     * constructors and reinit() functions, one therefore not only has to specify
+     * the sizes of the individual blocks, but also the number of elements of each
+     * of these blocks to be stored on the local process.
+     *
+     * @ingroup Vectors
+     * @see @ref GlossBlockLA "Block (linear algebra)"
+     * @author Wolfgang Bangerth, 2004
+     */
     class BlockVector : public BlockVectorBase<Vector>
     {
-      public:
-                                         /**
-                                          * Typedef the base class for simpler
-                                          * access to its own typedefs.
-                                          */
-        typedef BlockVectorBase<Vector> BaseClass;
+    public:
+      /**
+       * Typedef the base class for simpler
+       * access to its own typedefs.
+       */
+      typedef BlockVectorBase<Vector> BaseClass;
 
-                                         /**
-                                          * Typedef the type of the underlying
-                                          * vector.
-                                          */
-        typedef BaseClass::BlockType  BlockType;
+      /**
+       * Typedef the type of the underlying
+       * vector.
+       */
+      typedef BaseClass::BlockType  BlockType;
 
-                                         /**
-                                          * Import the typedefs from the base
-                                          * class.
-                                          */
-        typedef BaseClass::value_type      value_type;
-        typedef BaseClass::pointer         pointer;
-        typedef BaseClass::const_pointer   const_pointer;
-        typedef BaseClass::reference       reference;
-        typedef BaseClass::const_reference const_reference;
-        typedef BaseClass::size_type       size_type;
-        typedef BaseClass::iterator        iterator;
-        typedef BaseClass::const_iterator  const_iterator;
+      /**
+       * Import the typedefs from the base
+       * class.
+       */
+      typedef BaseClass::value_type      value_type;
+      typedef BaseClass::pointer         pointer;
+      typedef BaseClass::const_pointer   const_pointer;
+      typedef BaseClass::reference       reference;
+      typedef BaseClass::const_reference const_reference;
+      typedef BaseClass::size_type       size_type;
+      typedef BaseClass::iterator        iterator;
+      typedef BaseClass::const_iterator  const_iterator;
 
-                                         /**
-                                          * Default constructor. Generate an
-                                          * empty vector without any blocks.
-                                          */
-        BlockVector ();
+      /**
+       * Default constructor. Generate an
+       * empty vector without any blocks.
+       */
+      BlockVector ();
 
-                                         /**
-                                          *  Constructor. Generate a block
-                                          *  vector with @p n_blocks blocks,
-                                          *  each of which is a parallel
-                                          *  vector across @p communicator
-                                          *  with @p block_size elements of
-                                          *  which @p local_size elements are
-                                          *  stored on the present process.
-                                          */
-        explicit BlockVector (const unsigned int  n_blocks,
-                              const MPI_Comm     &communicator,
-                              const unsigned int  block_size,
-                              const unsigned int  local_size);
+      /**
+       *  Constructor. Generate a block
+       *  vector with @p n_blocks blocks,
+       *  each of which is a parallel
+       *  vector across @p communicator
+       *  with @p block_size elements of
+       *  which @p local_size elements are
+       *  stored on the present process.
+       */
+      explicit BlockVector (const unsigned int  n_blocks,
+                            const MPI_Comm     &communicator,
+                            const unsigned int  block_size,
+                            const unsigned int  local_size);
 
-                                         /**
-                                          * Copy-Constructor. Set all the
-                                          * properties of the parallel vector
-                                          * to those of the given argument and
-                                          * copy the elements.
-                                          */
-        BlockVector (const BlockVector  &V);
+      /**
+       * Copy-Constructor. Set all the
+       * properties of the parallel vector
+       * to those of the given argument and
+       * copy the elements.
+       */
+      BlockVector (const BlockVector &V);
 
-                                         /**
-                                          * Constructor. Set the number of
-                                          * blocks to
-                                          * <tt>block_sizes.size()</tt> and
-                                          * initialize each block with
-                                          * <tt>block_sizes[i]</tt> zero
-                                          * elements. The individual blocks
-                                          * are distributed across the given
-                                          * communicator, and each store
-                                          * <tt>local_elements[i]</tt>
-                                          * elements on the present process.
-                                          */
-        BlockVector (const std::vector<unsigned int> &block_sizes,
-                     const MPI_Comm                  &communicator,
-                     const std::vector<unsigned int> &local_elements);
+      /**
+       * Constructor. Set the number of
+       * blocks to
+       * <tt>block_sizes.size()</tt> and
+       * initialize each block with
+       * <tt>block_sizes[i]</tt> zero
+       * elements. The individual blocks
+       * are distributed across the given
+       * communicator, and each store
+       * <tt>local_elements[i]</tt>
+       * elements on the present process.
+       */
+      BlockVector (const std::vector<unsigned int> &block_sizes,
+                   const MPI_Comm                  &communicator,
+                   const std::vector<unsigned int> &local_elements);
 
-                                         /**
-                                          * Destructor. Clears memory
-                                          */
-        ~BlockVector ();
+      /**
+       * Destructor. Clears memory
+       */
+      ~BlockVector ();
 
-                                         /**
-                                          * Copy operator: fill all components
-                                          * of the vector that are locally
-                                          * stored with the given scalar value.
-                                          */
-        BlockVector & operator = (const value_type s);
+      /**
+       * Copy operator: fill all components
+       * of the vector that are locally
+       * stored with the given scalar value.
+       */
+      BlockVector &operator = (const value_type s);
 
-                                         /**
-                                          * Copy operator for arguments of the
-                                          * same type.
-                                          */
-        BlockVector &
-        operator= (const BlockVector &V);
+      /**
+       * Copy operator for arguments of the
+       * same type.
+       */
+      BlockVector &
+      operator= (const BlockVector &V);
 
-                                         /**
-                                          * Copy the given sequential
-                                          * (non-distributed) block vector
-                                          * into the present parallel block
-                                          * vector. It is assumed that they
-                                          * have the same size, and this
-                                          * operation does not change the
-                                          * partitioning of the parallel
-                                          * vectors by which its elements are
-                                          * distributed across several MPI
-                                          * processes. What this operation
-                                          * therefore does is to copy that
-                                          * chunk of the given vector @p v
-                                          * that corresponds to elements of
-                                          * the target vector that are stored
-                                          * locally, and copies them, for each
-                                          * of the individual blocks of this
-                                          * object. Elements that are not
-                                          * stored locally are not touched.
-                                          *
-                                          * This being a parallel vector, you
-                                          * must make sure that @em all
-                                          * processes call this function at
-                                          * the same time. It is not possible
-                                          * to change the local part of a
-                                          * parallel vector on only one
-                                          * process, independent of what other
-                                          * processes do, with this function.
-                                          */
-        BlockVector &
-        operator = (const PETScWrappers::BlockVector &v);
+      /**
+       * Copy the given sequential
+       * (non-distributed) block vector
+       * into the present parallel block
+       * vector. It is assumed that they
+       * have the same size, and this
+       * operation does not change the
+       * partitioning of the parallel
+       * vectors by which its elements are
+       * distributed across several MPI
+       * processes. What this operation
+       * therefore does is to copy that
+       * chunk of the given vector @p v
+       * that corresponds to elements of
+       * the target vector that are stored
+       * locally, and copies them, for each
+       * of the individual blocks of this
+       * object. Elements that are not
+       * stored locally are not touched.
+       *
+       * This being a parallel vector, you
+       * must make sure that @em all
+       * processes call this function at
+       * the same time. It is not possible
+       * to change the local part of a
+       * parallel vector on only one
+       * process, independent of what other
+       * processes do, with this function.
+       */
+      BlockVector &
+      operator = (const PETScWrappers::BlockVector &v);
 
-                                         /**
-                                          * Reinitialize the BlockVector to
-                                          * contain @p n_blocks of size @p
-                                          * block_size, each of which stores
-                                          * @p local_size elements
-                                          * locally. The @p communicator
-                                          * argument denotes which MPI channel
-                                          * each of these blocks shall
-                                          * communicate.
-                                          *
-                                          * If <tt>fast==false</tt>, the vector
-                                          * is filled with zeros.
-                                          */
-        void reinit (const unsigned int  n_blocks,
-                     const MPI_Comm     &communicator,
-                     const unsigned int  block_size,
-                     const unsigned int  local_size,
-                     const bool fast = false);
+      /**
+       * Reinitialize the BlockVector to
+       * contain @p n_blocks of size @p
+       * block_size, each of which stores
+       * @p local_size elements
+       * locally. The @p communicator
+       * argument denotes which MPI channel
+       * each of these blocks shall
+       * communicate.
+       *
+       * If <tt>fast==false</tt>, the vector
+       * is filled with zeros.
+       */
+      void reinit (const unsigned int  n_blocks,
+                   const MPI_Comm     &communicator,
+                   const unsigned int  block_size,
+                   const unsigned int  local_size,
+                   const bool fast = false);
 
-                                         /**
-                                          * Reinitialize the BlockVector such
-                                          * that it contains
-                                          * <tt>block_sizes.size()</tt>
-                                          * blocks. Each block is
-                                          * reinitialized to dimension
-                                          * <tt>block_sizes[i]</tt>. Each of
-                                          * them stores
-                                          * <tt>local_sizes[i]</tt> elements
-                                          * on the present process.
-                                          *
-                                          * If the number of blocks is the
-                                          * same as before this function
-                                          * was called, all vectors remain
-                                          * the same and reinit() is
-                                          * called for each vector.
-                                          *
-                                          * If <tt>fast==false</tt>, the vector
-                                          * is filled with zeros.
-                                          *
-                                          * Note that you must call this
-                                          * (or the other reinit()
-                                          * functions) function, rather
-                                          * than calling the reinit()
-                                          * functions of an individual
-                                          * block, to allow the block
-                                          * vector to update its caches of
-                                          * vector sizes. If you call
-                                          * reinit() of one of the
-                                          * blocks, then subsequent
-                                          * actions on this object may
-                                          * yield unpredictable results
-                                          * since they may be routed to
-                                          * the wrong block.
-                                          */
-        void reinit (const std::vector<unsigned int> &block_sizes,
-                     const MPI_Comm                  &communicator,
-                     const std::vector<unsigned int> &local_sizes,
-                     const bool                       fast=false);
+      /**
+       * Reinitialize the BlockVector such
+       * that it contains
+       * <tt>block_sizes.size()</tt>
+       * blocks. Each block is
+       * reinitialized to dimension
+       * <tt>block_sizes[i]</tt>. Each of
+       * them stores
+       * <tt>local_sizes[i]</tt> elements
+       * on the present process.
+       *
+       * If the number of blocks is the
+       * same as before this function
+       * was called, all vectors remain
+       * the same and reinit() is
+       * called for each vector.
+       *
+       * If <tt>fast==false</tt>, the vector
+       * is filled with zeros.
+       *
+       * Note that you must call this
+       * (or the other reinit()
+       * functions) function, rather
+       * than calling the reinit()
+       * functions of an individual
+       * block, to allow the block
+       * vector to update its caches of
+       * vector sizes. If you call
+       * reinit() of one of the
+       * blocks, then subsequent
+       * actions on this object may
+       * yield unpredictable results
+       * since they may be routed to
+       * the wrong block.
+       */
+      void reinit (const std::vector<unsigned int> &block_sizes,
+                   const MPI_Comm                  &communicator,
+                   const std::vector<unsigned int> &local_sizes,
+                   const bool                       fast=false);
 
         void reinit (const std::vector<unsigned int> &block_sizes,
         		const MPI_Comm                  &communicator);				// added by shuqiangwang
 
-                                         /**
-                                          * Change the dimension to that
-                                          * of the vector <tt>V</tt>. The same
-                                          * applies as for the other
-                                          * reinit() function.
-                                          *
-                                          * The elements of <tt>V</tt> are not
-                                          * copied, i.e.  this function is
-                                          * the same as calling <tt>reinit
-                                          * (V.size(), fast)</tt>.
-                                          *
-                                          * Note that you must call this
-                                          * (or the other reinit()
-                                          * functions) function, rather
-                                          * than calling the reinit()
-                                          * functions of an individual
-                                          * block, to allow the block
-                                          * vector to update its caches of
-                                          * vector sizes. If you call
-                                          * reinit() on one of the
-                                          * blocks, then subsequent
-                                          * actions on this object may
-                                          * yield unpredictable results
-                                          * since they may be routed to
-                                          * the wrong block.
-                                          */
-        void reinit (const BlockVector &V,
-                     const bool         fast=false);
+      /**
+       * Change the dimension to that
+       * of the vector <tt>V</tt>. The same
+       * applies as for the other
+       * reinit() function.
+       *
+       * The elements of <tt>V</tt> are not
+       * copied, i.e.  this function is
+       * the same as calling <tt>reinit
+       * (V.size(), fast)</tt>.
+       *
+       * Note that you must call this
+       * (or the other reinit()
+       * functions) function, rather
+       * than calling the reinit()
+       * functions of an individual
+       * block, to allow the block
+       * vector to update its caches of
+       * vector sizes. If you call
+       * reinit() on one of the
+       * blocks, then subsequent
+       * actions on this object may
+       * yield unpredictable results
+       * since they may be routed to
+       * the wrong block.
+       */
+      void reinit (const BlockVector &V,
+                   const bool         fast=false);
 
-                                         /**
-                                          * Return a reference to the MPI
-                                          * communicator object in use with
-                                          * this vector.
-                                          */
-        const MPI_Comm & get_mpi_communicator () const;
+      /**
+       * Return a reference to the MPI
+       * communicator object in use with
+       * this vector.
+       */
+      const MPI_Comm &get_mpi_communicator () const;
 
-                                         /**
-                                          * Swap the contents of this
-                                          * vector and the other vector
-                                          * <tt>v</tt>. One could do this
-                                          * operation with a temporary
-                                          * variable and copying over the
-                                          * data elements, but this
-                                          * function is significantly more
-                                          * efficient since it only swaps
-                                          * the pointers to the data of
-                                          * the two vectors and therefore
-                                          * does not need to allocate
-                                          * temporary storage and move
-                                          * data around.
-                                          *
-                                          * Limitation: right now this
-                                          * function only works if both
-                                          * vectors have the same number
-                                          * of blocks. If needed, the
-                                          * numbers of blocks should be
-                                          * exchanged, too.
-                                          *
-                                          * This function is analog to the
-                                          * the swap() function of all C++
-                                          * standard containers. Also,
-                                          * there is a global function
-                                          * swap(u,v) that simply calls
-                                          * <tt>u.swap(v)</tt>, again in analogy
-                                          * to standard functions.
-                                          */
-        void swap (BlockVector &v);
+      /**
+       * Swap the contents of this
+       * vector and the other vector
+       * <tt>v</tt>. One could do this
+       * operation with a temporary
+       * variable and copying over the
+       * data elements, but this
+       * function is significantly more
+       * efficient since it only swaps
+       * the pointers to the data of
+       * the two vectors and therefore
+       * does not need to allocate
+       * temporary storage and move
+       * data around.
+       *
+       * Limitation: right now this
+       * function only works if both
+       * vectors have the same number
+       * of blocks. If needed, the
+       * numbers of blocks should be
+       * exchanged, too.
+       *
+       * This function is analog to the
+       * the swap() function of all C++
+       * standard containers. Also,
+       * there is a global function
+       * swap(u,v) that simply calls
+       * <tt>u.swap(v)</tt>, again in analogy
+       * to standard functions.
+       */
+      void swap (BlockVector &v);
 
-                                         /**
-                                          * Print to a stream.
-                                          */
-        void print (std::ostream       &out,
-                    const unsigned int  precision = 3,
-                    const bool          scientific = true,
-                    const bool          across = true) const;
+      /**
+       * Print to a stream.
+       */
+      void print (std::ostream       &out,
+                  const unsigned int  precision = 3,
+                  const bool          scientific = true,
+                  const bool          across = true) const;
 
-                                         /**
-                                          * Exception
-                                          */
-        DeclException0 (ExcIteratorRangeDoesNotMatchVectorSize);
-                                         /**
-                                          * Exception
-                                          */
-        DeclException0 (ExcNonMatchingBlockVectors);
+      /**
+       * Exception
+       */
+      DeclException0 (ExcIteratorRangeDoesNotMatchVectorSize);
+      /**
+       * Exception
+       */
+      DeclException0 (ExcNonMatchingBlockVectors);
     };
 
-/*@}*/
+    /*@}*/
 
-/*----------------------- Inline functions ----------------------------------*/
+    /*----------------------- Inline functions ----------------------------------*/
 
 
     inline
@@ -357,9 +357,9 @@
 
 
     inline
-    BlockVector::BlockVector (const BlockVector& v)
-                    :
-                    BlockVectorBase<Vector > ()
+    BlockVector::BlockVector (const BlockVector &v)
+      :
+      BlockVectorBase<Vector > ()
     {
       this->components.resize (v.n_blocks());
       this->block_indices = v.block_indices;
@@ -426,7 +426,7 @@
 
       for (unsigned int i=0; i<this->n_blocks(); ++i)
         this->components[i].reinit(communicator, block_sizes[i],
-                             local_sizes[i], fast);
+                                   local_sizes[i], fast);
 
       collect_sizes();     // shuqiangwang
     }
@@ -445,14 +445,14 @@
 
     inline
     void
-    BlockVector::reinit (const BlockVector& v,
+    BlockVector::reinit (const BlockVector &v,
                          const bool fast)
     {
       this->block_indices = v.get_block_indices();
       if (this->components.size() != this->n_blocks())
         this->components.resize(this->n_blocks());
 
-      for (unsigned int i=0;i<this->n_blocks();++i)
+      for (unsigned int i=0; i<this->n_blocks(); ++i)
         block(i).reinit(v.block(i), fast);
 
       collect_sizes();     // shuqiangwang
@@ -490,7 +490,7 @@
                         const bool          scientific,
                         const bool          across) const
     {
-      for (unsigned int i=0;i<this->n_blocks();++i)
+      for (unsigned int i=0; i<this->n_blocks(); ++i)
         {
           if (across)
             out << 'C' << i << ':';
@@ -502,14 +502,14 @@
 
 
 
-/**
- * Global function which overloads the default implementation
- * of the C++ standard library which uses a temporary object. The
- * function simply exchanges the data of the two vectors.
- *
- * @relates PETScWrappers::MPI::BlockVector
- * @author Wolfgang Bangerth, 2000
- */
+    /**
+     * Global function which overloads the default implementation
+     * of the C++ standard library which uses a temporary object. The
+     * function simply exchanges the data of the two vectors.
+     *
+     * @relates PETScWrappers::MPI::BlockVector
+     * @author Wolfgang Bangerth, 2000
+     */
     inline
     void swap (BlockVector &u,
                BlockVector &v)

Added: branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_sparse_matrix.h
===================================================================
--- branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_sparse_matrix.h	                        (rev 0)
+++ branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_sparse_matrix.h	2012-11-28 19:03:50 UTC (rev 1392)
@@ -0,0 +1,3483 @@
+//---------------------------------------------------------------------------
+//    $Id: trilinos_sparse_matrix.h 27628 2012-11-20 22:49:26Z heister $
+//
+//    Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+#ifndef __deal2__trilinos_sparse_matrix_h
+#define __deal2__trilinos_sparse_matrix_h
+
+
+#include <deal.II/base/config.h>
+
+#ifdef DEAL_II_USE_TRILINOS
+
+#  include <deal.II/base/std_cxx1x/shared_ptr.h>
+#  include <deal.II/base/subscriptor.h>
+#  include <deal.II/base/index_set.h>
+#  include <deal.II/lac/full_matrix.h>
+#  include <deal.II/lac/exceptions.h>
+#  include <deal.II/lac/trilinos_vector_base.h>
+#  include <deal.II/lac/parallel_vector.h>
+
+#  include <vector>
+#  include <cmath>
+#  include <memory>
+
+#  define TrilinosScalar double
+#  include <Epetra_FECrsMatrix.h>
+#  include <Epetra_Map.h>
+#  include <Epetra_CrsGraph.h>
+#  include <Epetra_Vector.h>
+#  ifdef DEAL_II_COMPILER_SUPPORTS_MPI
+#    include <Epetra_MpiComm.h>
+#    include "mpi.h"
+#  else
+#    include "Epetra_SerialComm.h"
+#  endif
+
+DEAL_II_NAMESPACE_OPEN
+
+// forward declarations
+template <typename MatrixType> class BlockMatrixBase;
+
+template <typename number> class SparseMatrix;
+class SparsityPattern;
+
+namespace TrilinosWrappers
+{
+  // forward declarations
+  class VectorBase;
+  class SparseMatrix;
+  class SparsityPattern;
+
+  /**
+   * Iterators for Trilinos matrices
+   */
+  namespace MatrixIterators
+  {
+    /**
+     * STL conforming iterator. This class acts as an iterator walking
+     * over the elements of Trilinos matrices. The implementation of this
+     * class is similar to the one for PETSc matrices.
+     *
+     * Note that Trilinos stores the elements within each row in ascending
+     * order. This is opposed to the deal.II sparse matrix style where the
+     * diagonal element (if it exists) is stored before all other values, and
+     * the PETSc sparse matrices, where one can't guarantee a certain order of
+     * the elements.
+     *
+     * @ingroup TrilinosWrappers
+     * @author Martin Kronbichler, Wolfgang Bangerth, 2008
+     */
+    class const_iterator
+    {
+    private:
+      /**
+       * Accessor class for iterators
+       */
+      class Accessor
+      {
+      public:
+        /**
+         * Constructor. Since we use
+         * accessors only for read
+         * access, a const matrix
+         * pointer is sufficient.
+         */
+        Accessor (const SparseMatrix *matrix,
+                  const unsigned int  row,
+                  const unsigned int  index);
+
+        /**
+         * Row number of the element
+         * represented by this object.
+         */
+        unsigned int row() const;
+
+        /**
+         * Index in row of the element
+         * represented by this object.
+         */
+        unsigned int index() const;
+
+        /**
+         * Column number of the element
+         * represented by this object.
+         */
+        unsigned int column() const;
+
+        /**
+         * Value of this matrix entry.
+         */
+        TrilinosScalar value() const;
+
+        /**
+         * Exception
+         */
+        DeclException0 (ExcBeyondEndOfMatrix);
+
+        /**
+         * Exception
+         */
+        DeclException3 (ExcAccessToNonlocalRow,
+                        int, int, int,
+                        << "You tried to access row " << arg1
+                        << " of a distributed matrix, but only rows "
+                        << arg2 << " through " << arg3
+                        << " are stored locally and can be accessed.");
+
+      private:
+        /**
+         * The matrix accessed.
+         */
+        mutable SparseMatrix *matrix;
+
+        /**
+         * Current row number.
+         */
+        unsigned int a_row;
+
+        /**
+         * Current index in row.
+         */
+        unsigned int a_index;
+
+        /**
+         * Cache where we store the
+         * column indices of the
+         * present row. This is
+         * necessary, since Trilinos
+         * makes access to the elements
+         * of its matrices rather hard,
+         * and it is much more
+         * efficient to copy all column
+         * entries of a row once when
+         * we enter it than repeatedly
+         * asking Trilinos for
+         * individual ones. This also
+         * makes some sense since it is
+         * likely that we will access
+         * them sequentially anyway.
+         *
+         * In order to make copying of
+         * iterators/accessor of
+         * acceptable performance, we
+         * keep a shared pointer to
+         * these entries so that more
+         * than one accessor can access
+         * this data if necessary.
+         */
+        std_cxx1x::shared_ptr<std::vector<unsigned int> > colnum_cache;
+
+        /**
+         * Similar cache for the values
+         * of this row.
+         */
+        std_cxx1x::shared_ptr<std::vector<TrilinosScalar> > value_cache;
+
+        /**
+         * Discard the old row caches
+         * (they may still be used by
+         * other accessors) and
+         * generate new ones for the
+         * row pointed to presently by
+         * this accessor.
+         */
+        void visit_present_row ();
+
+        /**
+         * Make enclosing class a
+         * friend.
+         */
+        friend class const_iterator;
+      };
+
+    public:
+
+      /**
+       * Constructor. Create an
+       * iterator into the matrix @p
+       * matrix for the given row and
+       * the index within it.
+       */
+      const_iterator (const SparseMatrix *matrix,
+                      const unsigned int  row,
+                      const unsigned int  index);
+
+      /**
+       * Prefix increment.
+       */
+      const_iterator &operator++ ();
+
+      /**
+       * Postfix increment.
+       */
+      const_iterator operator++ (int);
+
+      /**
+       * Dereferencing operator.
+       */
+      const Accessor &operator* () const;
+
+      /**
+       * Dereferencing operator.
+       */
+      const Accessor *operator-> () const;
+
+      /**
+       * Comparison. True, if both
+       * iterators point to the same
+       * matrix position.
+       */
+      bool operator == (const const_iterator &) const;
+
+      /**
+       * Inverse of <tt>==</tt>.
+       */
+      bool operator != (const const_iterator &) const;
+
+      /**
+       * Comparison operator. Result
+       * is true if either the first
+       * row number is smaller or if
+       * the row numbers are equal
+       * and the first index is
+       * smaller.
+       */
+      bool operator < (const const_iterator &) const;
+
+      /**
+       * Exception
+       */
+      DeclException2 (ExcInvalidIndexWithinRow,
+                      int, int,
+                      << "Attempt to access element " << arg2
+                      << " of row " << arg1
+                      << " which doesn't have that many elements.");
+
+    private:
+      /**
+       * Store an object of the
+       * accessor class.
+       */
+      Accessor accessor;
+    };
+
+  }
+
+
+  /**
+   * This class implements a wrapper to use the Trilinos distributed
+   * sparse matrix class Epetra_FECrsMatrix. This is precisely the kind of
+   * matrix we deal with all the time - we most likely get it from some
+   * assembly process, where also entries not locally owned might need to
+   * be written and hence need to be forwarded to the owner process.  This
+   * class is designed to be used in a distributed memory architecture
+   * with an MPI compiler on the bottom, but works equally well also for
+   * serial processes. The only requirement for this class to work is that
+   * Trilinos has been installed with the same compiler as is used for
+   * generating deal.II.
+   *
+   * The interface of this class is modeled after the existing
+   * SparseMatrix class in deal.II. It has almost the same member
+   * functions, and is often exchangable. However, since Trilinos only
+   * supports a single scalar type (double), it is not templated, and only
+   * works with doubles.
+   *
+   * Note that Trilinos only guarantees that operations do what you expect
+   * if the functions @p GlobalAssemble has been called after matrix
+   * assembly.  Therefore, you need to call SparseMatrix::compress()
+   * before you actually use the matrix. This also calls @p FillComplete
+   * that compresses the storage format for sparse matrices by discarding
+   * unused elements. Trilinos allows to continue with assembling the
+   * matrix after calls to these functions, though.
+   *
+   * @ingroup TrilinosWrappers
+   * @ingroup Matrix1
+   * @author Martin Kronbichler, Wolfgang Bangerth, 2008, 2009
+   */
+  class SparseMatrix : public Subscriptor
+  {
+  public:
+    /**
+     * A structure that describes
+     * some of the traits of this
+     * class in terms of its run-time
+     * behavior. Some other classes
+     * (such as the block matrix
+     * classes) that take one or
+     * other of the matrix classes as
+     * its template parameters can
+     * tune their behavior based on
+     * the variables in this class.
+     */
+    struct Traits
+    {
+      /**
+       * It is safe to elide additions
+       * of zeros to individual
+       * elements of this matrix.
+       */
+      static const bool zero_addition_can_be_elided = true;
+    };
+
+    /**
+     * Declare a typedef for the
+     * iterator class.
+     */
+    typedef MatrixIterators::const_iterator const_iterator;
+
+    /**
+     * Declare a typedef in analogy
+     * to all the other container
+     * classes.
+     */
+    typedef TrilinosScalar value_type;
+
+    /**
+     * @name Constructors and initalization.
+     */
+//@{
+    /**
+     * Default constructor. Generates
+     * an empty (zero-size) matrix.
+     */
+    SparseMatrix ();
+
+    /**
+     * Generate a matrix that is completely
+     * stored locally, having #m rows and
+     * #n columns.
+     *
+     * The number of columns entries per
+     * row is specified as the maximum
+     * number of entries argument.
+     */
+    SparseMatrix (const unsigned int  m,
+                  const unsigned int  n,
+                  const unsigned int  n_max_entries_per_row);
+
+    /**
+     * Generate a matrix that is completely
+     * stored locally, having #m rows and
+     * #n columns.
+     *
+     * The vector
+     * <tt>n_entries_per_row</tt>
+     * specifies the number of entries in
+     * each row.
+     */
+    SparseMatrix (const unsigned int               m,
+                  const unsigned int               n,
+                  const std::vector<unsigned int> &n_entries_per_row);
+
+    /**
+     * Generate a matrix from a Trilinos
+     * sparsity pattern object.
+     */
+    SparseMatrix (const SparsityPattern &InputSparsityPattern);
+
+    /**
+     * Copy constructor. Sets the
+     * calling matrix to be the same
+     * as the input matrix, i.e.,
+     * using the same sparsity
+     * pattern and entries.
+     */
+    SparseMatrix (const SparseMatrix &InputMatrix);
+
+    /**
+     * Destructor. Made virtual so
+     * that one can use pointers to
+     * this class.
+     */
+    virtual ~SparseMatrix ();
+
+    /**
+     * This function initializes the
+     * Trilinos matrix with a deal.II
+     * sparsity pattern, i.e. it makes
+     * the Trilinos Epetra matrix know
+     * the position of nonzero entries
+     * according to the sparsity
+     * pattern. This function is meant
+     * for use in serial programs, where
+     * there is no need to specify how
+     * the matrix is going to be
+     * distributed among different
+     * processors. This function works in
+     * %parallel, too, but it is
+     * recommended to manually specify
+     * the %parallel partioning of the
+     * matrix using an Epetra_Map. When
+     * run in %parallel, it is currently
+     * necessary that each processor
+     * holds the sparsity_pattern
+     * structure because each processor
+     * sets its rows.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template<typename SparsityType>
+    void reinit (const SparsityType &sparsity_pattern);
+
+    /**
+     * This function reinitializes the
+     * Trilinos sparse matrix from a
+     * (possibly distributed) Trilinos
+     * sparsity pattern.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    void reinit (const SparsityPattern &sparsity_pattern);
+
+    /**
+     * This function copies the content
+     * in <tt>sparse_matrix</tt> to the
+     * calling matrix.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    void reinit (const SparseMatrix &sparse_matrix);
+
+    /**
+     * This function initializes the
+     * Trilinos matrix using the deal.II
+     * sparse matrix and the entries
+     * stored therein. It uses a
+     * threshold to copy only elements
+     * with modulus larger than the
+     * threshold (so zeros in the deal.II
+     * matrix can be filtered away).
+     *
+     * The optional parameter
+     * <tt>copy_values</tt> decides
+     * whether only the sparsity
+     * structure of the input matrix
+     * should be used or the matrix
+     * entries should be copied, too.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template <typename number>
+    void reinit (const ::dealii::SparseMatrix<number> &dealii_sparse_matrix,
+                 const double                          drop_tolerance=1e-13,
+                 const bool                            copy_values=true,
+                 const ::dealii::SparsityPattern      *use_this_sparsity=0);
+
+    /**
+     * This reinit function takes as
+     * input a Trilinos Epetra_CrsMatrix
+     * and copies its sparsity
+     * pattern. If so requested, even the
+     * content (values) will be copied.
+     */
+    void reinit (const Epetra_CrsMatrix &input_matrix,
+                 const bool              copy_values = true);
+//@}
+    /**
+     * @name Constructors and initialization using an Epetra_Map description
+     */
+//@{
+    /**
+     * Constructor using an Epetra_Map to
+     * describe the %parallel
+     * partitioning. The parameter @p
+     * n_max_entries_per_row sets the
+     * number of nonzero entries in each
+     * row that will be allocated. Note
+     * that this number does not need to
+     * be exact, and it is even allowed
+     * that the actual matrix structure
+     * has more nonzero entries than
+     * specified in the
+     * constructor. However it is still
+     * advantageous to provide good
+     * estimates here since this will
+     * considerably increase the
+     * performance of the matrix
+     * setup. However, there is no effect
+     * in the performance of
+     * matrix-vector products, since
+     * Trilinos reorganizes the matrix
+     * memory prior to use (in the
+     * compress() step).
+     */
+    SparseMatrix (const Epetra_Map   &parallel_partitioning,
+                  const unsigned int  n_max_entries_per_row = 0);
+
+    /**
+     * Same as before, but now set a
+     * value of nonzeros for each matrix
+     * row. Since we know the number of
+     * elements in the matrix exactly in
+     * this case, we can already allocate
+     * the right amount of memory, which
+     * makes the creation process
+     * including the insertion of nonzero
+     * elements by the respective
+     * SparseMatrix::reinit call
+     * considerably faster.
+     */
+    SparseMatrix (const Epetra_Map                &parallel_partitioning,
+                  const std::vector<unsigned int> &n_entries_per_row);
+
+    /**
+     * This constructor is similar to the
+     * one above, but it now takes two
+     * different Epetra maps for rows and
+     * columns. This interface is meant
+     * to be used for generating
+     * rectangular matrices, where one
+     * map describes the %parallel
+     * partitioning of the dofs
+     * associated with the matrix rows
+     * and the other one the partitioning
+     * of dofs in the matrix
+     * columns. Note that there is no
+     * real parallelism along the columns
+     * &ndash; the processor that owns a
+     * certain row always owns all the
+     * column elements, no matter how far
+     * they might be spread out. The
+     * second Epetra_Map is only used to
+     * specify the number of columns and
+     * for internal arragements when
+     * doing matrix-vector products with
+     * vectors based on that column map.
+     *
+     * The integer input @p
+     * n_max_entries_per_row defines the
+     * number of columns entries per row
+     * that will be allocated.
+     */
+    SparseMatrix (const Epetra_Map   &row_parallel_partitioning,
+                  const Epetra_Map   &col_parallel_partitioning,
+                  const unsigned int  n_max_entries_per_row = 0);
+
+    /**
+     * This constructor is similar to the
+     * one above, but it now takes two
+     * different Epetra maps for rows and
+     * columns. This interface is meant
+     * to be used for generating
+     * rectangular matrices, where one
+     * map specifies the %parallel
+     * distribution of degrees of freedom
+     * associated with matrix rows and
+     * the second one specifies the
+     * %parallel distribution the dofs
+     * associated with columns in the
+     * matrix. The second map also
+     * provides information for the
+     * internal arrangement in matrix
+     * vector products (i.e., the
+     * distribution of vector this matrix
+     * is to be multiplied with), but is
+     * not used for the distribution of
+     * the columns &ndash; rather, all
+     * column elements of a row are
+     * stored on the same processor in
+     * any case. The vector
+     * <tt>n_entries_per_row</tt>
+     * specifies the number of entries in
+     * each row of the newly generated
+     * matrix.
+     */
+    SparseMatrix (const Epetra_Map                &row_parallel_partitioning,
+                  const Epetra_Map                &col_parallel_partitioning,
+                  const std::vector<unsigned int> &n_entries_per_row);
+
+    /**
+     * This function is initializes the
+     * Trilinos Epetra matrix according to
+     * the specified sparsity_pattern, and
+     * also reassigns the matrix rows to
+     * different processes according to a
+     * user-supplied Epetra map. In
+     * programs following the style of the
+     * tutorial programs, this function
+     * (and the respective call for a
+     * rectangular matrix) are the natural
+     * way to initialize the matrix size,
+     * its distribution among the MPI
+     * processes (if run in %parallel) as
+     * well as the locatoin of non-zero
+     * elements. Trilinos stores the
+     * sparsity pattern internally, so it
+     * won't be needed any more after this
+     * call, in contrast to the deal.II own
+     * object. The optional argument @p
+     * exchange_data can be used for
+     * reinitialization with a sparsity
+     * pattern that is not fully
+     * constructed. This feature is only
+     * implemented for input sparsity
+     * patterns of type
+     * CompressedSimpleSparsityPattern. If
+     * the flag is not set, each processor
+     * just sets the elements in the
+     * sparsity pattern that belong to its
+     * rows.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template<typename SparsityType>
+    void reinit (const Epetra_Map    &parallel_partitioning,
+                 const SparsityType &sparsity_pattern,
+                 const bool          exchange_data = false);
+
+    /**
+     * This function is similar to the
+     * other initialization function
+     * above, but now also reassigns the
+     * matrix rows and columns according
+     * to two user-supplied Epetra maps.
+     * To be used for rectangular
+     * matrices. The optional argument @p
+     * exchange_data can be used for
+     * reinitialization with a sparsity
+     * pattern that is not fully
+     * constructed. This feature is only
+     * implemented for input sparsity
+     * patterns of type
+     * CompressedSimpleSparsityPattern.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template<typename SparsityType>
+    void reinit (const Epetra_Map    &row_parallel_partitioning,
+                 const Epetra_Map    &col_parallel_partitioning,
+                 const SparsityType &sparsity_pattern,
+                 const bool          exchange_data = false);
+
+    /**
+     * This function initializes the
+     * Trilinos matrix using the deal.II
+     * sparse matrix and the entries
+     * stored therein. It uses a
+     * threshold to copy only elements
+     * with modulus larger than the
+     * threshold (so zeros in the deal.II
+     * matrix can be filtered away). In
+     * contrast to the other reinit
+     * function with deal.II sparse
+     * matrix argument, this function
+     * takes a %parallel partitioning
+     * specified by the user instead of
+     * internally generating it.
+     *
+     * The optional parameter
+     * <tt>copy_values</tt> decides
+     * whether only the sparsity
+     * structure of the input matrix
+     * should be used or the matrix
+     * entries should be copied, too.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template <typename number>
+    void reinit (const Epetra_Map                     &parallel_partitioning,
+                 const ::dealii::SparseMatrix<number> &dealii_sparse_matrix,
+                 const double                          drop_tolerance=1e-13,
+                 const bool                            copy_values=true,
+                 const ::dealii::SparsityPattern      *use_this_sparsity=0);
+
+    /**
+     * This function is similar to the
+     * other initialization function with
+     * deal.II sparse matrix input above,
+     * but now takes Epetra maps for both
+     * the rows and the columns of the
+     * matrix. Chosen for rectangular
+     * matrices.
+     *
+     * The optional parameter
+     * <tt>copy_values</tt> decides
+     * whether only the sparsity
+     * structure of the input matrix
+     * should be used or the matrix
+     * entries should be copied, too.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template <typename number>
+    void reinit (const Epetra_Map                      &row_parallel_partitioning,
+                 const Epetra_Map                      &col_parallel_partitioning,
+                 const ::dealii::SparseMatrix<number> &dealii_sparse_matrix,
+                 const double                           drop_tolerance=1e-13,
+                 const bool                             copy_values=true,
+                 const ::dealii::SparsityPattern      *use_this_sparsity=0);
+//@}
+    /**
+     * @name Constructors and initialization using an IndexSet description
+     */
+//@{
+    /**
+     * Constructor using an IndexSet and
+     * an MPI communicator to describe
+     * the %parallel partitioning. The
+     * parameter @p n_max_entries_per_row
+     * sets the number of nonzero entries
+     * in each row that will be
+     * allocated. Note that this number
+     * does not need to be exact, and it
+     * is even allowed that the actual
+     * matrix structure has more nonzero
+     * entries than specified in the
+     * constructor. However it is still
+     * advantageous to provide good
+     * estimates here since this will
+     * considerably increase the
+     * performance of the matrix
+     * setup. However, there is no effect
+     * in the performance of
+     * matrix-vector products, since
+     * Trilinos reorganizes the matrix
+     * memory prior to use (in the
+     * compress() step).
+     */
+    SparseMatrix (const IndexSet     &parallel_partitioning,
+                  const MPI_Comm     &communicator = MPI_COMM_WORLD,
+                  const unsigned int  n_max_entries_per_row = 0);
+
+    /**
+     * Same as before, but now set the
+     * number of nonzeros in each matrix
+     * row separately. Since we know the
+     * number of elements in the matrix
+     * exactly in this case, we can
+     * already allocate the right amount
+     * of memory, which makes the
+     * creation process including the
+     * insertion of nonzero elements by
+     * the respective
+     * SparseMatrix::reinit call
+     * considerably faster.
+     */
+    SparseMatrix (const IndexSet                  &parallel_partitioning,
+                  const MPI_Comm                  &communicator,
+                  const std::vector<unsigned int> &n_entries_per_row);
+
+    /**
+     * This constructor is similar to the
+     * one above, but it now takes two
+     * different IndexSet partitions for
+     * row and columns. This interface is
+     * meant to be used for generating
+     * rectangular matrices, where the
+     * first index set describes the
+     * %parallel partitioning of the
+     * degrees of freedom associated with
+     * the matrix rows and the second one
+     * the partitioning of the matrix
+     * columns. The second index set
+     * specifies the partitioning of the
+     * vectors this matrix is to be
+     * multiplied with, not the
+     * distribution of the elements that
+     * actually appear in the matrix.
+     *
+     * The parameter @p
+     * n_max_entries_per_row defines how
+     * much memory will be allocated for
+     * each row. This number does not
+     * need to be accurate, as the
+     * structure is reorganized in the
+     * compress() call.
+     */
+    SparseMatrix (const IndexSet     &row_parallel_partitioning,
+                  const IndexSet     &col_parallel_partitioning,
+                  const MPI_Comm     &communicator = MPI_COMM_WORLD,
+                  const unsigned int  n_max_entries_per_row = 0);
+
+    /**
+     * This constructor is similar to the
+     * one above, but it now takes two
+     * different Epetra maps for rows and
+     * columns. This interface is meant
+     * to be used for generating
+     * rectangular matrices, where one
+     * map specifies the %parallel
+     * distribution of degrees of freedom
+     * associated with matrix rows and
+     * the second one specifies the
+     * %parallel distribution the dofs
+     * associated with columns in the
+     * matrix. The second map also
+     * provides information for the
+     * internal arrangement in matrix
+     * vector products (i.e., the
+     * distribution of vector this matrix
+     * is to be multiplied with), but is
+     * not used for the distribution of
+     * the columns &ndash; rather, all
+     * column elements of a row are
+     * stored on the same processor in
+     * any case. The vector
+     * <tt>n_entries_per_row</tt>
+     * specifies the number of entries in
+     * each row of the newly generated
+     * matrix.
+     */
+    SparseMatrix (const IndexSet                  &row_parallel_partitioning,
+                  const IndexSet                  &col_parallel_partitioning,
+                  const MPI_Comm                  &communicator,
+                  const std::vector<unsigned int> &n_entries_per_row);
+
+    /**
+     * This function is initializes the
+     * Trilinos Epetra matrix according
+     * to the specified sparsity_pattern,
+     * and also reassigns the matrix rows
+     * to different processes according
+     * to a user-supplied index set and
+     * %parallel communicator. In
+     * programs following the style of
+     * the tutorial programs, this
+     * function (and the respective call
+     * for a rectangular matrix) are the
+     * natural way to initialize the
+     * matrix size, its distribution
+     * among the MPI processes (if run in
+     * %parallel) as well as the locatoin
+     * of non-zero elements. Trilinos
+     * stores the sparsity pattern
+     * internally, so it won't be needed
+     * any more after this call, in
+     * contrast to the deal.II own
+     * object. The optional argument @p
+     * exchange_data can be used for
+     * reinitialization with a sparsity
+     * pattern that is not fully
+     * constructed. This feature is only
+     * implemented for input sparsity
+     * patterns of type
+     * CompressedSimpleSparsityPattern. If
+     * the flag is not set, each
+     * processor just sets the elements
+     * in the sparsity pattern that
+     * belong to its rows.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template<typename SparsityType>
+    void reinit (const IndexSet      &parallel_partitioning,
+                 const SparsityType &sparsity_pattern,
+                 const MPI_Comm      &communicator = MPI_COMM_WORLD,
+                 const bool           exchange_data = false);
+
+    /**
+     * This function is similar to the
+     * other initialization function
+     * above, but now also reassigns the
+     * matrix rows and columns according
+     * to two user-supplied index sets.
+     * To be used for rectangular
+     * matrices. The optional argument @p
+     * exchange_data can be used for
+     * reinitialization with a sparsity
+     * pattern that is not fully
+     * constructed. This feature is only
+     * implemented for input sparsity
+     * patterns of type
+     * CompressedSimpleSparsityPattern.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template<typename SparsityType>
+    void reinit (const IndexSet      &row_parallel_partitioning,
+                 const IndexSet      &col_parallel_partitioning,
+                 const SparsityType &sparsity_pattern,
+                 const MPI_Comm      &communicator = MPI_COMM_WORLD,
+                 const bool           exchange_data = false);
+
+    /**
+     * This function initializes the
+     * Trilinos matrix using the deal.II
+     * sparse matrix and the entries
+     * stored therein. It uses a
+     * threshold to copy only elements
+     * with modulus larger than the
+     * threshold (so zeros in the deal.II
+     * matrix can be filtered away). In
+     * contrast to the other reinit
+     * function with deal.II sparse
+     * matrix argument, this function
+     * takes a %parallel partitioning
+     * specified by the user instead of
+     * internally generating it.
+     *
+     * The optional parameter
+     * <tt>copy_values</tt> decides
+     * whether only the sparsity
+     * structure of the input matrix
+     * should be used or the matrix
+     * entries should be copied, too.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template <typename number>
+    void reinit (const IndexSet                       &parallel_partitioning,
+                 const ::dealii::SparseMatrix<number> &dealii_sparse_matrix,
+                 const MPI_Comm                       &communicator = MPI_COMM_WORLD,
+                 const double                          drop_tolerance=1e-13,
+                 const bool                            copy_values=true,
+                 const ::dealii::SparsityPattern      *use_this_sparsity=0);
+
+    /**
+     * This function is similar to the
+     * other initialization function with
+     * deal.II sparse matrix input above,
+     * but now takes index sets for both
+     * the rows and the columns of the
+     * matrix. Chosen for rectangular
+     * matrices.
+     *
+     * The optional parameter
+     * <tt>copy_values</tt> decides
+     * whether only the sparsity
+     * structure of the input matrix
+     * should be used or the matrix
+     * entries should be copied, too.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    template <typename number>
+    void reinit (const IndexSet                        &row_parallel_partitioning,
+                 const IndexSet                        &col_parallel_partitioning,
+                 const ::dealii::SparseMatrix<number> &dealii_sparse_matrix,
+                 const MPI_Comm                        &communicator = MPI_COMM_WORLD,
+                 const double                           drop_tolerance=1e-13,
+                 const bool                             copy_values=true,
+                 const ::dealii::SparsityPattern      *use_this_sparsity=0);
+//@}
+    /**
+     * @name Information on the matrix
+     */
+//@{
+
+    /**
+     * Return the number of rows in
+     * this matrix.
+     */
+    unsigned int m () const;
+
+    /**
+     * Return the number of columns
+     * in this matrix.
+     */
+    unsigned int n () const;
+
+    /**
+     * Return the local dimension
+     * of the matrix, i.e. the
+     * number of rows stored on the
+     * present MPI process. For
+     * sequential matrices, this
+     * number is the same as m(),
+     * but for %parallel matrices it
+     * may be smaller.
+     *
+     * To figure out which elements
+     * exactly are stored locally,
+     * use local_range().
+     */
+    unsigned int local_size () const;
+
+    /**
+     * Return a pair of indices
+     * indicating which rows of
+     * this matrix are stored
+     * locally. The first number is
+     * the index of the first row
+     * stored, the second the index
+     * of the one past the last one
+     * that is stored locally. If
+     * this is a sequential matrix,
+     * then the result will be the
+     * pair (0,m()), otherwise it
+     * will be a pair (i,i+n),
+     * where
+     * <tt>n=local_size()</tt>.
+     */
+    std::pair<unsigned int, unsigned int>
+    local_range () const;
+
+    /**
+     * Return whether @p index is
+     * in the local range or not,
+     * see also local_range().
+     */
+    bool in_local_range (const unsigned int index) const;
+
+    /**
+     * Return the number of nonzero
+     * elements of this matrix.
+     */
+    unsigned int n_nonzero_elements () const;
+
+    /**
+     * Number of entries in a
+     * specific row.
+     */
+    unsigned int row_length (const unsigned int row) const;
+
+    /**
+     * Returns the state of the matrix,
+     * i.e., whether compress() needs to
+     * be called after an operation
+     * requiring data exchange. A call to
+     * compress() is also needed when the
+     * method set() has been called (even
+     * when working in serial).
+     */
+    bool is_compressed () const;
+
+    /**
+     * Determine an estimate for the memory
+     * consumption (in bytes) of this
+     * object. Note that only the memory
+     * reserved on the current processor is
+     * returned in case this is called in
+     * an MPI-based program.
+     */
+    std::size_t memory_consumption () const;
+
+//@}
+    /**
+     * @name Modifying entries
+     */
+//@{
+
+    /**
+     * This operator assigns a scalar to
+     * a matrix. Since this does usually
+     * not make much sense (should we set
+     * all matrix entries to this value?
+     * Only the nonzero entries of the
+     * sparsity pattern?), this operation
+     * is only allowed if the actual
+     * value to be assigned is zero. This
+     * operator only exists to allow for
+     * the obvious notation
+     * <tt>matrix=0</tt>, which sets all
+     * elements of the matrix to zero,
+     * but keeps the sparsity pattern
+     * previously used.
+     */
+    SparseMatrix &
+    operator = (const double d);
+
+    /**
+     * Release all memory and return to a
+     * state just like after having
+     * called the default constructor.
+     *
+     * This is a collective operation
+     * that needs to be called on all
+     * processors in order to avoid a
+     * dead lock.
+     */
+    void clear ();
+
+    /**
+     * This command does two things:
+     * <ul>
+     * <li> If the matrix was initialized
+     * without a sparsity pattern,
+     * elements have been added manually
+     * using the set() command. When this
+     * process is completed, a call to
+     * compress() reorganizes the
+     * internal data structures (aparsity
+     * pattern) so that a fast access to
+     * data is possible in matrix-vector
+     * products.
+     * <li> If the matrix structure has
+     * already been fixed (either by
+     * initialization with a sparsity
+     * pattern or by calling compress()
+     * during the setup phase), this
+     * command does the %parallel
+     * exchange of data. This is
+     * necessary when we perform assembly
+     * on more than one (MPI) process,
+     * because then some non-local row
+     * data will accumulate on nodes that
+     * belong to the current's processor
+     * element, but are actually held by
+     * another. This command is usually
+     * called after all elements have
+     * been traversed.
+     * </ul>
+     *
+     * In both cases, this function
+     * compresses the data structures and
+     * allows the resulting matrix to be
+     * used in all other operations like
+     * matrix-vector products. This is a
+     * collective operation, i.e., it
+     * needs to be run on all processors
+     * when used in %parallel.
+     *
+     * See @ref GlossCompress "Compressing distributed objects"
+     * for more information.
+     */
+    void compress (::dealii::VectorOperation::values operation
+                   =::dealii::VectorOperation::unknown);
+
+    /**
+     * Set the element (<i>i,j</i>)
+     * to @p value.
+     *
+     * This function is able to insert new
+     * elements into the matrix as long as
+     * compress() has not been called, so
+     * the sparsity pattern will be
+     * extended. When compress() is called
+     * for the first time, then this is no
+     * longer possible and an insertion of
+     * elements at positions which have not
+     * been initialized will throw an
+     * exception. Note that in case
+     * elements need to be inserted, it is
+     * mandatory that elements are inserted
+     * only once. Otherwise, the elements
+     * will actually be added in the end
+     * (since it is not possible to
+     * efficiently find values to the same
+     * entry before compress() has been
+     * called). In the case that an element
+     * is set more than once, initialize
+     * the matrix with a sparsity pattern
+     * first.
+     */
+    void set (const unsigned int i,
+              const unsigned int j,
+              const TrilinosScalar value);
+
+    /**
+     * Set all elements given in a
+     * FullMatrix<double> into the sparse
+     * matrix locations given by
+     * <tt>indices</tt>. In other words,
+     * this function writes the elements
+     * in <tt>full_matrix</tt> into the
+     * calling matrix, using the
+     * local-to-global indexing specified
+     * by <tt>indices</tt> for both the
+     * rows and the columns of the
+     * matrix. This function assumes a
+     * quadratic sparse matrix and a
+     * quadratic full_matrix, the usual
+     * situation in FE calculations.
+     *
+     * This function is able to insert
+     * new elements into the matrix as
+     * long as compress() has not been
+     * called, so the sparsity pattern
+     * will be extended. When compress()
+     * is called for the first time, then
+     * this is no longer possible and an
+     * insertion of elements at positions
+     * which have not been initialized
+     * will throw an exception.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be inserted anyway
+     * or they should be filtered
+     * away. The default value is
+     * <tt>false</tt>, i.e., even zero
+     * values are inserted/replaced.
+     */
+    void set (const std::vector<unsigned int> &indices,
+              const FullMatrix<TrilinosScalar> &full_matrix,
+              const bool                        elide_zero_values = false);
+
+    /**
+     * Same function as before, but now
+     * including the possibility to use
+     * rectangular full_matrices and
+     * different local-to-global indexing
+     * on rows and columns, respectively.
+     */
+    void set (const std::vector<unsigned int> &row_indices,
+              const std::vector<unsigned int> &col_indices,
+              const FullMatrix<TrilinosScalar> &full_matrix,
+              const bool                        elide_zero_values = false);
+
+    /**
+     * Set several elements in the
+     * specified row of the matrix with
+     * column indices as given by
+     * <tt>col_indices</tt> to the
+     * respective value.
+     *
+     * This function is able to insert
+     * new elements into the matrix as
+     * long as compress() has not been
+     * called, so the sparsity pattern
+     * will be extended. When compress()
+     * is called for the first time, then
+     * this is no longer possible and an
+     * insertion of elements at positions
+     * which have not been initialized
+     * will throw an exception.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be inserted anyway
+     * or they should be filtered
+     * away. The default value is
+     * <tt>false</tt>, i.e., even zero
+     * values are inserted/replaced.
+     */
+    void set (const unsigned int                row,
+              const std::vector<unsigned int>   &col_indices,
+              const std::vector<TrilinosScalar> &values,
+              const bool                         elide_zero_values = false);
+
+    /**
+     * Set several elements to values
+     * given by <tt>values</tt> in a
+     * given row in columns given by
+     * col_indices into the sparse
+     * matrix.
+     *
+     * This function is able to insert
+     * new elements into the matrix as
+     * long as compress() has not been
+     * called, so the sparsity pattern
+     * will be extended. When compress()
+     * is called for the first time, then
+     * this is no longer possible and an
+     * insertion of elements at positions
+     * which have not been initialized
+     * will throw an exception.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be inserted anyway
+     * or they should be filtered
+     * away. The default value is
+     * <tt>false</tt>, i.e., even zero
+     * values are inserted/replaced.
+     */
+    void set (const unsigned int    row,
+              const unsigned int    n_cols,
+              const unsigned int   *col_indices,
+              const TrilinosScalar *values,
+              const bool            elide_zero_values = false);
+
+    /**
+     * Add @p value to the element
+     * (<i>i,j</i>).
+     *
+     * Just as the respective call in
+     * deal.II SparseMatrix<Number>
+     * class (but in contrast to the
+     * situation for PETSc based
+     * matrices), this function
+     * throws an exception if an
+     * entry does not exist in the
+     * sparsity pattern. Moreover, if
+     * <tt>value</tt> is not a finite
+     * number an exception is thrown.
+     */
+    void add (const unsigned int i,
+              const unsigned int j,
+              const TrilinosScalar value);
+
+    /**
+     * Add all elements given in a
+     * FullMatrix<double> into sparse
+     * matrix locations given by
+     * <tt>indices</tt>. In other words,
+     * this function adds the elements in
+     * <tt>full_matrix</tt> to the
+     * respective entries in calling
+     * matrix, using the local-to-global
+     * indexing specified by
+     * <tt>indices</tt> for both the rows
+     * and the columns of the
+     * matrix. This function assumes a
+     * quadratic sparse matrix and a
+     * quadratic full_matrix, the usual
+     * situation in FE calculations.
+     *
+     * Just as the respective call in
+     * deal.II SparseMatrix<Number>
+     * class (but in contrast to the
+     * situation for PETSc based
+     * matrices), this function
+     * throws an exception if an
+     * entry does not exist in the
+     * sparsity pattern.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be added anyway or
+     * these should be filtered away and
+     * only non-zero data is added. The
+     * default value is <tt>true</tt>,
+     * i.e., zero values won't be added
+     * into the matrix.
+     */
+    void add (const std::vector<unsigned int> &indices,
+              const FullMatrix<TrilinosScalar> &full_matrix,
+              const bool                        elide_zero_values = true);
+
+    /**
+     * Same function as before, but now
+     * including the possibility to use
+     * rectangular full_matrices and
+     * different local-to-global indexing
+     * on rows and columns, respectively.
+     */
+    void add (const std::vector<unsigned int> &row_indices,
+              const std::vector<unsigned int> &col_indices,
+              const FullMatrix<TrilinosScalar> &full_matrix,
+              const bool                        elide_zero_values = true);
+
+    /**
+     * Set several elements in the
+     * specified row of the matrix with
+     * column indices as given by
+     * <tt>col_indices</tt> to the
+     * respective value.
+     *
+     * Just as the respective call in
+     * deal.II SparseMatrix<Number>
+     * class (but in contrast to the
+     * situation for PETSc based
+     * matrices), this function
+     * throws an exception if an
+     * entry does not exist in the
+     * sparsity pattern.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be added anyway or
+     * these should be filtered away and
+     * only non-zero data is added. The
+     * default value is <tt>true</tt>,
+     * i.e., zero values won't be added
+     * into the matrix.
+     */
+    void add (const unsigned int                row,
+              const std::vector<unsigned int>   &col_indices,
+              const std::vector<TrilinosScalar> &values,
+              const bool                         elide_zero_values = true);
+
+    /**
+     * Add an array of values given by
+     * <tt>values</tt> in the given
+     * global matrix row at columns
+     * specified by col_indices in the
+     * sparse matrix.
+     *
+     * Just as the respective call in
+     * deal.II SparseMatrix<Number> class
+     * (but in contrast to the situation
+     * for PETSc based matrices), this
+     * function throws an exception if an
+     * entry does not exist in the
+     * sparsity pattern.
+     *
+     * The optional parameter
+     * <tt>elide_zero_values</tt> can be
+     * used to specify whether zero
+     * values should be added anyway or
+     * these should be filtered away and
+     * only non-zero data is added. The
+     * default value is <tt>true</tt>,
+     * i.e., zero values won't be added
+     * into the matrix.
+     */
+    void add (const unsigned int    row,
+              const unsigned int    n_cols,
+              const unsigned int   *col_indices,
+              const TrilinosScalar *values,
+              const bool            elide_zero_values = true,
+              const bool            col_indices_are_sorted = false);
+
+    /**
+     * Multiply the entire matrix
+     * by a fixed factor.
+     */
+    SparseMatrix &operator *= (const TrilinosScalar factor);
+
+    /**
+     * Divide the entire matrix by
+     * a fixed factor.
+     */
+    SparseMatrix &operator /= (const TrilinosScalar factor);
+
+    /**
+     * Copy the given (Trilinos) matrix
+     * (sparsity pattern and entries).
+     */
+    void copy_from (const SparseMatrix &source);
+
+    /**
+     * Add <tt>matrix</tt> scaled by
+     * <tt>factor</tt> to this matrix,
+     * i.e. the matrix
+     * <tt>factor*matrix</tt> is added to
+     * <tt>this</tt>. If the sparsity
+     * pattern of the calling matrix does
+     * not contain all the elements in
+     * the sparsity pattern of the input
+     * matrix, this function will throw
+     * an exception.
+     */
+    void add (const TrilinosScalar  factor,
+              const SparseMatrix   &matrix);
+
+    /**
+     * Remove all elements from
+     * this <tt>row</tt> by setting
+     * them to zero. The function
+     * does not modify the number
+     * of allocated nonzero
+     * entries, it only sets some
+     * entries to zero. It may drop
+     * them from the sparsity
+     * pattern, though (but retains
+     * the allocated memory in case
+     * new entries are again added
+     * later). Note that this is a
+     * global operation, so this
+     * needs to be done on all MPI
+     * processes.
+     *
+     * This operation is used in
+     * eliminating constraints
+     * (e.g. due to hanging nodes)
+     * and makes sure that we can
+     * write this modification to
+     * the matrix without having to
+     * read entries (such as the
+     * locations of non-zero
+     * elements) from it &mdash;
+     * without this operation,
+     * removing constraints on
+     * %parallel matrices is a
+     * rather complicated
+     * procedure.
+     *
+     * The second parameter can be
+     * used to set the diagonal
+     * entry of this row to a value
+     * different from zero. The
+     * default is to set it to
+     * zero.
+     */
+    void clear_row (const unsigned int   row,
+                    const TrilinosScalar new_diag_value = 0);
+
+    /**
+     * Same as clear_row(), except
+     * that it works on a number of
+     * rows at once.
+     *
+     * The second parameter can be
+     * used to set the diagonal
+     * entries of all cleared rows
+     * to something different from
+     * zero. Note that all of these
+     * diagonal entries get the
+     * same value -- if you want
+     * different values for the
+     * diagonal entries, you have
+     * to set them by hand.
+     */
+    void clear_rows (const std::vector<unsigned int> &rows,
+                     const TrilinosScalar             new_diag_value = 0);
+
+    /**
+     * Make an in-place transpose
+     * of a matrix.
+     */
+    void transpose ();
+
+//@}
+    /**
+     * @name Entry Access
+     */
+//@{
+
+    /**
+     * Return the value of the
+     * entry (<i>i,j</i>).  This
+     * may be an expensive
+     * operation and you should
+     * always take care where to
+     * call this function. As in
+     * the deal.II sparse matrix
+     * class, we throw an exception
+     * if the respective entry
+     * doesn't exist in the
+     * sparsity pattern of this
+     * class, which is requested
+     * from Trilinos. Moreover, an
+     * exception will be thrown
+     * when the requested element
+     * is not saved on the calling
+     * process.
+     */
+    TrilinosScalar operator () (const unsigned int i,
+                                const unsigned int j) const;
+
+    /**
+     * Return the value of the
+     * matrix entry
+     * (<i>i,j</i>). If this entry
+     * does not exist in the
+     * sparsity pattern, then zero
+     * is returned. While this may
+     * be convenient in some cases,
+     * note that it is simple to
+     * write algorithms that are
+     * slow compared to an optimal
+     * solution, since the sparsity
+     * of the matrix is not used.
+     * On the other hand, if you
+     * want to be sure the entry
+     * exists, you should use
+     * operator() instead.
+     *
+     * The lack of error checking
+     * in this function can also
+     * yield surprising results if
+     * you have a parallel
+     * matrix. In that case, just
+     * because you get a zero
+     * result from this function
+     * does not mean that either
+     * the entry does not exist in
+     * the sparsity pattern or that
+     * it does but has a value of
+     * zero. Rather, it could also
+     * be that it simply isn't
+     * stored on the current
+     * processor; in that case, it
+     * may be stored on a different
+     * processor, and possibly so
+     * with a nonzero value.
+     */
+    TrilinosScalar el (const unsigned int i,
+                       const unsigned int j) const;
+
+    /**
+     * Return the main diagonal
+     * element in the <i>i</i>th
+     * row. This function throws an
+     * error if the matrix is not
+     * quadratic and it also throws
+     * an error if <i>(i,i)</i> is not
+     * element of the local matrix.
+     * See also the comment in
+     * trilinos_sparse_matrix.cc.
+     */
+    TrilinosScalar diag_element (const unsigned int i) const;
+
+//@}
+    /**
+     * @name Multiplications
+     */
+//@{
+
+    /**
+     * Matrix-vector multiplication:
+     * let <i>dst = M*src</i> with
+     * <i>M</i> being this matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that both vectors have to
+     * be distributed vectors
+     * generated using the same Map
+     * as was used for the matrix in
+     * case you work on a distributed
+     * memory architecture, using the
+     * interface in the
+     * TrilinosWrappers::VectorBase
+     * class (or one of the two
+     * derived classes Vector and
+     * MPI::Vector).
+     *
+     * In case of a localized Vector,
+     * this function will only work
+     * when running on one processor,
+     * since the matrix object is
+     * inherently
+     * distributed. Otherwise, and
+     * exception will be thrown.
+     */
+    void vmult (VectorBase       &dst,
+                const VectorBase &src) const;
+
+    /**
+     * Same as before, but working with
+     * deal.II's own distributed vector
+     * class.
+     */
+    void vmult (parallel::distributed::Vector<TrilinosScalar>       &dst,
+                const parallel::distributed::Vector<TrilinosScalar> &src) const;
+
+    /**
+     * Matrix-vector multiplication:
+     * let <i>dst =
+     * M<sup>T</sup>*src</i> with
+     * <i>M</i> being this
+     * matrix. This function does the
+     * same as vmult() but takes the
+     * transposed matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that both vectors have to
+     * be distributed vectors
+     * generated using the same Map
+     * as was used for the matrix in
+     * case you work on a distributed
+     * memory architecture, using the
+     * interface in the
+     * TrilinosWrappers::VectorBase
+     * class (or one of the two
+     * derived classes Vector and
+     * MPI::Vector).
+     *
+     * In case of a localized Vector,
+     * this function will only work
+     * when running on one processor,
+     * since the matrix object is
+     * inherently
+     * distributed. Otherwise, and
+     * exception will be thrown.
+     */
+    void Tvmult (VectorBase       &dst,
+                 const VectorBase &src) const;
+
+    /**
+     * Same as before, but working with
+     * deal.II's own distributed vector
+     * class.
+     */
+    void Tvmult (parallel::distributed::Vector<TrilinosScalar>       &dst,
+                 const parallel::distributed::Vector<TrilinosScalar> &src) const;
+
+    /**
+     * Adding Matrix-vector
+     * multiplication. Add
+     * <i>M*src</i> on <i>dst</i>
+     * with <i>M</i> being this
+     * matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that both vectors have to
+     * be distributed vectors
+     * generated using the same Map
+     * as was used for the matrix in
+     * case you work on a distributed
+     * memory architecture, using the
+     * interface in the
+     * TrilinosWrappers::VectorBase
+     * class (or one of the two
+     * derived classes Vector and
+     * MPI::Vector).
+     *
+     * In case of a localized Vector,
+     * this function will only work
+     * when running on one processor,
+     * since the matrix object is
+     * inherently
+     * distributed. Otherwise, and
+     * exception will be thrown.
+     */
+    void vmult_add (VectorBase       &dst,
+                    const VectorBase &src) const;
+
+    /**
+     * Adding Matrix-vector
+     * multiplication. Add
+     * <i>M<sup>T</sup>*src</i> to
+     * <i>dst</i> with <i>M</i> being
+     * this matrix. This function
+     * does the same as vmult_add()
+     * but takes the transposed
+     * matrix.
+     *
+     * Source and destination must
+     * not be the same vector.
+     *
+     * Note that both vectors have to
+     * be distributed vectors
+     * generated using the same Map
+     * as was used for the matrix in
+     * case you work on a distributed
+     * memory architecture, using the
+     * interface in the
+     * TrilinosWrappers::VectorBase
+     * class (or one of the two
+     * derived classes Vector and
+     * MPI::Vector).
+     *
+     * In case of a localized Vector,
+     * this function will only work
+     * when running on one processor,
+     * since the matrix object is
+     * inherently
+     * distributed. Otherwise, and
+     * exception will be thrown.
+     */
+    void Tvmult_add (VectorBase       &dst,
+                     const VectorBase &src) const;
+
+    /**
+     * Return the square of the norm
+     * of the vector $v$ with respect
+     * to the norm induced by this
+     * matrix, i.e.,
+     * $\left(v,Mv\right)$. This is
+     * useful, e.g. in the finite
+     * element context, where the
+     * $L_2$ norm of a function
+     * equals the matrix norm with
+     * respect to the mass matrix of
+     * the vector representing the
+     * nodal values of the finite
+     * element function.
+     *
+     * Obviously, the matrix needs to
+     * be quadratic for this
+     * operation.
+     *
+     * The implementation of this
+     * function is not as efficient
+     * as the one in the @p
+     * SparseMatrix class used in
+     * deal.II (i.e. the original
+     * one, not the Trilinos wrapper
+     * class) since Trilinos doesn't
+     * support this operation and
+     * needs a temporary vector.
+     *
+     * Note that both vectors have to
+     * be distributed vectors
+     * generated using the same Map
+     * as was used for the matrix in
+     * case you work on a distributed
+     * memory architecture, using the
+     * interface in the
+     * TrilinosWrappers::VectorBase
+     * class (or one of the two
+     * derived classes Vector and
+     * MPI::Vector).
+     *
+     * In case of a localized Vector,
+     * this function will only work
+     * when running on one processor,
+     * since the matrix object is
+     * inherently
+     * distributed. Otherwise, and
+     * exception will be thrown.
+     */
+    TrilinosScalar matrix_norm_square (const VectorBase &v) const;
+
+    /**
+     * Compute the matrix scalar
+     * product $\left(u,Mv\right)$.
+     *
+     * The implementation of this
+     * function is not as efficient
+     * as the one in the @p
+     * SparseMatrix class used in
+     * deal.II (i.e. the original
+     * one, not the Trilinos
+     * wrapper class) since
+     * Trilinos doesn't support
+     * this operation and needs a
+     * temporary vector.
+     *
+     * Note that both vectors have to
+     * be distributed vectors
+     * generated using the same Map
+     * as was used for the matrix in
+     * case you work on a distributed
+     * memory architecture, using the
+     * interface in the
+     * TrilinosWrappers::VectorBase
+     * class (or one of the two
+     * derived classes Vector and
+     * MPI::Vector).
+     *
+     * In case of a localized Vector,
+     * this function will only work
+     * when running on one processor,
+     * since the matrix object is
+     * inherently
+     * distributed. Otherwise, and
+     * exception will be thrown.
+     */
+    TrilinosScalar matrix_scalar_product (const VectorBase &u,
+                                          const VectorBase &v) const;
+
+    /**
+     * Compute the residual of an
+     * equation <i>Mx=b</i>, where
+     * the residual is defined to
+     * be <i>r=b-Mx</i>. Write the
+     * residual into @p dst. The
+     * <i>l<sub>2</sub></i> norm of
+     * the residual vector is
+     * returned.
+     *
+     * Source <i>x</i> and
+     * destination <i>dst</i> must
+     * not be the same vector.
+     *
+     * Note that both vectors have to
+     * be distributed vectors
+     * generated using the same Map
+     * as was used for the matrix in
+     * case you work on a distributed
+     * memory architecture, using the
+     * interface in the
+     * TrilinosWrappers::VectorBase
+     * class (or one of the two
+     * derived classes Vector and
+     * MPI::Vector).
+     *
+     * In case of a localized Vector,
+     * this function will only work
+     * when running on one processor,
+     * since the matrix object is
+     * inherently
+     * distributed. Otherwise, and
+     * exception will be thrown.
+     */
+    TrilinosScalar residual (VectorBase       &dst,
+                             const VectorBase &x,
+                             const VectorBase &b) const;
+
+    /**
+     * Perform the matrix-matrix
+     * multiplication <tt>C = A * B</tt>,
+     * or, if an optional vector argument
+     * is given, <tt>C = A * diag(V) *
+     * B</tt>, where <tt>diag(V)</tt>
+     * defines a diagonal matrix with the
+     * vector entries.
+     *
+     * This function assumes that the
+     * calling matrix <tt>A</tt> and
+     * <tt>B</tt> have compatible
+     * sizes. The size of <tt>C</tt> will
+     * be set within this function.
+     *
+     * The content as well as the sparsity
+     * pattern of the matrix C will be
+     * changed by this function, so make
+     * sure that the sparsity pattern is
+     * not used somewhere else in your
+     * program. This is an expensive
+     * operation, so think twice before you
+     * use this function.
+     */
+    void mmult (SparseMatrix       &C,
+                const SparseMatrix &B,
+                const VectorBase   &V = VectorBase()) const;
+
+
+    /**
+     * Perform the matrix-matrix
+     * multiplication with the transpose of
+     * <tt>this</tt>, i.e., <tt>C =
+     * A<sup>T</sup> * B</tt>, or, if an
+     * optional vector argument is given,
+     * <tt>C = A<sup>T</sup> * diag(V) *
+     * B</tt>, where <tt>diag(V)</tt>
+     * defines a diagonal matrix with the
+     * vector entries.
+     *
+     * This function assumes that the
+     * calling matrix <tt>A</tt> and
+     * <tt>B</tt> have compatible
+     * sizes. The size of <tt>C</tt> will
+     * be set within this function.
+     *
+     * The content as well as the sparsity
+     * pattern of the matrix C will be
+     * changed by this function, so make
+     * sure that the sparsity pattern is
+     * not used somewhere else in your
+     * program. This is an expensive
+     * operation, so think twice before you
+     * use this function.
+     */
+    void Tmmult (SparseMatrix       &C,
+                 const SparseMatrix &B,
+                 const VectorBase   &V = VectorBase()) const;
+
+//@}
+    /**
+     * @name Matrix norms
+     */
+//@{
+
+    /**
+     * Return the
+     * <i>l</i><sub>1</sub>-norm of
+     * the matrix, that is
+     * $|M|_1=
+     * \max_{\mathrm{all\ columns\ } j}
+     * \sum_{\mathrm{all\ rows\ } i}
+     * |M_{ij}|$, (max. sum
+     * of columns).  This is the
+     * natural matrix norm that is
+     * compatible to the l1-norm for
+     * vectors, i.e.  $|Mv|_1 \leq
+     * |M|_1 |v|_1$.
+     * (cf. Haemmerlin-Hoffmann:
+     * Numerische Mathematik)
+     */
+    TrilinosScalar l1_norm () const;
+
+    /**
+     * Return the linfty-norm of the
+     * matrix, that is
+     * $|M|_\infty=\max_{\mathrm{all\
+     * rows\ } i}\sum_{\mathrm{all\
+     * columns\ } j} |M_{ij}|$,
+     * (max. sum of rows).  This is
+     * the natural matrix norm that
+     * is compatible to the
+     * linfty-norm of vectors, i.e.
+     * $|Mv|_\infty \leq |M|_\infty
+     * |v|_\infty$.
+     * (cf. Haemmerlin-Hoffmann:
+     * Numerische Mathematik)
+     */
+    TrilinosScalar linfty_norm () const;
+
+    /**
+     * Return the frobenius norm of
+     * the matrix, i.e. the square
+     * root of the sum of squares
+     * of all entries in the
+     * matrix.
+     */
+    TrilinosScalar frobenius_norm () const;
+
+//@}
+    /**
+     * @name Access to underlying Trilinos data
+     */
+//@{
+
+    /**
+     * Return a const reference to the
+     * underlying Trilinos
+     * Epetra_CrsMatrix data.
+     */
+    const Epetra_CrsMatrix &trilinos_matrix () const;
+
+    /**
+     * Return a const reference to the
+     * underlying Trilinos
+     * Epetra_CrsGraph data that stores
+     * the sparsity pattern of the
+     * matrix.
+     */
+    const Epetra_CrsGraph &trilinos_sparsity_pattern () const;
+
+    /**
+     * Return a const reference to the
+     * underlying Trilinos Epetra_Map
+     * that sets the partitioning of the
+     * domain space of this matrix, i.e.,
+     * the partitioning of the vectors
+     * this matrix has to be multiplied
+     * with.
+     */
+    const Epetra_Map &domain_partitioner () const;
+
+    /**
+     * Return a const reference to the
+     * underlying Trilinos Epetra_Map
+     * that sets the partitioning of the
+     * range space of this matrix, i.e.,
+     * the partitioning of the vectors
+     * that are result from matrix-vector
+     * products.
+     */
+    const Epetra_Map &range_partitioner () const;
+
+    /**
+     * Return a const reference to the
+     * underlying Trilinos Epetra_Map
+     * that sets the partitioning of the
+     * matrix rows. Equal to the
+     * partitioning of the range.
+     */
+    const Epetra_Map &row_partitioner () const;
+
+    /**
+     * Return a const reference to the
+     * underlying Trilinos Epetra_Map
+     * that sets the partitioning of the
+     * matrix columns. This is in general
+     * not equal to the partitioner
+     * Epetra_Map for the domain because
+     * of overlap in the matrix.
+     */
+    const Epetra_Map &col_partitioner () const;
+//@}
+    /**
+     * @name Iterators
+     */
+//@{
+
+    /**
+     * STL-like iterator with the
+     * first entry.
+     */
+    const_iterator begin () const;
+
+    /**
+     * Final iterator.
+     */
+    const_iterator end () const;
+
+    /**
+     * STL-like iterator with the
+     * first entry of row @p r.
+     *
+     * Note that if the given row
+     * is empty, i.e. does not
+     * contain any nonzero entries,
+     * then the iterator returned
+     * by this function equals
+     * <tt>end(r)</tt>. Note also
+     * that the iterator may not be
+     * dereferencable in that case.
+     */
+    const_iterator begin (const unsigned int r) const;
+
+    /**
+     * Final iterator of row
+     * <tt>r</tt>. It points to the
+     * first element past the end
+     * of line @p r, or past the
+     * end of the entire sparsity
+     * pattern.
+     *
+     * Note that the end iterator
+     * is not necessarily
+     * dereferencable. This is in
+     * particular the case if it is
+     * the end iterator for the
+     * last row of a matrix.
+     */
+    const_iterator end (const unsigned int r) const;
+
+//@}
+    /**
+     * @name Input/Output
+     */
+//@{
+
+    /**
+     * Abstract Trilinos object
+     * that helps view in ASCII
+     * other Trilinos
+     * objects. Currently this
+     * function is not
+     * implemented.  TODO: Not
+     * implemented.
+     */
+    void write_ascii () const;		// shuqiangwang
+
+    /**
+     * Print the matrix to the given
+     * stream, using the format
+     * <tt>(line,col) value</tt>, i.e. one
+     * nonzero entry of the matrix per
+     * line. The optional flag outputs the
+     * sparsity pattern in Trilinos style,
+     * where the data is sorted according
+     * to the processor number when printed
+     * to the stream, as well as a summary
+     * of the matrix like the global size.
+     */
+    void print (std::ostream &out,
+                const bool    write_extended_trilinos_info = false) const;
+
+//@}
+    /** @addtogroup Exceptions
+     *
+     */
+//@{
+    /**
+     * Exception
+     */
+    DeclException1 (ExcTrilinosError,
+                    int,
+                    << "An error with error number " << arg1
+                    << " occurred while calling a Trilinos function");
+
+    /**
+     * Exception
+     */
+    DeclException2 (ExcInvalidIndex,
+                    int, int,
+                    << "The entry with index <" << arg1 << ',' << arg2
+                    << "> does not exist.");
+
+    /**
+     * Exception
+     */
+    DeclException0 (ExcSourceEqualsDestination);
+
+    /**
+     * Exception
+     */
+    DeclException0 (ExcMatrixNotCompressed);
+
+    /**
+     * Exception
+     */
+    DeclException4 (ExcAccessToNonLocalElement,
+                    int, int, int, int,
+                    << "You tried to access element (" << arg1
+                    << "/" << arg2 << ")"
+                    << " of a distributed matrix, but only rows "
+                    << arg3 << " through " << arg4
+                    << " are stored locally and can be accessed.");
+
+    /**
+     * Exception
+     */
+    DeclException2 (ExcAccessToNonPresentElement,
+                    int, int,
+                    << "You tried to access element (" << arg1
+                    << "/" << arg2 << ")"
+                    << " of a sparse matrix, but it appears to not"
+                    << " exist in the Trilinos sparsity pattern.");
+//@}
+
+
+
+  protected:
+
+    /**
+    * For some matrix storage
+    * formats, in particular for the
+    * PETSc distributed blockmatrices,
+    * set and add operations on
+    * individual elements can not be
+    * freely mixed. Rather, one has
+    * to synchronize operations when
+    * one wants to switch from
+    * setting elements to adding to
+    * elements.
+    * BlockMatrixBase automatically
+    * synchronizes the access by
+    * calling this helper function
+    * for each block.
+    * This function ensures that the
+    * matrix is in a state that
+    * allows adding elements; if it
+    * previously already was in this
+    * state, the function does
+    * nothing.
+    */
+    void prepare_add();
+
+    /**
+    * Same as prepare_add() but
+    * prepare the matrix for setting
+    * elements if the representation
+    * of elements in this class
+    * requires such an operation.
+    */
+    void prepare_set();
+
+
+
+  private:
+
+    /**
+     * Pointer to the user-supplied
+     * Epetra Trilinos mapping of
+     * the matrix columns that
+     * assigns parts of the matrix
+     * to the individual processes.
+     */
+    std_cxx1x::shared_ptr<Epetra_Map> column_space_map;
+
+    /**
+     * A sparse matrix object in
+     * Trilinos to be used for
+     * finite element based
+     * problems which allows for
+     * assembling into non-local
+     * elements.  The actual type,
+     * a sparse matrix, is set in
+     * the constructor.
+     */
+    std_cxx1x::shared_ptr<Epetra_FECrsMatrix> matrix;
+
+    /**
+     * Trilinos doesn't allow to mix
+     * additions to matrix entries and
+     * overwriting them (to make
+     * synchronisation of %parallel
+     * computations simpler). The way we
+     * do it is to, for each access
+     * operation, store whether it is an
+     * insertion or an addition. If the
+     * previous one was of different
+     * type, then we first have to flush
+     * the Trilinos buffers; otherwise,
+     * we can simply go on. Luckily,
+     * Trilinos has an object for this
+     * which does already all the
+     * %parallel communications in such a
+     * case, so we simply use their
+     * model, which stores whether the
+     * last operation was an addition or
+     * an insertion.
+     */
+    Epetra_CombineMode last_action;
+
+    /**
+     * A boolean variable to hold
+     * information on whether the
+     * vector is compressed or not.
+     */
+    bool compressed;
+
+    /**
+     * An internal Trilinos vector that
+     * is used for accelerating vmult_add
+     * functions (in order not to need to
+     * recreate temporary vectors every
+     * time that function is called).
+     */
+    mutable VectorBase temp_vector;
+
+    /**
+     * An internal array of integer
+     * values that is used to store the
+     * column indices when
+     * adding/inserting local data into
+     * the (large) sparse matrix.
+     */
+    std::vector<unsigned int> column_indices;
+
+    /**
+     * An internal array of double values
+     * that is used to store the column
+     * indices when adding/inserting
+     * local data into the (large) sparse
+     * matrix.
+     */
+    std::vector<TrilinosScalar> column_values;
+
+    /**
+     *  To allow calling protected
+     *  prepare_add() and
+     *  prepare_set().
+     */
+    friend class BlockMatrixBase<SparseMatrix>;
+  };
+
+
+
+// -------------------------- inline and template functions ----------------------
+
+
+#ifndef DOXYGEN
+
+  namespace MatrixIterators
+  {
+
+    inline
+    const_iterator::Accessor::
+    Accessor (const SparseMatrix *matrix,
+              const unsigned int  row,
+              const unsigned int  index)
+      :
+      matrix(const_cast<SparseMatrix *>(matrix)),
+      a_row(row),
+      a_index(index)
+    {
+      visit_present_row ();
+    }
+
+
+    inline
+    unsigned int
+    const_iterator::Accessor::row() const
+    {
+      Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix());
+      return a_row;
+    }
+
+
+
+    inline
+    unsigned int
+    const_iterator::Accessor::column() const
+    {
+      Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix());
+      return (*colnum_cache)[a_index];
+    }
+
+
+
+    inline
+    unsigned int
+    const_iterator::Accessor::index() const
+    {
+      Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix());
+      return a_index;
+    }
+
+
+
+    inline
+    TrilinosScalar
+    const_iterator::Accessor::value() const
+    {
+      Assert (a_row < matrix->m(), ExcBeyondEndOfMatrix());
+      return (*value_cache)[a_index];
+    }
+
+
+
+    inline
+    const_iterator::
+    const_iterator(const SparseMatrix *matrix,
+                   const unsigned int  row,
+                   const unsigned int  index)
+      :
+      accessor(matrix, row, index)
+    {}
+
+
+
+    inline
+    const_iterator &
+    const_iterator::operator++ ()
+    {
+      Assert (accessor.a_row < accessor.matrix->m(), ExcIteratorPastEnd());
+
+      ++accessor.a_index;
+
+      // If at end of line: do one
+      // step, then cycle until we
+      // find a row with a nonzero
+      // number of entries.
+      if (accessor.a_index >= accessor.colnum_cache->size())
+        {
+          accessor.a_index = 0;
+          ++accessor.a_row;
+
+          while ((accessor.a_row < accessor.matrix->m())
+                 &&
+                 (accessor.matrix->row_length(accessor.a_row) == 0))
+            ++accessor.a_row;
+
+          accessor.visit_present_row();
+        }
+      return *this;
+    }
+
+
+
+    inline
+    const_iterator
+    const_iterator::operator++ (int)
+    {
+      const const_iterator old_state = *this;
+      ++(*this);
+      return old_state;
+    }
+
+
+
+    inline
+    const const_iterator::Accessor &
+    const_iterator::operator* () const
+    {
+      return accessor;
+    }
+
+
+
+    inline
+    const const_iterator::Accessor *
+    const_iterator::operator-> () const
+    {
+      return &accessor;
+    }
+
+
+
+    inline
+    bool
+    const_iterator::
+    operator == (const const_iterator &other) const
+    {
+      return (accessor.a_row == other.accessor.a_row &&
+              accessor.a_index == other.accessor.a_index);
+    }
+
+
+
+    inline
+    bool
+    const_iterator::
+    operator != (const const_iterator &other) const
+    {
+      return ! (*this == other);
+    }
+
+
+
+    inline
+    bool
+    const_iterator::
+    operator < (const const_iterator &other) const
+    {
+      return (accessor.row() < other.accessor.row() ||
+              (accessor.row() == other.accessor.row() &&
+               accessor.index() < other.accessor.index()));
+    }
+
+  }
+
+
+
+  inline
+  SparseMatrix::const_iterator
+  SparseMatrix::begin() const
+  {
+    return const_iterator(this, 0, 0);
+  }
+
+
+
+  inline
+  SparseMatrix::const_iterator
+  SparseMatrix::end() const
+  {
+    return const_iterator(this, m(), 0);
+  }
+
+
+
+  inline
+  SparseMatrix::const_iterator
+  SparseMatrix::begin(const unsigned int r) const
+  {
+    Assert (r < m(), ExcIndexRange(r, 0, m()));
+    if (row_length(r) > 0)
+      return const_iterator(this, r, 0);
+    else
+      return end (r);
+  }
+
+
+
+  inline
+  SparseMatrix::const_iterator
+  SparseMatrix::end(const unsigned int r) const
+  {
+    Assert (r < m(), ExcIndexRange(r, 0, m()));
+
+    // place the iterator on the first entry
+    // past this line, or at the end of the
+    // matrix
+    for (unsigned int i=r+1; i<m(); ++i)
+      if (row_length(i) > 0)
+        return const_iterator(this, i, 0);
+
+    // if there is no such line, then take the
+    // end iterator of the matrix
+    return end();
+  }
+
+
+
+  inline
+  bool
+  SparseMatrix::in_local_range (const unsigned int index) const
+  {
+    int begin, end;
+    begin = matrix->RowMap().MinMyGID();
+    end = matrix->RowMap().MaxMyGID()+1;
+
+    return ((index >= static_cast<unsigned int>(begin)) &&
+            (index < static_cast<unsigned int>(end)));
+  }
+
+
+
+  inline
+  bool
+  SparseMatrix::is_compressed () const
+  {
+    return compressed;
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::compress (::dealii::VectorOperation::values /*operation*/)
+  {
+    // flush buffers
+    int ierr;
+    ierr = matrix->GlobalAssemble (*column_space_map, matrix->RowMap(),
+                                   true);
+
+    AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+
+    ierr = matrix->OptimizeStorage ();
+    AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+
+    last_action = Zero;
+
+    compressed = true;
+  }
+
+
+
+  inline
+  SparseMatrix &
+  SparseMatrix::operator = (const double d)
+  {
+    Assert (d==0, ExcScalarAssignmentOnlyForZeroValue());
+    compress ();
+
+    const int ierr = matrix->PutScalar(d);
+    AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+
+    return *this;
+  }
+
+
+
+  // Inline the set() and add()
+  // functions, since they will be
+  // called frequently, and the
+  // compiler can optimize away
+  // some unnecessary loops when
+  // the sizes are given at
+  // compile time.
+  inline
+  void
+  SparseMatrix::set (const unsigned int   i,
+                     const unsigned int   j,
+                     const TrilinosScalar value)
+  {
+
+    Assert (numbers::is_finite(value), ExcNumberNotFinite());
+
+    set (i, 1, &j, &value, false);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::set (const std::vector<unsigned int> &indices,
+                     const FullMatrix<TrilinosScalar> &values,
+                     const bool                        elide_zero_values)
+  {
+    Assert (indices.size() == values.m(),
+            ExcDimensionMismatch(indices.size(), values.m()));
+    Assert (values.m() == values.n(), ExcNotQuadratic());
+
+    for (unsigned int i=0; i<indices.size(); ++i)
+      set (indices[i], indices.size(), &indices[0], &values(i,0),
+           elide_zero_values);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::set (const std::vector<unsigned int> &row_indices,
+                     const std::vector<unsigned int> &col_indices,
+                     const FullMatrix<TrilinosScalar> &values,
+                     const bool                        elide_zero_values)
+  {
+    Assert (row_indices.size() == values.m(),
+            ExcDimensionMismatch(row_indices.size(), values.m()));
+    Assert (col_indices.size() == values.n(),
+            ExcDimensionMismatch(col_indices.size(), values.n()));
+
+    for (unsigned int i=0; i<row_indices.size(); ++i)
+      set (row_indices[i], col_indices.size(), &col_indices[0], &values(i,0),
+           elide_zero_values);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::set (const unsigned int                 row,
+                     const std::vector<unsigned int>   &col_indices,
+                     const std::vector<TrilinosScalar> &values,
+                     const bool                         elide_zero_values)
+  {
+    Assert (col_indices.size() == values.size(),
+            ExcDimensionMismatch(col_indices.size(), values.size()));
+
+    set (row, col_indices.size(), &col_indices[0], &values[0],
+         elide_zero_values);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::set (const unsigned int    row,
+                     const unsigned int    n_cols,
+                     const unsigned int   *col_indices,
+                     const TrilinosScalar *values,
+                     const bool            elide_zero_values)
+  {
+    int ierr;
+    if (last_action == Add)
+      {
+        ierr = matrix->GlobalAssemble (*column_space_map, matrix->RowMap(),
+                                       true);
+
+        Assert (ierr == 0, ExcTrilinosError(ierr));
+      }
+
+    last_action = Insert;
+
+    int *col_index_ptr;
+    TrilinosScalar const *col_value_ptr;
+    int n_columns;
+
+    // If we don't elide zeros, the pointers
+    // are already available...
+    if (elide_zero_values == false)
+      {
+        col_index_ptr = (int *)col_indices;
+        col_value_ptr = values;
+        n_columns = n_cols;
+      }
+    else
+      {
+        // Otherwise, extract nonzero values in
+        // each row and get the respective
+        // indices.
+        if (column_indices.size() < n_cols)
+          {
+            column_indices.resize(n_cols);
+            column_values.resize(n_cols);
+          }
+
+        n_columns = 0;
+        for (unsigned int j=0; j<n_cols; ++j)
+          {
+            const double value = values[j];
+            Assert (numbers::is_finite(value), ExcNumberNotFinite());
+            if (value != 0)
+              {
+                column_indices[n_columns] = col_indices[j];
+                column_values[n_columns] = value;
+                n_columns++;
+              }
+          }
+
+        Assert(n_columns <= (int)n_cols, ExcInternalError());
+
+        col_index_ptr = (int *)&column_indices[0];
+        col_value_ptr = &column_values[0];
+      }
+
+
+    // If the calling matrix owns the row to
+    // which we want to insert values, we
+    // can directly call the Epetra_CrsMatrix
+    // input function, which is much faster
+    // than the Epetra_FECrsMatrix
+    // function. We distinguish between two
+    // cases: the first one is when the matrix
+    // is not filled (i.e., it is possible to
+    // add new elements to the sparsity pattern),
+    // and the second one is when the pattern is
+    // already fixed. In the former case, we
+    // add the possibility to insert new values,
+    // and in the second we just replace
+    // data.
+    if (row_partitioner().MyGID(static_cast<int>(row)) == true)
+      {
+        if (matrix->Filled() == false)
+          {
+            ierr = matrix->Epetra_CrsMatrix::InsertGlobalValues(row, n_columns,
+                                                                const_cast<double *>(col_value_ptr),
+                                                                col_index_ptr);
+
+            // When inserting elements, we do
+            // not want to create exceptions in
+            // the case when inserting non-local
+            // data (since that's what we want
+            // to do right now).
+            if (ierr > 0)
+              ierr = 0;
+          }
+        else
+          ierr = matrix->Epetra_CrsMatrix::ReplaceGlobalValues(row, n_columns,
+                                                               const_cast<double *>(col_value_ptr),
+                                                               col_index_ptr);
+      }
+    else
+      {
+        // When we're at off-processor data, we
+        // have to stick with the standard
+        // Insert/ReplaceGlobalValues
+        // function. Nevertheless, the way we
+        // call it is the fastest one (any other
+        // will lead to repeated allocation and
+        // deallocation of memory in order to
+        // call the function we already use,
+        // which is very unefficient if writing
+        // one element at a time).
+        compressed = false;
+
+        if (matrix->Filled() == false)
+          {
+            ierr = matrix->InsertGlobalValues (1, (int *)&row,
+                                               n_columns, col_index_ptr,
+                                               &col_value_ptr,
+                                               Epetra_FECrsMatrix::ROW_MAJOR);
+            if (ierr > 0)
+              ierr = 0;
+          }
+        else
+          ierr = matrix->ReplaceGlobalValues (1, (int *)&row,
+                                              n_columns, col_index_ptr,
+                                              &col_value_ptr,
+                                              Epetra_FECrsMatrix::ROW_MAJOR);
+      }
+
+    Assert (ierr <= 0, ExcAccessToNonPresentElement(row, col_index_ptr[0]));
+    AssertThrow (ierr >= 0, ExcTrilinosError(ierr));
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::add (const unsigned int   i,
+                     const unsigned int   j,
+                     const TrilinosScalar value)
+  {
+    Assert (numbers::is_finite(value), ExcNumberNotFinite());
+
+    if (value == 0)
+      {
+        // we have to do checkings on Insert/Add
+        // in any case
+        // to be consistent with the MPI
+        // communication model (see the comments
+        // in the documentation of
+        // TrilinosWrappers::Vector), but we can
+        // save some work if the addend is
+        // zero. However, these actions are done
+        // in case we pass on to the other
+        // function.
+        if (last_action == Insert)
+          {
+            int ierr;
+            ierr = matrix->GlobalAssemble(*column_space_map,
+                                          row_partitioner(), false);
+
+            Assert (ierr == 0, ExcTrilinosError(ierr));
+            (void)ierr; // removes -Wunused-but-set-variable in optimized mode
+          }
+
+        last_action = Add;
+
+        return;
+      }
+    else
+      add (i, 1, &j, &value, false);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::add (const std::vector<unsigned int> &indices,
+                     const FullMatrix<TrilinosScalar> &values,
+                     const bool                        elide_zero_values)
+  {
+    Assert (indices.size() == values.m(),
+            ExcDimensionMismatch(indices.size(), values.m()));
+    Assert (values.m() == values.n(), ExcNotQuadratic());
+
+    for (unsigned int i=0; i<indices.size(); ++i)
+      add (indices[i], indices.size(), &indices[0], &values(i,0),
+           elide_zero_values);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::add (const std::vector<unsigned int> &row_indices,
+                     const std::vector<unsigned int> &col_indices,
+                     const FullMatrix<TrilinosScalar> &values,
+                     const bool                        elide_zero_values)
+  {
+    Assert (row_indices.size() == values.m(),
+            ExcDimensionMismatch(row_indices.size(), values.m()));
+    Assert (col_indices.size() == values.n(),
+            ExcDimensionMismatch(col_indices.size(), values.n()));
+
+    for (unsigned int i=0; i<row_indices.size(); ++i)
+      add (row_indices[i], col_indices.size(), &col_indices[0],
+           &values(i,0), elide_zero_values);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::add (const unsigned int                 row,
+                     const std::vector<unsigned int>   &col_indices,
+                     const std::vector<TrilinosScalar> &values,
+                     const bool                         elide_zero_values)
+  {
+    Assert (col_indices.size() == values.size(),
+            ExcDimensionMismatch(col_indices.size(), values.size()));
+
+    add (row, col_indices.size(), &col_indices[0], &values[0],
+         elide_zero_values);
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::add (const unsigned int    row,
+                     const unsigned int    n_cols,
+                     const unsigned int   *col_indices,
+                     const TrilinosScalar *values,
+                     const bool            elide_zero_values,
+                     const bool            /*col_indices_are_sorted*/)
+  {
+    int ierr;
+    if (last_action == Insert)
+      {
+        // TODO: this could lead to a dead lock when only one processor
+        // calls GlobalAssemble.
+        ierr = matrix->GlobalAssemble(*column_space_map,
+                                      row_partitioner(), false);
+
+        AssertThrow (ierr == 0, ExcTrilinosError(ierr));
+      }
+
+    last_action = Add;
+
+    int *col_index_ptr;
+    TrilinosScalar const *col_value_ptr;
+    int n_columns;
+
+    // If we don't elide zeros, the pointers
+    // are already available...
+    if (elide_zero_values == false)
+      {
+        col_index_ptr = (int *)col_indices;
+        col_value_ptr = values;
+        n_columns = n_cols;
+#ifdef DEBUG
+        for (unsigned int j=0; j<n_cols; ++j)
+          Assert (numbers::is_finite(values[j]), ExcNumberNotFinite());
+#endif
+      }
+    else
+      {
+        // Otherwise, extract nonzero values in
+        // each row and the corresponding index.
+        if (column_indices.size() < n_cols)
+          {
+            column_indices.resize(n_cols);
+            column_values.resize(n_cols);
+          }
+
+        n_columns = 0;
+        for (unsigned int j=0; j<n_cols; ++j)
+          {
+            const double value = values[j];
+            Assert (numbers::is_finite(value), ExcNumberNotFinite());
+            if (value != 0)
+              {
+                column_indices[n_columns] = col_indices[j];
+                column_values[n_columns] = value;
+                n_columns++;
+              }
+          }
+
+        Assert(n_columns <= (int)n_cols, ExcInternalError());
+
+        col_index_ptr = (int *)&column_indices[0];
+        col_value_ptr = &column_values[0];
+      }
+
+    // If the calling matrix owns the row to
+    // which we want to add values, we
+    // can directly call the Epetra_CrsMatrix
+    // input function, which is much faster
+    // than the Epetra_FECrsMatrix function.
+    if (row_partitioner().MyGID(static_cast<int>(row)) == true)
+      {
+        ierr = matrix->Epetra_CrsMatrix::SumIntoGlobalValues(row, n_columns,
+                                                             const_cast<double *>(col_value_ptr),
+                                                             col_index_ptr);
+      }
+    else
+      {
+        // When we're at off-processor data, we
+        // have to stick with the standard
+        // SumIntoGlobalValues
+        // function. Nevertheless, the way we
+        // call it is the fastest one (any other
+        // will lead to repeated allocation and
+        // deallocation of memory in order to
+        // call the function we already use,
+        // which is very unefficient if writing
+        // one element at a time).
+        compressed = false;
+
+        ierr = matrix->SumIntoGlobalValues (1, (int *)&row, n_columns,
+                                            col_index_ptr,
+                                            &col_value_ptr,
+                                            Epetra_FECrsMatrix::ROW_MAJOR);
+      }
+
+#ifdef DEBUG
+    if (ierr > 0)
+      {
+        std::cout << "------------------------------------------"
+                  << std::endl;
+        std::cout << "Got error " << ierr << " in row " << row
+                  << " of proc " << row_partitioner().Comm().MyPID()
+                  << " when trying to add the columns:" << std::endl;
+        for (int i=0; i<n_columns; ++i)
+          std::cout << col_index_ptr[i] << " ";
+        std::cout << std::endl << std::endl;
+        std::cout << "Matrix row has the following indices:" << std::endl;
+        int n_indices, *indices;
+        trilinos_sparsity_pattern().ExtractMyRowView(row_partitioner().LID(static_cast<int>(row)),
+                                                     n_indices,
+                                                     indices);
+        for (int i=0; i<n_indices; ++i)
+          std::cout << indices[i] << " ";
+        std::cout << endl << std::endl;
+        Assert (ierr <= 0,
+                ExcAccessToNonPresentElement(row, col_index_ptr[0]));
+      }
+#endif
+    Assert (ierr >= 0, ExcTrilinosError(ierr));
+  }
+
+
+
+  // inline "simple" functions that are
+  // called frequently and do only involve
+  // a call to some Trilinos function.
+  inline
+  unsigned int
+  SparseMatrix::m () const
+  {
+    return matrix -> NumGlobalRows();
+  }
+
+
+
+  inline
+  unsigned int
+  SparseMatrix::n () const
+  {
+    return matrix -> NumGlobalCols();
+  }
+
+
+
+  inline
+  unsigned int
+  SparseMatrix::local_size () const
+  {
+    return matrix -> NumMyRows();
+  }
+
+
+
+  inline
+  std::pair<unsigned int, unsigned int>
+  SparseMatrix::local_range () const
+  {
+    unsigned int begin, end;
+    begin = matrix -> RowMap().MinMyGID();
+    end = matrix -> RowMap().MaxMyGID()+1;
+
+    return std::make_pair (begin, end);
+  }
+
+
+
+  inline
+  unsigned int
+  SparseMatrix::n_nonzero_elements () const
+  {
+    return matrix->NumGlobalNonzeros();
+  }
+
+
+
+  template <typename SparsityType>
+  inline
+  void SparseMatrix::reinit (const IndexSet      &parallel_partitioning,
+                             const SparsityType &sparsity_pattern,
+                             const MPI_Comm      &communicator,
+                             const bool           exchange_data)
+  {
+    Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator, false);
+    reinit (map, map, sparsity_pattern, exchange_data);
+  }
+
+
+
+  template <typename SparsityType>
+  inline
+  void SparseMatrix::reinit (const IndexSet      &row_parallel_partitioning,
+                             const IndexSet      &col_parallel_partitioning,
+                             const SparsityType &sparsity_pattern,
+                             const MPI_Comm      &communicator,
+                             const bool           exchange_data)
+  {
+    Epetra_Map row_map =
+      row_parallel_partitioning.make_trilinos_map (communicator, false);
+    Epetra_Map col_map =
+      col_parallel_partitioning.make_trilinos_map (communicator, false);
+    reinit (row_map, col_map, sparsity_pattern, exchange_data);
+  }
+
+
+
+  template <typename number>
+  inline
+  void SparseMatrix::reinit (const IndexSet      &parallel_partitioning,
+                             const ::dealii::SparseMatrix<number> &sparse_matrix,
+                             const MPI_Comm      &communicator,
+                             const double         drop_tolerance,
+                             const bool           copy_values,
+                             const ::dealii::SparsityPattern *use_this_sparsity)
+  {
+    Epetra_Map map = parallel_partitioning.make_trilinos_map (communicator, false);
+    reinit (map, map, sparse_matrix, drop_tolerance, copy_values,
+            use_this_sparsity);
+  }
+
+
+
+  template <typename number>
+  inline
+  void SparseMatrix::reinit (const IndexSet      &row_parallel_partitioning,
+                             const IndexSet      &col_parallel_partitioning,
+                             const ::dealii::SparseMatrix<number> &sparse_matrix,
+                             const MPI_Comm      &communicator,
+                             const double         drop_tolerance,
+                             const bool           copy_values,
+                             const ::dealii::SparsityPattern *use_this_sparsity)
+  {
+    Epetra_Map row_map =
+      row_parallel_partitioning.make_trilinos_map (communicator, false);
+    Epetra_Map col_map =
+      col_parallel_partitioning.make_trilinos_map (communicator, false);
+    reinit (row_map, col_map, sparse_matrix, drop_tolerance, copy_values,
+            use_this_sparsity);
+  }
+
+
+
+  inline
+  TrilinosScalar
+  SparseMatrix::l1_norm () const
+  {
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+    return matrix->NormOne();
+  }
+
+
+
+  inline
+  TrilinosScalar
+  SparseMatrix::linfty_norm () const
+  {
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+    return matrix->NormInf();
+  }
+
+
+
+  inline
+  TrilinosScalar
+  SparseMatrix::frobenius_norm () const
+  {
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+    return matrix->NormFrobenius();
+  }
+
+
+
+  inline
+  SparseMatrix &
+  SparseMatrix::operator *= (const TrilinosScalar a)
+  {
+    const int ierr = matrix->Scale (a);
+    Assert (ierr == 0, ExcTrilinosError(ierr));
+    (void)ierr; // removes -Wunused-variable in optimized mode
+
+    return *this;
+  }
+
+
+
+  inline
+  SparseMatrix &
+  SparseMatrix::operator /= (const TrilinosScalar a)
+  {
+    Assert (a !=0, ExcDivideByZero());
+
+    const TrilinosScalar factor = 1./a;
+
+    const int ierr = matrix->Scale (factor);
+    Assert (ierr == 0, ExcTrilinosError(ierr));
+    (void)ierr; // removes -Wunused-variable in optimized mode
+
+    return *this;
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::vmult (VectorBase       &dst,
+                       const VectorBase &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+
+    Assert (src.vector_partitioner().SameAs(matrix->DomainMap()) == true,
+            ExcMessage ("Column map of matrix does not fit with vector map!"));
+    Assert (dst.vector_partitioner().SameAs(matrix->RangeMap()) == true,
+            ExcMessage ("Row map of matrix does not fit with vector map!"));
+
+    const int ierr = matrix->Multiply (false, src.trilinos_vector(),
+                                       dst.trilinos_vector());
+    Assert (ierr == 0, ExcTrilinosError(ierr));
+    (void)ierr; // removes -Wunused-variable in optimized mode
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::vmult (parallel::distributed::Vector<TrilinosScalar>       &dst,
+                       const parallel::distributed::Vector<TrilinosScalar> &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+
+    AssertDimension (dst.local_size(), static_cast<unsigned int>(matrix->RangeMap().NumMyElements()));
+    AssertDimension (src.local_size(), static_cast<unsigned int>(matrix->DomainMap().NumMyElements()));
+
+    Epetra_Vector tril_dst (View, matrix->RangeMap(), dst.begin());
+    Epetra_Vector tril_src (View, matrix->DomainMap(),
+                            const_cast<double *>(src.begin()));
+
+    const int ierr = matrix->Multiply (false, tril_src, tril_dst);
+    Assert (ierr == 0, ExcTrilinosError(ierr));
+    (void)ierr; // removes -Wunused-variable in optimized mode
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::Tvmult (VectorBase       &dst,
+                        const VectorBase &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+
+    Assert (src.vector_partitioner().SameAs(matrix->RangeMap()) == true,
+            ExcMessage ("Column map of matrix does not fit with vector map!"));
+    Assert (dst.vector_partitioner().SameAs(matrix->DomainMap()) == true,
+            ExcMessage ("Row map of matrix does not fit with vector map!"));
+
+    const int ierr = matrix->Multiply (true, src.trilinos_vector(),
+                                       dst.trilinos_vector());
+    Assert (ierr == 0, ExcTrilinosError(ierr));
+    (void)ierr; // removes -Wunused-variable in optimized mode
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::Tvmult (parallel::distributed::Vector<TrilinosScalar>      &dst,
+                        const parallel::distributed::Vector<TrilinosScalar> &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+    Assert (matrix->Filled(), ExcMatrixNotCompressed());
+
+    AssertDimension (dst.local_size(), static_cast<unsigned int>(matrix->DomainMap().NumMyElements()));
+    AssertDimension (src.local_size(), static_cast<unsigned int>(matrix->RangeMap().NumMyElements()));
+
+    Epetra_Vector tril_dst (View, matrix->DomainMap(), dst.begin());
+    Epetra_Vector tril_src (View, matrix->RangeMap(),
+                            const_cast<double *>(src.begin()));
+
+    const int ierr = matrix->Multiply (true, tril_src, tril_dst);
+    Assert (ierr == 0, ExcTrilinosError(ierr));
+    (void)ierr; // removes -Wunused-variable in optimized mode
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::vmult_add (VectorBase       &dst,
+                           const VectorBase &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+
+    // Choose to reinit the vector with fast
+    // argument set, which does not overwrite
+    // the content -- this is what we need
+    // since we're going to overwrite that
+    // anyway in the vmult operation.
+    temp_vector.reinit(dst, true);
+
+    vmult (temp_vector, src);
+    dst += temp_vector;
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::Tvmult_add (VectorBase       &dst,
+                            const VectorBase &src) const
+  {
+    Assert (&src != &dst, ExcSourceEqualsDestination());
+
+    temp_vector.reinit(dst, true);
+
+    Tvmult (temp_vector, src);
+    dst += temp_vector;
+  }
+
+
+
+  inline
+  TrilinosScalar
+  SparseMatrix::matrix_norm_square (const VectorBase &v) const
+  {
+    Assert (row_partitioner().SameAs(domain_partitioner()),
+            ExcNotQuadratic());
+
+    temp_vector.reinit(v);
+
+    vmult (temp_vector, v);
+    return temp_vector*v;
+  }
+
+
+
+  inline
+  TrilinosScalar
+  SparseMatrix::matrix_scalar_product (const VectorBase &u,
+                                       const VectorBase &v) const
+  {
+    Assert (row_partitioner().SameAs(domain_partitioner()),
+            ExcNotQuadratic());
+
+    temp_vector.reinit(v);
+
+    vmult (temp_vector, v);
+    return u*temp_vector;
+  }
+
+
+
+  inline
+  TrilinosScalar
+  SparseMatrix::residual (VectorBase       &dst,
+                          const VectorBase &x,
+                          const VectorBase &b) const
+  {
+    vmult (dst, x);
+    dst -= b;
+    dst *= -1.;
+
+    return dst.l2_norm();
+  }
+
+
+  inline
+  const Epetra_CrsMatrix &
+  SparseMatrix::trilinos_matrix () const
+  {
+    return static_cast<const Epetra_CrsMatrix &>(*matrix);
+  }
+
+
+
+  inline
+  const Epetra_CrsGraph &
+  SparseMatrix::trilinos_sparsity_pattern () const
+  {
+    return matrix->Graph();
+  }
+
+
+
+  inline
+  const Epetra_Map &
+  SparseMatrix::domain_partitioner () const
+  {
+    return matrix->DomainMap();
+  }
+
+
+
+  inline
+  const Epetra_Map &
+  SparseMatrix::range_partitioner () const
+  {
+    return matrix->RangeMap();
+  }
+
+
+
+  inline
+  const Epetra_Map &
+  SparseMatrix::row_partitioner () const
+  {
+    return matrix->RowMap();
+  }
+
+
+
+  inline
+  const Epetra_Map &
+  SparseMatrix::col_partitioner () const
+  {
+    return matrix->ColMap();
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::prepare_add()
+  {
+    //nothing to do here
+  }
+
+
+
+  inline
+  void
+  SparseMatrix::prepare_set()
+  {
+    //nothing to do here
+  }
+
+
+
+#endif // DOXYGEN
+
+}
+
+
+DEAL_II_NAMESPACE_CLOSE
+
+
+#endif // DEAL_II_USE_TRILINOS
+
+
+/*-----------------------   trilinos_sparse_matrix.h     --------------------*/
+
+#endif
+/*-----------------------   trilinos_sparse_matrix.h     --------------------*/

Modified: branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_vector_base.h
===================================================================
--- branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_vector_base.h	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/include/deal.II/lac/trilinos_vector_base.h	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,5 +1,5 @@
 //---------------------------------------------------------------------------
-//    $Id: trilinos_vector_base.h 26093 2012-08-22 21:37:41Z heister $
+//    $Id: trilinos_vector_base.h 27628 2012-11-20 22:49:26Z heister $
 //
 //    Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors
 //
@@ -39,7 +39,7 @@
 
 DEAL_II_NAMESPACE_OPEN
 
-                                // forward declaration
+// forward declaration
 template <typename number> class Vector;
 
 
@@ -49,512 +49,512 @@
  */
 namespace TrilinosWrappers
 {
-                                // forward declaration
+  // forward declaration
   class VectorBase;
 
 
-                                       /**
-                                        * @cond internal
-                                        */
+  /**
+   * @cond internal
+   */
 
-/**
- * A namespace for internal implementation details of the
- * TrilinosWrapper members.
- *
- * @ingroup TrilinosWrappers
- */
+  /**
+   * A namespace for internal implementation details of the
+   * TrilinosWrapper members.
+   *
+   * @ingroup TrilinosWrappers
+   */
   namespace internal
   {
-                                       /**
-                                        * This class implements a
-                                        * wrapper for accessing the
-                                        * Trilinos vector in the same
-                                        * way as we access deal.II
-                                        * objects: it is initialized
-                                        * with a vector and an element
-                                        * within it, and has a
-                                        * conversion operator to
-                                        * extract the scalar value of
-                                        * this element. It also has a
-                                        * variety of assignment
-                                        * operator for writing to this
-                                        * one element.  @ingroup
-                                        * TrilinosWrappers
-                                        */
+    /**
+     * This class implements a
+     * wrapper for accessing the
+     * Trilinos vector in the same
+     * way as we access deal.II
+     * objects: it is initialized
+     * with a vector and an element
+     * within it, and has a
+     * conversion operator to
+     * extract the scalar value of
+     * this element. It also has a
+     * variety of assignment
+     * operator for writing to this
+     * one element.  @ingroup
+     * TrilinosWrappers
+     */
     class VectorReference
     {
-      private:
-                                       /**
-                                        * Constructor. It is made
-                                        * private so as to only allow
-                                        * the actual vector class to
-                                        * create it.
-                                        */
-        VectorReference (VectorBase        &vector,
-                         const unsigned int index);
+    private:
+      /**
+       * Constructor. It is made
+       * private so as to only allow
+       * the actual vector class to
+       * create it.
+       */
+      VectorReference (VectorBase        &vector,
+                       const unsigned int index);
 
-      public:
-                                       /**
-                                        * This looks like a copy
-                                        * operator, but does something
-                                        * different than usual. In
-                                        * particular, it does not copy
-                                        * the member variables of this
-                                        * reference. Rather, it
-                                        * handles the situation where
-                                        * we have two vectors @p v and
-                                        * @p w, and assign elements
-                                        * like in
-                                        * <tt>v(i)=w(i)</tt>. Here,
-                                        * both left and right hand
-                                        * side of the assignment have
-                                        * data type VectorReference,
-                                        * but what we really mean is
-                                        * to assign the vector
-                                        * elements represented by the
-                                        * two references. This
-                                        * operator implements this
-                                        * operation. Note also that
-                                        * this allows us to make the
-                                        * assignment operator const.
-                                        */
-        const VectorReference &
-          operator = (const VectorReference &r) const;
+    public:
+      /**
+       * This looks like a copy
+       * operator, but does something
+       * different than usual. In
+       * particular, it does not copy
+       * the member variables of this
+       * reference. Rather, it
+       * handles the situation where
+       * we have two vectors @p v and
+       * @p w, and assign elements
+       * like in
+       * <tt>v(i)=w(i)</tt>. Here,
+       * both left and right hand
+       * side of the assignment have
+       * data type VectorReference,
+       * but what we really mean is
+       * to assign the vector
+       * elements represented by the
+       * two references. This
+       * operator implements this
+       * operation. Note also that
+       * this allows us to make the
+       * assignment operator const.
+       */
+      const VectorReference &
+      operator = (const VectorReference &r) const;
 
-                                         /**
-                                          * Same as above but for non-const
-                                          * reference objects.
-                                          */
-        const VectorReference &
-          operator = (const VectorReference &r);
+      /**
+       * Same as above but for non-const
+       * reference objects.
+       */
+      const VectorReference &
+      operator = (const VectorReference &r);
 
-                                       /**
-                                        * Set the referenced element of the
-                                        * vector to <tt>s</tt>.
-                                        */
-        const VectorReference &
-          operator = (const TrilinosScalar &s) const;
+      /**
+       * Set the referenced element of the
+       * vector to <tt>s</tt>.
+       */
+      const VectorReference &
+      operator = (const TrilinosScalar &s) const;
 
-                                       /**
-                                        * Add <tt>s</tt> to the
-                                        * referenced element of the
-                                        * vector->
-                                        */
-        const VectorReference &
-          operator += (const TrilinosScalar &s) const;
+      /**
+       * Add <tt>s</tt> to the
+       * referenced element of the
+       * vector->
+       */
+      const VectorReference &
+      operator += (const TrilinosScalar &s) const;
 
-                                       /**
-                                        * Subtract <tt>s</tt> from the
-                                        * referenced element of the
-                                        * vector->
-                                        */
-        const VectorReference &
-          operator -= (const TrilinosScalar &s) const;
+      /**
+       * Subtract <tt>s</tt> from the
+       * referenced element of the
+       * vector->
+       */
+      const VectorReference &
+      operator -= (const TrilinosScalar &s) const;
 
-                                       /**
-                                        * Multiply the referenced
-                                        * element of the vector by
-                                        * <tt>s</tt>.
-                                        */
-        const VectorReference &
-          operator *= (const TrilinosScalar &s) const;
+      /**
+       * Multiply the referenced
+       * element of the vector by
+       * <tt>s</tt>.
+       */
+      const VectorReference &
+      operator *= (const TrilinosScalar &s) const;
 
-                                       /**
-                                        * Divide the referenced
-                                        * element of the vector by
-                                        * <tt>s</tt>.
-                                        */
-        const VectorReference &
-          operator /= (const TrilinosScalar &s) const;
+      /**
+       * Divide the referenced
+       * element of the vector by
+       * <tt>s</tt>.
+       */
+      const VectorReference &
+      operator /= (const TrilinosScalar &s) const;
 
-                                       /**
-                                        * Convert the reference to an
-                                        * actual value, i.e. return
-                                        * the value of the referenced
-                                        * element of the vector.
-                                        */
-        operator TrilinosScalar () const;
+      /**
+       * Convert the reference to an
+       * actual value, i.e. return
+       * the value of the referenced
+       * element of the vector.
+       */
+      operator TrilinosScalar () const;
 
-                                       /**
-                                        * Exception
-                                        */
-        DeclException1 (ExcTrilinosError,
-                        int,
-                        << "An error with error number " << arg1
-                        << " occurred while calling a Trilinos function");
+      /**
+       * Exception
+       */
+      DeclException1 (ExcTrilinosError,
+                      int,
+                      << "An error with error number " << arg1
+                      << " occurred while calling a Trilinos function");
 
-                                       /**
-                                        * Exception
-                                        */
-        DeclException3 (ExcAccessToNonLocalElement,
-                        int, int, int,
-                        << "You tried to access element " << arg1
-                        << " of a distributed vector, but only elements "
-                        << arg2 << " through " << arg3
-                        << " are stored locally and can be accessed.");
+      /**
+       * Exception
+       */
+      DeclException3 (ExcAccessToNonLocalElement,
+                      int, int, int,
+                      << "You tried to access element " << arg1
+                      << " of a distributed vector, but only elements "
+                      << arg2 << " through " << arg3
+                      << " are stored locally and can be accessed.");
 
-      private:
-                                       /**
-                                        * Point to the vector we are
-                                        * referencing.
-                                        */
-        VectorBase   &vector;
+    private:
+      /**
+       * Point to the vector we are
+       * referencing.
+       */
+      VectorBase   &vector;
 
-                                       /**
-                                        * Index of the referenced element
-                                        * of the vector.
-                                        */
-        const unsigned int  index;
+      /**
+       * Index of the referenced element
+       * of the vector.
+       */
+      const unsigned int  index;
 
-                                       /**
-                                        * Make the vector class a
-                                        * friend, so that it can
-                                        * create objects of the
-                                        * present type.
-                                        */
-        friend class ::dealii::TrilinosWrappers::VectorBase;
+      /**
+       * Make the vector class a
+       * friend, so that it can
+       * create objects of the
+       * present type.
+       */
+      friend class ::dealii::TrilinosWrappers::VectorBase;
     };
   }
-                                       /**
-                                        * @endcond
-                                        */
+  /**
+   * @endcond
+   */
 
 
-/**
- * Base class for the two types of Trilinos vectors, the distributed
- * memory vector MPI::Vector and a localized vector Vector. The latter
- * is designed for use in either serial implementations or as a
- * localized copy on each processor.  The implementation of this class
- * is based on the Trilinos vector class Epetra_FEVector, the (parallel)
- * partitioning of which is governed by an Epetra_Map. This means that
- * the vector type is generic and can be done in this base class, while
- * the definition of the partition map (and hence, the constructor and
- * reinit function) will have to be done in the derived classes. The
- * Epetra_FEVector is precisely the kind of vector we deal with all the
- * time - we probably get it from some assembly process, where also
- * entries not locally owned might need to written and hence need to be
- * forwarded to the owner. The only requirement for this class to work
- * is that Trilinos is installed with the same compiler as is used for
- * compilation of deal.II.
- *
- * The interface of this class is modeled after the existing Vector
- * class in deal.II. It has almost the same member functions, and is
- * often exchangable. However, since Trilinos only supports a single
- * scalar type (double), it is not templated, and only works with that
- * type.
- *
- * Note that Trilinos only guarantees that operations do what you expect
- * if the function @p GlobalAssemble has been called after vector
- * assembly in order to distribute the data. Therefore, you need to call
- * Vector::compress() before you actually use the vectors.
- *
- * @ingroup TrilinosWrappers
- * @ingroup Vectors
- * @author Martin Kronbichler, 2008
- */
+  /**
+   * Base class for the two types of Trilinos vectors, the distributed
+   * memory vector MPI::Vector and a localized vector Vector. The latter
+   * is designed for use in either serial implementations or as a
+   * localized copy on each processor.  The implementation of this class
+   * is based on the Trilinos vector class Epetra_FEVector, the (parallel)
+   * partitioning of which is governed by an Epetra_Map. This means that
+   * the vector type is generic and can be done in this base class, while
+   * the definition of the partition map (and hence, the constructor and
+   * reinit function) will have to be done in the derived classes. The
+   * Epetra_FEVector is precisely the kind of vector we deal with all the
+   * time - we probably get it from some assembly process, where also
+   * entries not locally owned might need to written and hence need to be
+   * forwarded to the owner. The only requirement for this class to work
+   * is that Trilinos is installed with the same compiler as is used for
+   * compilation of deal.II.
+   *
+   * The interface of this class is modeled after the existing Vector
+   * class in deal.II. It has almost the same member functions, and is
+   * often exchangable. However, since Trilinos only supports a single
+   * scalar type (double), it is not templated, and only works with that
+   * type.
+   *
+   * Note that Trilinos only guarantees that operations do what you expect
+   * if the function @p GlobalAssemble has been called after vector
+   * assembly in order to distribute the data. Therefore, you need to call
+   * Vector::compress() before you actually use the vectors.
+   *
+   * @ingroup TrilinosWrappers
+   * @ingroup Vectors
+   * @author Martin Kronbichler, 2008
+   */
   class VectorBase : public Subscriptor
   {
-    public:
-                                       /**
-                                        * Declare some of the standard
-                                        * types used in all
-                                        * containers. These types
-                                        * parallel those in the
-                                        * <tt>C</tt> standard libraries
-                                        * <tt>vector<...></tt> class.
-                                        */
-      typedef TrilinosScalar            value_type;
-      typedef TrilinosScalar            real_type;
-      typedef std::size_t               size_type;
-      typedef internal::VectorReference reference;
-      typedef const internal::VectorReference const_reference;
+  public:
+    /**
+     * Declare some of the standard
+     * types used in all
+     * containers. These types
+     * parallel those in the
+     * <tt>C</tt> standard libraries
+     * <tt>vector<...></tt> class.
+     */
+    typedef TrilinosScalar            value_type;
+    typedef TrilinosScalar            real_type;
+    typedef std::size_t               size_type;
+    typedef internal::VectorReference reference;
+    typedef const internal::VectorReference const_reference;
 
-                                       /**
-                                        * @name 1: Basic Object-handling
-                                        */
-                                       //@{
+    /**
+     * @name 1: Basic Object-handling
+     */
+    //@{
 
-                                       /**
-                                        * Default constructor that
-                                        * generates an empty (zero size)
-                                        * vector. The function
-                                        * <tt>reinit()</tt> will have to
-                                        * give the vector the correct
-                                        * size and distribution among
-                                        * processes in case of an MPI
-                                        * run.
-                                        */
-      VectorBase ();
+    /**
+     * Default constructor that
+     * generates an empty (zero size)
+     * vector. The function
+     * <tt>reinit()</tt> will have to
+     * give the vector the correct
+     * size and distribution among
+     * processes in case of an MPI
+     * run.
+     */
+    VectorBase ();
 
-                                       /**
-                                        * Copy constructor. Sets the
-                                        * dimension to that of the given
-                                        * vector, and copies all the
-                                        * elements.
-                                        */
-      VectorBase (const VectorBase &v);
+    /**
+     * Copy constructor. Sets the
+     * dimension to that of the given
+     * vector, and copies all the
+     * elements.
+     */
+    VectorBase (const VectorBase &v);
 
-                                       /**
-                                        * Destructor
-                                        */
-      virtual ~VectorBase ();
+    /**
+     * Destructor
+     */
+    virtual ~VectorBase ();
 
-                                       /**
-                                        * Release all memory and return
-                                        * to a state just like after
-                                        * having called the default
-                                        * constructor.
-                                        */
-      void clear ();
+    /**
+     * Release all memory and return
+     * to a state just like after
+     * having called the default
+     * constructor.
+     */
+    void clear ();
 
-                                       /**
-                                        * Reinit functionality, sets the
-                                        * dimension and possibly the
-                                        * parallel partitioning (Epetra_Map)
-                                        * of the calling vector to the
-                                        * settings of the input vector.
-                                        */
-      void reinit (const VectorBase &v,
-                   const bool        fast = false);
+    /**
+     * Reinit functionality, sets the
+     * dimension and possibly the
+     * parallel partitioning (Epetra_Map)
+     * of the calling vector to the
+     * settings of the input vector.
+     */
+    void reinit (const VectorBase &v,
+                 const bool        fast = false);
 
-                                       /**
-                                        * Compress the underlying
-                                        * representation of the Trilinos
-                                        * object, i.e. flush the buffers
-                                        * of the vector object if it has
-                                        * any. This function is
-                                        * necessary after writing into a
-                                        * vector element-by-element and
-                                        * before anything else can be
-                                        * done on it.
-                                        *
-                                        * The (defaulted) argument can
-                                        * be used to specify the
-                                        * compress mode
-                                        * (<code>Add</code> or
-                                        * <code>Insert</code>) in case
-                                        * the vector has not been
-                                        * written to since the last
-                                        * time this function was
-                                        * called. The argument is
-                                        * ignored if the vector has
-                                        * been added or written to
-                                        * since the last time
-                                        * compress() was called.
-                                        *
-                                        * See @ref GlossCompress "Compressing distributed objects"
-                                        * for more information.
-                                        */
-      void compress (::dealii::VectorOperation::values operation
-		     =::dealii::VectorOperation::unknown);
+    /**
+     * Compress the underlying
+     * representation of the Trilinos
+     * object, i.e. flush the buffers
+     * of the vector object if it has
+     * any. This function is
+     * necessary after writing into a
+     * vector element-by-element and
+     * before anything else can be
+     * done on it.
+     *
+     * The (defaulted) argument can
+     * be used to specify the
+     * compress mode
+     * (<code>Add</code> or
+     * <code>Insert</code>) in case
+     * the vector has not been
+     * written to since the last
+     * time this function was
+     * called. The argument is
+     * ignored if the vector has
+     * been added or written to
+     * since the last time
+     * compress() was called.
+     *
+     * See @ref GlossCompress "Compressing distributed objects"
+     * for more information.
+     */
+    void compress (::dealii::VectorOperation::values operation
+                   =::dealii::VectorOperation::unknown);
 
-				       /**
-					* @deprecated
-					*/
-      void compress (const Epetra_CombineMode last_action);
+    /**
+    * @deprecated
+    */
+    void compress (const Epetra_CombineMode last_action);
 
-                                       /**
-                                        * Returns the state of the
-                                        * vector, i.e., whether
-                                        * compress() has already been
-                                        * called after an operation
-                                        * requiring data exchange.
-                                        */
-      bool is_compressed () const;
+    /**
+     * Returns the state of the
+     * vector, i.e., whether
+     * compress() has already been
+     * called after an operation
+     * requiring data exchange.
+     */
+    bool is_compressed () const;
 
-                                       /**
-                                        * Set all components of the
-                                        * vector to the given number @p
-                                        * s. Simply pass this down to
-                                        * the Trilinos Epetra object,
-                                        * but we still need to declare
-                                        * this function to make the
-                                        * example given in the
-                                        * discussion about making the
-                                        * constructor explicit work.
-                                        *
-                                        * Since the semantics of
-                                        * assigning a scalar to a vector
-                                        * are not immediately clear,
-                                        * this operator should really
-                                        * only be used if you want to
-                                        * set the entire vector to
-                                        * zero. This allows the
-                                        * intuitive notation
-                                        * <tt>v=0</tt>. Assigning other
-                                        * values is deprecated and may
-                                        * be disallowed in the future.
-                                        */
-      VectorBase &
-        operator = (const TrilinosScalar s);
+    /**
+     * Set all components of the
+     * vector to the given number @p
+     * s. Simply pass this down to
+     * the Trilinos Epetra object,
+     * but we still need to declare
+     * this function to make the
+     * example given in the
+     * discussion about making the
+     * constructor explicit work.
+     *
+     * Since the semantics of
+     * assigning a scalar to a vector
+     * are not immediately clear,
+     * this operator should really
+     * only be used if you want to
+     * set the entire vector to
+     * zero. This allows the
+     * intuitive notation
+     * <tt>v=0</tt>. Assigning other
+     * values is deprecated and may
+     * be disallowed in the future.
+     */
+    VectorBase &
+    operator = (const TrilinosScalar s);
 
-                                       /**
-                                        * Copy function. This function takes
-                                        * a VectorBase vector and copies all
-                                        * the elements. The target vector
-                                        * will have the same parallel
-                                        * distribution as the calling
-                                        * vector.
-                                        */
-      VectorBase &
-        operator = (const VectorBase &v);
+    /**
+     * Copy function. This function takes
+     * a VectorBase vector and copies all
+     * the elements. The target vector
+     * will have the same parallel
+     * distribution as the calling
+     * vector.
+     */
+    VectorBase &
+    operator = (const VectorBase &v);
 
-                                       /**
-                                        * Another copy function. This
-                                        * one takes a deal.II vector and
-                                        * copies it into a
-                                        * TrilinosWrapper vector. Note
-                                        * that since we do not provide
-                                        * any Epetra_map that tells
-                                        * about the partitioning of the
-                                        * vector among the MPI
-                                        * processes, the size of the
-                                        * TrilinosWrapper vector has to
-                                        * be the same as the size of the
-                                        * input vector. In order to
-                                        * change the map, use the
-                                        * reinit(const Epetra_Map
-                                        * &input_map) function.
-                                        */
-      template <typename Number>
-      VectorBase &
-        operator = (const ::dealii::Vector<Number> &v);
+    /**
+     * Another copy function. This
+     * one takes a deal.II vector and
+     * copies it into a
+     * TrilinosWrapper vector. Note
+     * that since we do not provide
+     * any Epetra_map that tells
+     * about the partitioning of the
+     * vector among the MPI
+     * processes, the size of the
+     * TrilinosWrapper vector has to
+     * be the same as the size of the
+     * input vector. In order to
+     * change the map, use the
+     * reinit(const Epetra_Map
+     * &input_map) function.
+     */
+    template <typename Number>
+    VectorBase &
+    operator = (const ::dealii::Vector<Number> &v);
 
-                                       /**
-                                        * Test for equality. This
-                                        * function assumes that the
-                                        * present vector and the one to
-                                        * compare with have the same
-                                        * size already, since comparing
-                                        * vectors of different sizes
-                                        * makes not much sense anyway.
-                                        */
-      bool operator == (const VectorBase &v) const;
+    /**
+     * Test for equality. This
+     * function assumes that the
+     * present vector and the one to
+     * compare with have the same
+     * size already, since comparing
+     * vectors of different sizes
+     * makes not much sense anyway.
+     */
+    bool operator == (const VectorBase &v) const;
 
-                                       /**
-                                        * Test for inequality. This
-                                        * function assumes that the
-                                        * present vector and the one to
-                                        * compare with have the same
-                                        * size already, since comparing
-                                        * vectors of different sizes
-                                        * makes not much sense anyway.
-                                        */
-      bool operator != (const VectorBase &v) const;
+    /**
+     * Test for inequality. This
+     * function assumes that the
+     * present vector and the one to
+     * compare with have the same
+     * size already, since comparing
+     * vectors of different sizes
+     * makes not much sense anyway.
+     */
+    bool operator != (const VectorBase &v) const;
 
-                                       /**
-                                        * Return the global dimension of
-                                        * the vector.
-                                        */
-      unsigned int size () const;
+    /**
+     * Return the global dimension of
+     * the vector.
+     */
+    unsigned int size () const;
 
-                                       /**
-                                        * Return the local dimension of
-                                        * the vector, i.e. the number of
-                                        * elements stored on the present
-                                        * MPI process. For sequential
-                                        * vectors, this number is the
-                                        * same as size(), but for
-                                        * parallel vectors it may be
-                                        * smaller.
-                                        *
-                                        * To figure out which elements
-                                        * exactly are stored locally,
-                                        * use local_range().
-                                        *
-                                        * If the vector contains ghost
-                                        * elements, they are included in
-                                        * this number.
-                                        */
-      unsigned int local_size () const;
+    /**
+     * Return the local dimension of
+     * the vector, i.e. the number of
+     * elements stored on the present
+     * MPI process. For sequential
+     * vectors, this number is the
+     * same as size(), but for
+     * parallel vectors it may be
+     * smaller.
+     *
+     * To figure out which elements
+     * exactly are stored locally,
+     * use local_range().
+     *
+     * If the vector contains ghost
+     * elements, they are included in
+     * this number.
+     */
+    unsigned int local_size () const;
 
-                                       /**
-                                        * Return a pair of indices
-                                        * indicating which elements of
-                                        * this vector are stored
-                                        * locally. The first number is
-                                        * the index of the first element
-                                        * stored, the second the index
-                                        * of the one past the last one
-                                        * that is stored locally. If
-                                        * this is a sequential vector,
-                                        * then the result will be the
-                                        * pair (0,N), otherwise it will
-                                        * be a pair (i,i+n), where
-                                        * <tt>n=local_size()</tt>.
-                                        */
-      std::pair<unsigned int, unsigned int> local_range () const;
+    /**
+     * Return a pair of indices
+     * indicating which elements of
+     * this vector are stored
+     * locally. The first number is
+     * the index of the first element
+     * stored, the second the index
+     * of the one past the last one
+     * that is stored locally. If
+     * this is a sequential vector,
+     * then the result will be the
+     * pair (0,N), otherwise it will
+     * be a pair (i,i+n), where
+     * <tt>n=local_size()</tt>.
+     */
+    std::pair<unsigned int, unsigned int> local_range () const;
 
-                                       /**
-                                        * Return whether @p index is in
-                                        * the local range or not, see
-                                        * also local_range().
-                                        */
-      bool in_local_range (const unsigned int index) const;
+    /**
+     * Return whether @p index is in
+     * the local range or not, see
+     * also local_range().
+     */
+    bool in_local_range (const unsigned int index) const;
 
-                                       /**
-                                        * Return if the vector contains ghost
-                                        * elements. This answer is true if there
-                                        * are ghost elements on at least one
-                                        * process.
-                                        */
-      bool has_ghost_elements() const;
+    /**
+     * Return if the vector contains ghost
+     * elements. This answer is true if there
+     * are ghost elements on at least one
+     * process.
+     */
+    bool has_ghost_elements() const;
 
-                                       /**
-                                        * Return the scalar (inner)
-                                        * product of two vectors. The
-                                        * vectors must have the same
-                                        * size.
-                                        */
-      TrilinosScalar operator * (const VectorBase &vec) const;
+    /**
+     * Return the scalar (inner)
+     * product of two vectors. The
+     * vectors must have the same
+     * size.
+     */
+    TrilinosScalar operator * (const VectorBase &vec) const;
 
-                                       /**
-                                        * Return square of the
-                                        * $l_2$-norm.
-                                        */
-      real_type norm_sqr () const;
+    /**
+     * Return square of the
+     * $l_2$-norm.
+     */
+    real_type norm_sqr () const;
 
-                                       /**
-                                        * Mean value of the elements of
-                                        * this vector.
-                                        */
-      TrilinosScalar mean_value () const;
+    /**
+     * Mean value of the elements of
+     * this vector.
+     */
+    TrilinosScalar mean_value () const;
 
-                                       /**
-                                        * Compute the minimal value of
-                                        * the elements of this vector.
-                                        */
-      TrilinosScalar minimal_value () const;
+    /**
+     * Compute the minimal value of
+     * the elements of this vector.
+     */
+    TrilinosScalar minimal_value () const;
 
-                                       /**
-                                        * $l_1$-norm of the vector.  The
-                                        * sum of the absolute values.
-                                        */
-      real_type l1_norm () const;
+    /**
+     * $l_1$-norm of the vector.  The
+     * sum of the absolute values.
+     */
+    real_type l1_norm () const;
 
-                                       /**
-                                        * $l_2$-norm of the vector.  The
-                                        * square root of the sum of the
-                                        * squares of the elements.
-                                        */
-      real_type l2_norm () const;
+    /**
+     * $l_2$-norm of the vector.  The
+     * square root of the sum of the
+     * squares of the elements.
+     */
+    real_type l2_norm () const;
 
-                                       /**
-                                        * $l_p$-norm of the vector. The
-                                        * <i>p</i>th root of the sum of
-                                        * the <i>p</i>th powers of the
-                                        * absolute values of the
-                                        * elements.
-                                        */
-      real_type lp_norm (const TrilinosScalar p) const;
+    /**
+     * $l_p$-norm of the vector. The
+     * <i>p</i>th root of the sum of
+     * the <i>p</i>th powers of the
+     * absolute values of the
+     * elements.
+     */
+    real_type lp_norm (const TrilinosScalar p) const;
 
-                                       /**
-                                        * Maximum absolute value of the
-                                        * elements.
-                                        */
-      real_type linfty_norm () const;
+    /**
+     * Maximum absolute value of the
+     * elements.
+     */
+    real_type linfty_norm () const;
 
-									  /**
+    /**
 									   * Return vector component with
 									   * the minimal magnitude.
 									   */
@@ -566,486 +566,486 @@
 									   */
       real_type max () const;
                                        /**
-                                        * Return whether the vector
-                                        * contains only elements with
-                                        * value zero. This function is
-                                        * mainly for internal
-                                        * consistency checks and should
-                                        * seldom be used when not in
-                                        * debug mode since it uses quite
-                                        * some time.
-                                        */
-      bool all_zero () const;
+     * Return whether the vector
+     * contains only elements with
+     * value zero. This function is
+     * mainly for internal
+     * consistency checks and should
+     * seldom be used when not in
+     * debug mode since it uses quite
+     * some time.
+     */
+    bool all_zero () const;
 
-                                       /**
-                                        * Return @p true if the vector
-                                        * has no negative entries,
-                                        * i.e. all entries are zero or
-                                        * positive. This function is
-                                        * used, for example, to check
-                                        * whether refinement indicators
-                                        * are really all positive (or
-                                        * zero).
-                                        */
-      bool is_non_negative () const;
-                                       //@}
+    /**
+     * Return @p true if the vector
+     * has no negative entries,
+     * i.e. all entries are zero or
+     * positive. This function is
+     * used, for example, to check
+     * whether refinement indicators
+     * are really all positive (or
+     * zero).
+     */
+    bool is_non_negative () const;
+    //@}
 
 
-                                       /**
-                                        * @name 2: Data-Access
-                                        */
-                                       //@{
+    /**
+     * @name 2: Data-Access
+     */
+    //@{
 
-                                       /**
-                                        * Provide access to a given
-                                        * element, both read and write.
-                                        */
-      reference
-        operator () (const unsigned int index);
+    /**
+     * Provide access to a given
+     * element, both read and write.
+     */
+    reference
+    operator () (const unsigned int index);
 
-                                       /**
-                                        * Provide read-only access to an
-                                        * element. This is equivalent to
-                                        * the <code>el()</code> command.
-                                        */
-      TrilinosScalar
-        operator () (const unsigned int index) const;
+    /**
+     * Provide read-only access to an
+     * element. This is equivalent to
+     * the <code>el()</code> command.
+     */
+    TrilinosScalar
+    operator () (const unsigned int index) const;
 
-                                       /**
-                                        * Provide access to a given
-                                        * element, both read and write.
-                                        *
-                                        * Exactly the same as operator().
-                                        */
-      reference
-        operator [] (const unsigned int index);
+    /**
+     * Provide access to a given
+     * element, both read and write.
+     *
+     * Exactly the same as operator().
+     */
+    reference
+    operator [] (const unsigned int index);
 
-                                       /**
-                                        * Provide read-only access to an
-                                        * element. This is equivalent to
-                                        * the <code>el()</code> command.
-                                        *
-                                        * Exactly the same as operator().
-                                        */
-      TrilinosScalar
-        operator [] (const unsigned int index) const;
+    /**
+     * Provide read-only access to an
+     * element. This is equivalent to
+     * the <code>el()</code> command.
+     *
+     * Exactly the same as operator().
+     */
+    TrilinosScalar
+    operator [] (const unsigned int index) const;
 
-                                       /**
-                                        * Return the value of the vector
-                                        * entry <i>i</i>. Note that this
-                                        * function does only work
-                                        * properly when we request a
-                                        * data stored on the local
-                                        * processor. The function will
-                                        * throw an exception in case the
-                                        * elements sits on another
-                                        * process.
-                                        */
-      TrilinosScalar el (const unsigned int index) const;
+    /**
+     * Return the value of the vector
+     * entry <i>i</i>. Note that this
+     * function does only work
+     * properly when we request a
+     * data stored on the local
+     * processor. The function will
+     * throw an exception in case the
+     * elements sits on another
+     * process.
+     */
+    TrilinosScalar el (const unsigned int index) const;
 
-                                       /**
-                                        * A collective set operation:
-                                        * instead of setting individual
-                                        * elements of a vector, this
-                                        * function allows to set a whole
-                                        * set of elements at once. The
-                                        * indices of the elements to be
-                                        * set are stated in the first
-                                        * argument, the corresponding
-                                        * values in the second.
-                                        */
-      void set (const std::vector<unsigned int>    &indices,
-                const std::vector<TrilinosScalar>  &values);
+    /**
+     * A collective set operation:
+     * instead of setting individual
+     * elements of a vector, this
+     * function allows to set a whole
+     * set of elements at once. The
+     * indices of the elements to be
+     * set are stated in the first
+     * argument, the corresponding
+     * values in the second.
+     */
+    void set (const std::vector<unsigned int>    &indices,
+              const std::vector<TrilinosScalar> &values);
 
-                                       /**
-                                        * This is a second collective
-                                        * set operation. As a
-                                        * difference, this function
-                                        * takes a deal.II vector of
-                                        * values.
-                                        */
-      void set (const std::vector<unsigned int>        &indices,
-                const ::dealii::Vector<TrilinosScalar> &values);
-                                       //@}
+    /**
+     * This is a second collective
+     * set operation. As a
+     * difference, this function
+     * takes a deal.II vector of
+     * values.
+     */
+    void set (const std::vector<unsigned int>        &indices,
+              const ::dealii::Vector<TrilinosScalar> &values);
+    //@}
 
 
-                                       /**
-                                        * @name 3: Modification of vectors
-                                        */
-                                       //@{
+    /**
+     * @name 3: Modification of vectors
+     */
+    //@{
 
-                                       /**
-                                        * This collective set operation
-                                        * is of lower level and can
-                                        * handle anything else &mdash;
-                                        * the only thing you have to
-                                        * provide is an address where
-                                        * all the indices are stored and
-                                        * the number of elements to be
-                                        * set.
-                                        */
-      void set (const unsigned int    n_elements,
-                const unsigned int   *indices,
-                const TrilinosScalar *values);
+    /**
+     * This collective set operation
+     * is of lower level and can
+     * handle anything else &mdash;
+     * the only thing you have to
+     * provide is an address where
+     * all the indices are stored and
+     * the number of elements to be
+     * set.
+     */
+    void set (const unsigned int    n_elements,
+              const unsigned int   *indices,
+              const TrilinosScalar *values);
 
-                                       /**
-                                        * A collective add operation:
-                                        * This funnction adds a whole
-                                        * set of values stored in @p
-                                        * values to the vector
-                                        * components specified by @p
-                                        * indices.
-                                        */
-      void add (const std::vector<unsigned int>   &indices,
-                const std::vector<TrilinosScalar> &values);
+    /**
+     * A collective add operation:
+     * This funnction adds a whole
+     * set of values stored in @p
+     * values to the vector
+     * components specified by @p
+     * indices.
+     */
+    void add (const std::vector<unsigned int>   &indices,
+              const std::vector<TrilinosScalar> &values);
 
-                                       /**
-                                        * This is a second collective
-                                        * add operation. As a
-                                        * difference, this function
-                                        * takes a deal.II vector of
-                                        * values.
-                                        */
-      void add (const std::vector<unsigned int>        &indices,
-                const ::dealii::Vector<TrilinosScalar> &values);
+    /**
+     * This is a second collective
+     * add operation. As a
+     * difference, this function
+     * takes a deal.II vector of
+     * values.
+     */
+    void add (const std::vector<unsigned int>        &indices,
+              const ::dealii::Vector<TrilinosScalar> &values);
 
-                                      /**
-                                       * Take an address where
-                                       * <tt>n_elements</tt> are stored
-                                       * contiguously and add them into
-                                       * the vector. Handles all cases
-                                       * which are not covered by the
-                                       * other two <tt>add()</tt>
-                                       * functions above.
-                                       */
-      void add (const unsigned int    n_elements,
-                const unsigned int   *indices,
-                const TrilinosScalar *values);
+    /**
+     * Take an address where
+     * <tt>n_elements</tt> are stored
+     * contiguously and add them into
+     * the vector. Handles all cases
+     * which are not covered by the
+     * other two <tt>add()</tt>
+     * functions above.
+     */
+    void add (const unsigned int    n_elements,
+              const unsigned int   *indices,
+              const TrilinosScalar *values);
 
-                                       /**
-                                        * Multiply the entire vector by
-                                        * a fixed factor.
-                                        */
-      VectorBase & operator *= (const TrilinosScalar factor);
+    /**
+     * Multiply the entire vector by
+     * a fixed factor.
+     */
+    VectorBase &operator *= (const TrilinosScalar factor);
 
-                                       /**
-                                        * Divide the entire vector by a
-                                        * fixed factor.
-                                        */
-      VectorBase & operator /= (const TrilinosScalar factor);
+    /**
+     * Divide the entire vector by a
+     * fixed factor.
+     */
+    VectorBase &operator /= (const TrilinosScalar factor);
 
-                                       /**
-                                        * Add the given vector to the
-                                        * present one.
-                                        */
-      VectorBase & operator += (const VectorBase &V);
+    /**
+     * Add the given vector to the
+     * present one.
+     */
+    VectorBase &operator += (const VectorBase &V);
 
-                                       /**
-                                        * Subtract the given vector from
-                                        * the present one.
-                                        */
-      VectorBase & operator -= (const VectorBase &V);
+    /**
+     * Subtract the given vector from
+     * the present one.
+     */
+    VectorBase &operator -= (const VectorBase &V);
 
-                                       /**
-                                        * Addition of @p s to all
-                                        * components. Note that @p s is
-                                        * a scalar and not a vector.
-                                        */
-      void add (const TrilinosScalar s);
+    /**
+     * Addition of @p s to all
+     * components. Note that @p s is
+     * a scalar and not a vector.
+     */
+    void add (const TrilinosScalar s);
 
-                                       /**
-                                        * Simple vector addition, equal
-                                        * to the <tt>operator
-                                        * +=</tt>.
-                                        *
-                                        * Though, if the second argument
-                                        * <tt>allow_different_maps</tt>
-                                        * is set, then it is possible to
-                                        * add data from a different map.
-                                        */
-      void add (const VectorBase &V,
-                const bool        allow_different_maps = false);
+    /**
+     * Simple vector addition, equal
+     * to the <tt>operator
+     * +=</tt>.
+     *
+     * Though, if the second argument
+     * <tt>allow_different_maps</tt>
+     * is set, then it is possible to
+     * add data from a different map.
+     */
+    void add (const VectorBase &V,
+              const bool        allow_different_maps = false);
 
-                                       /**
-                                        * Simple addition of a multiple
-                                        * of a vector, i.e. <tt>*this =
-                                        * a*V</tt>.
-                                        */
-      void add (const TrilinosScalar  a,
-                const VectorBase     &V);
+    /**
+     * Simple addition of a multiple
+     * of a vector, i.e. <tt>*this =
+     * a*V</tt>.
+     */
+    void add (const TrilinosScalar  a,
+              const VectorBase     &V);
 
-                                       /**
-                                        * Multiple addition of scaled
-                                        * vectors, i.e. <tt>*this = a*V +
-                                        * b*W</tt>.
-                                        */
-      void add (const TrilinosScalar  a,
-                const VectorBase     &V,
-                const TrilinosScalar  b,
-                const VectorBase     &W);
+    /**
+     * Multiple addition of scaled
+     * vectors, i.e. <tt>*this = a*V +
+     * b*W</tt>.
+     */
+    void add (const TrilinosScalar  a,
+              const VectorBase     &V,
+              const TrilinosScalar  b,
+              const VectorBase     &W);
 
-                                       /**
-                                        * Scaling and simple vector
-                                        * addition, i.e.  <tt>*this =
-                                        * s*(*this) + V</tt>.
-                                        */
-      void sadd (const TrilinosScalar  s,
-                 const VectorBase     &V);
+    /**
+     * Scaling and simple vector
+     * addition, i.e.  <tt>*this =
+     * s*(*this) + V</tt>.
+     */
+    void sadd (const TrilinosScalar  s,
+               const VectorBase     &V);
 
-                                       /**
-                                        * Scaling and simple addition,
-                                        * i.e.  <tt>*this = s*(*this) +
-                                        * a*V</tt>.
-                                        */
-      void sadd (const TrilinosScalar  s,
-                 const TrilinosScalar  a,
-                 const VectorBase     &V);
+    /**
+     * Scaling and simple addition,
+     * i.e.  <tt>*this = s*(*this) +
+     * a*V</tt>.
+     */
+    void sadd (const TrilinosScalar  s,
+               const TrilinosScalar  a,
+               const VectorBase     &V);
 
-                                       /**
-                                        * Scaling and multiple addition.
-                                        */
-      void sadd (const TrilinosScalar  s,
-                 const TrilinosScalar  a,
-                 const VectorBase     &V,
-                 const TrilinosScalar  b,
-                 const VectorBase     &W);
+    /**
+     * Scaling and multiple addition.
+     */
+    void sadd (const TrilinosScalar  s,
+               const TrilinosScalar  a,
+               const VectorBase     &V,
+               const TrilinosScalar  b,
+               const VectorBase     &W);
 
-                                       /**
-                                        * Scaling and multiple addition.
-                                        * <tt>*this = s*(*this) + a*V +
-                                        * b*W + c*X</tt>.
-                                        */
-      void sadd (const TrilinosScalar  s,
-                 const TrilinosScalar  a,
-                 const VectorBase     &V,
-                 const TrilinosScalar  b,
-                 const VectorBase     &W,
-                 const TrilinosScalar  c,
-                 const VectorBase     &X);
+    /**
+     * Scaling and multiple addition.
+     * <tt>*this = s*(*this) + a*V +
+     * b*W + c*X</tt>.
+     */
+    void sadd (const TrilinosScalar  s,
+               const TrilinosScalar  a,
+               const VectorBase     &V,
+               const TrilinosScalar  b,
+               const VectorBase     &W,
+               const TrilinosScalar  c,
+               const VectorBase     &X);
 
-                                       /**
-                                        * Scale each element of this
-                                        * vector by the corresponding
-                                        * element in the argument. This
-                                        * function is mostly meant to
-                                        * simulate multiplication (and
-                                        * immediate re-assignment) by a
-                                        * diagonal scaling matrix.
-                                        */
-      void scale (const VectorBase &scaling_factors);
+    /**
+     * Scale each element of this
+     * vector by the corresponding
+     * element in the argument. This
+     * function is mostly meant to
+     * simulate multiplication (and
+     * immediate re-assignment) by a
+     * diagonal scaling matrix.
+     */
+    void scale (const VectorBase &scaling_factors);
 
-                                       /**
-                                        * Assignment <tt>*this =
-                                        * a*V</tt>.
-                                        */
-      void equ (const TrilinosScalar  a,
-                const VectorBase     &V);
+    /**
+     * Assignment <tt>*this =
+     * a*V</tt>.
+     */
+    void equ (const TrilinosScalar  a,
+              const VectorBase     &V);
 
-                                       /**
-                                        * Assignment <tt>*this = a*V +
-                                        * b*W</tt>.
-                                        */
-      void equ (const TrilinosScalar  a,
-                const VectorBase     &V,
-                const TrilinosScalar  b,
-                const VectorBase     &W);
+    /**
+     * Assignment <tt>*this = a*V +
+     * b*W</tt>.
+     */
+    void equ (const TrilinosScalar  a,
+              const VectorBase     &V,
+              const TrilinosScalar  b,
+              const VectorBase     &W);
 
-                                       /**
-                                        * Compute the elementwise ratio
-                                        * of the two given vectors, that
-                                        * is let <tt>this[i] =
-                                        * a[i]/b[i]</tt>. This is useful
-                                        * for example if you want to
-                                        * compute the cellwise ratio of
-                                        * true to estimated error.
-                                        *
-                                        * This vector is appropriately
-                                        * scaled to hold the result.
-                                        *
-                                        * If any of the <tt>b[i]</tt> is
-                                        * zero, the result is
-                                        * undefined. No attempt is made
-                                        * to catch such situations.
-                                        */
-      void ratio (const VectorBase &a,
-                  const VectorBase &b);
-                                       //@}
+    /**
+     * Compute the elementwise ratio
+     * of the two given vectors, that
+     * is let <tt>this[i] =
+     * a[i]/b[i]</tt>. This is useful
+     * for example if you want to
+     * compute the cellwise ratio of
+     * true to estimated error.
+     *
+     * This vector is appropriately
+     * scaled to hold the result.
+     *
+     * If any of the <tt>b[i]</tt> is
+     * zero, the result is
+     * undefined. No attempt is made
+     * to catch such situations.
+     */
+    void ratio (const VectorBase &a,
+                const VectorBase &b);
+    //@}
 
 
-                                       /**
-                                        * @name 4: Mixed stuff
-                                        */
-                                       //@{
+    /**
+     * @name 4: Mixed stuff
+     */
+    //@{
 
-                                       /**
-                                        * Return a const reference to the
-                                        * underlying Trilinos
-                                        * Epetra_MultiVector class.
-                                        */
-      const Epetra_MultiVector & trilinos_vector () const;
+    /**
+     * Return a const reference to the
+     * underlying Trilinos
+     * Epetra_MultiVector class.
+     */
+    const Epetra_MultiVector &trilinos_vector () const;
 
-                                       /**
-                                        * Return a (modifyable) reference to
-                                        * the underlying Trilinos
-                                        * Epetra_FEVector class.
-                                        */
-      Epetra_FEVector & trilinos_vector ();
+    /**
+     * Return a (modifyable) reference to
+     * the underlying Trilinos
+     * Epetra_FEVector class.
+     */
+    Epetra_FEVector &trilinos_vector ();
 
-                                       /**
-                                        * Return a const reference to the
-                                        * underlying Trilinos Epetra_Map
-                                        * that sets the parallel
-                                        * partitioning of the vector.
-                                        */
-      const Epetra_Map & vector_partitioner () const;
+    /**
+     * Return a const reference to the
+     * underlying Trilinos Epetra_Map
+     * that sets the parallel
+     * partitioning of the vector.
+     */
+    const Epetra_Map &vector_partitioner () const;
 
-                                       /**
-                                        *  Output of vector in
-                                        *  user-defined format in analogy
-                                        *  to the dealii::Vector<number>
-                                        *  class.
-                                        */
-      void print (const char* format = 0) const;
+    /**
+     *  Output of vector in
+     *  user-defined format in analogy
+     *  to the dealii::Vector<number>
+     *  class.
+     */
+    void print (const char *format = 0) const;
 
-                                       /**
-                                        * Print to a stream. @p
-                                        * precision denotes the desired
-                                        * precision with which values
-                                        * shall be printed, @p
-                                        * scientific whether scientific
-                                        * notation shall be used. If @p
-                                        * across is @p true then the
-                                        * vector is printed in a line,
-                                        * while if @p false then the
-                                        * elements are printed on a
-                                        * separate line each.
-                                        */
-      void print (std::ostream       &out,
-                  const unsigned int  precision  = 3,
-                  const bool          scientific = true,
-                  const bool          across     = true) const;
+    /**
+     * Print to a stream. @p
+     * precision denotes the desired
+     * precision with which values
+     * shall be printed, @p
+     * scientific whether scientific
+     * notation shall be used. If @p
+     * across is @p true then the
+     * vector is printed in a line,
+     * while if @p false then the
+     * elements are printed on a
+     * separate line each.
+     */
+    void print (std::ostream       &out,
+                const unsigned int  precision  = 3,
+                const bool          scientific = true,
+                const bool          across     = true) const;
 
-                                       /**
-                                        * Swap the contents of this
-                                        * vector and the other vector @p
-                                        * v. One could do this operation
-                                        * with a temporary variable and
-                                        * copying over the data
-                                        * elements, but this function is
-                                        * significantly more efficient
-                                        * since it only swaps the
-                                        * pointers to the data of the
-                                        * two vectors and therefore does
-                                        * not need to allocate temporary
-                                        * storage and move data
-                                        * around. Note that the vectors
-                                        * need to be of the same size
-                                        * and base on the same map.
-                                        *
-                                        * This function is analog to the
-                                        * the @p swap function of all C
-                                        * standard containers. Also,
-                                        * there is a global function
-                                        * <tt>swap(u,v)</tt> that simply
-                                        * calls <tt>u.swap(v)</tt>,
-                                        * again in analogy to standard
-                                        * functions.
-                                        */
-      void swap (VectorBase &v);
+    /**
+     * Swap the contents of this
+     * vector and the other vector @p
+     * v. One could do this operation
+     * with a temporary variable and
+     * copying over the data
+     * elements, but this function is
+     * significantly more efficient
+     * since it only swaps the
+     * pointers to the data of the
+     * two vectors and therefore does
+     * not need to allocate temporary
+     * storage and move data
+     * around. Note that the vectors
+     * need to be of the same size
+     * and base on the same map.
+     *
+     * This function is analog to the
+     * the @p swap function of all C
+     * standard containers. Also,
+     * there is a global function
+     * <tt>swap(u,v)</tt> that simply
+     * calls <tt>u.swap(v)</tt>,
+     * again in analogy to standard
+     * functions.
+     */
+    void swap (VectorBase &v);
 
-                                       /**
-                                        * Estimate for the memory
-                                        * consumption in bytes.
-                                        */
-      std::size_t memory_consumption () const;
-                                       //@}
+    /**
+     * Estimate for the memory
+     * consumption in bytes.
+     */
+    std::size_t memory_consumption () const;
+    //@}
 
-                                       /**
-                                        * Exception
-                                        */
-      DeclException0 (ExcGhostsPresent);
+    /**
+     * Exception
+     */
+    DeclException0 (ExcGhostsPresent);
 
-                                       /**
-                                        * Exception
-                                        */
-      DeclException0 (ExcDifferentParallelPartitioning);
+    /**
+     * Exception
+     */
+    DeclException0 (ExcDifferentParallelPartitioning);
 
-                                       /**
-                                        * Exception
-                                        */
-      DeclException1 (ExcTrilinosError,
-                      int,
-                      << "An error with error number " << arg1
-                      << " occurred while calling a Trilinos function");
+    /**
+     * Exception
+     */
+    DeclException1 (ExcTrilinosError,
+                    int,
+                    << "An error with error number " << arg1
+                    << " occurred while calling a Trilinos function");
 
-                                       /**
-                                        * Exception
-                                        */
-      DeclException3 (ExcAccessToNonlocalElement,
-                      int, int, int,
-                      << "You tried to access element " << arg1
-                      << " of a distributed vector, but only entries "
-                      << arg2 << " through " << arg3
-                      << " are stored locally and can be accessed.");
+    /**
+     * Exception
+     */
+    DeclException3 (ExcAccessToNonlocalElement,
+                    int, int, int,
+                    << "You tried to access element " << arg1
+                    << " of a distributed vector, but only entries "
+                    << arg2 << " through " << arg3
+                    << " are stored locally and can be accessed.");
 
 
-    private:
-                                       /**
-                                        * Trilinos doesn't allow to
-                                        * mix additions to matrix
-                                        * entries and overwriting them
-                                        * (to make synchronisation of
-                                        * parallel computations
-                                        * simpler). The way we do it
-                                        * is to, for each access
-                                        * operation, store whether it
-                                        * is an insertion or an
-                                        * addition. If the previous
-                                        * one was of different type,
-                                        * then we first have to flush
-                                        * the Trilinos buffers;
-                                        * otherwise, we can simply go
-                                        * on.  Luckily, Trilinos has
-                                        * an object for this which
-                                        * does already all the
-                                        * parallel communications in
-                                        * such a case, so we simply
-                                        * use their model, which
-                                        * stores whether the last
-                                        * operation was an addition or
-                                        * an insertion.
-                                        */
-      Epetra_CombineMode last_action;
+  private:
+    /**
+     * Trilinos doesn't allow to
+     * mix additions to matrix
+     * entries and overwriting them
+     * (to make synchronisation of
+     * parallel computations
+     * simpler). The way we do it
+     * is to, for each access
+     * operation, store whether it
+     * is an insertion or an
+     * addition. If the previous
+     * one was of different type,
+     * then we first have to flush
+     * the Trilinos buffers;
+     * otherwise, we can simply go
+     * on.  Luckily, Trilinos has
+     * an object for this which
+     * does already all the
+     * parallel communications in
+     * such a case, so we simply
+     * use their model, which
+     * stores whether the last
+     * operation was an addition or
+     * an insertion.
+     */
+    Epetra_CombineMode last_action;
 
-                                       /**
-                                        * A boolean variable to hold
-                                        * information on whether the
-                                        * vector is compressed or not.
-                                        */
-      bool compressed;
+    /**
+     * A boolean variable to hold
+     * information on whether the
+     * vector is compressed or not.
+     */
+    bool compressed;
 
-      /**
-       * Whether this vector has ghost elements. This is true
-       * on all processors even if only one of them has any
-       * ghost elements.
-       */
-      bool has_ghosts;
+    /**
+     * Whether this vector has ghost elements. This is true
+     * on all processors even if only one of them has any
+     * ghost elements.
+     */
+    bool has_ghosts;
 
-                                       /**
-                                        * An Epetra distibuted vector
-                                        * type. Requires an existing
-                                        * Epetra_Map for storing data.
-                                        */
-      std_cxx1x::shared_ptr<Epetra_FEVector> vector;
+    /**
+     * An Epetra distibuted vector
+     * type. Requires an existing
+     * Epetra_Map for storing data.
+     */
+    std_cxx1x::shared_ptr<Epetra_FEVector> vector;
 
 
-                                       /**
-                                        * Make the reference class a
-                                        * friend.
-                                        */
-      friend class internal::VectorReference;
-      friend class Vector;
-      friend class MPI::Vector;
+    /**
+     * Make the reference class a
+     * friend.
+     */
+    friend class internal::VectorReference;
+    friend class Vector;
+    friend class MPI::Vector;
   };
 
 
@@ -1053,14 +1053,14 @@
 
 // ------------------- inline and template functions --------------
 
-/**
- * Global function swap which overloads the default implementation of
- * the C standard library which uses a temporary object. The function
- * simply exchanges the data of the two vectors.
- *
- * @relates TrilinosWrappers::VectorBase
- * @author Martin Kronbichler, Wolfgang Bangerth, 2008
- */
+  /**
+   * Global function swap which overloads the default implementation of
+   * the C standard library which uses a temporary object. The function
+   * simply exchanges the data of the two vectors.
+   *
+   * @relates TrilinosWrappers::VectorBase
+   * @author Martin Kronbichler, Wolfgang Bangerth, 2008
+   */
   inline
   void swap (VectorBase &u, VectorBase &v)
   {
@@ -1075,9 +1075,9 @@
     inline
     VectorReference::VectorReference (VectorBase        &vector,
                                       const unsigned int index)
-                    :
-                    vector (vector),
-                    index (index)
+      :
+      vector (vector),
+      index (index)
     {}
 
 
@@ -1085,10 +1085,10 @@
     const VectorReference &
     VectorReference::operator = (const VectorReference &r) const
     {
-                                        // as explained in the class
-                                        // documentation, this is not the copy
-                                        // operator. so simply pass on to the
-                                        // "correct" assignment operator
+      // as explained in the class
+      // documentation, this is not the copy
+      // operator. so simply pass on to the
+      // "correct" assignment operator
       *this = static_cast<TrilinosScalar> (r);
 
       return *this;
@@ -1100,7 +1100,7 @@
     const VectorReference &
     VectorReference::operator = (const VectorReference &r)
     {
-                                        // as above
+      // as above
       *this = static_cast<TrilinosScalar> (r);
 
       return *this;
@@ -1235,7 +1235,8 @@
   void
   VectorBase::compress (const Epetra_CombineMode last_action)
   {
-    ::dealii::VectorOperation::values last_action_;
+    ::dealii::VectorOperation::values last_action_ =
+      ::dealii::VectorOperation::unknown;
     if (last_action == Add)
       last_action_ = ::dealii::VectorOperation::add;
     else if (last_action == Insert)
@@ -1245,41 +1246,41 @@
 
     compress(last_action_);
   }
-  
 
 
+
   inline
   void
   VectorBase::compress (::dealii::VectorOperation::values given_last_action)
   {
-				     //Select which mode to send to
-				     //Trilinos. Note that we use last_action
-				     //if available and ignore what the user
-				     //tells us to detect wrongly mixed
-				     //operations. Typically given_last_action
-				     //is only used on machines that do not
-				     //execute an operation (because they have
-				     //no own cells for example).
+    //Select which mode to send to
+    //Trilinos. Note that we use last_action
+    //if available and ignore what the user
+    //tells us to detect wrongly mixed
+    //operations. Typically given_last_action
+    //is only used on machines that do not
+    //execute an operation (because they have
+    //no own cells for example).
     Epetra_CombineMode mode = last_action;
     if (last_action == Zero)
       {
-	if (given_last_action==::dealii::VectorOperation::add)
-	  mode = Add;
-	else if (given_last_action==::dealii::VectorOperation::insert)
-	  mode = Insert;
+        if (given_last_action==::dealii::VectorOperation::add)
+          mode = Add;
+        else if (given_last_action==::dealii::VectorOperation::insert)
+          mode = Insert;
       }
 
 #ifdef DEBUG
 #  ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                                     // check that every process has decided
-                                     // to use the same mode. This will
-                                     // otherwise result in undefined
-                                     // behaviour in the call to
-                                     // GlobalAssemble().
+    // check that every process has decided
+    // to use the same mode. This will
+    // otherwise result in undefined
+    // behaviour in the call to
+    // GlobalAssemble().
     double double_mode = mode;
     Utilities::MPI::MinMaxAvg result
       = Utilities::MPI::min_max_avg (double_mode,
-                                     dynamic_cast<const Epetra_MpiComm*>
+                                     dynamic_cast<const Epetra_MpiComm *>
                                      (&vector_partitioner().Comm())->GetMpiComm());
     Assert(result.max-result.min<1e-5,
            ExcMessage ("Not all processors agree whether the last operation on "
@@ -1289,8 +1290,8 @@
 #  endif
 #endif
 
-                                 // Now pass over the information about
-                                 // what we did last to the vector.
+    // Now pass over the information about
+    // what we did last to the vector.
     const int ierr = vector->GlobalAssemble(mode);
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
     last_action = Zero;
@@ -1304,8 +1305,8 @@
   VectorBase &
   VectorBase::operator = (const TrilinosScalar s)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
 
     Assert (numbers::is_finite(s), ExcNumberNotFinite());
@@ -1322,10 +1323,10 @@
   inline
   void
   VectorBase::set (const std::vector<unsigned int>    &indices,
-                   const std::vector<TrilinosScalar>  &values)
+                   const std::vector<TrilinosScalar> &values)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
 
     Assert (indices.size() == values.size(),
@@ -1341,8 +1342,8 @@
   VectorBase::set (const std::vector<unsigned int>        &indices,
                    const ::dealii::Vector<TrilinosScalar> &values)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
 
     Assert (indices.size() == values.size(),
@@ -1359,8 +1360,8 @@
                    const unsigned int   *indices,
                    const TrilinosScalar *values)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
 
     if (last_action == Add)
@@ -1372,11 +1373,11 @@
     for (unsigned int i=0; i<n_elements; ++i)
       {
         const unsigned int row = indices[i];
-        const int local_row = vector->Map().LID(indices[i]);
+        const int local_row = vector->Map().LID(static_cast<int>(row));
         if (local_row == -1)
           {
             const int ierr = vector->ReplaceGlobalValues (1,
-                                                          (const int*)(&row),
+                                                          (const int *)(&row),
                                                           &values[i]);
             AssertThrow (ierr == 0, ExcTrilinosError(ierr));
             compressed = false;
@@ -1391,10 +1392,10 @@
   inline
   void
   VectorBase::add (const std::vector<unsigned int>    &indices,
-                   const std::vector<TrilinosScalar>  &values)
+                   const std::vector<TrilinosScalar> &values)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (indices.size() == values.size(),
             ExcDimensionMismatch(indices.size(),values.size()));
@@ -1409,8 +1410,8 @@
   VectorBase::add (const std::vector<unsigned int>        &indices,
                    const ::dealii::Vector<TrilinosScalar> &values)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (indices.size() == values.size(),
             ExcDimensionMismatch(indices.size(),values.size()));
@@ -1426,8 +1427,8 @@
                    const unsigned int   *indices,
                    const TrilinosScalar *values)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
 
     if (last_action != Add)
@@ -1440,11 +1441,11 @@
     for (unsigned int i=0; i<n_elements; ++i)
       {
         const unsigned int row = indices[i];
-        const int local_row = vector->Map().LID(row);
+        const int local_row = vector->Map().LID(static_cast<int>(row));
         if (local_row == -1)
           {
             const int ierr = vector->SumIntoGlobalValues (1,
-                                                          (const int*)(&row),
+                                                          (const int *)(&row),
                                                           &values[i]);
             AssertThrow (ierr == 0, ExcTrilinosError(ierr));
             compressed = false;
@@ -1583,8 +1584,8 @@
     TrilinosScalar sum=0;
     const unsigned int n_local = local_size();
 
-                                        // loop over all the elements because
-                                        // Trilinos does not support lp norms
+    // loop over all the elements because
+    // Trilinos does not support lp norms
     for (unsigned int i=0; i<n_local; i++)
       sum += std::pow(std::fabs((*vector)[0][i]), p);
 
@@ -1599,11 +1600,11 @@
   VectorBase::real_type
   VectorBase::linfty_norm () const
   {
-                                     // while we disallow the other
-                                     // norm operations on ghosted
-                                     // vectors, this particular norm
-                                     // is safe to run even in the
-                                     // presence of ghost elements
+    // while we disallow the other
+    // norm operations on ghosted
+    // vectors, this particular norm
+    // is safe to run even in the
+    // presence of ghost elements
     TrilinosScalar d;
     const int ierr = vector->NormInf (&d);
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
@@ -1613,11 +1614,11 @@
 
 
 
-                                   // inline also scalar products, vector
-                                   // additions etc. since they are all
-                                   // representable by a single Trilinos
-                                   // call. This reduces the overhead of the
-                                   // wrapper class.
+  // inline also scalar products, vector
+  // additions etc. since they are all
+  // representable by a single Trilinos
+  // call. This reduces the overhead of the
+  // wrapper class.
   inline
   VectorBase &
   VectorBase::operator *= (const TrilinosScalar a)
@@ -1688,8 +1689,8 @@
   void
   VectorBase::add (const TrilinosScalar s)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (numbers::is_finite(s), ExcNumberNotFinite());
 
@@ -1705,8 +1706,8 @@
   VectorBase::add (const TrilinosScalar  a,
                    const VectorBase     &v)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (local_size() == v.local_size(),
             ExcDimensionMismatch(local_size(), v.local_size()));
@@ -1726,8 +1727,8 @@
                    const TrilinosScalar  b,
                    const VectorBase     &w)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (local_size() == v.local_size(),
             ExcDimensionMismatch(local_size(), v.local_size()));
@@ -1749,8 +1750,8 @@
   VectorBase::sadd (const TrilinosScalar  s,
                     const VectorBase     &v)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (local_size() == v.local_size(),
             ExcDimensionMismatch(local_size(), v.local_size()));
@@ -1770,8 +1771,8 @@
                     const TrilinosScalar  a,
                     const VectorBase     &v)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (local_size() == v.local_size(),
             ExcDimensionMismatch(local_size(), v.local_size()));
@@ -1794,8 +1795,8 @@
                     const TrilinosScalar  b,
                     const VectorBase     &w)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (local_size() == v.local_size(),
             ExcDimensionMismatch(local_size(), v.local_size()));
@@ -1823,8 +1824,8 @@
                     const TrilinosScalar  c,
                     const VectorBase     &x)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (local_size() == v.local_size(),
             ExcDimensionMismatch(local_size(), v.local_size()));
@@ -1838,9 +1839,9 @@
     Assert (numbers::is_finite(b), ExcNumberNotFinite());
     Assert (numbers::is_finite(c), ExcNumberNotFinite());
 
-                                        // Update member can only
-                                        // input two other vectors so
-                                        // do it in two steps
+    // Update member can only
+    // input two other vectors so
+    // do it in two steps
     const int ierr = vector->Update(a, *(v.vector), b, *(w.vector), s);
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
@@ -1855,8 +1856,8 @@
   void
   VectorBase::scale (const VectorBase &factors)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (local_size() == factors.local_size(),
             ExcDimensionMismatch(local_size(), factors.local_size()));
@@ -1872,12 +1873,12 @@
   VectorBase::equ (const TrilinosScalar  a,
                    const VectorBase     &v)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (numbers::is_finite(a), ExcNumberNotFinite());
 
-                                   // If we don't have the same map, copy.
+    // If we don't have the same map, copy.
     if (vector->Map().SameAs(v.vector->Map())==false)
       {
         *vector = *v.vector;
@@ -1885,7 +1886,7 @@
       }
     else
       {
-                                   // Otherwise, just update
+        // Otherwise, just update
         int ierr = vector->Update(a, *v.vector, 0.0);
         AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
@@ -1903,8 +1904,8 @@
                    const TrilinosScalar  b,
                    const VectorBase     &w)
   {
-                                     // if we have ghost values, do not allow
-                                     // writing to this vector at all.
+    // if we have ghost values, do not allow
+    // writing to this vector at all.
     Assert (!has_ghost_elements(), ExcGhostsPresent());
     Assert (v.local_size() == w.local_size(),
             ExcDimensionMismatch (v.local_size(), w.local_size()));
@@ -1912,19 +1913,19 @@
     Assert (numbers::is_finite(a), ExcNumberNotFinite());
     Assert (numbers::is_finite(b), ExcNumberNotFinite());
 
-                                   // If we don't have the same map, copy.
-     if (vector->Map().SameAs(v.vector->Map())==false)
+    // If we don't have the same map, copy.
+    if (vector->Map().SameAs(v.vector->Map())==false)
       {
         *vector = *v.vector;
         sadd(a, b, w);
       }
     else
       {
-                                   // Otherwise, just update. verify
-                                   // that *this does not only have
-                                   // the same map as v (the
-                                   // if-condition above) but also as
-                                   // w
+        // Otherwise, just update. verify
+        // that *this does not only have
+        // the same map as v (the
+        // if-condition above) but also as
+        // w
         Assert (vector->Map().SameAs(w.vector->Map()),
                 ExcDifferentParallelPartitioning());
         int ierr = vector->Update(a, *v.vector, b, *w.vector, 0.0);
@@ -1958,7 +1959,7 @@
   const Epetra_MultiVector &
   VectorBase::trilinos_vector () const
   {
-    return static_cast<const Epetra_MultiVector&>(*vector);
+    return static_cast<const Epetra_MultiVector &>(*vector);
   }
 
 
@@ -1976,7 +1977,7 @@
   const Epetra_Map &
   VectorBase::vector_partitioner () const
   {
-    return static_cast<const Epetra_Map&>(vector->Map());
+    return static_cast<const Epetra_Map &>(vector->Map());
   }
 
 

Modified: branches/s-wang/for_deal.II/source/lac/constraint_matrix.cc
===================================================================
--- branches/s-wang/for_deal.II/source/lac/constraint_matrix.cc	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/source/lac/constraint_matrix.cc	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,5 +1,5 @@
 //---------------------------------------------------------------------------
-//    $Id: constraint_matrix.cc 26168 2012-08-29 21:27:03Z heister $
+//    $Id: constraint_matrix.cc 27628 2012-11-20 22:49:26Z heister $
 //
 //    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
 //
@@ -41,20 +41,13 @@
 #include <algorithm>
 #include <numeric>
 #include <set>
+#include <ostream>
 
-// we only need output streams, but older compilers did not provide
-// them in a separate include file
-#ifdef HAVE_STD_OSTREAM_HEADER
-#  include <ostream>
-#else
-#  include <iostream>
-#endif
-
 DEAL_II_NAMESPACE_OPEN
 
 
 
-                                        // Static member variable
+// Static member variable
 const Table<2,bool> ConstraintMatrix::default_empty_table = Table<2,bool>();
 
 
@@ -97,7 +90,7 @@
 ConstraintMatrix::add_lines (const std::set<unsigned int> &lines)
 {
   for (std::set<unsigned int>::const_iterator
-         i = lines.begin(); i != lines.end(); ++i)
+       i = lines.begin(); i != lines.end(); ++i)
     add_line (*i);
 }
 
@@ -124,38 +117,38 @@
 
 void
 ConstraintMatrix::add_entries
-  (const unsigned int                                  line,
-   const std::vector<std::pair<unsigned int,double> > &col_val_pairs)
+(const unsigned int                                  line,
+ const std::vector<std::pair<unsigned int,double> > &col_val_pairs)
 {
   Assert (sorted==false, ExcMatrixIsClosed());
   Assert (is_constrained(line), ExcLineInexistant(line));
 
-  ConstraintLine * line_ptr = &lines[lines_cache[calculate_line_index(line)]];
+  ConstraintLine *line_ptr = &lines[lines_cache[calculate_line_index(line)]];
   Assert (line_ptr->line == line, ExcInternalError());
 
-                                   // if in debug mode, check whether an
-                                   // entry for this column already
-                                   // exists and if its the same as
-                                   // the one entered at present
-                                   //
-                                   // in any case: skip this entry if
-                                   // an entry for this column already
-                                   // exists, since we don't want to
-                                   // enter it twice
+  // if in debug mode, check whether an
+  // entry for this column already
+  // exists and if its the same as
+  // the one entered at present
+  //
+  // in any case: skip this entry if
+  // an entry for this column already
+  // exists, since we don't want to
+  // enter it twice
   for (std::vector<std::pair<unsigned int,double> >::const_iterator
-         col_val_pair = col_val_pairs.begin();
+       col_val_pair = col_val_pairs.begin();
        col_val_pair!=col_val_pairs.end(); ++col_val_pair)
     {
       Assert (line != col_val_pair->first,
               ExcMessage ("Can't constrain a degree of freedom to itself"));
 
       for (ConstraintLine::Entries::const_iterator
-             p=line_ptr->entries.begin();
+           p=line_ptr->entries.begin();
            p != line_ptr->entries.end(); ++p)
         if (p->first == col_val_pair->first)
           {
-                                             // entry exists, break
-                                             // innermost loop
+            // entry exists, break
+            // innermost loop
             Assert (p->second == col_val_pair->second,
                     ExcEntryAlreadyExists(line, col_val_pair->first,
                                           p->second, col_val_pair->second));
@@ -169,8 +162,8 @@
 
 
 void ConstraintMatrix::add_selected_constraints
-  (const ConstraintMatrix &constraints,
-   const IndexSet         &filter)
+(const ConstraintMatrix &constraints,
+ const IndexSet         &filter)
 {
   if (constraints.n_constraints() == 0)
     return;
@@ -198,13 +191,13 @@
   if (sorted == true)
     return;
 
-                                   // sort the lines
+  // sort the lines
   std::sort (lines.begin(), lines.end());
 
-                                   // update list of pointers and give the
-                                   // vector a sharp size since we won't
-                                   // modify the size any more after this
-                                   // point.
+  // update list of pointers and give the
+  // vector a sharp size since we won't
+  // modify the size any more after this
+  // point.
   {
     std::vector<unsigned int> new_lines (lines_cache.size(),
                                          numbers::invalid_unsigned_int);
@@ -215,24 +208,24 @@
     std::swap (lines_cache, new_lines);
   }
 
-                                   // in debug mode: check whether we really
-                                   // set the pointers correctly.
+  // in debug mode: check whether we really
+  // set the pointers correctly.
   for (unsigned int i=0; i<lines_cache.size(); ++i)
     if (lines_cache[i] != numbers::invalid_unsigned_int)
       Assert (i == calculate_line_index(lines[lines_cache[i]].line),
               ExcInternalError());
 
-                                   // first, strip zero entries, as we
-                                   // have to do that only once
+  // first, strip zero entries, as we
+  // have to do that only once
   for (std::vector<ConstraintLine>::iterator line = lines.begin();
        line!=lines.end(); ++line)
-                                     // first remove zero
-                                     // entries. that would mean that
-                                     // in the linear constraint for a
-                                     // node, x_i = ax_1 + bx_2 + ...,
-                                     // another node times 0
-                                     // appears. obviously,
-                                     // 0*something can be omitted
+    // first remove zero
+    // entries. that would mean that
+    // in the linear constraint for a
+    // node, x_i = ax_1 + bx_2 + ...,
+    // another node times 0
+    // appears. obviously,
+    // 0*something can be omitted
     line->entries.erase (std::remove_if (line->entries.begin(),
                                          line->entries.end(),
                                          &check_zero_weight),
@@ -250,40 +243,40 @@
   // in our system.
   unsigned int largest_idx = 0;
   for (std::vector<ConstraintLine>::iterator line = lines.begin();
-             line!=lines.end(); ++line)
+       line!=lines.end(); ++line)
     {
-      for (ConstraintLine::Entries::iterator it = line->entries.begin();it!=line->entries.end();++it)
+      for (ConstraintLine::Entries::iterator it = line->entries.begin(); it!=line->entries.end(); ++it)
         {
           largest_idx=std::max(largest_idx, it->first);
         }
     }
 #endif
 
-                                   // replace references to dofs that
-                                   // are themselves constrained. note
-                                   // that because we may replace
-                                   // references to other dofs that
-                                   // may themselves be constrained to
-                                   // third ones, we have to iterate
-                                   // over all this until we replace
-                                   // no chains of constraints any
-                                   // more
-                                   //
-                                   // the iteration replaces
-                                   // references to constrained
-                                   // degrees of freedom by
-                                   // second-order references. for
-                                   // example if x3=x0/2+x2/2 and
-                                   // x2=x0/2+x1/2, then the new list
-                                   // will be x3=x0/2+x0/4+x1/4. note
-                                   // that x0 appear twice. we will
-                                   // throw this duplicate out in the
-                                   // following step, where we sort
-                                   // the list so that throwing out
-                                   // duplicates becomes much more
-                                   // efficient. also, we have to do
-                                   // it only once, rather than in
-                                   // each iteration
+  // replace references to dofs that
+  // are themselves constrained. note
+  // that because we may replace
+  // references to other dofs that
+  // may themselves be constrained to
+  // third ones, we have to iterate
+  // over all this until we replace
+  // no chains of constraints any
+  // more
+  //
+  // the iteration replaces
+  // references to constrained
+  // degrees of freedom by
+  // second-order references. for
+  // example if x3=x0/2+x2/2 and
+  // x2=x0/2+x1/2, then the new list
+  // will be x3=x0/2+x0/4+x1/4. note
+  // that x0 appear twice. we will
+  // throw this duplicate out in the
+  // following step, where we sort
+  // the list so that throwing out
+  // duplicates becomes much more
+  // efficient. also, we have to do
+  // it only once, rather than in
+  // each iteration
   unsigned int iteration = 0;
   while (true)
     {
@@ -300,16 +293,16 @@
 
 
 
-                                           // loop over all entries of
-                                           // this line (including
-                                           // ones that we have
-                                           // appended in this go
-                                           // around) and see whether
-                                           // they are further
-                                           // constrained. ignore
-                                           // elements that we don't
-                                           // store on the current
-                                           // processor
+          // loop over all entries of
+          // this line (including
+          // ones that we have
+          // appended in this go
+          // around) and see whether
+          // they are further
+          // constrained. ignore
+          // elements that we don't
+          // store on the current
+          // processor
           unsigned int entry = 0;
           while (entry < line->entries.size())
             if (((local_lines.size() == 0)
@@ -318,58 +311,58 @@
                 &&
                 is_constrained (line->entries[entry].first))
               {
-                                                 // ok, this entry is
-                                                 // further
-                                                 // constrained:
+                // ok, this entry is
+                // further
+                // constrained:
                 chained_constraint_replaced = true;
 
-                                                 // look up the chain
-                                                 // of constraints for
-                                                 // this entry
+                // look up the chain
+                // of constraints for
+                // this entry
                 const unsigned int dof_index = line->entries[entry].first;
                 const double       weight = line->entries[entry].second;
 
                 Assert (dof_index != line->line,
                         ExcMessage ("Cycle in constraints detected!"));
 
-                const ConstraintLine * constrained_line =
+                const ConstraintLine *constrained_line =
                   &lines[lines_cache[calculate_line_index(dof_index)]];
                 Assert (constrained_line->line == dof_index,
                         ExcInternalError());
 
-                                                 // now we have to
-                                                 // replace an entry
-                                                 // by its
-                                                 // expansion. we do
-                                                 // that by
-                                                 // overwriting the
-                                                 // entry by the first
-                                                 // entry of the
-                                                 // expansion and
-                                                 // adding the
-                                                 // remaining ones to
-                                                 // the end, where we
-                                                 // will later process
-                                                 // them once more
-                                                 //
-                                                 // we can of course
-                                                 // only do that if
-                                                 // the DoF that we
-                                                 // are currently
-                                                 // handle is
-                                                 // constrained by a
-                                                 // linear combination
-                                                 // of other dofs:
+                // now we have to
+                // replace an entry
+                // by its
+                // expansion. we do
+                // that by
+                // overwriting the
+                // entry by the first
+                // entry of the
+                // expansion and
+                // adding the
+                // remaining ones to
+                // the end, where we
+                // will later process
+                // them once more
+                //
+                // we can of course
+                // only do that if
+                // the DoF that we
+                // are currently
+                // handle is
+                // constrained by a
+                // linear combination
+                // of other dofs:
                 if (constrained_line->entries.size() > 0)
                   {
                     for (unsigned int i=0; i<constrained_line->entries.size(); ++i)
                       Assert (dof_index != constrained_line->entries[i].first,
                               ExcMessage ("Cycle in constraints detected!"));
 
-                                                     // replace first
-                                                     // entry, then tack
-                                                     // the rest to the
-                                                     // end of the list
+                    // replace first
+                    // entry, then tack
+                    // the rest to the
+                    // end of the list
                     line->entries[entry] =
                       std::make_pair (constrained_line->entries[0].first,
                                       constrained_line->entries[0].second *
@@ -377,9 +370,9 @@
 
                     for (unsigned int i=1; i<constrained_line->entries.size(); ++i)
                       line->entries
-                        .push_back (std::make_pair (constrained_line->entries[i].first,
-                                                    constrained_line->entries[i].second *
-                                                    weight));
+                      .push_back (std::make_pair (constrained_line->entries[i].first,
+                                                  constrained_line->entries[i].second *
+                                                  weight));
 
 #ifdef DEBUG
                     // keep track of how many entries we replace in this line. If we do more than
@@ -391,18 +384,18 @@
 #endif
                   }
                 else
-                                                   // the DoF that we
-                                                   // encountered is not
-                                                   // constrained by a linear
-                                                   // combination of other
-                                                   // dofs but is equal to
-                                                   // just the inhomogeneity
-                                                   // (i.e. its chain of
-                                                   // entries is empty). in
-                                                   // that case, we can't just
-                                                   // overwrite the current
-                                                   // entry, but we have to
-                                                   // actually eliminate it
+                  // the DoF that we
+                  // encountered is not
+                  // constrained by a linear
+                  // combination of other
+                  // dofs but is equal to
+                  // just the inhomogeneity
+                  // (i.e. its chain of
+                  // entries is empty). in
+                  // that case, we can't just
+                  // overwrite the current
+                  // entry, but we have to
+                  // actually eliminate it
                   {
                     line->entries.erase (line->entries.begin()+entry);
                   }
@@ -410,60 +403,60 @@
                 line->inhomogeneity += constrained_line->inhomogeneity *
                                        weight;
 
-                                                 // now that we're here, do
-                                                 // not increase index by
-                                                 // one but rather make
-                                                 // another pass for the
-                                                 // present entry because we
-                                                 // have replaced the
-                                                 // present entry by another
-                                                 // one, or because we have
-                                                 // deleted it and shifted
-                                                 // all following ones one
-                                                 // forward
+                // now that we're here, do
+                // not increase index by
+                // one but rather make
+                // another pass for the
+                // present entry because we
+                // have replaced the
+                // present entry by another
+                // one, or because we have
+                // deleted it and shifted
+                // all following ones one
+                // forward
               }
             else
-                                               // entry not further
-                                               // constrained. just move
-                                               // ahead by one
+              // entry not further
+              // constrained. just move
+              // ahead by one
               ++entry;
         }
 
-                                       // if we didn't do anything in
-                                       // this round, then quit the
-                                       // loop
+      // if we didn't do anything in
+      // this round, then quit the
+      // loop
       if (chained_constraint_replaced == false)
         break;
 
-                                       // increase iteration count. note
-                                       // that we should not iterate more
-                                       // times than there are constraints,
-                                       // since this puts a natural upper
-                                       // bound on the length of constraint
-                                       // chains
+      // increase iteration count. note
+      // that we should not iterate more
+      // times than there are constraints,
+      // since this puts a natural upper
+      // bound on the length of constraint
+      // chains
       ++iteration;
       Assert (iteration <= lines.size(), ExcInternalError());
     }
 
-                                   // finally sort the entries and re-scale
-                                   // them if necessary. in this step, we also
-                                   // throw out duplicates as mentioned
-                                   // above. moreover, as some entries might
-                                   // have had zero weights, we replace them
-                                   // by a vector with sharp sizes.
+  // finally sort the entries and re-scale
+  // them if necessary. in this step, we also
+  // throw out duplicates as mentioned
+  // above. moreover, as some entries might
+  // have had zero weights, we replace them
+  // by a vector with sharp sizes.
   for (std::vector<ConstraintLine>::iterator line = lines.begin();
        line!=lines.end(); ++line)
     {
       std::sort (line->entries.begin(), line->entries.end());
 
-                                       // loop over the now sorted list and
-                                       // see whether any of the entries
-                                       // references the same dofs more than
-                                       // once in order to find how many
-                                       // non-duplicate entries we have. This
-                                       // lets us allocate the correct amount
-                                       // of memory for the constraint
-                                       // entries.
+      // loop over the now sorted list and
+      // see whether any of the entries
+      // references the same dofs more than
+      // once in order to find how many
+      // non-duplicate entries we have. This
+      // lets us allocate the correct amount
+      // of memory for the constraint
+      // entries.
       unsigned int duplicates = 0;
       for (unsigned int i=1; i<line->entries.size(); ++i)
         if (line->entries[i].first == line->entries[i-1].first)
@@ -473,17 +466,17 @@
         {
           ConstraintLine::Entries new_entries;
 
-                                             // if we have no duplicates, copy
-                                             // verbatim the entries. this
-                                             // way, the final size is of the
-                                             // vector is correct.
+          // if we have no duplicates, copy
+          // verbatim the entries. this
+          // way, the final size is of the
+          // vector is correct.
           if (duplicates == 0)
             new_entries = line->entries;
           else
             {
-                                             // otherwise, we need to go
-                                             // through the list by and and
-                                             // resolve the duplicates
+              // otherwise, we need to go
+              // through the list by and and
+              // resolve the duplicates
               new_entries.reserve (line->entries.size() - duplicates);
               new_entries.push_back(line->entries[0]);
               for (unsigned int j=1; j<line->entries.size(); ++j)
@@ -499,10 +492,10 @@
               Assert (new_entries.size() == line->entries.size() - duplicates,
                       ExcInternalError());
 
-                                             // make sure there are
-                                             // really no duplicates
-                                             // left and that the list
-                                             // is still sorted
+              // make sure there are
+              // really no duplicates
+              // left and that the list
+              // is still sorted
               for (unsigned int j=1; j<new_entries.size(); ++j)
                 {
                   Assert (new_entries[j].first != new_entries[j-1].first,
@@ -512,38 +505,38 @@
                 }
             }
 
-                                             // replace old list of
-                                             // constraints for this dof by
-                                             // the new one
+          // replace old list of
+          // constraints for this dof by
+          // the new one
           line->entries.swap (new_entries);
         }
 
-                                       // finally do the following
-                                       // check: if the sum of
-                                       // weights for the
-                                       // constraints is close to
-                                       // one, but not exactly
-                                       // one, then rescale all
-                                       // the weights so that they
-                                       // sum up to 1. this adds a
-                                       // little numerical
-                                       // stability and avoids all
-                                       // sorts of problems where
-                                       // the actual value is
-                                       // close to, but not quite
-                                       // what we expected
-                                       //
-                                       // the case where the
-                                       // weights don't quite sum
-                                       // up happens when we
-                                       // compute the
-                                       // interpolation weights
-                                       // "on the fly", i.e. not
-                                       // from precomputed
-                                       // tables. in this case,
-                                       // the interpolation
-                                       // weights are also subject
-                                       // to round-off
+      // finally do the following
+      // check: if the sum of
+      // weights for the
+      // constraints is close to
+      // one, but not exactly
+      // one, then rescale all
+      // the weights so that they
+      // sum up to 1. this adds a
+      // little numerical
+      // stability and avoids all
+      // sorts of problems where
+      // the actual value is
+      // close to, but not quite
+      // what we expected
+      //
+      // the case where the
+      // weights don't quite sum
+      // up happens when we
+      // compute the
+      // interpolation weights
+      // "on the fly", i.e. not
+      // from precomputed
+      // tables. in this case,
+      // the interpolation
+      // weights are also subject
+      // to round-off
       double sum = 0;
       for (unsigned int i=0; i<line->entries.size(); ++i)
         sum += line->entries[i].second;
@@ -556,22 +549,22 @@
     } // end of loop over all constraint lines
 
 #ifdef DEBUG
-                                   // if in debug mode: check that no dof is
-                                   // constrained to another dof that is also
-                                   // constrained. exclude dofs from this
-                                   // check whose constraint lines are not
-                                   // stored on the local processor
+  // if in debug mode: check that no dof is
+  // constrained to another dof that is also
+  // constrained. exclude dofs from this
+  // check whose constraint lines are not
+  // stored on the local processor
   for (std::vector<ConstraintLine>::const_iterator line=lines.begin();
        line!=lines.end(); ++line)
     for (ConstraintLine::Entries::const_iterator
-           entry=line->entries.begin();
+         entry=line->entries.begin();
          entry!=line->entries.end(); ++entry)
       if ((local_lines.size() == 0)
           ||
           (local_lines.is_element(entry->first)))
         {
-                                           // make sure that entry->first is
-                                           // not the index of a line itself
+          // make sure that entry->first is
+          // not the index of a line itself
           const bool is_circle = is_constrained(entry->first);
           Assert (is_circle == false,
                   ExcDoFConstrainedToConstrainedDoF(line->line, entry->first));
@@ -590,8 +583,8 @@
   AssertThrow(local_lines == other_constraints.local_lines,
               ExcNotImplemented());
 
-                                   // store the previous state with
-                                   // respect to sorting
+  // store the previous state with
+  // respect to sorting
   const bool object_was_sorted = sorted;
   sorted = false;
 
@@ -599,21 +592,21 @@
     lines_cache.resize(other_constraints.lines_cache.size(),
                        numbers::invalid_unsigned_int);
 
-                                   // first action is to fold into the present
-                                   // object possible constraints in the
-                                   // second object. we don't strictly need to
-                                   // do this any more since the
-                                   // ConstraintMatrix has learned to deal
-                                   // with chains of constraints in the
-                                   // close() function, but we have
-                                   // traditionally done this and it's not
-                                   // overly hard to do.
-                                   //
-                                   // for this, loop over all
-                                   // constraints and replace the
-                                   // constraint lines with a new one
-                                   // where constraints are replaced
-                                   // if necessary.
+  // first action is to fold into the present
+  // object possible constraints in the
+  // second object. we don't strictly need to
+  // do this any more since the
+  // ConstraintMatrix has learned to deal
+  // with chains of constraints in the
+  // close() function, but we have
+  // traditionally done this and it's not
+  // overly hard to do.
+  //
+  // for this, loop over all
+  // constraints and replace the
+  // constraint lines with a new one
+  // where constraints are replaced
+  // if necessary.
   ConstraintLine::Entries tmp;
   for (std::vector<ConstraintLine>::iterator line=lines.begin();
        line!=lines.end(); ++line)
@@ -621,10 +614,10 @@
       tmp.clear ();
       for (unsigned int i=0; i<line->entries.size(); ++i)
         {
-                                           // if the present dof is not
-                                           // constrained, or if we won't take
-                                           // the constraint from the other
-                                           // object, then simply copy it over
+          // if the present dof is not
+          // constrained, or if we won't take
+          // the constraint from the other
+          // object, then simply copy it over
           if (other_constraints.is_constrained(line->entries[i].first) == false
               ||
               ((merge_conflict_behavior != right_object_wins)
@@ -634,16 +627,16 @@
                this->is_constrained(line->entries[i].first)))
             tmp.push_back(line->entries[i]);
           else
-                                             // otherwise resolve
-                                             // further constraints by
-                                             // replacing the old
-                                             // entry by a sequence of
-                                             // new entries taken from
-                                             // the other object, but
-                                             // with multiplied
-                                             // weights
+            // otherwise resolve
+            // further constraints by
+            // replacing the old
+            // entry by a sequence of
+            // new entries taken from
+            // the other object, but
+            // with multiplied
+            // weights
             {
-              const ConstraintLine::Entries* other_line
+              const ConstraintLine::Entries *other_line
                 = other_constraints.get_constraint_entries (line->entries[i].first);
               Assert (other_line != 0,
                       ExcInternalError());
@@ -659,64 +652,64 @@
                                      weight;
             }
         }
-                                       // finally exchange old and
-                                       // newly resolved line
+      // finally exchange old and
+      // newly resolved line
       line->entries.swap (tmp);
     }
 
 
 
-                                   // next action: append those lines at the
-                                   // end that we want to add
+  // next action: append those lines at the
+  // end that we want to add
   for (std::vector<ConstraintLine>::const_iterator
-         line=other_constraints.lines.begin();
+       line=other_constraints.lines.begin();
        line!=other_constraints.lines.end(); ++line)
     if (is_constrained(line->line) == false)
       lines.push_back (*line);
     else
       {
-                                         // the constrained dof we want to
-                                         // copy from the other object is also
-                                         // constrained here. let's see what
-                                         // we should do with that
+        // the constrained dof we want to
+        // copy from the other object is also
+        // constrained here. let's see what
+        // we should do with that
         switch (merge_conflict_behavior)
           {
-            case no_conflicts_allowed:
-                  AssertThrow (false,
-                               ExcDoFIsConstrainedFromBothObjects (line->line));
-                  break;
+          case no_conflicts_allowed:
+            AssertThrow (false,
+                         ExcDoFIsConstrainedFromBothObjects (line->line));
+            break;
 
-            case left_object_wins:
-                                                   // ignore this constraint
-                  break;
+          case left_object_wins:
+            // ignore this constraint
+            break;
 
-            case right_object_wins:
-                                                   // we need to replace the
-                                                   // existing constraint by
-                                                   // the one from the other
-                                                   // object
-                  lines[lines_cache[calculate_line_index(line->line)]].entries
-                    = line->entries;
-                  lines[lines_cache[calculate_line_index(line->line)]].inhomogeneity
-                    = line->inhomogeneity;
-                  break;
+          case right_object_wins:
+            // we need to replace the
+            // existing constraint by
+            // the one from the other
+            // object
+            lines[lines_cache[calculate_line_index(line->line)]].entries
+              = line->entries;
+            lines[lines_cache[calculate_line_index(line->line)]].inhomogeneity
+              = line->inhomogeneity;
+            break;
 
-            default:
-                  Assert (false, ExcNotImplemented());
+          default:
+            Assert (false, ExcNotImplemented());
           }
       }
 
-                                // update the lines cache
+  // update the lines cache
   unsigned int counter = 0;
   for (std::vector<ConstraintLine>::const_iterator line=lines.begin();
        line!=lines.end(); ++line, ++counter)
     lines_cache[calculate_line_index(line->line)] = counter;
 
-                                   // if the object was sorted before,
-                                   // then make sure it is so
-                                   // afterward as well. otherwise
-                                   // leave everything in the unsorted
-                                   // state
+  // if the object was sorted before,
+  // then make sure it is so
+  // afterward as well. otherwise
+  // leave everything in the unsorted
+  // state
   if (object_was_sorted == true)
     close ();
 }
@@ -725,7 +718,7 @@
 
 void ConstraintMatrix::shift (const unsigned int offset)
 {
-                                   //TODO: this doesn't work with IndexSets yet. [TH]
+  //TODO: this doesn't work with IndexSets yet. [TH]
   AssertThrow(local_lines.size()==0, ExcNotImplemented());
 
   lines_cache.insert (lines_cache.begin(), offset,
@@ -736,7 +729,7 @@
     {
       i->line += offset;
       for (ConstraintLine::Entries::iterator
-             j = i->entries.begin();
+           j = i->entries.begin();
            j != i->entries.end(); ++j)
         j->first += offset;
     }
@@ -761,7 +754,7 @@
 
 
 
-void ConstraintMatrix::reinit (const IndexSet & local_constraints)
+void ConstraintMatrix::reinit (const IndexSet &local_constraints)
 {
   local_lines = local_constraints;
   clear();
@@ -778,10 +771,10 @@
           ExcNotQuadratic());
 
 
-                                   // store for each line of the matrix
-                                   // its new line number
-                                   // after compression. If the shift is
-                                   // -1, this line will be condensed away
+  // store for each line of the matrix
+  // its new line number
+  // after compression. If the shift is
+  // -1, this line will be condensed away
   std::vector<int> new_line;
 
   new_line.reserve (uncondensed.n_rows());
@@ -791,21 +784,21 @@
   unsigned int n_rows = uncondensed.n_rows();
 
   if (next_constraint == lines.end())
-                                     // if no constraint is to be handled
+    // if no constraint is to be handled
     for (unsigned int row=0; row!=n_rows; ++row)
       new_line.push_back (row);
   else
     for (unsigned int row=0; row!=n_rows; ++row)
       if (row == next_constraint->line)
         {
-                                           // this line is constrained
+          // this line is constrained
           new_line.push_back (-1);
-                                           // note that @p{lines} is ordered
+          // note that @p{lines} is ordered
           ++shift;
           ++next_constraint;
           if (next_constraint == lines.end())
-                                             // nothing more to do; finish rest
-                                             // of loop
+            // nothing more to do; finish rest
+            // of loop
             {
               for (unsigned int i=row+1; i<n_rows; ++i)
                 new_line.push_back (i-shift);
@@ -817,26 +810,26 @@
 
 
   next_constraint = lines.begin();
-                                   // note: in this loop we need not check
-                                   // whether @p{next_constraint} is a valid
-                                   // iterator, since @p{next_constraint} is
-                                   // only evaluated so often as there are
-                                   // entries in new_line[*] which tells us
-                                   // which constraints exist
+  // note: in this loop we need not check
+  // whether @p{next_constraint} is a valid
+  // iterator, since @p{next_constraint} is
+  // only evaluated so often as there are
+  // entries in new_line[*] which tells us
+  // which constraints exist
   for (unsigned int row=0; row<uncondensed.n_rows(); ++row)
     if (new_line[row] != -1)
-                                       // line not constrained
-                                       // copy entries if column will not
-                                       // be condensed away, distribute
-                                       // otherwise
+      // line not constrained
+      // copy entries if column will not
+      // be condensed away, distribute
+      // otherwise
       for (unsigned int j=uncondensed.get_rowstart_indices()[row];
            j<uncondensed.get_rowstart_indices()[row+1]; ++j)
         if (new_line[uncondensed.get_column_numbers()[j]] != -1)
           condensed.add (new_line[row], new_line[uncondensed.get_column_numbers()[j]]);
         else
           {
-                                             // let c point to the constraint
-                                             // of this column
+            // let c point to the constraint
+            // of this column
             std::vector<ConstraintLine>::const_iterator c = lines.begin();
             while (c->line != uncondensed.get_column_numbers()[j])
               ++c;
@@ -845,23 +838,23 @@
               condensed.add (new_line[row], new_line[c->entries[q].first]);
           }
     else
-                                       // line must be distributed
+      // line must be distributed
       {
         for (unsigned int j=uncondensed.get_rowstart_indices()[row];
              j<uncondensed.get_rowstart_indices()[row+1]; ++j)
-                                           // for each entry: distribute
+          // for each entry: distribute
           if (new_line[uncondensed.get_column_numbers()[j]] != -1)
-                                             // column is not constrained
+            // column is not constrained
             for (unsigned int q=0; q!=next_constraint->entries.size(); ++q)
               condensed.add (new_line[next_constraint->entries[q].first],
                              new_line[uncondensed.get_column_numbers()[j]]);
 
           else
-                                             // not only this line but
-                                             // also this col is constrained
+            // not only this line but
+            // also this col is constrained
             {
-                                               // let c point to the constraint
-                                               // of this column
+              // let c point to the constraint
+              // of this column
               std::vector<ConstraintLine>::const_iterator c = lines.begin();
               while (c->line != uncondensed.get_column_numbers()[j]) ++c;
 
@@ -886,13 +879,13 @@
   Assert (sparsity.n_rows() == sparsity.n_cols(),
           ExcNotQuadratic());
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute(sparsity.n_rows(),
                                        numbers::invalid_unsigned_int);
 
@@ -904,28 +897,28 @@
     {
       if (distribute[row] == numbers::invalid_unsigned_int)
         {
-                                           // regular line. loop over cols all
-                                           // valid cols. note that this
-                                           // changes the line we are
-                                           // presently working on: we add
-                                           // additional entries. these are
-                                           // put to the end of the
-                                           // row. however, as constrained
-                                           // nodes cannot be constrained to
-                                           // other constrained nodes, nothing
-                                           // will happen if we run into these
-                                           // added nodes, as they can't be
-                                           // distributed further. we might
-                                           // store the position of the last
-                                           // old entry and stop work there,
-                                           // but since operating on the newly
-                                           // added ones only takes two
-                                           // comparisons (column index valid,
-                                           // distribute[column] necessarily
-                                           // ==numbers::invalid_unsigned_int),
-                                           // it is cheaper to not do so and
-                                           // run right until the end of the
-                                           // line
+          // regular line. loop over cols all
+          // valid cols. note that this
+          // changes the line we are
+          // presently working on: we add
+          // additional entries. these are
+          // put to the end of the
+          // row. however, as constrained
+          // nodes cannot be constrained to
+          // other constrained nodes, nothing
+          // will happen if we run into these
+          // added nodes, as they can't be
+          // distributed further. we might
+          // store the position of the last
+          // old entry and stop work there,
+          // but since operating on the newly
+          // added ones only takes two
+          // comparisons (column index valid,
+          // distribute[column] necessarily
+          // ==numbers::invalid_unsigned_int),
+          // it is cheaper to not do so and
+          // run right until the end of the
+          // line
           for (SparsityPattern::iterator entry = sparsity.begin(row);
                ((entry != sparsity.end(row)) &&
                 entry->is_valid_entry());
@@ -935,11 +928,11 @@
 
               if (distribute[column] != numbers::invalid_unsigned_int)
                 {
-                                                   // distribute entry
-                                                   // at regular row
-                                                   // @p{row} and
-                                                   // irregular column
-                                                   // sparsity.colnums[j]
+                  // distribute entry
+                  // at regular row
+                  // @p{row} and
+                  // irregular column
+                  // sparsity.colnums[j]
                   for (unsigned int q=0;
                        q!=lines[distribute[column]].entries.size();
                        ++q)
@@ -949,27 +942,27 @@
             }
         }
       else
-                                         // row must be
-                                         // distributed. note that
-                                         // here the present row is
-                                         // not touched (unlike above)
+        // row must be
+        // distributed. note that
+        // here the present row is
+        // not touched (unlike above)
         {
           for (SparsityPattern::iterator entry = sparsity.begin(row);
                (entry != sparsity.end(row)) && entry->is_valid_entry(); ++entry)
             {
               const unsigned int column = entry->column();
               if (distribute[column] == numbers::invalid_unsigned_int)
-                                                 // distribute entry at irregular
-                                                 // row @p{row} and regular column
-                                                 // sparsity.colnums[j]
+                // distribute entry at irregular
+                // row @p{row} and regular column
+                // sparsity.colnums[j]
                 for (unsigned int q=0;
                      q!=lines[distribute[row]].entries.size(); ++q)
                   sparsity.add (lines[distribute[row]].entries[q].first,
                                 column);
               else
-                                                 // distribute entry at irregular
-                                                 // row @p{row} and irregular column
-                                                 // sparsity.get_column_numbers()[j]
+                // distribute entry at irregular
+                // row @p{row} and irregular column
+                // sparsity.get_column_numbers()[j]
                 for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                   for (unsigned int q=0;
                        q!=lines[distribute[column]].entries.size(); ++q)
@@ -990,13 +983,13 @@
   Assert (sparsity.n_rows() == sparsity.n_cols(),
           ExcNotQuadratic());
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute(sparsity.n_rows(),
                                        numbers::invalid_unsigned_int);
 
@@ -1007,77 +1000,77 @@
   for (unsigned int row=0; row<n_rows; ++row)
     {
       if (distribute[row] == numbers::invalid_unsigned_int)
-                                         // regular line. loop over
-                                         // cols. note that as we
-                                         // proceed to distribute
-                                         // cols, the loop may get
-                                         // longer
+        // regular line. loop over
+        // cols. note that as we
+        // proceed to distribute
+        // cols, the loop may get
+        // longer
         for (unsigned int j=0; j<sparsity.row_length(row); ++j)
           {
             const unsigned int column = sparsity.column_number(row,j);
 
             if (distribute[column] != numbers::invalid_unsigned_int)
               {
-                                                 // distribute entry
-                                                 // at regular row
-                                                 // @p{row} and
-                                                 // irregular column
-                                                 // column. note that
-                                                 // this changes the
-                                                 // line we are
-                                                 // presently working
-                                                 // on: we add
-                                                 // additional
-                                                 // entries. if we add
-                                                 // another entry at a
-                                                 // column behind the
-                                                 // present one, we
-                                                 // will encounter it
-                                                 // later on (but
-                                                 // since it can't be
-                                                 // further
-                                                 // constrained, won't
-                                                 // have to do
-                                                 // anything about
-                                                 // it). if we add it
-                                                 // up front of the
-                                                 // present column, we
-                                                 // will find the
-                                                 // present column
-                                                 // later on again as
-                                                 // it was shifted
-                                                 // back (again
-                                                 // nothing happens,
-                                                 // in particular no
-                                                 // endless loop, as
-                                                 // when we encounter
-                                                 // it the second time
-                                                 // we won't be able
-                                                 // to add more
-                                                 // entries as they
-                                                 // all already exist,
-                                                 // but we do the same
-                                                 // work more often
-                                                 // than necessary,
-                                                 // and the loop gets
-                                                 // longer), so move
-                                                 // the cursor one to
-                                                 // the right in the
-                                                 // case that we add
-                                                 // an entry up front
-                                                 // that did not exist
-                                                 // before. check
-                                                 // whether it existed
-                                                 // before by tracking
-                                                 // the length of this
-                                                 // row
+                // distribute entry
+                // at regular row
+                // @p{row} and
+                // irregular column
+                // column. note that
+                // this changes the
+                // line we are
+                // presently working
+                // on: we add
+                // additional
+                // entries. if we add
+                // another entry at a
+                // column behind the
+                // present one, we
+                // will encounter it
+                // later on (but
+                // since it can't be
+                // further
+                // constrained, won't
+                // have to do
+                // anything about
+                // it). if we add it
+                // up front of the
+                // present column, we
+                // will find the
+                // present column
+                // later on again as
+                // it was shifted
+                // back (again
+                // nothing happens,
+                // in particular no
+                // endless loop, as
+                // when we encounter
+                // it the second time
+                // we won't be able
+                // to add more
+                // entries as they
+                // all already exist,
+                // but we do the same
+                // work more often
+                // than necessary,
+                // and the loop gets
+                // longer), so move
+                // the cursor one to
+                // the right in the
+                // case that we add
+                // an entry up front
+                // that did not exist
+                // before. check
+                // whether it existed
+                // before by tracking
+                // the length of this
+                // row
                 unsigned int old_rowlength = sparsity.row_length(row);
                 for (unsigned int q=0;
                      q!=lines[distribute[column]].entries.size();
                      ++q)
                   {
                     const unsigned int
-                      new_col = lines[distribute[column]].entries[q].first;
+                    new_col = lines[distribute[column]].entries[q].first;
 
                     sparsity.add (row, new_col);
 
@@ -1089,27 +1082,27 @@
               };
           }
       else
-                                         // row must be distributed
+        // row must be distributed
         for (unsigned int j=0; j<sparsity.row_length(row); ++j)
           {
             const unsigned int column = sparsity.column_number(row,j);
 
             if (distribute[column] == numbers::invalid_unsigned_int)
-                                               // distribute entry at irregular
-                                               // row @p{row} and regular column
-                                               // sparsity.colnums[j]
+              // distribute entry at irregular
+              // row @p{row} and regular column
+              // sparsity.colnums[j]
               for (unsigned int q=0;
                    q!=lines[distribute[row]].entries.size(); ++q)
                 sparsity.add (lines[distribute[row]].entries[q].first,
                               column);
             else
-                                               // distribute entry at irregular
-                                               // row @p{row} and irregular column
-                                               // sparsity.get_column_numbers()[j]
+              // distribute entry at irregular
+              // row @p{row} and irregular column
+              // sparsity.get_column_numbers()[j]
               for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                 for (unsigned int q=0;
                      q!=lines[distribute[sparsity.column_number(row,j)]]
-                                    .entries.size(); ++q)
+                     .entries.size(); ++q)
                   sparsity.add (lines[distribute[row]].entries[p].first,
                                 lines[distribute[sparsity.column_number(row,j)]]
                                 .entries[q].first);
@@ -1125,13 +1118,13 @@
   Assert (sparsity.n_rows() == sparsity.n_cols(),
           ExcNotQuadratic());
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute(sparsity.n_rows(),
                                        numbers::invalid_unsigned_int);
 
@@ -1143,10 +1136,10 @@
     {
       if (distribute[row] == numbers::invalid_unsigned_int)
         {
-                                           // regular line. loop over
-                                           // cols. note that as we proceed to
-                                           // distribute cols, the loop may
-                                           // get longer
+          // regular line. loop over
+          // cols. note that as we proceed to
+          // distribute cols, the loop may
+          // get longer
           CompressedSetSparsityPattern::row_iterator col_num = sparsity.row_begin (row);
 
           for (; col_num != sparsity.row_end (row); ++col_num)
@@ -1161,7 +1154,7 @@
                        ++q)
                     {
                       const unsigned int
-                        new_col = lines[distribute[column]].entries[q].first;
+                      new_col = lines[distribute[column]].entries[q].first;
 
                       sparsity.add (row, new_col);
                     }
@@ -1192,7 +1185,7 @@
                 for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                   for (unsigned int q=0;
                        q!=lines[distribute[column]]
-                         .entries.size(); ++q)
+                       .entries.size(); ++q)
                     sparsity.add (lines[distribute[row]].entries[p].first,
                                   lines[distribute[column]]
                                   .entries[q].first);
@@ -1209,13 +1202,13 @@
   Assert (sparsity.n_rows() == sparsity.n_cols(),
           ExcNotQuadratic());
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute(sparsity.n_rows(),
                                        numbers::invalid_unsigned_int);
 
@@ -1226,77 +1219,77 @@
   for (unsigned int row=0; row<n_rows; ++row)
     {
       if (distribute[row] == numbers::invalid_unsigned_int)
-                                         // regular line. loop over
-                                         // cols. note that as we
-                                         // proceed to distribute
-                                         // cols, the loop may get
-                                         // longer
+        // regular line. loop over
+        // cols. note that as we
+        // proceed to distribute
+        // cols, the loop may get
+        // longer
         for (unsigned int j=0; j<sparsity.row_length(row); ++j)
           {
             const unsigned int column = sparsity.column_number(row,j);
 
             if (distribute[column] != numbers::invalid_unsigned_int)
               {
-                                                 // distribute entry
-                                                 // at regular row
-                                                 // @p{row} and
-                                                 // irregular column
-                                                 // column. note that
-                                                 // this changes the
-                                                 // line we are
-                                                 // presently working
-                                                 // on: we add
-                                                 // additional
-                                                 // entries. if we add
-                                                 // another entry at a
-                                                 // column behind the
-                                                 // present one, we
-                                                 // will encounter it
-                                                 // later on (but
-                                                 // since it can't be
-                                                 // further
-                                                 // constrained, won't
-                                                 // have to do
-                                                 // anything about
-                                                 // it). if we add it
-                                                 // up front of the
-                                                 // present column, we
-                                                 // will find the
-                                                 // present column
-                                                 // later on again as
-                                                 // it was shifted
-                                                 // back (again
-                                                 // nothing happens,
-                                                 // in particular no
-                                                 // endless loop, as
-                                                 // when we encounter
-                                                 // it the second time
-                                                 // we won't be able
-                                                 // to add more
-                                                 // entries as they
-                                                 // all already exist,
-                                                 // but we do the same
-                                                 // work more often
-                                                 // than necessary,
-                                                 // and the loop gets
-                                                 // longer), so move
-                                                 // the cursor one to
-                                                 // the right in the
-                                                 // case that we add
-                                                 // an entry up front
-                                                 // that did not exist
-                                                 // before. check
-                                                 // whether it existed
-                                                 // before by tracking
-                                                 // the length of this
-                                                 // row
+                // distribute entry
+                // at regular row
+                // @p{row} and
+                // irregular column
+                // column. note that
+                // this changes the
+                // line we are
+                // presently working
+                // on: we add
+                // additional
+                // entries. if we add
+                // another entry at a
+                // column behind the
+                // present one, we
+                // will encounter it
+                // later on (but
+                // since it can't be
+                // further
+                // constrained, won't
+                // have to do
+                // anything about
+                // it). if we add it
+                // up front of the
+                // present column, we
+                // will find the
+                // present column
+                // later on again as
+                // it was shifted
+                // back (again
+                // nothing happens,
+                // in particular no
+                // endless loop, as
+                // when we encounter
+                // it the second time
+                // we won't be able
+                // to add more
+                // entries as they
+                // all already exist,
+                // but we do the same
+                // work more often
+                // than necessary,
+                // and the loop gets
+                // longer), so move
+                // the cursor one to
+                // the right in the
+                // case that we add
+                // an entry up front
+                // that did not exist
+                // before. check
+                // whether it existed
+                // before by tracking
+                // the length of this
+                // row
                 unsigned int old_rowlength = sparsity.row_length(row);
                 for (unsigned int q=0;
                      q!=lines[distribute[column]].entries.size();
                      ++q)
                   {
                     const unsigned int
-                      new_col = lines[distribute[column]].entries[q].first;
+                    new_col = lines[distribute[column]].entries[q].first;
 
                     sparsity.add (row, new_col);
 
@@ -1308,27 +1301,27 @@
               };
           }
       else
-                                         // row must be distributed
+        // row must be distributed
         for (unsigned int j=0; j<sparsity.row_length(row); ++j)
           {
             const unsigned int column = sparsity.column_number(row,j);
 
             if (distribute[column] == numbers::invalid_unsigned_int)
-                                               // distribute entry at irregular
-                                               // row @p{row} and regular column
-                                               // sparsity.colnums[j]
+              // distribute entry at irregular
+              // row @p{row} and regular column
+              // sparsity.colnums[j]
               for (unsigned int q=0;
                    q!=lines[distribute[row]].entries.size(); ++q)
                 sparsity.add (lines[distribute[row]].entries[q].first,
                               column);
             else
-                                               // distribute entry at irregular
-                                               // row @p{row} and irregular column
-                                               // sparsity.get_column_numbers()[j]
+              // distribute entry at irregular
+              // row @p{row} and irregular column
+              // sparsity.get_column_numbers()[j]
               for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                 for (unsigned int q=0;
                      q!=lines[distribute[sparsity.column_number(row,j)]]
-                                    .entries.size(); ++q)
+                     .entries.size(); ++q)
                   sparsity.add (lines[distribute[row]].entries[p].first,
                                 lines[distribute[sparsity.column_number(row,j)]]
                                 .entries[q].first);
@@ -1350,17 +1343,17 @@
           ExcNotQuadratic());
 
   const BlockIndices &
-    index_mapping = sparsity.get_column_indices();
+  index_mapping = sparsity.get_column_indices();
 
   const unsigned int n_blocks = sparsity.n_block_rows();
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute (sparsity.n_rows(),
                                         numbers::invalid_unsigned_int);
 
@@ -1370,43 +1363,43 @@
   const unsigned int n_rows = sparsity.n_rows();
   for (unsigned int row=0; row<n_rows; ++row)
     {
-                                       // get index of this row
-                                       // within the blocks
+      // get index of this row
+      // within the blocks
       const std::pair<unsigned int,unsigned int>
-        block_index = index_mapping.global_to_local(row);
+      block_index = index_mapping.global_to_local(row);
       const unsigned int block_row = block_index.first;
 
       if (distribute[row] == numbers::invalid_unsigned_int)
-                                         // regular line. loop over
-                                         // all columns and see
-                                         // whether this column must
-                                         // be distributed
+        // regular line. loop over
+        // all columns and see
+        // whether this column must
+        // be distributed
         {
 
-                                           // to loop over all entries
-                                           // in this row, we have to
-                                           // loop over all blocks in
-                                           // this blockrow and the
-                                           // corresponding row
-                                           // therein
+          // to loop over all entries
+          // in this row, we have to
+          // loop over all blocks in
+          // this blockrow and the
+          // corresponding row
+          // therein
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const SparsityPattern &
-                block_sparsity = sparsity.block(block_row, block_col);
+              block_sparsity = sparsity.block(block_row, block_col);
 
               for (SparsityPattern::const_iterator
-                     entry = block_sparsity.begin(block_index.second);
+                   entry = block_sparsity.begin(block_index.second);
                    (entry != block_sparsity.end(block_index.second)) &&
-                     entry->is_valid_entry();
+                   entry->is_valid_entry();
                    ++entry)
                 {
                   const unsigned int global_col
                     = index_mapping.local_to_global(block_col, entry->column());
 
                   if (distribute[global_col] != numbers::invalid_unsigned_int)
-                                                     // distribute entry at regular
-                                                     // row @p{row} and irregular column
-                                                     // global_col
+                    // distribute entry at regular
+                    // row @p{row} and irregular column
+                    // global_col
                     {
                       for (unsigned int q=0;
                            q!=lines[distribute[global_col]].entries.size(); ++q)
@@ -1418,37 +1411,37 @@
         }
       else
         {
-                                           // row must be
-                                           // distributed. split the
-                                           // whole row into the
-                                           // chunks defined by the
-                                           // blocks
+          // row must be
+          // distributed. split the
+          // whole row into the
+          // chunks defined by the
+          // blocks
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const SparsityPattern &
-                block_sparsity = sparsity.block(block_row,block_col);
+              block_sparsity = sparsity.block(block_row,block_col);
 
               for (SparsityPattern::const_iterator
-                     entry = block_sparsity.begin(block_index.second);
+                   entry = block_sparsity.begin(block_index.second);
                    (entry != block_sparsity.end(block_index.second)) &&
-                     entry->is_valid_entry();
+                   entry->is_valid_entry();
                    ++entry)
                 {
                   const unsigned int global_col
                     = index_mapping.local_to_global (block_col, entry->column());
 
                   if (distribute[global_col] == numbers::invalid_unsigned_int)
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and regular column
-                                                     // global_col.
+                    // distribute entry at irregular
+                    // row @p{row} and regular column
+                    // global_col.
                     {
                       for (unsigned int q=0; q!=lines[distribute[row]].entries.size(); ++q)
                         sparsity.add (lines[distribute[row]].entries[q].first, global_col);
                     }
                   else
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and irregular column
-                                                     // @p{global_col}
+                    // distribute entry at irregular
+                    // row @p{row} and irregular column
+                    // @p{global_col}
                     {
                       for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                         for (unsigned int q=0; q!=lines[distribute[global_col]].entries.size(); ++q)
@@ -1476,17 +1469,17 @@
           ExcNotQuadratic());
 
   const BlockIndices &
-    index_mapping = sparsity.get_column_indices();
+  index_mapping = sparsity.get_column_indices();
 
   const unsigned int n_blocks = sparsity.n_block_rows();
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute (sparsity.n_rows(),
                                         numbers::invalid_unsigned_int);
 
@@ -1496,43 +1489,43 @@
   const unsigned int n_rows = sparsity.n_rows();
   for (unsigned int row=0; row<n_rows; ++row)
     {
-                                       // get index of this row
-                                       // within the blocks
+      // get index of this row
+      // within the blocks
       const std::pair<unsigned int,unsigned int>
-        block_index = index_mapping.global_to_local(row);
+      block_index = index_mapping.global_to_local(row);
       const unsigned int block_row = block_index.first;
       const unsigned int local_row = block_index.second;
 
       if (distribute[row] == numbers::invalid_unsigned_int)
-                                         // regular line. loop over
-                                         // all columns and see
-                                         // whether this column must
-                                         // be distributed. note that
-                                         // as we proceed to
-                                         // distribute cols, the loop
-                                         // over cols may get longer.
-                                         //
-                                         // don't try to be clever
-                                         // here as in the algorithm
-                                         // for the
-                                         // CompressedSparsityPattern,
-                                         // as that would be much more
-                                         // complicated here. after
-                                         // all, we know that
-                                         // compressed patterns are
-                                         // inefficient...
+        // regular line. loop over
+        // all columns and see
+        // whether this column must
+        // be distributed. note that
+        // as we proceed to
+        // distribute cols, the loop
+        // over cols may get longer.
+        //
+        // don't try to be clever
+        // here as in the algorithm
+        // for the
+        // CompressedSparsityPattern,
+        // as that would be much more
+        // complicated here. after
+        // all, we know that
+        // compressed patterns are
+        // inefficient...
         {
 
-                                           // to loop over all entries
-                                           // in this row, we have to
-                                           // loop over all blocks in
-                                           // this blockrow and the
-                                           // corresponding row
-                                           // therein
+          // to loop over all entries
+          // in this row, we have to
+          // loop over all blocks in
+          // this blockrow and the
+          // corresponding row
+          // therein
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const CompressedSparsityPattern &
-                block_sparsity = sparsity.block(block_row, block_col);
+              block_sparsity = sparsity.block(block_row, block_col);
 
               for (unsigned int j=0; j<block_sparsity.row_length(local_row); ++j)
                 {
@@ -1541,13 +1534,13 @@
                                                     block_sparsity.column_number(local_row,j));
 
                   if (distribute[global_col] != numbers::invalid_unsigned_int)
-                                                     // distribute entry at regular
-                                                     // row @p{row} and irregular column
-                                                     // global_col
+                    // distribute entry at regular
+                    // row @p{row} and irregular column
+                    // global_col
                     {
                       for (unsigned int q=0;
                            q!=lines[distribute[global_col]]
-                                          .entries.size(); ++q)
+                           .entries.size(); ++q)
                         sparsity.add (row,
                                       lines[distribute[global_col]].entries[q].first);
                     };
@@ -1556,15 +1549,15 @@
         }
       else
         {
-                                           // row must be
-                                           // distributed. split the
-                                           // whole row into the
-                                           // chunks defined by the
-                                           // blocks
+          // row must be
+          // distributed. split the
+          // whole row into the
+          // chunks defined by the
+          // blocks
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const CompressedSparsityPattern &
-                block_sparsity = sparsity.block(block_row,block_col);
+              block_sparsity = sparsity.block(block_row,block_col);
 
               for (unsigned int j=0; j<block_sparsity.row_length(local_row); ++j)
                 {
@@ -1573,18 +1566,18 @@
                                                      block_sparsity.column_number(local_row,j));
 
                   if (distribute[global_col] == numbers::invalid_unsigned_int)
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and regular column
-                                                     // global_col.
+                    // distribute entry at irregular
+                    // row @p{row} and regular column
+                    // global_col.
                     {
                       for (unsigned int q=0; q!=lines[distribute[row]].entries.size(); ++q)
                         sparsity.add (lines[distribute[row]].entries[q].first,
                                       global_col);
                     }
                   else
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and irregular column
-                                                     // @p{global_col}
+                    // distribute entry at irregular
+                    // row @p{row} and irregular column
+                    // @p{global_col}
                     {
                       for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                         for (unsigned int q=0; q!=lines[distribute[global_col]].entries.size(); ++q)
@@ -1610,17 +1603,17 @@
           ExcNotQuadratic());
 
   const BlockIndices &
-    index_mapping = sparsity.get_column_indices();
+  index_mapping = sparsity.get_column_indices();
 
   const unsigned int n_blocks = sparsity.n_block_rows();
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute (sparsity.n_rows(),
                                         numbers::invalid_unsigned_int);
 
@@ -1630,59 +1623,59 @@
   const unsigned int n_rows = sparsity.n_rows();
   for (unsigned int row=0; row<n_rows; ++row)
     {
-                                       // get index of this row
-                                       // within the blocks
+      // get index of this row
+      // within the blocks
       const std::pair<unsigned int,unsigned int>
-        block_index = index_mapping.global_to_local(row);
+      block_index = index_mapping.global_to_local(row);
       const unsigned int block_row = block_index.first;
       const unsigned int local_row = block_index.second;
 
       if (distribute[row] == numbers::invalid_unsigned_int)
-                                         // regular line. loop over
-                                         // all columns and see
-                                         // whether this column must
-                                         // be distributed. note that
-                                         // as we proceed to
-                                         // distribute cols, the loop
-                                         // over cols may get longer.
-                                         //
-                                         // don't try to be clever
-                                         // here as in the algorithm
-                                         // for the
-                                         // CompressedSparsityPattern,
-                                         // as that would be much more
-                                         // complicated here. after
-                                         // all, we know that
-                                         // compressed patterns are
-                                         // inefficient...
+        // regular line. loop over
+        // all columns and see
+        // whether this column must
+        // be distributed. note that
+        // as we proceed to
+        // distribute cols, the loop
+        // over cols may get longer.
+        //
+        // don't try to be clever
+        // here as in the algorithm
+        // for the
+        // CompressedSparsityPattern,
+        // as that would be much more
+        // complicated here. after
+        // all, we know that
+        // compressed patterns are
+        // inefficient...
         {
 
-                                           // to loop over all entries
-                                           // in this row, we have to
-                                           // loop over all blocks in
-                                           // this blockrow and the
-                                           // corresponding row
-                                           // therein
+          // to loop over all entries
+          // in this row, we have to
+          // loop over all blocks in
+          // this blockrow and the
+          // corresponding row
+          // therein
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const CompressedSetSparsityPattern &
-                block_sparsity = sparsity.block(block_row, block_col);
+              block_sparsity = sparsity.block(block_row, block_col);
 
               for (CompressedSetSparsityPattern::row_iterator
-                     j = block_sparsity.row_begin(local_row);
+                   j = block_sparsity.row_begin(local_row);
                    j != block_sparsity.row_end(local_row); ++j)
                 {
                   const unsigned int global_col
                     = index_mapping.local_to_global(block_col, *j);
 
                   if (distribute[global_col] != numbers::invalid_unsigned_int)
-                                                     // distribute entry at regular
-                                                     // row @p{row} and irregular column
-                                                     // global_col
+                    // distribute entry at regular
+                    // row @p{row} and irregular column
+                    // global_col
                     {
                       for (unsigned int q=0;
                            q!=lines[distribute[global_col]]
-                                          .entries.size(); ++q)
+                           .entries.size(); ++q)
                         sparsity.add (row,
                                       lines[distribute[global_col]].entries[q].first);
                     };
@@ -1691,36 +1684,36 @@
         }
       else
         {
-                                           // row must be
-                                           // distributed. split the
-                                           // whole row into the
-                                           // chunks defined by the
-                                           // blocks
+          // row must be
+          // distributed. split the
+          // whole row into the
+          // chunks defined by the
+          // blocks
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const CompressedSetSparsityPattern &
-                block_sparsity = sparsity.block(block_row,block_col);
+              block_sparsity = sparsity.block(block_row,block_col);
 
               for (CompressedSetSparsityPattern::row_iterator
-                     j = block_sparsity.row_begin(local_row);
+                   j = block_sparsity.row_begin(local_row);
                    j != block_sparsity.row_end(local_row); ++j)
                 {
                   const unsigned int global_col
                     = index_mapping.local_to_global (block_col, *j);
 
                   if (distribute[global_col] == numbers::invalid_unsigned_int)
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and regular column
-                                                     // global_col.
+                    // distribute entry at irregular
+                    // row @p{row} and regular column
+                    // global_col.
                     {
                       for (unsigned int q=0; q!=lines[distribute[row]].entries.size(); ++q)
                         sparsity.add (lines[distribute[row]].entries[q].first,
                                       global_col);
                     }
                   else
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and irregular column
-                                                     // @p{global_col}
+                    // distribute entry at irregular
+                    // row @p{row} and irregular column
+                    // @p{global_col}
                     {
                       for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                         for (unsigned int q=0; q!=lines[distribute[global_col]].entries.size(); ++q)
@@ -1746,17 +1739,17 @@
           ExcNotQuadratic());
 
   const BlockIndices &
-    index_mapping = sparsity.get_column_indices();
+  index_mapping = sparsity.get_column_indices();
 
   const unsigned int n_blocks = sparsity.n_block_rows();
 
-                                   // store for each index whether it must be
-                                   // distributed or not. If entry is
-                                   // numbers::invalid_unsigned_int,
-                                   // no distribution is necessary.
-                                   // otherwise, the number states which line
-                                   // in the constraint matrix handles this
-                                   // index
+  // store for each index whether it must be
+  // distributed or not. If entry is
+  // numbers::invalid_unsigned_int,
+  // no distribution is necessary.
+  // otherwise, the number states which line
+  // in the constraint matrix handles this
+  // index
   std::vector<unsigned int> distribute (sparsity.n_rows(),
                                         numbers::invalid_unsigned_int);
 
@@ -1766,43 +1759,43 @@
   const unsigned int n_rows = sparsity.n_rows();
   for (unsigned int row=0; row<n_rows; ++row)
     {
-                                       // get index of this row
-                                       // within the blocks
+      // get index of this row
+      // within the blocks
       const std::pair<unsigned int,unsigned int>
-        block_index = index_mapping.global_to_local(row);
+      block_index = index_mapping.global_to_local(row);
       const unsigned int block_row = block_index.first;
       const unsigned int local_row = block_index.second;
 
       if (distribute[row] == numbers::invalid_unsigned_int)
-                                         // regular line. loop over
-                                         // all columns and see
-                                         // whether this column must
-                                         // be distributed. note that
-                                         // as we proceed to
-                                         // distribute cols, the loop
-                                         // over cols may get longer.
-                                         //
-                                         // don't try to be clever
-                                         // here as in the algorithm
-                                         // for the
-                                         // CompressedSparsityPattern,
-                                         // as that would be much more
-                                         // complicated here. after
-                                         // all, we know that
-                                         // compressed patterns are
-                                         // inefficient...
+        // regular line. loop over
+        // all columns and see
+        // whether this column must
+        // be distributed. note that
+        // as we proceed to
+        // distribute cols, the loop
+        // over cols may get longer.
+        //
+        // don't try to be clever
+        // here as in the algorithm
+        // for the
+        // CompressedSparsityPattern,
+        // as that would be much more
+        // complicated here. after
+        // all, we know that
+        // compressed patterns are
+        // inefficient...
         {
 
-                                           // to loop over all entries
-                                           // in this row, we have to
-                                           // loop over all blocks in
-                                           // this blockrow and the
-                                           // corresponding row
-                                           // therein
+          // to loop over all entries
+          // in this row, we have to
+          // loop over all blocks in
+          // this blockrow and the
+          // corresponding row
+          // therein
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const CompressedSimpleSparsityPattern &
-                block_sparsity = sparsity.block(block_row, block_col);
+              block_sparsity = sparsity.block(block_row, block_col);
 
               for (unsigned int j=0; j<block_sparsity.row_length(local_row); ++j)
                 {
@@ -1811,13 +1804,13 @@
                                                     block_sparsity.column_number(local_row,j));
 
                   if (distribute[global_col] != numbers::invalid_unsigned_int)
-                                                     // distribute entry at regular
-                                                     // row @p{row} and irregular column
-                                                     // global_col
+                    // distribute entry at regular
+                    // row @p{row} and irregular column
+                    // global_col
                     {
                       for (unsigned int q=0;
                            q!=lines[distribute[global_col]]
-                                          .entries.size(); ++q)
+                           .entries.size(); ++q)
                         sparsity.add (row,
                                       lines[distribute[global_col]].entries[q].first);
                     };
@@ -1826,15 +1819,15 @@
         }
       else
         {
-                                           // row must be
-                                           // distributed. split the
-                                           // whole row into the
-                                           // chunks defined by the
-                                           // blocks
+          // row must be
+          // distributed. split the
+          // whole row into the
+          // chunks defined by the
+          // blocks
           for (unsigned int block_col=0; block_col<n_blocks; ++block_col)
             {
               const CompressedSimpleSparsityPattern &
-                block_sparsity = sparsity.block(block_row,block_col);
+              block_sparsity = sparsity.block(block_row,block_col);
 
               for (unsigned int j=0; j<block_sparsity.row_length(local_row); ++j)
                 {
@@ -1843,18 +1836,18 @@
                                                      block_sparsity.column_number(local_row,j));
 
                   if (distribute[global_col] == numbers::invalid_unsigned_int)
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and regular column
-                                                     // global_col.
+                    // distribute entry at irregular
+                    // row @p{row} and regular column
+                    // global_col.
                     {
                       for (unsigned int q=0; q!=lines[distribute[row]].entries.size(); ++q)
                         sparsity.add (lines[distribute[row]].entries[q].first,
                                       global_col);
                     }
                   else
-                                                     // distribute entry at irregular
-                                                     // row @p{row} and irregular column
-                                                     // @p{global_col}
+                    // distribute entry at irregular
+                    // row @p{row} and irregular column
+                    // @p{global_col}
                     {
                       for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p)
                         for (unsigned int q=0; q!=lines[distribute[global_col]].entries.size(); ++q)
@@ -1871,12 +1864,12 @@
 
 #ifdef DEAL_II_USE_TRILINOS
 
-                                   // this is a specialization for a
-                                   // parallel (non-block) Trilinos
-                                   // vector. The basic idea is to just work
-                                   // on the local range of the vector. But
-                                   // we need access to values that the
-                                   // local nodes are constrained to.
+// this is a specialization for a
+// parallel (non-block) Trilinos
+// vector. The basic idea is to just work
+// on the local range of the vector. But
+// we need access to values that the
+// local nodes are constrained to.
 
 template<>
 void
@@ -1884,12 +1877,12 @@
 {
   Assert (sorted==true, ExcMatrixIsClosed());
 
-                                   //TODO: not implemented yet, we need to fix
-                                   //LocalRange() first to only include
-                                   //"owned" indices. For this we need to keep
-                                   //track of the owned indices, because
-                                   //Trilinos doesn't. Use same constructor
-                                   //interface as in PETSc with two IndexSets!
+  //TODO: not implemented yet, we need to fix
+  //LocalRange() first to only include
+  //"owned" indices. For this we need to keep
+  //track of the owned indices, because
+  //Trilinos doesn't. Use same constructor
+  //interface as in PETSc with two IndexSets!
   AssertThrow (vec.vector_partitioner().IsOneToOne(),
                ExcMessage ("Distribute does not work on vectors with overlapping parallel partitioning."));
 
@@ -1903,14 +1896,14 @@
   const constraint_iterator end_my_constraints
     = Utilities::lower_bound(lines.begin(),lines.end(),index_comparison);
 
-                                   // Here we search all the indices that we
-                                   // need to have read-access to - the
-                                   // local nodes and all the nodes that the
-                                   // constraints indicate.
+  // Here we search all the indices that we
+  // need to have read-access to - the
+  // local nodes and all the nodes that the
+  // constraints indicate.
   IndexSet my_indices (vec.size());
   {
     const std::pair<unsigned int, unsigned int>
-      local_range = vec.local_range();
+    local_range = vec.local_range();
 
     my_indices.add_range (local_range.first, local_range.second);
 
@@ -1929,26 +1922,26 @@
 
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
   const Epetra_MpiComm *mpi_comm
-    = dynamic_cast<const Epetra_MpiComm*>(&vec.trilinos_vector().Comm());
+    = dynamic_cast<const Epetra_MpiComm *>(&vec.trilinos_vector().Comm());
 
   Assert (mpi_comm != 0, ExcInternalError());
 
   TrilinosWrappers::MPI::Vector vec_distribute
-    (my_indices.make_trilinos_map (mpi_comm->Comm(), true));
+  (my_indices.make_trilinos_map (mpi_comm->Comm(), true));
 #else
   TrilinosWrappers::MPI::Vector vec_distribute
-    (my_indices.make_trilinos_map (MPI_COMM_WORLD, true));
+  (my_indices.make_trilinos_map (MPI_COMM_WORLD, true));
 #endif
 
-                                   // here we import the data
+  // here we import the data
   vec_distribute.reinit(vec,false,true);
 
   for (constraint_iterator it = begin_my_constraints;
        it != end_my_constraints; ++it)
     {
-                                       // fill entry in line
-                                       // next_constraint.line by adding the
-                                       // different contributions
+      // fill entry in line
+      // next_constraint.line by adding the
+      // different contributions
       double new_value = it->inhomogeneity;
       for (unsigned int i=0; i<it->entries.size(); ++i)
         new_value += (vec_distribute(it->entries[i].first) *
@@ -1956,10 +1949,10 @@
       vec(it->line) = new_value;
     }
 
-                                   // some processes might not apply
-                                   // constraints, so we need to explicitly
-                                   // state, that the others are doing an
-                                   // insert here:
+  // some processes might not apply
+  // constraints, so we need to explicitly
+  // state, that the others are doing an
+  // insert here:
   vec.compress (::dealii::VectorOperation::insert);
 }
 
@@ -1977,24 +1970,24 @@
       typedef std::vector<ConstraintLine>::const_iterator constraint_iterator;
       ConstraintLine index_comparison;
       index_comparison.line = vec.block(block).local_range().first
-        +vec.get_block_indices().block_start(block);
+                              +vec.get_block_indices().block_start(block);
       const constraint_iterator begin_my_constraints =
         Utilities::lower_bound (lines.begin(),lines.end(),index_comparison);
 
       index_comparison.line = vec.block(block).local_range().second
-        +vec.get_block_indices().block_start(block);
+                              +vec.get_block_indices().block_start(block);
 
       const constraint_iterator end_my_constraints
         = Utilities::lower_bound(lines.begin(),lines.end(),index_comparison);
 
-                                   // Here we search all the indices that we
-                                   // need to have read-access to - the local
-                                   // nodes and all the nodes that the
-                                   // constraints indicate. No caching done
-                                   // yet. would need some more clever data
-                                   // structures for doing that.
+      // Here we search all the indices that we
+      // need to have read-access to - the local
+      // nodes and all the nodes that the
+      // constraints indicate. No caching done
+      // yet. would need some more clever data
+      // structures for doing that.
       const std::pair<unsigned int, unsigned int>
-        local_range = vec.block(block).local_range();
+      local_range = vec.block(block).local_range();
 
       my_indices.add_range (local_range.first, local_range.second);
 
@@ -2013,18 +2006,18 @@
 
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
   const Epetra_MpiComm *mpi_comm
-    = dynamic_cast<const Epetra_MpiComm*>(&vec.block(0).trilinos_vector().Comm());
+    = dynamic_cast<const Epetra_MpiComm *>(&vec.block(0).trilinos_vector().Comm());
 
   Assert (mpi_comm != 0, ExcInternalError());
 
   TrilinosWrappers::MPI::Vector vec_distribute
-    (my_indices.make_trilinos_map (mpi_comm->Comm(), true));
+  (my_indices.make_trilinos_map (mpi_comm->Comm(), true));
 #else
   TrilinosWrappers::MPI::Vector vec_distribute
-    (my_indices.make_trilinos_map (MPI_COMM_WORLD, true));
+  (my_indices.make_trilinos_map (MPI_COMM_WORLD, true));
 #endif
 
-                                   // here we import the data
+  // here we import the data
   vec_distribute.reinit(vec,true);
 
   for (unsigned int block=0; block<vec.n_blocks(); ++block)
@@ -2032,12 +2025,12 @@
       typedef std::vector<ConstraintLine>::const_iterator constraint_iterator;
       ConstraintLine index_comparison;
       index_comparison.line = vec.block(block).local_range().first
-        +vec.get_block_indices().block_start(block);
+                              +vec.get_block_indices().block_start(block);
       const constraint_iterator begin_my_constraints =
         Utilities::lower_bound (lines.begin(),lines.end(),index_comparison);
 
       index_comparison.line = vec.block(block).local_range().second
-        +vec.get_block_indices().block_start(block);
+                              +vec.get_block_indices().block_start(block);
 
       const constraint_iterator end_my_constraints
         = Utilities::lower_bound(lines.begin(),lines.end(),index_comparison);
@@ -2045,9 +2038,9 @@
       for (constraint_iterator it = begin_my_constraints;
            it != end_my_constraints; ++it)
         {
-                                       // fill entry in line
-                                       // next_constraint.line by adding the
-                                       // different contributions
+          // fill entry in line
+          // next_constraint.line by adding the
+          // different contributions
           double new_value = it->inhomogeneity;
           for (unsigned int i=0; i<it->entries.size(); ++i)
             new_value += (vec_distribute(it->entries[i].first) *
@@ -2062,12 +2055,12 @@
 
 #ifdef DEAL_II_USE_PETSC
 
-                                   // this is a specialization for a
-                                   // parallel (non-block) PETSc
-                                   // vector. The basic idea is to just work
-                                   // on the local range of the vector. But
-                                   // we need access to values that the
-                                   // local nodes are constrained to.
+// this is a specialization for a
+// parallel (non-block) PETSc
+// vector. The basic idea is to just work
+// on the local range of the vector. But
+// we need access to values that the
+// local nodes are constrained to.
 
 template<>
 void
@@ -2085,11 +2078,11 @@
   const constraint_iterator end_my_constraints
     = Utilities::lower_bound(lines.begin(),lines.end(),index_comparison);
 
-                                   // all indices we need to read from
+  // all indices we need to read from
   IndexSet my_indices (vec.size());
 
   const std::pair<unsigned int, unsigned int>
-    local_range = vec.local_range();
+  local_range = vec.local_range();
 
   my_indices.add_range (local_range.first, local_range.second);
 
@@ -2109,21 +2102,21 @@
   local_range_is.add_range(local_range.first, local_range.second);
 
 
-                                   // create a vector and import those indices
+  // create a vector and import those indices
   PETScWrappers::MPI::Vector ghost_vec (vec.get_mpi_communicator(),
                                         local_range_is,
                                         my_indices);
   ghost_vec = vec;
   ghost_vec.update_ghost_values();
 
-                                   // finally do the distribution on own
-                                   // constraints
+  // finally do the distribution on own
+  // constraints
   for (constraint_iterator it = begin_my_constraints;
        it != end_my_constraints; ++it)
     {
-                                       // fill entry in line
-                                       // next_constraint.line by adding the
-                                       // different contributions
+      // fill entry in line
+      // next_constraint.line by adding the
+      // different contributions
       PetscScalar new_value = it->inhomogeneity;
       for (unsigned int i=0; i<it->entries.size(); ++i)
         new_value += (PetscScalar(ghost_vec(it->entries[i].first)) *
@@ -2135,6 +2128,7 @@
 }
 
 
+
 template<>
 void
 ConstraintMatrix::distribute (PETScWrappers::MPI::BlockVector &vec) const   // modified by shuqiangwang
@@ -2262,12 +2256,12 @@
   if (is_constrained(index) == false)
     return false;
 
-  const ConstraintLine & p = lines[lines_cache[calculate_line_index(index)]];
+  const ConstraintLine &p = lines[lines_cache[calculate_line_index(index)]];
   Assert (p.line == index, ExcInternalError());
 
-                                       // return if an entry for this
-                                       // line was found and if it has
-                                       // only one entry equal to 1.0
+  // return if an entry for this
+  // line was found and if it has
+  // only one entry equal to 1.0
   return ((p.entries.size() == 1) &&
           (p.entries[0].second == 1.0));
 }
@@ -2279,9 +2273,9 @@
   unsigned int return_value = 0;
   for (std::vector<ConstraintLine>::const_iterator i=lines.begin();
        i!=lines.end(); ++i)
-                                     // use static cast, since
-                                     // typeof(size)==std::size_t, which is !=
-                                     // unsigned int on AIX
+    // use static cast, since
+    // typeof(size)==std::size_t, which is !=
+    // unsigned int on AIX
     return_value = std::max(return_value,
                             static_cast<unsigned int>(i->entries.size()));
 
@@ -2305,9 +2299,9 @@
 {
   for (unsigned int i=0; i!=lines.size(); ++i)
     {
-                                       // output the list of
-                                       // constraints as pairs of dofs
-                                       // and their weights
+      // output the list of
+      // constraints as pairs of dofs
+      // and their weights
       if (lines[i].entries.size() > 0)
         {
           for (unsigned int j=0; j<lines[i].entries.size(); ++j)
@@ -2315,18 +2309,18 @@
                 << " " << lines[i].entries[j].first
                 << ":  " << lines[i].entries[j].second << "\n";
 
-                                       // print out inhomogeneity.
+          // print out inhomogeneity.
           if (lines[i].inhomogeneity != 0)
             out << "    " << lines[i].line
                 << ": " << lines[i].inhomogeneity << "\n";
         }
       else
-                                         // but also output something
-                                         // if the constraint simply
-                                         // reads x[13]=0, i.e. where
-                                         // the right hand side is not
-                                         // a linear combination of
-                                         // other dofs
+        // but also output something
+        // if the constraint simply
+        // reads x[13]=0, i.e. where
+        // the right hand side is not
+        // a linear combination of
+        // other dofs
         {
           if (lines[i].inhomogeneity != 0)
             out << "    " << lines[i].line
@@ -2349,8 +2343,8 @@
       << std::endl;
   for (unsigned int i=0; i!=lines.size(); ++i)
     {
-                                       // same concept as in the
-                                       // previous function
+      // same concept as in the
+      // previous function
       if (lines[i].entries.size() > 0)
         for (unsigned int j=0; j<lines[i].entries.size(); ++j)
           out << "  " << lines[i].line << "->" << lines[i].entries[j].first
@@ -2390,31 +2384,31 @@
 
 #define VECTOR_FUNCTIONS(VectorType) \
   template void ConstraintMatrix::condense<VectorType >(const VectorType &uncondensed,\
-                                                       VectorType       &condensed) const;\
+                                                        VectorType       &condensed) const;\
   template void ConstraintMatrix::condense<VectorType >(VectorType &vec) const;\
   template void ConstraintMatrix::condense<float,VectorType >(const SparseMatrix<float> &uncondensed, \
                                                               const VectorType &uncondensed_vector, \
                                                               SparseMatrix<float> &condensed, \
                                                               VectorType       &condensed_vector) const; \
   template void ConstraintMatrix::condense<double,VectorType >(const SparseMatrix<double> &uncondensed, \
-                                                               const VectorType &uncondensed_vector, \
-                                                               SparseMatrix<double> &condensed, \
-                                                               VectorType       &condensed_vector) const; \
+      const VectorType &uncondensed_vector, \
+      SparseMatrix<double> &condensed, \
+      VectorType       &condensed_vector) const; \
   template void ConstraintMatrix:: \
-    distribute_local_to_global<VectorType > (const Vector<double>            &, \
-                                             const std::vector<unsigned int> &, \
-                                             VectorType                      &, \
-                                             const FullMatrix<double>        &) const; \
+  distribute_local_to_global<VectorType > (const Vector<double>            &, \
+                                           const std::vector<unsigned int> &, \
+                                           VectorType                      &, \
+                                           const FullMatrix<double>        &) const; \
   template void ConstraintMatrix::distribute<VectorType >(const VectorType &condensed,\
-                                                         VectorType       &uncondensed) const;\
+                                                          VectorType       &uncondensed) const;\
   template void ConstraintMatrix::distribute<VectorType >(VectorType &vec) const
 
 #define PARALLEL_VECTOR_FUNCTIONS(VectorType) \
   template void ConstraintMatrix:: \
-    distribute_local_to_global<VectorType > (const Vector<double>            &, \
-                                             const std::vector<unsigned int> &, \
-                                             VectorType                      &, \
-                                             const FullMatrix<double>        &) const
+  distribute_local_to_global<VectorType > (const Vector<double>            &, \
+                                           const std::vector<unsigned int> &, \
+                                           VectorType                      &, \
+                                           const FullMatrix<double>        &) const
 
 
 // TODO: Can PETSc really do all the operations required by the above
@@ -2433,41 +2427,41 @@
 #endif
 
 #define MATRIX_VECTOR_FUNCTIONS(MatrixType, VectorType) \
-template void ConstraintMatrix:: \
-distribute_local_to_global<MatrixType,VectorType > (const FullMatrix<double>        &, \
-                                                    const Vector<double>            &, \
-                                                    const std::vector<unsigned int> &, \
-                                                    MatrixType                      &, \
-                                                    VectorType                      &, \
-                                                    bool                             , \
-                                                    internal::bool2type<false>) const
+  template void ConstraintMatrix:: \
+  distribute_local_to_global<MatrixType,VectorType > (const FullMatrix<double>        &, \
+                                                      const Vector<double>            &, \
+                                                      const std::vector<unsigned int> &, \
+                                                      MatrixType                      &, \
+                                                      VectorType                      &, \
+                                                      bool                             , \
+                                                      internal::bool2type<false>) const
 #define MATRIX_FUNCTIONS(MatrixType) \
-template void ConstraintMatrix:: \
-distribute_local_to_global<MatrixType,Vector<double> > (const FullMatrix<double>        &, \
-                                                        const Vector<double>            &, \
-                                                        const std::vector<unsigned int> &, \
-                                                        MatrixType                      &, \
-                                                        Vector<double>                  &, \
-                                                        bool                             , \
-                                                        internal::bool2type<false>) const
+  template void ConstraintMatrix:: \
+  distribute_local_to_global<MatrixType,Vector<double> > (const FullMatrix<double>        &, \
+                                                          const Vector<double>            &, \
+                                                          const std::vector<unsigned int> &, \
+                                                          MatrixType                      &, \
+                                                          Vector<double>                  &, \
+                                                          bool                             , \
+                                                          internal::bool2type<false>) const
 #define BLOCK_MATRIX_VECTOR_FUNCTIONS(MatrixType, VectorType)   \
-template void ConstraintMatrix:: \
-distribute_local_to_global<MatrixType,VectorType > (const FullMatrix<double>        &, \
-                                                    const Vector<double>            &, \
-                                                    const std::vector<unsigned int> &, \
-                                                    MatrixType                      &, \
-                                                    VectorType                      &, \
-                                                    bool                             , \
-                                                    internal::bool2type<true>) const
+  template void ConstraintMatrix:: \
+  distribute_local_to_global<MatrixType,VectorType > (const FullMatrix<double>        &, \
+                                                      const Vector<double>            &, \
+                                                      const std::vector<unsigned int> &, \
+                                                      MatrixType                      &, \
+                                                      VectorType                      &, \
+                                                      bool                             , \
+                                                      internal::bool2type<true>) const
 #define BLOCK_MATRIX_FUNCTIONS(MatrixType)      \
-template void ConstraintMatrix:: \
-distribute_local_to_global<MatrixType,Vector<double> > (const FullMatrix<double>        &, \
-                                                        const Vector<double>            &, \
-                                                        const std::vector<unsigned int> &, \
-                                                        MatrixType                      &, \
-                                                        Vector<double>                  &, \
-                                                        bool                             , \
-                                                        internal::bool2type<true>) const
+  template void ConstraintMatrix:: \
+  distribute_local_to_global<MatrixType,Vector<double> > (const FullMatrix<double>        &, \
+                                                          const Vector<double>            &, \
+                                                          const std::vector<unsigned int> &, \
+                                                          MatrixType                      &, \
+                                                          Vector<double>                  &, \
+                                                          bool                             , \
+                                                          internal::bool2type<true>) const
 
 MATRIX_FUNCTIONS(SparseMatrix<double>);
 MATRIX_FUNCTIONS(SparseMatrix<float>);
@@ -2511,30 +2505,30 @@
 
 #define SPARSITY_FUNCTIONS(SparsityType) \
   template void ConstraintMatrix::add_entries_local_to_global<SparsityType> (\
-    const std::vector<unsigned int> &, \
-    SparsityType &,                    \
-    const bool,                        \
-    const Table<2,bool> &, \
-    internal::bool2type<false>) const; \
+      const std::vector<unsigned int> &, \
+      SparsityType &,                    \
+      const bool,                        \
+      const Table<2,bool> &, \
+      internal::bool2type<false>) const; \
   template void ConstraintMatrix::add_entries_local_to_global<SparsityType> (\
-    const std::vector<unsigned int> &, \
-    const std::vector<unsigned int> &, \
-    SparsityType &,                    \
-    const bool,                        \
-    const Table<2,bool> &) const
+      const std::vector<unsigned int> &, \
+      const std::vector<unsigned int> &, \
+      SparsityType &,                    \
+      const bool,                        \
+      const Table<2,bool> &) const
 #define BLOCK_SPARSITY_FUNCTIONS(SparsityType) \
   template void ConstraintMatrix::add_entries_local_to_global<SparsityType> (\
-    const std::vector<unsigned int> &, \
-    SparsityType &,                    \
-    const bool,                        \
-    const Table<2,bool> &, \
-    internal::bool2type<true>) const; \
+      const std::vector<unsigned int> &, \
+      SparsityType &,                    \
+      const bool,                        \
+      const Table<2,bool> &, \
+      internal::bool2type<true>) const; \
   template void ConstraintMatrix::add_entries_local_to_global<SparsityType> (\
-    const std::vector<unsigned int> &, \
-    const std::vector<unsigned int> &, \
-    SparsityType &,                    \
-    const bool,                        \
-    const Table<2,bool> &) const
+      const std::vector<unsigned int> &, \
+      const std::vector<unsigned int> &, \
+      SparsityType &,                    \
+      const bool,                        \
+      const Table<2,bool> &) const
 
 SPARSITY_FUNCTIONS(SparsityPattern);
 SPARSITY_FUNCTIONS(CompressedSparsityPattern);
@@ -2553,10 +2547,10 @@
 
 #define ONLY_MATRIX_FUNCTIONS(MatrixType) \
   template void ConstraintMatrix::distribute_local_to_global<MatrixType > (\
-  const FullMatrix<double>        &, \
-  const std::vector<unsigned int> &, \
-  const std::vector<unsigned int> &, \
-  MatrixType                      &) const
+      const FullMatrix<double>        &, \
+      const std::vector<unsigned int> &, \
+      const std::vector<unsigned int> &, \
+      MatrixType                      &) const
 
 ONLY_MATRIX_FUNCTIONS(SparseMatrix<float>);
 ONLY_MATRIX_FUNCTIONS(SparseMatrix<double>);

Modified: branches/s-wang/for_deal.II/source/lac/petsc_matrix_base.cc
===================================================================
--- branches/s-wang/for_deal.II/source/lac/petsc_matrix_base.cc	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/source/lac/petsc_matrix_base.cc	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,5 +1,5 @@
 //---------------------------------------------------------------------------
-//    $Id: petsc_matrix_base.cc 26045 2012-08-21 09:38:15Z young $
+//    $Id: petsc_matrix_base.cc 27628 2012-11-20 22:49:26Z heister $
 //    Version: $Name$
 //
 //    Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
@@ -31,10 +31,10 @@
     MatrixBase::const_iterator::Accessor::
     visit_present_row ()
     {
-                                       // if we are asked to visit the
-                                       // past-the-end line, then simply
-                                       // release all our caches and go on
-                                       // with life
+      // if we are asked to visit the
+      // past-the-end line, then simply
+      // release all our caches and go on
+      // with life
       if (this->a_row == matrix->m())
         {
           colnum_cache.reset ();
@@ -43,11 +43,11 @@
           return;
         }
 
-                                       // otherwise first flush PETSc caches
+      // otherwise first flush PETSc caches
       matrix->compress ();
 
-                                       // get a representation of the present
-                                       // row
+      // get a representation of the present
+      // row
       PetscInt           ncols;
       const PetscInt    *colnums;
       const PetscScalar *values;
@@ -56,18 +56,18 @@
       ierr = MatGetRow(*matrix, this->a_row, &ncols, &colnums, &values);
       AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
 
-                                       // copy it into our caches if the line
-                                       // isn't empty. if it is, then we've
-                                       // done something wrong, since we
-                                       // shouldn't have initialized an
-                                       // iterator for an empty line (what
-                                       // would it point to?)
+      // copy it into our caches if the line
+      // isn't empty. if it is, then we've
+      // done something wrong, since we
+      // shouldn't have initialized an
+      // iterator for an empty line (what
+      // would it point to?)
       Assert (ncols != 0, ExcInternalError());
       colnum_cache.reset (new std::vector<unsigned int> (colnums,
                                                          colnums+ncols));
       value_cache.reset (new std::vector<PetscScalar> (values, values+ncols));
 
-                                       // and finally restore the matrix
+      // and finally restore the matrix
       ierr = MatRestoreRow(*matrix, this->a_row, &ncols, &colnums, &values);
       AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
     }
@@ -76,8 +76,8 @@
 
 
   MatrixBase::MatrixBase ()
-                  :
-                  last_action (LastAction::none)
+    :
+    last_action (LastAction::none)
   {}
 
 
@@ -97,15 +97,15 @@
   void
   MatrixBase::clear ()
   {
-                                     // destroy the matrix...
+    // destroy the matrix...
 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
     int ierr = MatDestroy (matrix);
 #else
     int ierr = MatDestroy (&matrix);
 #endif
     AssertThrow (ierr == 0, ExcPETScError(ierr));
-                                     // ...and replace it by an empty
-                                     // sequential matrix
+    // ...and replace it by an empty
+    // sequential matrix
     const int m=0, n=0, n_nonzero_per_row=0;
     ierr = MatCreateSeqAIJ(PETSC_COMM_SELF, m, n, n_nonzero_per_row,
                            0, &matrix);
@@ -119,10 +119,10 @@
   {
     Assert (d==value_type(), ExcScalarAssignmentOnlyForZeroValue());
 
-                                     // flush previously cached elements. this
-                                     // seems to be necessary since petsc
-                                     // 2.2.1, at least for parallel vectors
-                                     // (see test bits/petsc_64)
+    // flush previously cached elements. this
+    // seems to be necessary since petsc
+    // 2.2.1, at least for parallel vectors
+    // (see test bits/petsc_64)
     compress ();
 
     const int ierr = MatZeroEntries (matrix);
@@ -139,8 +139,8 @@
   {
     compress ();
 
-                                     // now set all the entries of this row to
-                                     // zero
+    // now set all the entries of this row to
+    // zero
     const PetscInt petsc_row = row;
 
     IS index_set;
@@ -176,13 +176,13 @@
   {
     compress ();
 
-                                     // now set all the entries of these rows
-                                     // to zero
+    // now set all the entries of these rows
+    // to zero
     const std::vector<PetscInt> petsc_rows (rows.begin(), rows.end());
 
-                                     // call the functions. note that we have
-                                     // to call them even if #rows is empty,
-                                     // since this is a collective operation
+    // call the functions. note that we have
+    // to call them even if #rows is empty,
+    // since this is a collective operation
     IS index_set;
 
 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
@@ -222,7 +222,7 @@
 #else
     int
 #endif
-      petsc_i = i, petsc_j = j;
+    petsc_i = i, petsc_j = j;
     PetscScalar value;
 
     const int ierr
@@ -240,17 +240,17 @@
   {
     Assert (m() == n(), ExcNotQuadratic());
 
-                                     // this doesn't seem to work any
-                                     // different than any other element
+    // this doesn't seem to work any
+    // different than any other element
     return el(i,i);
   }
 
 
 
   void
-  MatrixBase::compress (::dealii::VectorOperation::values operation)
+  MatrixBase::compress (::dealii::VectorOperation::values operation)	// why operation is not used?
   {
-                                     // flush buffers
+    // flush buffers
     int ierr;
     ierr = MatAssemblyBegin (matrix,MAT_FINAL_ASSEMBLY);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
@@ -271,7 +271,7 @@
 #else
     int
 #endif
-      n_rows, n_cols;
+    n_rows, n_cols;
     int ierr = MatGetSize (matrix, &n_rows, &n_cols);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
@@ -288,7 +288,7 @@
 #else
     int
 #endif
-      n_rows, n_cols;
+    n_rows, n_cols;
     int ierr = MatGetSize (matrix, &n_rows, &n_cols);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
@@ -305,7 +305,7 @@
 #else
     int
 #endif
-      n_rows, n_cols;
+    n_rows, n_cols;
     int ierr = MatGetLocalSize (matrix, &n_rows, &n_cols);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
 
@@ -322,7 +322,7 @@
 #else
     int
 #endif
-      begin, end;
+    begin, end;
     const int ierr = MatGetOwnershipRange (static_cast<const Mat &>(matrix),
                                            &begin, &end);
     AssertThrow (ierr == 0, ExcPETScError(ierr));
@@ -357,8 +357,8 @@
 //entries in a row bypassing the call to compress(), but I can't find one
     Assert (row < m(), ExcInternalError());
 
-                                     // get a representation of the present
-                                     // row
+    // get a representation of the present
+    // row
     PetscInt ncols;
     const PetscInt    *colnums;
     const PetscScalar *values;
@@ -369,9 +369,9 @@
     ierr = MatGetRow(*this, row, &ncols, &colnums, &values);
     AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
 
-                                     // then restore the matrix and return the
-                                     // number of columns in this row as
-                                     // queried previously
+    // then restore the matrix and return the
+    // number of columns in this row as
+    // queried previously
     ierr = MatRestoreRow(*this, row, &ncols, &colnums, &values);
     AssertThrow (ierr == 0, MatrixBase::ExcPETScError(ierr));
 
@@ -428,10 +428,10 @@
     return tmp*v;
   }
 
-  
+
   PetscScalar
   MatrixBase::matrix_scalar_product (const VectorBase &u,
-				     const VectorBase &v) const
+                                     const VectorBase &v) const
   {
     Vector tmp(v.size());
     vmult (tmp, v);
@@ -530,9 +530,9 @@
                         const VectorBase &x,
                         const VectorBase &b) const
   {
-                                     // avoid the use of a temporary, and
-                                     // rather do one negation pass more than
-                                     // necessary
+    // avoid the use of a temporary, and
+    // rather do one negation pass more than
+    // necessary
     vmult (dst, x);
     dst -= b;
     dst *= -1;
@@ -564,10 +564,10 @@
 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
     PetscTruth
 #else
-      PetscBool
+    PetscBool
 #endif
-      truth;
-                                       // First flush PETSc caches
+    truth;
+    // First flush PETSc caches
     compress ();
     MatIsSymmetric (matrix, tolerance, &truth);
     return truth;
@@ -583,11 +583,11 @@
 #if DEAL_II_PETSC_VERSION_LT(3,2,0)
     PetscTruth
 #else
-      PetscBool
+    PetscBool
 #endif
-      truth;
+    truth;
 
-                                     // First flush PETSc caches
+    // First flush PETSc caches
     compress ();
     MatIsHermitian (matrix, tolerance, &truth);
 
@@ -595,16 +595,16 @@
   }
 
   void
-  MatrixBase::write_ascii () const
+  MatrixBase::write_ascii() const
   {
-                                       // First flush PETSc caches
-    compress ();
+    // First flush PETSc caches
+//    compress ();					// shuqiangwang: call compress() before call write_ascii().
 
-                                       // Set options
+    // Set options
     PetscViewerSetFormat (PETSC_VIEWER_STDOUT_WORLD,
                           PETSC_VIEWER_DEFAULT);
 
-                                       // Write to screen
+    // Write to screen
     MatView (matrix,PETSC_VIEWER_STDOUT_WORLD);
   }
 

Added: branches/s-wang/for_deal.II/source/lac/petsc_solver.cc
===================================================================
--- branches/s-wang/for_deal.II/source/lac/petsc_solver.cc	                        (rev 0)
+++ branches/s-wang/for_deal.II/source/lac/petsc_solver.cc	2012-11-28 19:03:50 UTC (rev 1392)
@@ -0,0 +1,890 @@
+//---------------------------------------------------------------------------
+//    $Id: petsc_solver.cc 27668 2012-11-21 23:50:16Z bangerth $
+//    Version: $Name$
+//
+//    Copyright (C) 2004, 2006, 2008, 2009, 2010, 2012 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//---------------------------------------------------------------------------
+
+#include <deal.II/base/logstream.h>
+#include <deal.II/lac/petsc_solver.h>
+
+#ifdef DEAL_II_USE_PETSC
+
+#  include <deal.II/lac/petsc_matrix_base.h>
+#  include <deal.II/lac/petsc_vector_base.h>
+#  include <deal.II/lac/petsc_precondition.h>
+#  include <cmath>
+
+#include <petscversion.h>
+
+DEAL_II_NAMESPACE_OPEN
+
+namespace PETScWrappers
+{
+
+  SolverBase::SolverData::~SolverData ()
+  {
+    // destroy the solver object
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+    int ierr = KSPDestroy (ksp);
+#else
+    int ierr = KSPDestroy (&ksp);
+#endif
+
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+  }
+
+
+
+  SolverBase::SolverBase (SolverControl &cn,
+                          const MPI_Comm &mpi_communicator)
+    :
+    solver_control (cn),
+    mpi_communicator (mpi_communicator)
+  {}
+
+
+
+  SolverBase::~SolverBase ()
+  {}
+
+
+
+  void
+  SolverBase::solve (const MatrixBase         &A,
+                     VectorBase               &x,
+                     const VectorBase         &b,
+                     const PreconditionerBase &preconditioner)
+  {
+    int ierr;
+    // first create a solver object if this
+    // is necessary
+    if (solver_data.get() == 0)
+      {
+        solver_data.reset (new SolverData());
+
+        ierr = KSPCreate (mpi_communicator, &solver_data->ksp);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        // set the matrices involved. the
+        // last argument is irrelevant here,
+        // since we use the solver only once
+        // anyway
+        ierr = KSPSetOperators (solver_data->ksp, A, preconditioner,
+                                SAME_PRECONDITIONER);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        // let derived classes set the solver
+        // type, and the preconditioning
+        // object set the type of
+        // preconditioner
+        set_solver_type (solver_data->ksp);
+
+        ierr = KSPSetPC (solver_data->ksp, preconditioner.get_pc());
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        // then a convergence monitor
+        // function. that function simply
+        // checks with the solver_control
+        // object we have in this object for
+        // convergence
+        KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
+                               reinterpret_cast<void *>(&solver_control),
+                               PETSC_NULL);
+
+        KSPSetNormType(solver_data->ksp, KSP_NORM_UNPRECONDITIONED);	// shuqiangwang
+//        int maxits;
+//        double rtol, atol, dtol;
+//        KSPGetTolerances(solver_data->ksp, &rtol, &atol, &dtol, &maxits);
+////        KSPSetTolerances(solver_data->ksp, rtol, solver_control.tolerance(), dtol, solver_control.max_steps());
+//        KSPSetTolerances(solver_data->ksp, solver_control.tolerance(), atol, dtol, solver_control.max_steps());
+      }
+
+    // set the command line option prefix name
+    ierr = KSPSetOptionsPrefix(solver_data->ksp, prefix_name.c_str());
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // set the command line options provided
+    // by the user to override the defaults
+    ierr = KSPSetFromOptions (solver_data->ksp);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // then do the real work: set up solver
+    // internal data and solve the
+    // system.
+    ierr = KSPSetUp (solver_data->ksp);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    ierr = KSPSolve (solver_data->ksp, b, x);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // do not destroy solver object
+//    solver_data.reset ();
+
+    // in case of failure: throw
+    // exception
+    if (solver_control.last_check() != SolverControl::success)
+      throw SolverControl::NoConvergence (solver_control.last_step(),
+                                          solver_control.last_value());
+    // otherwise exit as normal
+  }
+
+
+  void
+  SolverBase::set_prefix(const std::string &prefix)
+  {
+    prefix_name = prefix ;
+  }
+
+
+  void
+  SolverBase::reset()
+  {
+    solver_data.reset ();
+  }
+
+
+  SolverControl &
+  SolverBase::control() const
+  {
+    return solver_control;
+  }
+
+
+  int
+  SolverBase::convergence_test (KSP                 /*ksp*/,
+#ifdef PETSC_USE_64BIT_INDICES
+                                const PetscInt      iteration,
+#else
+                                const int           iteration,
+#endif
+                                const PetscReal     residual_norm,
+                                KSPConvergedReason *reason,
+                                void               *solver_control_x)
+  {
+    SolverControl &solver_control = *reinterpret_cast<SolverControl *>(solver_control_x);
+
+    const SolverControl::State state
+      = solver_control.check (iteration, residual_norm);
+
+    switch (state)
+      {
+      case ::dealii::SolverControl::iterate:
+        *reason = KSP_CONVERGED_ITERATING;
+        break;
+
+      case ::dealii::SolverControl::success:
+        *reason = static_cast<KSPConvergedReason>(1);
+        break;
+
+      case ::dealii::SolverControl::failure:
+        if (solver_control.last_step() > solver_control.max_steps())
+          *reason = KSP_DIVERGED_ITS;
+        else
+          *reason = KSP_DIVERGED_DTOL;
+        break;
+
+      default:
+        Assert (false, ExcNotImplemented());
+      }
+
+    // return without failure
+    return 0;
+  }
+
+
+
+  /* ---------------------- SolverRichardson ------------------------ */
+
+  SolverRichardson::AdditionalData::
+  AdditionalData (const double omega)
+    :
+    omega (omega)
+  {}
+
+
+
+  SolverRichardson::SolverRichardson (SolverControl        &cn,
+                                      const MPI_Comm       &mpi_communicator,
+                                      const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverRichardson::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPRICHARDSON);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // set the damping factor from the data
+    ierr = KSPRichardsonSetScale (ksp, additional_data.omega);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+
+    // Hand over the absolute
+    // tolerance and the maximum
+    // iteration number to the PETSc
+    // convergence criterion. The
+    // custom deal.II SolverControl
+    // object is ignored by the PETSc
+    // Richardson method (when no
+    // PETSc monitoring is present),
+    // since in this case PETSc
+    // uses a faster version of
+    // the Richardson iteration,
+    // where no residual is
+    // available.
+    KSPSetTolerances(ksp, PETSC_DEFAULT, this->solver_control.tolerance(),
+                     PETSC_DEFAULT, this->solver_control.max_steps()+1);
+  }
+
+
+  /* ---------------------- SolverChebychev ------------------------ */
+
+  SolverChebychev::SolverChebychev (SolverControl        &cn,
+                                    const MPI_Comm       &mpi_communicator,
+                                    const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverChebychev::set_solver_type (KSP &ksp) const
+  {
+    // set the type of solver. note the
+    // completely pointless change in
+    // spelling Chebyshev between PETSc 3.2
+    // and 3.3...
+    int ierr;
+
+#if DEAL_II_PETSC_VERSION_LT(3,3,0)
+    ierr = KSPSetType (ksp, KSPCHEBYCHEV);
+#else
+    ierr = KSPSetType (ksp, KSPCHEBYSHEV);
+#endif
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverCG ------------------------ */
+
+  SolverCG::SolverCG (SolverControl        &cn,
+                      const MPI_Comm       &mpi_communicator,
+                      const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverCG::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPCG);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverBiCG ------------------------ */
+
+  SolverBiCG::SolverBiCG (SolverControl        &cn,
+                          const MPI_Comm       &mpi_communicator,
+                          const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverBiCG::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPBICG);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverGMRES ------------------------ */
+
+  SolverGMRES::AdditionalData::
+  AdditionalData (const unsigned int restart_parameter,
+                  const bool right_preconditioning)
+    :
+    restart_parameter (restart_parameter),
+    right_preconditioning (right_preconditioning)
+  {}
+
+
+
+  SolverGMRES::SolverGMRES (SolverControl        &cn,
+                            const MPI_Comm       &mpi_communicator,
+                            const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverGMRES::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPGMRES);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // set the restart parameter from the
+    // data. we would like to use the simple
+    // code that is commented out, but this
+    // leads to nasty warning and error
+    // messages due to some stupidity on
+    // PETSc's side: KSPGMRESSetRestart is
+    // implemented as a macro in which return
+    // statements are hidden. This may work
+    // if people strictly follow the PETSc
+    // coding style of always having
+    // functions return an integer error
+    // code, but the present function isn't
+    // like this.
+    /*
+        ierr = KSPGMRESSetRestart (ksp, additional_data.restart_parameter);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+    */
+    // so rather expand their macros by hand,
+    // and do some equally nasty stuff that at
+    // least doesn't yield warnings...
+    int (*fun_ptr)(KSP,int);
+    ierr = PetscObjectQueryFunction((PetscObject)(ksp),
+                                    "KSPGMRESSetRestart_C",
+                                    (void (* *)())&fun_ptr);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    ierr = (*fun_ptr)(ksp,additional_data.restart_parameter);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // Set preconditioning side to
+    // right
+    if (additional_data.right_preconditioning)
+      {
+#if DEAL_II_PETSC_VERSION_LT(3,2,0)
+        ierr = KSPSetPreconditionerSide(ksp, PC_RIGHT);
+#else
+        ierr = KSPSetPCSide(ksp, PC_RIGHT);
+#endif
+
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+      }
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverBicgstab ------------------------ */
+
+  SolverBicgstab::SolverBicgstab (SolverControl        &cn,
+                                  const MPI_Comm       &mpi_communicator,
+                                  const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverBicgstab::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPBCGS);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverCGS ------------------------ */
+
+  SolverCGS::SolverCGS (SolverControl        &cn,
+                        const MPI_Comm       &mpi_communicator,
+                        const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverCGS::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPCGS);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverTFQMR ------------------------ */
+
+  SolverTFQMR::SolverTFQMR (SolverControl        &cn,
+                            const MPI_Comm       &mpi_communicator,
+                            const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverTFQMR::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPTFQMR);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverTCQMR ------------------------ */
+
+  SolverTCQMR::SolverTCQMR (SolverControl        &cn,
+                            const MPI_Comm       &mpi_communicator,
+                            const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverTCQMR::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPTCQMR);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverCR ------------------------ */
+
+  SolverCR::SolverCR (SolverControl        &cn,
+                      const MPI_Comm       &mpi_communicator,
+                      const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverCR::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPCR);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverLSQR ------------------------ */
+
+  SolverLSQR::SolverLSQR (SolverControl        &cn,
+                          const MPI_Comm       &mpi_communicator,
+                          const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverLSQR::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPLSQR);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // in the deal.II solvers, we always
+    // honor the initial guess in the
+    // solution vector. do so here as well:
+    KSPSetInitialGuessNonzero (ksp, PETSC_TRUE);
+  }
+
+
+  /* ---------------------- SolverPreOnly ------------------------ */
+
+  SolverPreOnly::SolverPreOnly (SolverControl        &cn,
+                                const MPI_Comm       &mpi_communicator,
+                                const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data)
+  {}
+
+
+  void
+  SolverPreOnly::set_solver_type (KSP &ksp) const
+  {
+    int ierr;
+    ierr = KSPSetType (ksp, KSPPREONLY);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    // The KSPPREONLY solver of
+    // PETSc never calls the convergence
+    // monitor, which leads to failure
+    // even when everything was ok.
+    // Therefore the SolverControl status
+    // is set to some nice values, which
+    // guarantee a nice result at the end
+    // of the solution process.
+    solver_control.check (1, 0.0);
+
+    // Using the PREONLY solver with
+    // a nonzero initial guess leads
+    // PETSc to produce some error messages.
+    KSPSetInitialGuessNonzero (ksp, PETSC_FALSE);
+  }
+
+
+  /* ---------------------- SparseDirectMUMPS------------------------ */
+
+  SparseDirectMUMPS::SparseDirectMUMPS (SolverControl     &cn,
+                                        const MPI_Comm       &mpi_communicator,
+                                        const AdditionalData &data)
+    :
+    SolverBase (cn, mpi_communicator),
+    additional_data (data),
+    symmetric_mode(false)
+  {}
+
+
+  void
+  SparseDirectMUMPS::set_solver_type (KSP &ksp) const
+  {
+    /**
+    * KSPPREONLY implements a stub
+    * method that applies only the
+    * preconditioner.  Its use is due
+    * to SparseDirectMUMPS being
+    * a direct (rather than iterative)
+    * solver
+    */
+    int ierr;
+    ierr = KSPSetType (ksp, KSPPREONLY);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    /**
+     * The KSPPREONLY solver of
+     * PETSc never calls the convergence
+     * monitor, which leads to failure
+     * even when everything was ok.
+     * Therefore, the SolverControl
+     * status is set to some nice
+     * values, which guarantee a nice
+     * result at the end of the solution
+     * process.
+     */
+    solver_control.check (1, 0.0);
+
+    /**
+     * Using a PREONLY solver with a
+     * nonzero initial guess leads PETSc
+     * to produce some error messages.
+     */
+    KSPSetInitialGuessNonzero (ksp, PETSC_FALSE);
+  }
+
+  void
+  SparseDirectMUMPS::solve (const MatrixBase &A,
+                            VectorBase       &x,
+                            const VectorBase &b)
+  {
+#ifdef PETSC_HAVE_MUMPS
+    /**
+     * had some trouble with the
+     * deallog printing to console
+     * the outcome of the solve function
+     * for every process. Brought
+     * down the depth level to zero
+     * to alleviate this
+     */
+    deallog.depth_console (0);
+    int ierr;
+
+    /**
+     * factorization matrix to be
+     * obtained from MUMPS
+     */
+    Mat F;
+
+    /**
+     * setting MUMPS integer control
+     * parameters ICNTL to be passed
+     * to MUMPS.  Setting
+     * entry 7 of MUMPS ICNTL array
+     * (of size 40) to a value of 2.
+     * This sets use of Approximate
+     * Minimum Fill (AMF)
+     */
+    PetscInt ival=2, icntl=7;
+    /**
+     * number of iterations to
+     * solution (should be 1)
+     * for a direct solver
+     */
+    PetscInt its;
+    /**
+     * norm of residual
+     */
+    PetscReal rnorm;
+
+    /**
+     * creating a solver object
+     * if this is necessary
+     */
+    if (solver_data.get() == 0)
+      {
+        solver_data.reset (new SolverDataMUMPS ());
+
+        /**
+         * creates the default KSP
+         * context and puts it in
+         * the location solver_data->ksp
+         */
+        ierr = KSPCreate (mpi_communicator, &solver_data->ksp);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * set the matrices involved.
+         * the last argument is irrelevant
+         * here, since we use the solver
+         * only once anyway
+         */
+        ierr = KSPSetOperators (solver_data->ksp, A, A,
+                                DIFFERENT_NONZERO_PATTERN);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * setting the solver type
+         */
+        set_solver_type (solver_data->ksp);
+
+        /**
+        * getting the associated
+        * preconditioner context
+        */
+        ierr = KSPGetPC (solver_data->ksp, & solver_data->pc);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * build PETSc PC for particular
+                 * PCLU or PCCHOLESKY preconditioner
+                 * depending on whether the
+                 * symmetric mode has been set
+                 */
+        if (symmetric_mode)
+          ierr = PCSetType (solver_data->pc, PCCHOLESKY);
+        else
+          ierr = PCSetType (solver_data->pc, PCLU);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * convergence monitor function
+         * that checks with the solver_control
+         * object for convergence
+         */
+        KSPSetConvergenceTest (solver_data->ksp, &convergence_test,
+                               reinterpret_cast<void *>(&solver_control),
+                               PETSC_NULL);
+
+        /**
+         * set the software that is to be
+         * used to perform the lu factorization
+         * here we start to see differences
+         * with the base class solve function
+         */
+        ierr = PCFactorSetMatSolverPackage (solver_data->pc, MATSOLVERMUMPS);
+        AssertThrow (ierr == 0, ExcPETScError (ierr));
+
+        /**
+         * set up the package to call
+         * for the factorization
+         */
+        ierr = PCFactorSetUpMatSolverPackage (solver_data->pc);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * get the factored matrix F from the
+         * preconditioner context.  This routine
+         * is valid only for LU, ILU, Cholesky,
+         * and imcomplete Cholesky
+         */
+        ierr = PCFactorGetMatrix(solver_data->pc, &F);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * Passing the control parameters
+         * to MUMPS
+         */
+        ierr = MatMumpsSetIcntl (F, icntl, ival);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * set the command line option prefix name
+         */
+        ierr = KSPSetOptionsPrefix(solver_data->ksp, prefix_name.c_str());
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+        /**
+         * set the command line options provided
+         * by the user to override the defaults
+         */
+        ierr = KSPSetFromOptions (solver_data->ksp);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+      }
+
+    /**
+     * solve the linear system
+     */
+    ierr = KSPSolve (solver_data->ksp, b, x);
+    AssertThrow (ierr == 0, ExcPETScError(ierr));
+
+    /**
+    * in case of failure
+    * throw exception
+    */
+    if (solver_control.last_check() != SolverControl::success)
+      throw SolverControl::NoConvergence (solver_control.last_step(),
+                                          solver_control.last_value());
+    else
+      {
+        /**
+         * obtain convergence
+         * information. obtain
+         * the number of iterations
+         * and residual norm
+         */
+        ierr = KSPGetIterationNumber (solver_data->ksp, &its);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+        ierr = KSPGetResidualNorm (solver_data->ksp, &rnorm);
+        AssertThrow (ierr == 0, ExcPETScError(ierr));
+      }
+
+#else  // PETSC_HAVE_MUMPS
+    Assert (false,
+            ExcMessage ("Your PETSc installation does not include a copy of "
+                        "MUMPS package necessary for this solver"));
+
+    // Cast to void to silence compiler
+    // warnings
+    (void) A;
+    (void) x;
+    (void) b;
+#endif
+
+  }
+
+  int SparseDirectMUMPS::convergence_test (KSP            /*ksp*/,
+#ifdef PETSC_USE_64BIT_INDICES
+                                           const PetscInt       iteration,
+#else
+                                           const int            iteration,
+#endif
+                                           const PetscReal      residual_norm,
+                                           KSPConvergedReason   *reason,
+                                           void                 *solver_control_x)
+  {
+    SolverControl &solver_control = *reinterpret_cast<SolverControl *>(solver_control_x);
+
+    const SolverControl::State state
+      = solver_control.check (iteration, residual_norm);
+
+    switch (state)
+      {
+      case ::dealii::SolverControl::iterate:
+        *reason = KSP_CONVERGED_ITERATING;
+        break;
+
+      case ::dealii::SolverControl::success:
+        *reason = static_cast<KSPConvergedReason>(1);
+        break;
+
+      case ::dealii::SolverControl::failure:
+        if (solver_control.last_step() > solver_control.max_steps())
+          *reason = KSP_DIVERGED_ITS;
+        else
+          *reason = KSP_DIVERGED_DTOL;
+        break;
+
+      default:
+        Assert (false, ExcNotImplemented());
+      }
+
+    return 0;
+  }
+
+  void
+  SparseDirectMUMPS::set_symmetric_mode(const bool flag)
+  {
+    symmetric_mode = flag;
+  }
+
+}
+
+DEAL_II_NAMESPACE_CLOSE
+
+#endif // DEAL_II_USE_PETSC

Modified: branches/s-wang/for_deal.II/source/lac/trilinos_sparse_matrix.cc
===================================================================
--- branches/s-wang/for_deal.II/source/lac/trilinos_sparse_matrix.cc	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/source/lac/trilinos_sparse_matrix.cc	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,5 +1,5 @@
 //---------------------------------------------------------------------------
-//    $Id: trilinos_sparse_matrix.cc 25809 2012-08-09 13:41:07Z heister $
+//    $Id: trilinos_sparse_matrix.cc 27628 2012-11-20 22:49:26Z heister $
 //    Version: $Name$
 //
 //    Copyright (C) 2008, 2009, 2010, 2011, 2012 by the deal.II authors
@@ -38,10 +38,10 @@
     SparseMatrix::const_iterator::Accessor::
     visit_present_row ()
     {
-                                  // if we are asked to visit the
-                                  // past-the-end line, then simply
-                                  // release all our caches and go on
-                                  // with life
+      // if we are asked to visit the
+      // past-the-end line, then simply
+      // release all our caches and go on
+      // with life
       if (this->a_row == matrix->m())
         {
           colnum_cache.reset ();
@@ -50,11 +50,11 @@
           return;
         }
 
-                                  // otherwise first flush Trilinos caches
+      // otherwise first flush Trilinos caches
       matrix->compress ();
 
-                                  // get a representation of the present
-                                  // row
+      // get a representation of the present
+      // row
       int ncols;
       int colnums = matrix->n();
       if (value_cache.get() == 0)
@@ -69,84 +69,84 @@
         }
 
       int ierr = matrix->trilinos_matrix().
-        ExtractGlobalRowCopy((int)this->a_row,
-                             colnums,
-                             ncols, &((*value_cache)[0]),
-                             reinterpret_cast<int*>(&((*colnum_cache)[0])));
+                 ExtractGlobalRowCopy((int)this->a_row,
+                                      colnums,
+                                      ncols, &((*value_cache)[0]),
+                                      reinterpret_cast<int *>(&((*colnum_cache)[0])));
       value_cache->resize (ncols);
       colnum_cache->resize (ncols);
       AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-                                  // copy it into our caches if the
-                                  // line isn't empty. if it is, then
-                                  // we've done something wrong, since
-                                  // we shouldn't have initialized an
-                                  // iterator for an empty line (what
-                                  // would it point to?)
+      // copy it into our caches if the
+      // line isn't empty. if it is, then
+      // we've done something wrong, since
+      // we shouldn't have initialized an
+      // iterator for an empty line (what
+      // would it point to?)
     }
   }
 
 
-                                  // The constructor is actually the
-                                  // only point where we have to check
-                                  // whether we build a serial or a
-                                  // parallel Trilinos matrix.
-                                  // Actually, it does not even matter
-                                  // how many threads there are, but
-                                  // only if we use an MPI compiler or
-                                  // a standard compiler. So, even one
-                                  // thread on a configuration with
-                                  // MPI will still get a parallel
-                                  // interface.
+  // The constructor is actually the
+  // only point where we have to check
+  // whether we build a serial or a
+  // parallel Trilinos matrix.
+  // Actually, it does not even matter
+  // how many threads there are, but
+  // only if we use an MPI compiler or
+  // a standard compiler. So, even one
+  // thread on a configuration with
+  // MPI will still get a parallel
+  // interface.
   SparseMatrix::SparseMatrix ()
-                  :
-                  column_space_map (new Epetra_Map (0, 0,
-                                                     Utilities::Trilinos::comm_self())),
-                  matrix (new Epetra_FECrsMatrix(View, *column_space_map,
-                                                  *column_space_map, 0)),
-                  last_action (Zero),
-                  compressed (true)
+    :
+    column_space_map (new Epetra_Map (0, 0,
+                                      Utilities::Trilinos::comm_self())),
+    matrix (new Epetra_FECrsMatrix(View, *column_space_map,
+                                   *column_space_map, 0)),
+    last_action (Zero),
+    compressed (true)
   {
     matrix->FillComplete();
   }
 
 
 
-  SparseMatrix::SparseMatrix (const Epetra_Map  &input_map,
+  SparseMatrix::SparseMatrix (const Epetra_Map &input_map,
                               const unsigned int n_max_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map (input_map)),
-                  matrix (new Epetra_FECrsMatrix(Copy, *column_space_map,
-                                                  int(n_max_entries_per_row), false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map (input_map)),
+    matrix (new Epetra_FECrsMatrix(Copy, *column_space_map,
+                                   int(n_max_entries_per_row), false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
 
   SparseMatrix::SparseMatrix (const Epetra_Map                &input_map,
                               const std::vector<unsigned int> &n_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map (input_map)),
-                  matrix (new Epetra_FECrsMatrix
-                          (Copy, *column_space_map,
-                           (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
-                           false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map (input_map)),
+    matrix (new Epetra_FECrsMatrix
+            (Copy, *column_space_map,
+             (int *)const_cast<unsigned int *>(&(n_entries_per_row[0])),
+             false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
 
-  SparseMatrix::SparseMatrix (const Epetra_Map  &input_row_map,
-                              const Epetra_Map  &input_col_map,
+  SparseMatrix::SparseMatrix (const Epetra_Map &input_row_map,
+                              const Epetra_Map &input_col_map,
                               const unsigned int n_max_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map (input_col_map)),
-                  matrix (new Epetra_FECrsMatrix(Copy, input_row_map,
-                                                 int(n_max_entries_per_row), false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map (input_col_map)),
+    matrix (new Epetra_FECrsMatrix(Copy, input_row_map,
+                                   int(n_max_entries_per_row), false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
@@ -154,13 +154,13 @@
   SparseMatrix::SparseMatrix (const Epetra_Map                &input_row_map,
                               const Epetra_Map                &input_col_map,
                               const std::vector<unsigned int> &n_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map (input_col_map)),
-                  matrix (new Epetra_FECrsMatrix(Copy, input_row_map,
-                      (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
-                                                 false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map (input_col_map)),
+    matrix (new Epetra_FECrsMatrix(Copy, input_row_map,
+                                   (int *)const_cast<unsigned int *>(&(n_entries_per_row[0])),
+                                   false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
@@ -168,26 +168,26 @@
   SparseMatrix::SparseMatrix (const unsigned int m,
                               const unsigned int n,
                               const unsigned int n_max_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map (n, 0,
-                                                    Utilities::Trilinos::comm_self())),
+    :
+    column_space_map (new Epetra_Map (static_cast<int>(n), 0,
+                                      Utilities::Trilinos::comm_self())),
 
-                                   // on one processor only, we know how the
-                                   // columns of the matrix will be
-                                   // distributed (everything on one
-                                   // processor), so we can hand in this
-                                   // information to the constructor. we
-                                   // can't do so in parallel, where the
-                                   // information from columns is only
-                                   // available when entries have been added
-                  matrix (new Epetra_FECrsMatrix(Copy,
-                                                 Epetra_Map (m, 0,
-                                                             Utilities::Trilinos::comm_self()),
-                                                 *column_space_map,
-                                                 n_max_entries_per_row,
-                                                 false)),
-                  last_action (Zero),
-                  compressed (false)
+    // on one processor only, we know how the
+    // columns of the matrix will be
+    // distributed (everything on one
+    // processor), so we can hand in this
+    // information to the constructor. we
+    // can't do so in parallel, where the
+    // information from columns is only
+    // available when entries have been added
+    matrix (new Epetra_FECrsMatrix(Copy,
+                                   Epetra_Map (static_cast<int>(m), 0,
+                                               Utilities::Trilinos::comm_self()),
+                                   *column_space_map,
+                                   n_max_entries_per_row,
+                                   false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
@@ -195,17 +195,17 @@
   SparseMatrix::SparseMatrix (const unsigned int               m,
                               const unsigned int               n,
                               const std::vector<unsigned int> &n_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map (n, 0,
-                                                    Utilities::Trilinos::comm_self())),
-                  matrix (new Epetra_FECrsMatrix(Copy,
-                                                 Epetra_Map (m, 0,
-                                                             Utilities::Trilinos::comm_self()),
-                                                 *column_space_map,
-                           (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
-                                                 false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map (static_cast<int>(n), 0,
+                                      Utilities::Trilinos::comm_self())),
+    matrix (new Epetra_FECrsMatrix(Copy,
+                                   Epetra_Map (static_cast<int>(m), 0,
+                                               Utilities::Trilinos::comm_self()),
+                                   *column_space_map,
+                                   (int *)const_cast<unsigned int *>(&(n_entries_per_row[0])),
+                                   false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
@@ -213,15 +213,15 @@
   SparseMatrix::SparseMatrix (const IndexSet     &parallel_partitioning,
                               const MPI_Comm     &communicator,
                               const unsigned int n_max_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map(parallel_partitioning.
-                                                   make_trilinos_map(communicator, false))),
-                  matrix (new Epetra_FECrsMatrix(Copy,
-                                                 *column_space_map,
-                                                 n_max_entries_per_row,
-                                                 false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map(parallel_partitioning.
+                                     make_trilinos_map(communicator, false))),
+    matrix (new Epetra_FECrsMatrix(Copy,
+                                   *column_space_map,
+                                   n_max_entries_per_row,
+                                   false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
@@ -229,15 +229,15 @@
   SparseMatrix::SparseMatrix (const IndexSet     &parallel_partitioning,
                               const MPI_Comm     &communicator,
                               const std::vector<unsigned int> &n_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map(parallel_partitioning.
-                                                   make_trilinos_map(communicator, false))),
-                  matrix (new Epetra_FECrsMatrix(Copy,
-                                                 *column_space_map,
-                           (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
-                                                 false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map(parallel_partitioning.
+                                     make_trilinos_map(communicator, false))),
+    matrix (new Epetra_FECrsMatrix(Copy,
+                                   *column_space_map,
+                                   (int *)const_cast<unsigned int *>(&(n_entries_per_row[0])),
+                                   false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
@@ -246,16 +246,16 @@
                               const IndexSet     &col_parallel_partitioning,
                               const MPI_Comm     &communicator,
                               const unsigned int n_max_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map(col_parallel_partitioning.
-                                                   make_trilinos_map(communicator, false))),
-                  matrix (new Epetra_FECrsMatrix(Copy,
-                                                 row_parallel_partitioning.
-                                                 make_trilinos_map(communicator, false),
-                                                 n_max_entries_per_row,
-                                                 false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map(col_parallel_partitioning.
+                                     make_trilinos_map(communicator, false))),
+    matrix (new Epetra_FECrsMatrix(Copy,
+                                   row_parallel_partitioning.
+                                   make_trilinos_map(communicator, false),
+                                   n_max_entries_per_row,
+                                   false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
@@ -264,28 +264,28 @@
                               const IndexSet     &col_parallel_partitioning,
                               const MPI_Comm     &communicator,
                               const std::vector<unsigned int> &n_entries_per_row)
-                  :
-                  column_space_map (new Epetra_Map(col_parallel_partitioning.
-                                                   make_trilinos_map(communicator, false))),
-                  matrix (new Epetra_FECrsMatrix(Copy,
-                                                 row_parallel_partitioning.
-                                                 make_trilinos_map(communicator, false),
-                           (int*)const_cast<unsigned int*>(&(n_entries_per_row[0])),
-                                                 false)),
-                  last_action (Zero),
-                  compressed (false)
+    :
+    column_space_map (new Epetra_Map(col_parallel_partitioning.
+                                     make_trilinos_map(communicator, false))),
+    matrix (new Epetra_FECrsMatrix(Copy,
+                                   row_parallel_partitioning.
+                                   make_trilinos_map(communicator, false),
+                                   (int *)const_cast<unsigned int *>(&(n_entries_per_row[0])),
+                                   false)),
+    last_action (Zero),
+    compressed (false)
   {}
 
 
 
   SparseMatrix::SparseMatrix (const SparsityPattern &sparsity_pattern)
-                  :
-                  column_space_map (new Epetra_Map (sparsity_pattern.domain_partitioner())),
-                  matrix (new Epetra_FECrsMatrix(Copy,
-                                                 sparsity_pattern.trilinos_sparsity_pattern(),
-                                                 false)),
-                  last_action (Zero),
-                  compressed (true)
+    :
+    column_space_map (new Epetra_Map (sparsity_pattern.domain_partitioner())),
+    matrix (new Epetra_FECrsMatrix(Copy,
+                                   sparsity_pattern.trilinos_sparsity_pattern(),
+                                   false)),
+    last_action (Zero),
+    compressed (true)
   {
     Assert(sparsity_pattern.trilinos_sparsity_pattern().Filled() == true,
            ExcMessage("The Trilinos sparsity pattern has not been compressed."));
@@ -295,12 +295,12 @@
 
 
   SparseMatrix::SparseMatrix (const SparseMatrix &input_matrix)
-                  :
-                  Subscriptor(),
-                  column_space_map (new Epetra_Map (input_matrix.domain_partitioner())),
-                  matrix (new Epetra_FECrsMatrix(*input_matrix.matrix)),
-                  last_action (Zero),
-                  compressed (true)
+    :
+    Subscriptor(),
+    column_space_map (new Epetra_Map (input_matrix.domain_partitioner())),
+    matrix (new Epetra_FECrsMatrix(*input_matrix.matrix)),
+    last_action (Zero),
+    compressed (true)
   {}
 
 
@@ -314,17 +314,17 @@
   SparseMatrix::copy_from (const SparseMatrix &m)
   {
 
-                                   // check whether we need to update the
-                                   // partitioner or can just copy the data:
-                                   // in case we have the same distribution,
-                                   // we can just copy the data.
+    // check whether we need to update the
+    // partitioner or can just copy the data:
+    // in case we have the same distribution,
+    // we can just copy the data.
     if (local_range() == m.local_range())
       *matrix = *m.matrix;
     else
       {
         column_space_map.reset (new Epetra_Map (m.domain_partitioner()));
 
-                                // release memory before reallocation
+        // release memory before reallocation
         matrix.reset ();
         temp_vector.clear ();
         matrix.reset (new Epetra_FECrsMatrix(*m.matrix));
@@ -339,10 +339,10 @@
   void
   SparseMatrix::reinit (const SparsityType &sparsity_pattern)
   {
-    const Epetra_Map rows (sparsity_pattern.n_rows(),
+    const Epetra_Map rows (static_cast<int>(sparsity_pattern.n_rows()),
                            0,
                            Utilities::Trilinos::comm_self());
-    const Epetra_Map columns (sparsity_pattern.n_cols(),
+    const Epetra_Map columns (static_cast<int>(sparsity_pattern.n_cols()),
                               0,
                               Utilities::Trilinos::comm_self());
 
@@ -354,7 +354,7 @@
   template <typename SparsityType>
   void
   SparseMatrix::reinit (const Epetra_Map    &input_map,
-                        const SparsityType  &sparsity_pattern,
+                        const SparsityType &sparsity_pattern,
                         const bool           exchange_data)
   {
     reinit (input_map, input_map, sparsity_pattern, exchange_data);
@@ -366,21 +366,21 @@
   void
   SparseMatrix::reinit (const Epetra_Map    &input_row_map,
                         const Epetra_Map    &input_col_map,
-                        const SparsityType  &sparsity_pattern,
+                        const SparsityType &sparsity_pattern,
                         const bool           exchange_data)
   {
-                                // release memory before reallocation
+    // release memory before reallocation
     temp_vector.clear();
     matrix.reset();
 
-                                // if we want to exchange data, build
-                                // a usual Trilinos sparsity pattern
-                                // and let that handle the
-                                // exchange. otherwise, manually
-                                // create a CrsGraph, which consumes
-                                // considerably less memory because it
-                                // can set correct number of indices
-                                // right from the start
+    // if we want to exchange data, build
+    // a usual Trilinos sparsity pattern
+    // and let that handle the
+    // exchange. otherwise, manually
+    // create a CrsGraph, which consumes
+    // considerably less memory because it
+    // can set correct number of indices
+    // right from the start
     if (exchange_data)
       {
         SparsityPattern trilinos_sparsity;
@@ -403,35 +403,35 @@
     column_space_map.reset (new Epetra_Map (input_col_map));
 
     const unsigned int first_row = input_row_map.MinMyGID(),
-      last_row = input_row_map.MaxMyGID()+1;
+                       last_row = input_row_map.MaxMyGID()+1;
     std::vector<int> n_entries_per_row(last_row-first_row);
 
     for (unsigned int row=first_row; row<last_row; ++row)
       n_entries_per_row[row-first_row] = sparsity_pattern.row_length(row);
 
-                                  // The deal.II notation of a Sparsity
-                                  // pattern corresponds to the Epetra
-                                  // concept of a Graph. Hence, we generate
-                                  // a graph by copying the sparsity pattern
-                                  // into it, and then build up the matrix
-                                  // from the graph. This is considerable
-                                  // faster than directly filling elements
-                                  // into the matrix. Moreover, it consumes
-                                  // less memory, since the internal
-                                  // reordering is done on ints only, and we
-                                  // can leave the doubles aside.
+    // The deal.II notation of a Sparsity
+    // pattern corresponds to the Epetra
+    // concept of a Graph. Hence, we generate
+    // a graph by copying the sparsity pattern
+    // into it, and then build up the matrix
+    // from the graph. This is considerable
+    // faster than directly filling elements
+    // into the matrix. Moreover, it consumes
+    // less memory, since the internal
+    // reordering is done on ints only, and we
+    // can leave the doubles aside.
 
-                                   // for more than one processor, need to
-                                   // specify only row map first and let the
-                                   // matrix entries decide about the column
-                                   // map (which says which columns are
-                                   // present in the matrix, not to be
-                                   // confused with the col_map that tells
-                                   // how the domain dofs of the matrix will
-                                   // be distributed). for only one
-                                   // processor, we can directly assign the
-                                   // columns as well. Compare this with bug
-                                   // # 4123 in the Sandia Bugzilla.
+    // for more than one processor, need to
+    // specify only row map first and let the
+    // matrix entries decide about the column
+    // map (which says which columns are
+    // present in the matrix, not to be
+    // confused with the col_map that tells
+    // how the domain dofs of the matrix will
+    // be distributed). for only one
+    // processor, we can directly assign the
+    // columns as well. Compare this with bug
+    // # 4123 in the Sandia Bugzilla.
     std_cxx1x::shared_ptr<Epetra_CrsGraph> graph;
     if (input_row_map.Comm().NumProc() > 1)
       graph.reset (new Epetra_CrsGraph (Copy, input_row_map,
@@ -440,13 +440,13 @@
       graph.reset (new Epetra_CrsGraph (Copy, input_row_map, input_col_map,
                                         &n_entries_per_row[0], true));
 
-                                  // This functions assumes that the
-                                  // sparsity pattern sits on all processors
-                                  // (completely). The parallel version uses
-                                  // an Epetra graph that is already
-                                  // distributed.
+    // This functions assumes that the
+    // sparsity pattern sits on all processors
+    // (completely). The parallel version uses
+    // an Epetra graph that is already
+    // distributed.
 
-                                  // now insert the indices
+    // now insert the indices
     std::vector<int>   row_indices;
 
     for (unsigned int row=first_row; row<last_row; ++row)
@@ -458,7 +458,7 @@
         row_indices.resize (row_length, -1);
 
         typename SparsityType::row_iterator col_num = sparsity_pattern.row_begin (row),
-          row_end = sparsity_pattern.row_end(row);
+                                            row_end = sparsity_pattern.row_end(row);
         for (unsigned int col = 0; col_num != row_end; ++col_num, ++col)
           row_indices[col] = *col_num;
 
@@ -466,24 +466,24 @@
                                                      &row_indices[0]);
       }
 
-                                  // Eventually, optimize the graph
-                                  // structure (sort indices, make memory
-                                  // contiguous, etc).
+    // Eventually, optimize the graph
+    // structure (sort indices, make memory
+    // contiguous, etc).
     graph->FillComplete(input_col_map, input_row_map);
     graph->OptimizeStorage();
 
-                                   // check whether we got the number of
-                                   // columns right.
+    // check whether we got the number of
+    // columns right.
     AssertDimension (sparsity_pattern.n_cols(),
                      static_cast<unsigned int>(graph->NumGlobalCols()));
 
-                                  // And now finally generate the matrix.
+    // And now finally generate the matrix.
     matrix.reset (new Epetra_FECrsMatrix(Copy, *graph, false));
     last_action = Zero;
 
-                                  // In the end, the matrix needs to
-                                  // be compressed in order to be
-                                  // really ready.
+    // In the end, the matrix needs to
+    // be compressed in order to be
+    // really ready.
     compress();
   }
 
@@ -495,8 +495,8 @@
     temp_vector.clear ();
     matrix.reset ();
 
-                                   // reinit with a (parallel) Trilinos
-                                   // sparsity pattern.
+    // reinit with a (parallel) Trilinos
+    // sparsity pattern.
     column_space_map.reset (new Epetra_Map
                             (sparsity_pattern.domain_partitioner()));
     matrix.reset (new Epetra_FECrsMatrix
@@ -527,10 +527,10 @@
                         const bool                            copy_values,
                         const ::dealii::SparsityPattern      *use_this_sparsity)
   {
-    const Epetra_Map rows (dealii_sparse_matrix.m(),
+    const Epetra_Map rows (static_cast<int>(dealii_sparse_matrix.m()),
                            0,
                            Utilities::Trilinos::comm_self());
-    const Epetra_Map columns (dealii_sparse_matrix.n(),
+    const Epetra_Map columns (static_cast<int>(dealii_sparse_matrix.n()),
                               0,
                               Utilities::Trilinos::comm_self());
     reinit (rows, columns, dealii_sparse_matrix, drop_tolerance,
@@ -564,8 +564,8 @@
   {
     if (copy_values == false)
       {
-                                   // in case we do not copy values, just
-                                   // call the other function.
+        // in case we do not copy values, just
+        // call the other function.
         if (use_this_sparsity == 0)
           reinit (input_row_map, input_col_map,
                   dealii_sparse_matrix.get_sparsity_pattern());
@@ -584,7 +584,7 @@
             ExcDimensionMismatch (input_col_map.NumGlobalElements(),
                                   dealii_sparse_matrix.n()));
 
-    const ::dealii::SparsityPattern & sparsity_pattern =
+    const ::dealii::SparsityPattern &sparsity_pattern =
       (use_this_sparsity!=0)? *use_this_sparsity :
       dealii_sparse_matrix.get_sparsity_pattern();
 
@@ -598,21 +598,21 @@
       reinit (trilinos_sparsity);
     }
 
-  set_matrix_values:
-                                // fill the values. the same as above: go
-                                // through all rows of the matrix, and then
-                                // all columns. since the sparsity patterns of
-                                // the input matrix and the specified sparsity
-                                // pattern might be different, need to go
-                                // through the row for both these sparsity
-                                // structures simultaneously in order to
-                                // really set the correct values.
-    const std::size_t * const in_rowstart_indices
+set_matrix_values:
+    // fill the values. the same as above: go
+    // through all rows of the matrix, and then
+    // all columns. since the sparsity patterns of
+    // the input matrix and the specified sparsity
+    // pattern might be different, need to go
+    // through the row for both these sparsity
+    // structures simultaneously in order to
+    // really set the correct values.
+    const std::size_t *const in_rowstart_indices
       = dealii_sparse_matrix.get_sparsity_pattern().get_rowstart_indices();
-    const unsigned int * const in_cols
+    const unsigned int *const in_cols
       = dealii_sparse_matrix.get_sparsity_pattern().get_column_numbers();
-    const unsigned int * cols = sparsity_pattern.get_column_numbers();
-    const std::size_t * rowstart_indices =
+    const unsigned int *cols = sparsity_pattern.get_column_numbers();
+    const std::size_t *rowstart_indices =
       sparsity_pattern.get_rowstart_indices();
 
     unsigned int maximum_row_length = matrix->MaxNumEntries();
@@ -621,7 +621,7 @@
     std::size_t in_index, index;
 
     for (unsigned int row=0; row<n_rows; ++row)
-      if (input_row_map.MyGID(row))
+      if (input_row_map.MyGID(static_cast<int>(row)))
         {
           index = rowstart_indices[row];
           in_index = in_rowstart_indices[row];
@@ -650,7 +650,7 @@
               ++index;
               ++in_index;
             }
-          set (row, col, reinterpret_cast<unsigned int*>(&row_indices[0]),
+          set (row, col, reinterpret_cast<unsigned int *>(&row_indices[0]),
                &values[0], false);
         }
 
@@ -678,10 +678,10 @@
 
     if (copy_values == true)
       {
-                                // point to the first data entry in the two
-                                // matrices and copy the content
-        const TrilinosScalar * in_values = input_matrix[0];
-        TrilinosScalar * values = (*matrix)[0];
+        // point to the first data entry in the two
+        // matrices and copy the content
+        const TrilinosScalar *in_values = input_matrix[0];
+        TrilinosScalar *values = (*matrix)[0];
         const unsigned int my_nonzeros = input_matrix.NumMyNonzeros();
         std::memcpy (&values[0], &in_values[0],
                      my_nonzeros*sizeof (TrilinosScalar));
@@ -695,9 +695,9 @@
   void
   SparseMatrix::clear ()
   {
-                                  // When we clear the matrix, reset
-                                  // the pointer and generate an
-                                  // empty matrix.
+    // When we clear the matrix, reset
+    // the pointer and generate an
+    // empty matrix.
     column_space_map.reset (new Epetra_Map (0, 0,
                                             Utilities::Trilinos::comm_self()));
     temp_vector.clear();
@@ -716,9 +716,9 @@
   {
     Assert (matrix->Filled()==true, ExcMatrixNotCompressed());
 
-                                  // Only do this on the rows owned
-                                  // locally on this processor.
-    int local_row = matrix->LRID(row);
+    // Only do this on the rows owned
+    // locally on this processor.
+    int local_row = matrix->LRID(static_cast<int>(row));
     if (local_row >= 0)
       {
         TrilinosScalar *values;
@@ -730,7 +730,7 @@
         Assert (ierr == 0,
                 ExcTrilinosError(ierr));
 
-        int* diag_find = std::find(col_indices,col_indices+num_entries,
+        int *diag_find = std::find(col_indices,col_indices+num_entries,
                                    local_row);
         int diag_index = (int)(diag_find - col_indices);
 
@@ -754,11 +754,11 @@
     for (unsigned int row=0; row<rows.size(); ++row)
       clear_row(rows[row], new_diag_value);
 
-                                        // This function needs to be called
-                                        // on all processors. We change some
-                                        // data, so we need to flush the
-                                        // buffers to make sure that the
-                                        // right data is used.
+    // This function needs to be called
+    // on all processors. We change some
+    // data, so we need to flush the
+    // buffers to make sure that the
+    // right data is used.
     compress();
   }
 
@@ -768,17 +768,17 @@
   SparseMatrix::operator() (const unsigned int i,
                             const unsigned int j) const
   {
-                                      // Extract local indices in
-                                      // the matrix.
-    int trilinos_i = matrix->LRID(i), trilinos_j = matrix->LCID(j);
+    // Extract local indices in
+    // the matrix.
+    int trilinos_i = matrix->LRID(static_cast<int>(i)), trilinos_j = matrix->LCID(static_cast<int>(j));
     TrilinosScalar value = 0.;
 
-                                      // If the data is not on the
-                                      // present processor, we throw
-                                      // an exception. This is one of
-                                      // the two tiny differences to
-                                      // the el(i,j) call, which does
-                                      // not throw any assertions.
+    // If the data is not on the
+    // present processor, we throw
+    // an exception. This is one of
+    // the two tiny differences to
+    // the el(i,j) call, which does
+    // not throw any assertions.
     if (trilinos_i == -1)
       {
         Assert (false, ExcAccessToNonLocalElement(i, j, local_range().first,
@@ -786,21 +786,21 @@
       }
     else
       {
-                                      // Check whether the matrix has
-                                      // already been transformed to local
-                                      // indices.
+        // Check whether the matrix has
+        // already been transformed to local
+        // indices.
         Assert (matrix->Filled(), ExcMatrixNotCompressed());
 
-                                      // Prepare pointers for extraction
-                                      // of a view of the row.
+        // Prepare pointers for extraction
+        // of a view of the row.
         int nnz_present = matrix->NumMyEntries(trilinos_i);
         int nnz_extracted;
         int *col_indices;
         TrilinosScalar *values;
 
-                                      // Generate the view and make
-                                      // sure that we have not generated
-                                      // an error.
+        // Generate the view and make
+        // sure that we have not generated
+        // an error.
         int ierr = matrix->ExtractMyRowView(trilinos_i, nnz_extracted,
                                             values, col_indices);
         Assert (ierr==0, ExcTrilinosError(ierr));
@@ -808,23 +808,23 @@
         Assert (nnz_present == nnz_extracted,
                 ExcDimensionMismatch(nnz_present, nnz_extracted));
 
-                                      // Search the index where we
-                                      // look for the value, and then
-                                      // finally get it.
+        // Search the index where we
+        // look for the value, and then
+        // finally get it.
 
-        int* el_find = std::find(col_indices, col_indices + nnz_present,
+        int *el_find = std::find(col_indices, col_indices + nnz_present,
                                  trilinos_j);
 
         int local_col_index = (int)(el_find - col_indices);
 
-                                        // This is actually the only
-                                        // difference to the el(i,j)
-                                        // function, which means that
-                                        // we throw an exception in
-                                        // this case instead of just
-                                        // returning zero for an
-                                        // element that is not present
-                                        // in the sparsity pattern.
+        // This is actually the only
+        // difference to the el(i,j)
+        // function, which means that
+        // we throw an exception in
+        // this case instead of just
+        // returning zero for an
+        // element that is not present
+        // in the sparsity pattern.
         if (local_col_index == nnz_present)
           {
             Assert (false, ExcInvalidIndex (i,j));
@@ -842,65 +842,65 @@
   SparseMatrix::el (const unsigned int i,
                     const unsigned int j) const
   {
-                                      // Extract local indices in
-                                      // the matrix.
-    int trilinos_i = matrix->LRID(i), trilinos_j = matrix->LCID(j);
+    // Extract local indices in
+    // the matrix.
+    int trilinos_i = matrix->LRID(static_cast<int>(i)), trilinos_j = matrix->LCID(static_cast<int>(j));
     TrilinosScalar value = 0.;
 
-                                      // If the data is not on the
-                                      // present processor, we can't
-                                      // continue. Just print out zero
-                                      // as discussed in the
-                                      // documentation of this
-                                      // function. if you want error
-                                      // checking, use operator().
+    // If the data is not on the
+    // present processor, we can't
+    // continue. Just print out zero
+    // as discussed in the
+    // documentation of this
+    // function. if you want error
+    // checking, use operator().
     if ((trilinos_i == -1 ) || (trilinos_j == -1))
       return 0.;
     else
-    {
-                                      // Check whether the matrix
-                                      // already is transformed to
-                                      // local indices.
-      Assert (matrix->Filled(), ExcMatrixNotCompressed());
+      {
+        // Check whether the matrix
+        // already is transformed to
+        // local indices.
+        Assert (matrix->Filled(), ExcMatrixNotCompressed());
 
-                                      // Prepare pointers for extraction
-                                      // of a view of the row.
-      int nnz_present = matrix->NumMyEntries(trilinos_i);
-      int nnz_extracted;
-      int *col_indices;
-      TrilinosScalar *values;
+        // Prepare pointers for extraction
+        // of a view of the row.
+        int nnz_present = matrix->NumMyEntries(trilinos_i);
+        int nnz_extracted;
+        int *col_indices;
+        TrilinosScalar *values;
 
-                                      // Generate the view and make
-                                      // sure that we have not generated
-                                      // an error.
-      int ierr = matrix->ExtractMyRowView(trilinos_i, nnz_extracted,
-                                          values, col_indices);
-      Assert (ierr==0, ExcTrilinosError(ierr));
+        // Generate the view and make
+        // sure that we have not generated
+        // an error.
+        int ierr = matrix->ExtractMyRowView(trilinos_i, nnz_extracted,
+                                            values, col_indices);
+        Assert (ierr==0, ExcTrilinosError(ierr));
 
-      Assert (nnz_present == nnz_extracted,
-              ExcDimensionMismatch(nnz_present, nnz_extracted));
+        Assert (nnz_present == nnz_extracted,
+                ExcDimensionMismatch(nnz_present, nnz_extracted));
 
-                                      // Search the index where we
-                                      // look for the value, and then
-                                      // finally get it.
-      int* el_find = std::find(col_indices, col_indices + nnz_present,
-                               trilinos_j);
+        // Search the index where we
+        // look for the value, and then
+        // finally get it.
+        int *el_find = std::find(col_indices, col_indices + nnz_present,
+                                 trilinos_j);
 
-      int local_col_index = (int)(el_find - col_indices);
+        int local_col_index = (int)(el_find - col_indices);
 
 
-                                        // This is actually the only
-                                        // difference to the () function
-                                        // querying (i,j), where we throw an
-                                        // exception instead of just
-                                        // returning zero for an element
-                                        // that is not present in the
-                                        // sparsity pattern.
-      if (local_col_index == nnz_present)
-        value = 0;
-      else
-        value = values[local_col_index];
-    }
+        // This is actually the only
+        // difference to the () function
+        // querying (i,j), where we throw an
+        // exception instead of just
+        // returning zero for an element
+        // that is not present in the
+        // sparsity pattern.
+        if (local_col_index == nnz_present)
+          value = 0;
+        else
+          value = values[local_col_index];
+      }
 
     return value;
   }
@@ -911,19 +911,19 @@
   SparseMatrix::diag_element (const unsigned int i) const
   {
     Assert (m() == n(), ExcNotQuadratic());
-    
+
 #ifdef DEBUG
-				     // use operator() in debug mode because
-				     // it checks if this is a valid element
-				     // (in parallel)
+    // use operator() in debug mode because
+    // it checks if this is a valid element
+    // (in parallel)
     return operator()(i,i);
-#else    
-                                  // Trilinos doesn't seem to have a
-                                  // more efficient way to access the
-                                  // diagonal than by just using the
-                                  // standard el(i,j) function.
+#else
+    // Trilinos doesn't seem to have a
+    // more efficient way to access the
+    // diagonal than by just using the
+    // standard el(i,j) function.
     return el(i,i);
-#endif    
+#endif
   }
 
 
@@ -933,14 +933,14 @@
   {
     Assert (row < m(), ExcInternalError());
 
-                                  // get a representation of the
-                                  // present row
+    // get a representation of the
+    // present row
     int ncols = -1;
-    int local_row = matrix->LRID(row);
+    int local_row = matrix->LRID(static_cast<int>(row));
 
-                                  // on the processor who owns this
-                                  // row, we'll have a non-negative
-                                  // value.
+    // on the processor who owns this
+    // row, we'll have a non-negative
+    // value.
     if (local_row >= 0)
       {
         int ierr = matrix->NumMyRowEntries (local_row, ncols);
@@ -978,16 +978,16 @@
 
       result.clear();
 
-                                   // create a suitable operator B: in case
-                                   // we do not use a vector, all we need to
-                                   // do is to set the pointer. Otherwise,
-                                   // we insert the data from B, but
-                                   // multiply each row with the respective
-                                   // vector element.
+      // create a suitable operator B: in case
+      // we do not use a vector, all we need to
+      // do is to set the pointer. Otherwise,
+      // we insert the data from B, but
+      // multiply each row with the respective
+      // vector element.
       Teuchos::RCP<Epetra_CrsMatrix> mod_B;
       if (use_vector == false)
         {
-          mod_B = Teuchos::rcp(const_cast<Epetra_CrsMatrix*>
+          mod_B = Teuchos::rcp(const_cast<Epetra_CrsMatrix *>
                                (&inputright.trilinos_matrix()),
                                false);
         }
@@ -1015,15 +1015,15 @@
             }
         }
 
-                                   // use ML built-in method for performing
-                                   // the matrix-matrix product.
-                                   // create ML operators on top of the
-                                   // Epetra matrices. if we use a
-                                   // transposed matrix, let ML know it
-      ML_Comm* comm;
+      // use ML built-in method for performing
+      // the matrix-matrix product.
+      // create ML operators on top of the
+      // Epetra matrices. if we use a
+      // transposed matrix, let ML know it
+      ML_Comm *comm;
       ML_Comm_Create(&comm);
 #ifdef ML_MPI
-      const Epetra_MpiComm *epcomm = dynamic_cast<const Epetra_MpiComm*>(&(inputleft.trilinos_matrix().Comm()));
+      const Epetra_MpiComm *epcomm = dynamic_cast<const Epetra_MpiComm *>(&(inputleft.trilinos_matrix().Comm()));
       // Get the MPI communicator, as it may not be MPI_COMM_W0RLD, and update the ML comm object
       if (epcomm) ML_Comm_Set_UsrComm(comm,epcomm->Comm());
 #endif
@@ -1034,11 +1034,11 @@
 
       if (transpose_left == false)
         ML_Operator_WrapEpetraCrsMatrix
-          (const_cast<Epetra_CrsMatrix*>(&inputleft.trilinos_matrix()),A_,
-           false);
+        (const_cast<Epetra_CrsMatrix *>(&inputleft.trilinos_matrix()),A_,
+         false);
       else
         {
-                                // create transposed matrix
+          // create transposed matrix
           SparsityPattern sparsity_transposed (inputleft.domain_partitioner(),
                                                inputleft.range_partitioner());
           Assert (inputleft.domain_partitioner().LinearMap() == true,
@@ -1060,7 +1060,7 @@
           for (unsigned int i=0; i<inputleft.local_size(); ++i)
             {
               int num_entries, * indices;
-              double * values;
+              double *values;
               inputleft.trilinos_matrix().ExtractMyRowView(i, num_entries,
                                                            values, indices);
               Assert (num_entries >= 0, ExcInternalError());
@@ -1071,19 +1071,19 @@
             }
           transposed_mat.compress();
           ML_Operator_WrapEpetraCrsMatrix
-            (const_cast<Epetra_CrsMatrix*>(&transposed_mat.trilinos_matrix()),
-             A_,false);
+          (const_cast<Epetra_CrsMatrix *>(&transposed_mat.trilinos_matrix()),
+           A_,false);
         }
       ML_Operator_WrapEpetraCrsMatrix(mod_B.get(),B_,false);
 
-                                   // We implement the multiplication by
-                                   // hand in a similar way as is done in
-                                   // ml/src/Operator/ml_rap.c for a triple
-                                   // matrix product. This means that the
-                                   // code is very similar to the one found
-                                   // in ml/src/Operator/ml_rap.c
+      // We implement the multiplication by
+      // hand in a similar way as is done in
+      // ml/src/Operator/ml_rap.c for a triple
+      // matrix product. This means that the
+      // code is very similar to the one found
+      // in ml/src/Operator/ml_rap.c
 
-                                   // import data if necessary
+      // import data if necessary
       ML_Operator *Btmp, *Ctmp, *Ctmp2, *tptr;
       ML_CommInfoOP *getrow_comm;
       int max_per_proc;
@@ -1102,11 +1102,11 @@
         ML_exchange_rows( B_, &Btmp, A_->getrow->pre_comm);
       else Btmp = B_;
 
-                                   // perform matrix-matrix product
+      // perform matrix-matrix product
       ML_matmat_mult(A_, Btmp , &Ctmp);
 
-                                   // release temporary structures we needed
-                                   // for multiplication
+      // release temporary structures we needed
+      // for multiplication
       ML_free(B_->getrow->loc_glob_map);
       B_->getrow->loc_glob_map = NULL;
       B_->getrow->use_loc_glob_map = ML_NO;
@@ -1120,7 +1120,7 @@
           ML_Operator_Destroy(&Btmp);
         }
 
-                                   // make correct data structures
+      // make correct data structures
       if (A_->getrow->post_comm != NULL)
         ML_exchange_rows(Ctmp, &Ctmp2, A_->getrow->post_comm);
       else
@@ -1137,15 +1137,15 @@
           ML_Operator_Destroy (&Ctmp2);
         }
 
-                                   // create an Epetra matrix from the ML
-                                   // matrix that we got as a result.
-      Epetra_CrsMatrix * C_mat;
+      // create an Epetra matrix from the ML
+      // matrix that we got as a result.
+      Epetra_CrsMatrix *C_mat;
       ML_Operator2EpetraCrsMatrix(C_, C_mat);
       C_mat->FillComplete();
       C_mat->OptimizeStorage();
       result.reinit (*C_mat);
 
-                                   // destroy allocated memory
+      // destroy allocated memory
       delete C_mat;
       ML_Operator_Destroy (&A_);
       ML_Operator_Destroy (&B_);
@@ -1183,21 +1183,21 @@
     Assert (rhs.n() == n(), ExcDimensionMismatch (rhs.n(), n()));
 
     const std::pair<unsigned int, unsigned int>
-      local_range = rhs.local_range();
+    local_range = rhs.local_range();
 
     int ierr;
 
-                                   // If both matrices have been transformed
-                                   // to local index space (in Trilinos
-                                   // speak: they are filled), we're having
-                                   // matrices based on the same indices
-                                   // with the same number of nonzeros
-                                   // (actually, we'd need sparsity pattern,
-                                   // but that is too expensive to check),
-                                   // we can extract views of the column
-                                   // data on both matrices and simply
-                                   // manipulate the values that are
-                                   // addressed by the pointers.
+    // If both matrices have been transformed
+    // to local index space (in Trilinos
+    // speak: they are filled), we're having
+    // matrices based on the same indices
+    // with the same number of nonzeros
+    // (actually, we'd need sparsity pattern,
+    // but that is too expensive to check),
+    // we can extract views of the column
+    // data on both matrices and simply
+    // manipulate the values that are
+    // addressed by the pointers.
     if (matrix->Filled() == true &&
         rhs.matrix->Filled() == true &&
         this->local_range() == local_range &&
@@ -1210,18 +1210,18 @@
                   ExcDimensionMismatch(matrix->NumGlobalEntries(row),
                                        rhs.matrix->NumGlobalEntries(row)));
 
-          const int row_local = matrix->RowMap().LID(row);
+          const int row_local = matrix->RowMap().LID(static_cast<int>(row));
           int n_entries, rhs_n_entries;
           TrilinosScalar *value_ptr, *rhs_value_ptr;
 
-                                   // In debug mode, we want to check
-                                   // whether the indices really are the
-                                   // same in the calling matrix and the
-                                   // input matrix. The reason for doing
-                                   // this only in debug mode is that both
-                                   // extracting indices and comparing
-                                   // indices is relatively slow compared to
-                                   // just working with the values.
+          // In debug mode, we want to check
+          // whether the indices really are the
+          // same in the calling matrix and the
+          // input matrix. The reason for doing
+          // this only in debug mode is that both
+          // extracting indices and comparing
+          // indices is relatively slow compared to
+          // just working with the values.
 #ifdef DEBUG
           int *index_ptr, *rhs_index_ptr;
           ierr = rhs.matrix->ExtractMyRowView (row_local, rhs_n_entries,
@@ -1248,21 +1248,21 @@
 #endif
             }
         }
-                                   // If we have different sparsity patterns
-                                   // (expressed by a different number of
-                                   // nonzero elements), we have to be more
-                                   // careful and extract a copy of the row
-                                   // data, multiply it by the factor and
-                                   // then add it to the matrix using the
-                                   // respective add() function.
+    // If we have different sparsity patterns
+    // (expressed by a different number of
+    // nonzero elements), we have to be more
+    // careful and extract a copy of the row
+    // data, multiply it by the factor and
+    // then add it to the matrix using the
+    // respective add() function.
     else
       {
         unsigned int max_row_length = 0;
         for (unsigned int row=local_range.first;
-           row < local_range.second; ++row)
-            max_row_length
-              = std::max (max_row_length,
-                          static_cast<unsigned int>(rhs.matrix->NumGlobalEntries(row)));
+             row < local_range.second; ++row)
+          max_row_length
+            = std::max (max_row_length,
+                        static_cast<unsigned int>(rhs.matrix->NumGlobalEntries(row)));
 
         std::vector<int>            column_indices (max_row_length);
         std::vector<TrilinosScalar> values (max_row_length);
@@ -1272,7 +1272,7 @@
           for (unsigned int row=local_range.first;
                row < local_range.second; ++row)
             {
-              const int row_local = matrix->RowMap().LID(row);
+              const int row_local = matrix->RowMap().LID(static_cast<int>(row));
               int n_entries;
 
               ierr = rhs.matrix->ExtractMyRowCopy (row_local, max_row_length,
@@ -1297,14 +1297,14 @@
               {
                 int n_entries;
                 ierr = rhs.matrix->Epetra_CrsMatrix::ExtractGlobalRowCopy
-                    ((int)row, max_row_length, n_entries, &values[0], &column_indices[0]);
+                       ((int)row, max_row_length, n_entries, &values[0], &column_indices[0]);
                 Assert (ierr == 0, ExcTrilinosError(ierr));
 
                 for (int i=0; i<n_entries; ++i)
                   values[i] *= factor;
 
                 ierr = matrix->Epetra_CrsMatrix::SumIntoGlobalValues
-                    ((int)row, n_entries, &values[0], &column_indices[0]);
+                       ((int)row, n_entries, &values[0], &column_indices[0]);
                 Assert (ierr == 0, ExcTrilinosError(ierr));
               }
             compress ();
@@ -1318,11 +1318,11 @@
   void
   SparseMatrix::transpose ()
   {
-                                  // This only flips a flag that tells
-                                  // Trilinos that any vmult operation
-                                  // should be done with the
-                                  // transpose. However, the matrix
-                                  // structure is not reset.
+    // This only flips a flag that tells
+    // Trilinos that any vmult operation
+    // should be done with the
+    // transpose. However, the matrix
+    // structure is not reset.
     int ierr;
 
     if (!matrix->UseTranspose())
@@ -1338,7 +1338,8 @@
   }
 
 /**
- * 	remove the zeros before 'e' in the scientific notation of a floating point value.
+ * 	shuqiangwag: remove the zeros before 'e' in the scientific notation of a floating 
+ * 	point value for output.
  */
   static void simplify_scientific_string(int len, const char inStr[20], char outStr[20])
   {
@@ -1388,7 +1389,7 @@
    * shuqiangwang: output to be the same as petsc style.
    */
   void
-  SparseMatrix::write_ascii ()
+  SparseMatrix::write_ascii () const
   {
 //    Assert (false, ExcNotImplemented());
 	  double * values;
@@ -1416,10 +1417,9 @@
   }
 
 
-
-                                  // As of now, no particularly neat
-                                  // ouput is generated in case of
-                                  // multiple processors.
+  // As of now, no particularly neat
+  // ouput is generated in case of
+  // multiple processors.
   void
   SparseMatrix::print (std::ostream &out,
                        const bool    print_detailed_trilinos_information) const
@@ -1428,8 +1428,8 @@
       out << *matrix;
     else
       {
-        double * values;
-        int * indices;
+        double *values;
+        int *indices;
         int num_entries;
 
         for (int i=0; i<matrix->NumMyRows(); ++i)
@@ -1450,7 +1450,7 @@
   SparseMatrix::memory_consumption () const
   {
     unsigned int static_memory = sizeof(this) + sizeof (*matrix)
-      + sizeof(*matrix->Graph().DataPtr());
+                                 + sizeof(*matrix->Graph().DataPtr());
     return ((sizeof(TrilinosScalar)+sizeof(int))*matrix->NumMyNonzeros() +
             sizeof(int)*local_size() +
             static_memory);

Modified: branches/s-wang/for_deal.II/source/lac/trilinos_vector_base.cc
===================================================================
--- branches/s-wang/for_deal.II/source/lac/trilinos_vector_base.cc	2012-11-28 16:51:43 UTC (rev 1391)
+++ branches/s-wang/for_deal.II/source/lac/trilinos_vector_base.cc	2012-11-28 19:03:50 UTC (rev 1392)
@@ -1,5 +1,5 @@
 //---------------------------------------------------------------------------
-//    $Id: trilinos_vector_base.cc 26093 2012-08-22 21:37:41Z heister $
+//    $Id: trilinos_vector_base.cc 27628 2012-11-20 22:49:26Z heister $
 //    Version: $Name$
 //
 //    Copyright (C) 2008, 2010, 2011, 2012 by the deal.II authors
@@ -32,15 +32,15 @@
       Assert (index < vector.size(),
               ExcIndexRange (index, 0, vector.size()));
 
-                                        // Trilinos allows for vectors
-                                        // to be referenced by the [] or
-                                        // () operators but only ()
-                                        // checks index bounds. We check
-                                        // these bounds by ourselves, so
-                                        // we can use []. Note that we
-                                        // can only get local values.
+      // Trilinos allows for vectors
+      // to be referenced by the [] or
+      // () operators but only ()
+      // checks index bounds. We check
+      // these bounds by ourselves, so
+      // we can use []. Note that we
+      // can only get local values.
 
-      const int local_index = vector.vector->Map().LID(index);
+      const int local_index = vector.vector->Map().LID(static_cast<int>(index));
       Assert (local_index >= 0,
               ExcAccessToNonLocalElement (index,
                                           vector.vector->Map().MinMyGID(),
@@ -54,28 +54,28 @@
 
 
   VectorBase::VectorBase ()
-                        :
-                        last_action (Zero),
-                        compressed  (true),
-                        has_ghosts  (false),
+    :
+    last_action (Zero),
+    compressed  (true),
+    has_ghosts  (false),
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                        vector(new Epetra_FEVector(
-                                 Epetra_Map(0,0,Epetra_MpiComm(MPI_COMM_SELF))))
+    vector(new Epetra_FEVector(
+             Epetra_Map(0,0,Epetra_MpiComm(MPI_COMM_SELF))))
 #else
-                        vector(new Epetra_FEVector(
-                                 Epetra_Map(0,0,Epetra_SerialComm())))
+    vector(new Epetra_FEVector(
+             Epetra_Map(0,0,Epetra_SerialComm())))
 #endif
   {}
 
 
 
   VectorBase::VectorBase (const VectorBase &v)
-                        :
-                        Subscriptor(),
-                        last_action (Zero),
-                        compressed (true),
-                        has_ghosts  (v.has_ghosts),
-                        vector(new Epetra_FEVector(*v.vector))
+    :
+    Subscriptor(),
+    last_action (Zero),
+    compressed (true),
+    has_ghosts  (v.has_ghosts),
+    vector(new Epetra_FEVector(*v.vector))
   {}
 
 
@@ -88,9 +88,9 @@
   void
   VectorBase::clear ()
   {
-                                     // When we clear the vector,
-                                     // reset the pointer and generate
-                                     // an empty vector.
+    // When we clear the vector,
+    // reset the pointer and generate
+    // an empty vector.
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
     Epetra_Map map (0, 0, Epetra_MpiComm(MPI_COMM_SELF));
 #else
@@ -144,16 +144,16 @@
     Assert (size() == v.size(),
             ExcDimensionMismatch(size(), v.size()));
 
-                                     // this is probably not very efficient
-                                     // but works. in particular, we could do
-                                     // better if we know that
-                                     // number==TrilinosScalar because then we
-                                     // could elide the copying of elements
-                                     //
-                                     // let's hope this isn't a
-                                     // particularly frequent operation
+    // this is probably not very efficient
+    // but works. in particular, we could do
+    // better if we know that
+    // number==TrilinosScalar because then we
+    // could elide the copying of elements
+    //
+    // let's hope this isn't a
+    // particularly frequent operation
     std::pair<unsigned int, unsigned int>
-      local_range = this->local_range ();
+    local_range = this->local_range ();
     for (unsigned int i=local_range.first; i<local_range.second; ++i)
       (*vector)[0][i-local_range.first] = v(i);
 
@@ -165,17 +165,17 @@
   TrilinosScalar
   VectorBase::el (const unsigned int index) const
   {
-                                        // Extract local indices in
-                                        // the vector.
-    int trilinos_i = vector->Map().LID(index);
+    // Extract local indices in
+    // the vector.
+    int trilinos_i = vector->Map().LID(static_cast<int>(index));
     TrilinosScalar value = 0.;
 
-                                        // If the element is not
-                                        // present on the current
-                                        // processor, we can't
-                                        // continue. Just print out 0.
+    // If the element is not
+    // present on the current
+    // processor, we can't
+    // continue. Just print out 0.
 
-                                        // TODO: Is this reasonable?
+    // TODO: Is this reasonable?
     if (trilinos_i == -1 )
       {
         return 0.;
@@ -193,16 +193,16 @@
   TrilinosScalar
   VectorBase::operator () (const unsigned int index) const
   {
-                                        // Extract local indices in
-                                        // the vector.
-    int trilinos_i = vector->Map().LID(index);
+    // Extract local indices in
+    // the vector.
+    int trilinos_i = vector->Map().LID(static_cast<int>(index));
     TrilinosScalar value = 0.;
 
-                                        // If the element is not present
-                                        // on the current processor, we
-                                        // can't continue. This is the
-                                        // main difference to the el()
-                                        // function.
+    // If the element is not present
+    // on the current processor, we
+    // can't continue. This is the
+    // main difference to the el()
+    // function.
     if (trilinos_i == -1 )
       {
         Assert (false, ExcAccessToNonlocalElement(index, local_range().first,
@@ -287,14 +287,15 @@
 	  return d;
   }
 
+
   bool
   VectorBase::all_zero () const
   {
-                                     // get a representation of the vector and
-                                     // loop over all the elements
+    // get a representation of the vector and
+    // loop over all the elements
     TrilinosScalar *start_ptr = (*vector)[0];
     const TrilinosScalar *ptr  = start_ptr,
-                         *eptr = start_ptr + local_size();
+                          *eptr = start_ptr + local_size();
     unsigned int flag = 0;
     while (ptr != eptr)
       {
@@ -307,10 +308,10 @@
       }
 
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                                     // in parallel, check that the vector
-                                     // is zero on _all_ processors.
+    // in parallel, check that the vector
+    // is zero on _all_ processors.
     const Epetra_MpiComm *mpi_comm
-      = dynamic_cast<const Epetra_MpiComm*>(&vector->Map().Comm());
+      = dynamic_cast<const Epetra_MpiComm *>(&vector->Map().Comm());
     unsigned int num_nonzero = Utilities::MPI::sum(flag, mpi_comm->Comm());
     return num_nonzero == 0;
 #else
@@ -325,26 +326,26 @@
   VectorBase::is_non_negative () const
   {
 #ifdef DEAL_II_COMPILER_SUPPORTS_MPI
-                                     // if this vector is a parallel one, then
-                                     // we need to communicate to determine
-                                     // the answer to the current
-                                     // function. this still has to be
-                                     // implemented
+    // if this vector is a parallel one, then
+    // we need to communicate to determine
+    // the answer to the current
+    // function. this still has to be
+    // implemented
     AssertThrow(local_size() == size(), ExcNotImplemented());
 #endif
-                                     // get a representation of the vector and
-                                     // loop over all the elements
+    // get a representation of the vector and
+    // loop over all the elements
     TrilinosScalar *start_ptr;
     int leading_dimension;
     int ierr = vector->ExtractView (&start_ptr, &leading_dimension);
     AssertThrow (ierr == 0, ExcTrilinosError(ierr));
 
-                                       // TODO: This
-                                       // won't work in parallel like
-                                       // this. Find out a better way to
-                                       // this in that case.
+    // TODO: This
+    // won't work in parallel like
+    // this. Find out a better way to
+    // this in that case.
     const TrilinosScalar *ptr  = start_ptr,
-                         *eptr = start_ptr + size();
+                          *eptr = start_ptr + size();
     bool flag = true;
     while (ptr != eptr)
       {
@@ -361,10 +362,10 @@
 
 
 
-                                        // TODO: up to now only local
-                                        // data printed out! Find a
-                                        // way to neatly output
-                                        // distributed data...
+  // TODO: up to now only local
+  // data printed out! Find a
+  // way to neatly output
+  // distributed data...
   void
   VectorBase::print (const char *format) const
   {
@@ -392,12 +393,12 @@
   {
     AssertThrow (out, ExcIO());
 
-                                        // get a representation of the
-                                        // vector and loop over all
-                                        // the elements TODO: up to
-                                        // now only local data printed
-                                        // out! Find a way to neatly
-                                        // output distributed data...
+    // get a representation of the
+    // vector and loop over all
+    // the elements TODO: up to
+    // now only local data printed
+    // out! Find a way to neatly
+    // output distributed data...
     TrilinosScalar *val;
     int leading_dimension;
     int ierr = vector->ExtractView (&val, &leading_dimension);
@@ -417,8 +418,8 @@
         out << static_cast<double>(val[i]) << std::endl;
     out << std::endl;
 
-                                        // restore the representation
-                                        // of the vector
+    // restore the representation
+    // of the vector
     AssertThrow (out, ExcIO());
   }
 
@@ -437,13 +438,13 @@
   std::size_t
   VectorBase::memory_consumption () const
   {
-                                     //TODO[TH]: No accurate memory
-                                     //consumption for Trilinos vectors
-                                     //yet. This is a rough approximation with
-                                     //one index and the value per local
-                                     //entry.
+    //TODO[TH]: No accurate memory
+    //consumption for Trilinos vectors
+    //yet. This is a rough approximation with
+    //one index and the value per local
+    //entry.
     return sizeof(*this)
-      + this->local_size()*( sizeof(double)+sizeof(int) );
+           + this->local_size()*( sizeof(double)+sizeof(int) );
   }
 
 } /* end of namespace TrilinosWrappers */



More information about the CIG-COMMITS mailing list