#include <grid/tria_iterator.h>
#include <grid/tria_accessor.h>
#include <grid/grid_generator.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
#include <base/parameter_handler.h>
#include <dofs/dof_constraints.h>
#include <numerics/dof_renumbering.h>
cout << " Renumbering degrees of freedom..." << endl;
DoFRenumbering::Cuthill_McKee (*dof);
- SparseMatrixStruct sparsity (dof->n_dofs(),
- dof->max_couplings_between_dofs());
+ SparsityPattern sparsity (dof->n_dofs(),
+ dof->max_couplings_between_dofs());
DoFTools::make_sparsity_pattern (*dof, sparsity);
/**
* Sparsity pattern of the system matrix.
*/
- SparseMatrixStruct system_sparsity;
+ SparsityPattern system_sparsity;
/**
* System matrix.
// many rows and columns as there
// are degrees of freedom on the
// grid:
- SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(),
- dof_handler.n_dofs());
+ SparsityPattern sparsity_pattern (dof_handler.n_dofs(),
+ dof_handler.n_dofs());
// We fill it with the places where
// nonzero elements will be located
// given the present numbering of
// Renumber the degrees of freedom...
DoFRenumbering::Cuthill_McKee (dof_handler);
// ...regenerate the sparsity pattern...
- SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(),
- dof_handler.n_dofs());
+ SparsityPattern sparsity_pattern (dof_handler.n_dofs(),
+ dof_handler.n_dofs());
DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern);
sparsity_pattern.compress ();
// ...and output the result:
// system matrix resulting from
// the discretization of the
// Laplace equation...
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
// ...and variables which will
// `sealed', so to say), and we can
// initialize the matrix itself
// with it. Note that the
- // SparseMatrixStruct object does
+ // SparsityPattern object does
// not hold the values of the
// matrix, it only stores the
// places where entries are. The
FEQ1<dim> fe;
DoFHandler<dim> dof_handler;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
FEQ1<dim> fe;
DoFHandler<dim> dof_handler;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
// hanging nodes:
ConstraintMatrix hanging_node_constraints;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
ConstraintMatrix hanging_node_constraints;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
#include <grid/tria_iterator.templates.h>
#include <fe/fe.h>
-#include <lac/vector.h>
-#include <lac/full_matrix.h>
-#include <lac/sparse_matrix.h>
-
#include <vector>
* Condense a given sparsity pattern. This
* function assumes the uncondensed
* matrix struct to be compressed and the
- * to be filled one to be empty. The
+ * one to be filled to be empty. The
* condensed structure is compressed
* afterwards.
*
* The constraint matrix object must be
* closed to call this function.
*/
- void condense (const SparseMatrixStruct &uncondensed,
- SparseMatrixStruct &condensed) const;
+ void condense (const SparsityPattern &uncondensed,
+ SparsityPattern &condensed) const;
/**
* The matrix struct is compressed at the
* end of the function.
*/
- void condense (SparseMatrixStruct &sparsity) const;
+ void condense (SparsityPattern &sparsity) const;
/**
* Condense a given matrix. The associated
+/*---------------------------- dof_constraints.templates.h ---------------------------*/
+/* $Id$ */
+#ifndef __dof_constraints_templates_H
+#define __dof_constraints_templates_H
+/*---------------------------- dof_constraints.templates.h ---------------------------*/
+
+
+#include <dofs/dof_constraints.h>
+#include <lac/sparse_matrix.h>
+
+
template<typename number>
void
ConstraintMatrix::condense (const SparseMatrix<number> &uncondensed,
SparseMatrix<number> &condensed) const
{
- const SparseMatrixStruct &uncondensed_struct = uncondensed.get_sparsity_pattern ();
+ const SparsityPattern &uncondensed_struct = uncondensed.get_sparsity_pattern ();
Assert (sorted == true, ExcMatrixNotClosed());
Assert (uncondensed_struct.is_compressed() == true, ExcMatrixNotClosed());
void
ConstraintMatrix::condense (SparseMatrix<number> &uncondensed) const
{
- const SparseMatrixStruct &sparsity = uncondensed.get_sparsity_pattern ();
+ const SparsityPattern &sparsity = uncondensed.get_sparsity_pattern ();
Assert (sorted == true, ExcMatrixNotClosed());
Assert (sparsity.is_compressed() == true, ExcMatrixNotClosed());
};
+
+
+
+/*---------------------------- dof_constraints.templates.h ---------------------------*/
+/* end of #ifndef __dof_constraints_templates_H */
+#endif
+/*---------------------------- dof_constraints.templates.h ---------------------------*/
* This is the maximum number of entries
* per line in the system matrix; this
* information can therefore be used upon
- * construction of the #SparseMatrixStruct#
+ * construction of the #SparsityPattern#
* object.
*
* The returned number is not really the
* afterwards.
*
* Remember using
- * #SparseMatrixStruct::compress()#
+ * #SparsityPattern::compress()#
* after generating the pattern.
*/
template<int dim>
static void make_sparsity_pattern (const DoFHandler<dim> &dof,
- SparseMatrixStruct &sparsity_pattern);
+ SparsityPattern &sparsity_pattern);
/**
* Locate non-zero entries for
template<int dim>
static void make_sparsity_pattern (const DoFHandler<dim> &dof,
const vector<vector<bool> > &mask,
- SparseMatrixStruct &sparsity_pattern);
+ SparsityPattern &sparsity_pattern);
/**
* Write the sparsity structure
* #ConstraintMatrix::condense(1)#,
* you have to compress the
* matrix yourself, using
- * #SparseMatrixStruct::compress()#.
+ * #SparsityPattern::compress()#.
*
* Since this function is
* obviously useless in one
static void
make_boundary_sparsity_pattern (const DoFHandler<dim> &dof,
const vector<int> &dof_to_boundary_mapping,
- SparseMatrixStruct &sparsity_pattern);
+ SparsityPattern &sparsity_pattern);
/**
* Write the sparsity structure of the
make_boundary_sparsity_pattern (const DoFHandler<dim>& dof,
const typename DoFHandler<dim>::FunctionMap &boundary_indicators,
const vector<int> &dof_to_boundary_mapping,
- SparseMatrixStruct &sparsity);
+ SparsityPattern &sparsity);
/**
* Generate sparsity pattern for
*/
template<int dim>
static void make_flux_sparsity_pattern (const DoFHandler<dim> &dof_handler,
- SparseMatrixStruct &sparsity_pattern);
+ SparsityPattern &sparsity_pattern);
/**
* Make up the constraints which
* #ConstraintMatrix::condense(1)#,
* you have to compress the
* matrix yourself, using
- * #SparseMatrixStruct::compress()#.
+ * #SparsityPattern::compress()#.
*/
template <int dim>
static void
make_sparsity_pattern (const MGDoFHandler<dim> &dof_handler,
const unsigned int level,
- SparseMatrixStruct &sparsity);
+ SparsityPattern &sparsity);
};
* #ConstraintMatrix::condense(1)#,
* you have to compress the
* matrix yourself, using
- * #SparseMatrixStruct::compress()#.
+ * #SparsityPattern::compress()#.
*/
template <int dim>
static void
make_sparsity_pattern (const MGDoFHandler<dim> &dof_handler,
const unsigned int level,
- SparseMatrixStruct &sparsity);
+ SparsityPattern &sparsity);
};
#include <base/smartpointer.h>
#include <lac/forward_declarations.h>
#include <grid/forward_declarations.h>
-#include <lac/sparse_matrix.h>
#include <lac/vector.h>
#include <lac/mgbase.h>
private:
- vector<SparseMatrixStruct> prolongation_sparsities;
+ /**
+ * Sparsity patterns for the
+ * prolongation matrices on each
+ * level.
+ */
+ vector<SparsityPattern> prolongation_sparsities;
- /**
- * The actual prolongation matrix.
- * column indices belong to the
- * dof indices of the mother cell,
- * i.e. the coarse level.
- * while row indices belong to the
- * child cell, i.e. the fine level.
- */
+ /**
+ * The actual prolongation matrix.
+ * column indices belong to the
+ * dof indices of the mother cell,
+ * i.e. the coarse level.
+ * while row indices belong to the
+ * child cell, i.e. the fine level.
+ */
vector<SparseMatrix<float> > prolongation_matrices;
};
/**
* Sparsity pattern of the system matrix.
*/
- SparseMatrixStruct system_sparsity;
+ SparsityPattern system_sparsity;
/**
* System matrix.
*/
- SparseMatrix<double> system_matrix;
+ SparseMatrix<double> system_matrix;
/**
* Vector storing the right hand side.
*/
- Vector<double> right_hand_side;
+ Vector<double> right_hand_side;
/**
* Solution vector.
*/
- Vector<double> solution;
+ Vector<double> solution;
/**
* List of constraints introduced by
*
* The renumbering algorithms need quite a lot of memory, since they have
* to store for each dof with which other dofs it couples. This is done
- * using a #SparseMatrixStruct# object used to store the sparsity pattern of
+ * using a #SparsityPattern# object used to store the sparsity pattern of
* matrices. It
* is not useful for the user to do anything between distributing the dofs
* and renumbering, i.e. the calls to #DoFHandler::distribute_dofs# and
*
* All functions take a sparse matrix object to hold the matrix to be
* created. The functions assume that the matrix is initialized with a
- * sparsity pattern (#SparseMatrixStruct#) corresponding to the given degree
+ * sparsity pattern (#SparsityPattern#) corresponding to the given degree
* of freedom handler, i.e. the sparsity structure is already as needed.
* You can do this by calling the #DoFHandler<dim>::make_sparsity_pattern#
* function.
#include <base/smartpointer.h>
#include <lac/forward_declarations.h>
#include <grid/forward_declarations.h>
-#include <lac/sparse_matrix.h>
#include <lac/vector.h>
#include <lac/mgbase.h>
private:
- vector<SparseMatrixStruct> prolongation_sparsities;
+ /**
+ * Sparsity patterns for the
+ * prolongation matrices on each
+ * level.
+ */
+ vector<SparsityPattern> prolongation_sparsities;
- /**
- * The actual prolongation matrix.
- * column indices belong to the
- * dof indices of the mother cell,
- * i.e. the coarse level.
- * while row indices belong to the
- * child cell, i.e. the fine level.
- */
+ /**
+ * The actual prolongation matrix.
+ * column indices belong to the
+ * dof indices of the mother cell,
+ * i.e. the coarse level.
+ * while row indices belong to the
+ * child cell, i.e. the fine level.
+ */
vector<SparseMatrix<float> > prolongation_matrices;
};
#include <fe/fe.h>
#include <lac/vector.h>
-#include <lac/full_matrix.h>
#include <lac/sparse_matrix.h>
#include <vector>
#include <dofs/dof_constraints.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
#include <lac/vector.h>
#include <iostream>
#include <algorithm>
-bool ConstraintMatrix::ConstraintLine::operator < (const ConstraintMatrix::ConstraintLine &a) const {
+bool ConstraintMatrix::ConstraintLine::operator < (const ConstraintMatrix::ConstraintLine &a) const
+{
return line < a.line;
};
-void ConstraintMatrix::condense (const SparseMatrixStruct &uncondensed,
- SparseMatrixStruct &condensed) const {
+void ConstraintMatrix::condense (const SparsityPattern &uncondensed,
+ SparsityPattern &condensed) const {
Assert (sorted == true, ExcMatrixNotClosed());
Assert (uncondensed.is_compressed() == true, ExcMatrixNotClosed());
Assert (uncondensed.n_rows() == uncondensed.n_cols(),
-void ConstraintMatrix::condense (SparseMatrixStruct &sparsity) const {
+void ConstraintMatrix::condense (SparsityPattern &sparsity) const {
Assert (sorted == true, ExcMatrixNotClosed());
Assert (sparsity.is_compressed() == false, ExcMatrixIsClosed());
Assert (sparsity.n_rows() == sparsity.n_cols(),
/* $Id$ */
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
#include <dofs/dof_accessor.h>
#include <grid/tria_iterator.h>
#include <dofs/dof_handler.h>
const bool use_constraints,
const vector<int> &starting_indices) {
// make the connection graph
- SparseMatrixStruct sparsity (dof_handler.n_dofs(),
- dof_handler.max_couplings_between_dofs());
+ SparsityPattern sparsity (dof_handler.n_dofs(),
+ dof_handler.max_couplings_between_dofs());
DoFTools::make_sparsity_pattern (dof_handler, sparsity);
if (use_constraints)
const bool reversed_numbering,
const vector<int> &starting_indices) {
// make the connection graph
- SparseMatrixStruct sparsity (dof_handler.n_dofs(level),
- dof_handler.max_couplings_between_dofs());
+ SparsityPattern sparsity (dof_handler.n_dofs(level),
+ dof_handler.max_couplings_between_dofs());
MGDoFTools::make_sparsity_pattern (dof_handler, level, sparsity);
const int n_dofs = sparsity.n_rows();
#include <fe/fe.h>
#include <fe/fe_system.h>
#include <dofs/dof_tools.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
#include <lac/vector.h>
#include <algorithm>
template <int dim>
void
-DoFTools::make_sparsity_pattern (const DoFHandler<dim>& dof,
- SparseMatrixStruct &sparsity)
+DoFTools::make_sparsity_pattern (const DoFHandler<dim> &dof,
+ SparsityPattern &sparsity)
{
const unsigned int n_dofs = dof.n_dofs();
template <int dim>
void
-DoFTools::make_sparsity_pattern (const DoFHandler<dim>& dof,
- const vector<vector<bool> > &mask,
- SparseMatrixStruct &sparsity)
+DoFTools::make_sparsity_pattern (const DoFHandler<dim> &dof,
+ const vector<vector<bool> > &mask,
+ SparsityPattern &sparsity)
{
const unsigned int n_dofs = dof.n_dofs();
const unsigned int dofs_per_cell = dof.get_fe().dofs_per_cell;
template <>
void DoFTools::make_boundary_sparsity_pattern (const DoFHandler<1>&,
- const vector<int> &,
- SparseMatrixStruct &)
+ const vector<int> &,
+ SparsityPattern &)
{
Assert (false, ExcInternalError());
};
DoFTools::make_boundary_sparsity_pattern (const DoFHandler<1>&,
const DoFHandler<1>::FunctionMap &,
const vector<int> &,
- SparseMatrixStruct &)
+ SparsityPattern &)
{
Assert (false, ExcInternalError());
}
void
DoFTools::make_boundary_sparsity_pattern (const DoFHandler<dim>& dof,
const vector<int> &dof_to_boundary_mapping,
- SparseMatrixStruct &sparsity)
+ SparsityPattern &sparsity)
{
const unsigned int n_dofs = dof.n_dofs();
void DoFTools::make_boundary_sparsity_pattern (const DoFHandler<dim>& dof,
const DoFHandler<dim>::FunctionMap &boundary_indicators,
const vector<int> &dof_to_boundary_mapping,
- SparseMatrixStruct &sparsity)
+ SparsityPattern &sparsity)
{
const unsigned int n_dofs = dof.n_dofs();
template<int dim>
void
-DoFTools::make_flux_sparsity_pattern (const DoFHandler<dim>& dof,
- SparseMatrixStruct &sparsity)
+DoFTools::make_flux_sparsity_pattern (const DoFHandler<dim> &dof,
+ SparsityPattern &sparsity)
{
const unsigned int n_dofs = dof.n_dofs();
#if deal_II_dimension > 1
template void
DoFTools::make_flux_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
- SparseMatrixStruct &sparsity);
+ SparsityPattern &sparsity);
template void
DoFTools::make_boundary_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
const vector<int> &,
- SparseMatrixStruct &);
+ SparsityPattern &);
template void
DoFTools::make_boundary_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
const DoFHandler<deal_II_dimension>::FunctionMap &boundary_indicators,
const vector<int> &dof_to_boundary_mapping,
- SparseMatrixStruct &sparsity);
+ SparsityPattern &sparsity);
#endif
template void
DoFTools::make_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
- SparseMatrixStruct &sparsity);
+ SparsityPattern &sparsity);
template void
DoFTools::make_sparsity_pattern (const DoFHandler<deal_II_dimension>& dof,
const vector<vector<bool> > &mask,
- SparseMatrixStruct &sparsity);
+ SparsityPattern &sparsity);
template
void
#include <fe/fe.h>
#include <lac/vector.h>
-#include <lac/full_matrix.h>
-#include <lac/sparse_matrix.h>
+
+
#include <grid/tria.h>
#include <grid/geometry_info.h>
#include <fe/fe.h>
-#include <lac/sparse_matrix.h>
#include <algorithm>
/* $Id$ */
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
#include <dofs/mg_dof_handler.h>
#include <dofs/mg_dof_accessor.h>
#include <grid/tria_iterator.h>
template <int dim>
void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<dim> &mg_dof_handler,
const unsigned int level,
- SparseMatrixStruct &sparsity)
+ SparsityPattern &sparsity)
{
Assert (sparsity.n_rows() == mg_dof_handler.n_dofs(level),
ExcDimensionMismatch (sparsity.n_rows(), mg_dof_handler.n_dofs(level)));
// explicit instantiations
template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<deal_II_dimension> &,
const unsigned int,
- SparseMatrixStruct &);
+ SparsityPattern &);
#include <fe/fe.h>
#include <lac/vector.h>
-#include <lac/full_matrix.h>
-#include <lac/sparse_matrix.h>
+
+
#include <grid/tria.h>
#include <grid/geometry_info.h>
#include <fe/fe.h>
-#include <lac/sparse_matrix.h>
#include <algorithm>
/* $Id$ */
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
#include <dofs/mg_dof_handler.h>
#include <dofs/mg_dof_accessor.h>
#include <grid/tria_iterator.h>
template <int dim>
void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<dim> &mg_dof_handler,
const unsigned int level,
- SparseMatrixStruct &sparsity)
+ SparsityPattern &sparsity)
{
Assert (sparsity.n_rows() == mg_dof_handler.n_dofs(level),
ExcDimensionMismatch (sparsity.n_rows(), mg_dof_handler.n_dofs(level)));
// explicit instantiations
template void MGDoFTools::make_sparsity_pattern (const MGDoFHandler<deal_II_dimension> &,
const unsigned int,
- SparseMatrixStruct &);
+ SparsityPattern &);
#include <numerics/multigrid.h>
#include <numerics/mg_smoother.h>
#include <lac/vector.h>
+#include <lac/sparse_matrix.h>
#include <algorithm>
#include <numerics/multigrid.templates.h>
#include <numerics/mg_smoother.h>
#include <lac/vector.h>
-
+#include <lac/sparse_matrix.h>
/* --------------------------------- MG ------------------------------------ */
// level which have children
for (unsigned int level=0; level<n_levels-1; ++level)
{
- prolongation_sparsities.push_back (SparseMatrixStruct());
+ prolongation_sparsities.push_back (SparsityPattern ());
// reset the dimension of the structure.
// note that for the number of entries
// per row, the number of mother dofs
return;
- map<int,double>::const_iterator dof = boundary_values.begin(),
- endd = boundary_values.end();
+ map<int,double>::const_iterator dof = boundary_values.begin(),
+ endd = boundary_values.end();
const unsigned int n_dofs = matrix.m();
- const SparseMatrixStruct &sparsity = matrix.get_sparsity_pattern();
+ const SparsityPattern &sparsity = matrix.get_sparsity_pattern();
const unsigned int *sparsity_rowstart = sparsity.get_rowstart_indices();
const int *sparsity_colnums = sparsity.get_column_numbers();
#include <numerics/multigrid.h>
#include <numerics/mg_smoother.h>
#include <lac/vector.h>
+#include <lac/sparse_matrix.h>
#include <algorithm>
#include <numerics/multigrid.templates.h>
#include <numerics/mg_smoother.h>
#include <lac/vector.h>
-
+#include <lac/sparse_matrix.h>
/* --------------------------------- MG ------------------------------------ */
// level which have children
for (unsigned int level=0; level<n_levels-1; ++level)
{
- prolongation_sparsities.push_back (SparseMatrixStruct());
+ prolongation_sparsities.push_back (SparsityPattern ());
// reset the dimension of the structure.
// note that for the number of entries
// per row, the number of mother dofs
// set up mass matrix and right hand side
vec.reinit (dof.n_dofs());
- SparseMatrixStruct sparsity(dof.n_dofs(),
- dof.n_dofs(),
- dof.max_couplings_between_dofs());
+ SparsityPattern sparsity(dof.n_dofs(),
+ dof.n_dofs(),
+ dof.max_couplings_between_dofs());
DoFTools::make_sparsity_pattern (dof, sparsity);
constraints.condense (sparsity);
dof.map_dof_to_boundary_indices (boundary_functions, dof_to_boundary_mapping);
// set up sparsity structure
- SparseMatrixStruct sparsity(dof.n_boundary_dofs(boundary_functions),
- dof.max_couplings_between_boundary_dofs());
+ SparsityPattern sparsity(dof.n_boundary_dofs(boundary_functions),
+ dof.max_couplings_between_boundary_dofs());
DoFTools::make_boundary_sparsity_pattern (dof,
boundary_functions,
dof_to_boundary_mapping,
// many rows and columns as there
// are degrees of freedom on the
// grid:
- SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(),
- dof_handler.n_dofs());
+ SparsityPattern sparsity_pattern (dof_handler.n_dofs(),
+ dof_handler.n_dofs());
// We fill it with the places where
// nonzero elements will be located
// given the present numbering of
// Renumber the degrees of freedom...
DoFRenumbering::Cuthill_McKee (dof_handler);
// ...regenerate the sparsity pattern...
- SparseMatrixStruct sparsity_pattern (dof_handler.n_dofs(),
- dof_handler.n_dofs());
+ SparsityPattern sparsity_pattern (dof_handler.n_dofs(),
+ dof_handler.n_dofs());
DoFTools::make_sparsity_pattern (dof_handler, sparsity_pattern);
sparsity_pattern.compress ();
// ...and output the result:
// system matrix resulting from
// the discretization of the
// Laplace equation...
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
// ...and variables which will
// `sealed', so to say), and we can
// initialize the matrix itself
// with it. Note that the
- // SparseMatrixStruct object does
+ // SparsityPattern object does
// not hold the values of the
// matrix, it only stores the
// places where entries are. The
FEQ1<dim> fe;
DoFHandler<dim> dof_handler;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
FEQ1<dim> fe;
DoFHandler<dim> dof_handler;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
// hanging nodes:
ConstraintMatrix hanging_node_constraints;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
ConstraintMatrix hanging_node_constraints;
- SparseMatrixStruct sparsity_pattern;
+ SparsityPattern sparsity_pattern;
SparseMatrix<double> system_matrix;
Vector<double> solution;
A(0) {};
+
template <typename number, typename inverse_type>
PreconditionBlock<number,inverse_type>::~PreconditionBlock ()
{
inverse.erase(inverse.begin(), inverse.end());
}
+
+
template <typename number, typename inverse_type>
void PreconditionBlock<number,inverse_type>::clear ()
{
blocksize=0;
}
+
+
template <typename number, typename inverse_type>
void PreconditionBlock<number,inverse_type>::use_matrix(
const SparseMatrix<number> &M)
}
+
template <typename number, typename inverse_type>
void PreconditionBlock<number,inverse_type>::set_block_size(unsigned int bsize) {
blocksize=bsize;
}
+
template <typename number, typename inverse_type>
unsigned int PreconditionBlock<number,inverse_type>::block_size() const {
return blocksize;
}
+
template <typename number, typename inverse_type>
void PreconditionBlock<number,inverse_type>::invert_diagblocks()
{
omega(omega) {}
+
template<typename number, typename inverse_type>
PreconditionBlockSOR<number,inverse_type>::~PreconditionBlockSOR(){}
+
template <typename number, typename inverse_type>
template <typename number2>
void PreconditionBlockSOR<number,inverse_type>::operator() (Vector<number2> &dst,
Assert (inverse.size()==0 || inverse.size()==n_cells,
ExcWrongNumberOfInverses(inverse.size(), n_cells));
- const SparseMatrixStruct &spars=M.get_sparsity_pattern();
- const unsigned int *rowstart = spars.get_rowstart_indices();
- const int *columns = spars.get_column_numbers();
+ const SparsityPattern &spars = M.get_sparsity_pattern();
+ const unsigned int *rowstart = spars.get_rowstart_indices();
+ const int *columns = spars.get_column_numbers();
Vector<number2> b_cell(blocksize), x_cell(blocksize);
#define __solver_selector_H
/*---------------------------- solver_selector.h ---------------------------*/
-#include <lac/solver.h>
#include <base/smartpointer.h>
-#include <lac/sparse_matrix.h>
+#include <lac/solver.h>
#include <lac/vector.h>
#include <lac/vector_memory.h>
#include <lac/solver_control.h>
#include <lac/vector_memory.h>
#include <lac/solver_richardson.h>
#include <lac/precondition.h>
-
+#include <lac/forward_declarations.h>
/**
* superset of the sparsity pattern in the original matrix.
*
* Such fill-in can be accomplished by various ways, one of which is a
- * copy-constructor of the #SparseMatrixStruct# class which allows the addition
+ * copy-constructor of the #SparsityPattern# class which allows the addition
* of side-diagonals to a given sparsity structure.
*
*
*
* You have to initialize
* the matrix before usage with
- * #reinit(SparseMatrixStruct)#.
+ * #reinit(SparsityPattern)#.
*/
SparseILU ();
* long as #reinit# is not called with a
* new sparsity structure.
*/
- SparseILU (const SparseMatrixStruct &sparsity);
+ SparseILU (const SparsityPattern &sparsity);
/**
* Reinitialize the object but keep to
* function is not publically visible
* any more.
*/
- void reinit (const SparseMatrixStruct &sparsity);
+ void reinit (const SparsityPattern &sparsity);
/**
* Perform the incomplete LU factorization
template <typename number>
-SparseILU<number>::SparseILU (const SparseMatrixStruct &sparsity) :
+SparseILU<number>::SparseILU (const SparsityPattern &sparsity) :
SparseMatrix<number> (sparsity)
{};
template <typename number>
-void SparseILU<number>::reinit (const SparseMatrixStruct &sparsity)
+void SparseILU<number>::reinit (const SparsityPattern &sparsity)
{
SparseMatrix<number>::reinit (sparsity);
};
// now work only on this
// matrix
- const SparseMatrixStruct &sparsity = get_sparsity_pattern();
+ const SparsityPattern &sparsity = get_sparsity_pattern();
const unsigned int * const rowstart_indices = sparsity.get_rowstart_indices();
const int * const column_numbers = sparsity.get_column_numbers();
#include <base/exceptions.h>
#include <base/subscriptor.h>
#include <base/smartpointer.h>
-
-#include <vector>
-
-
-//forward declarations
-template <typename number> class Vector;
-template <typename number> class SparseMatrix;
-class ostream;
-
-
-
-/**
- * Structure representing the sparsity pattern of a sparse matrix.
- *
- * The following picture will illustrate the relation between the
- * #SparceMatrixStructure# an the #SparceMatrix#.
- *
- * \begin{verbatim}
- * SparseMatrixStructure: \
- * |
- * _________________________ |
- * rowstart |0 | 4| 8|11|13|.... |
- * |__|__|__|__|__|__________ |
- * | \ \ |
- * | \ \__ |
- * | \ \ |
- * | \ \__ |
- * \ / \ \ |
- * | \ \__ |
- * | \ \ |
- * | \ \__ |
- * | \ \ |
- * 0___________4___________8____ \ Position
- * colnums |3 | 2| 9|17| 1| 4| 6| 8| 4|.. /
- * /__|/_|__|__|__|__|__|__|__|__ |
- * / / |
- * / \______ _____/ \_____ _____/ |
- * / \/ \/ |
- * / / row = 0 row = 1 |
- * / / |
- * / / |
- * / / |
- * / /___colnums[1] |
- * / |
- * /_________colnums[0] |
- * |
- * /
- * \end{verbatim}
- *
- * \begin{verbatim}
- * For row = 0
- *
- * it exists: (0| 3) = colnums[0]
- * (0| 2) = colnums[1]
- * (0| 9) = colnums[2]
- * (0|17) = colnums[3]
- *
- * For row = 1
- *
- * it exists: (1| 1) = colnums[4]
- * (1| 4) = colnums[5]
- * ....
- *
- * \end{verbatim}
- *
- * \begin{verbatim}
- * SparseMatrix: \
- * |
- * _____________________________ |
- * val | | | | | | | | | 3|.. \ Value
- * |__|__|__|__|__|__|__|__|__|__ /
- * |
- * |
- * /
- * \end{verbatim}
- *
- * If you want to get the #3# you need to get its position in the
- * table above and its value by returning the value of the element on
- * which the pointer shows, using #*val#. For example #val[8]=3#. Its
- * position is #colnums[8]# so #row=2#. In other words, if you want to get
- * the element #a_{24}# you know that #row=2#. To get the element, a
- * search of #4# form #colnums[rowstart[2]]# to #colnums[rowstart[3]]# is
- * needed. Then #a_{24}=val[number of the found element] = 3#.
- *
- *
- * @author Original version by Roland Becker, Guido Kanschat, Franz-Theo Suttmeier; lots of enhancements, reorganisation and documentation by Wolfgang Bangerth; some documentation by Rasched Zamni
- */
-class SparseMatrixStruct : public Subscriptor
-{
- public:
- /**
- * Initialize the matrix empty,
- * that is with no memory
- * allocated. This is useful if
- * you want such objects as
- * member variables in other
- * classes. You can make the
- * structure usable by calling
- * the #reinit# function.
- */
- SparseMatrixStruct ();
-
- /**
- * Copy constructor. This constructor is
- * only allowed to be called if the matrix
- * structure to be copied is empty. This is
- * so in order to prevent involuntary
- * copies of objects for temporaries, which
- * can use large amounts of computing time.
- * However, copy constructors are needed
- * if yo want to use the STL data types
- * on classes like this, e.g. to write
- * such statements like
- * #v.push_back (SparseMatrixStruct());#,
- * with #v# a vector of #SparseMatrixStruct#
- * objects.
- *
- * Usually, it is sufficient to use the
- * explicit keyword to disallow unwanted
- * temporaries, but for the STL vectors,
- * this does not work. Since copying a
- * structure like this is not useful
- * anyway because multiple matrices can
- * use the same sparsity structure, copies
- * are only allowed for empty objects, as
- * described above.
- */
- SparseMatrixStruct (const SparseMatrixStruct &);
-
- /**
- * Initialize a rectangular matrix with
- * #m# rows and #n# columns.
- * The matrix may contain at most #max_per_row#
- * nonzero entries per row.
- */
- SparseMatrixStruct (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row);
-
- /**
- * Initialize a rectangular
- * matrix with #m# rows and #n#
- * columns. The maximal number
- * of nonzero entries for each
- * row is given by the
- * #row_lengths# array.
- */
- SparseMatrixStruct (const unsigned int m,
- const unsigned int n,
- const vector<unsigned int> &row_lengths);
-
- /**
- * Initialize a square matrix of dimension
- * #n# with at most #max_per_row#
- * nonzero entries per row.
- */
- SparseMatrixStruct (const unsigned int n,
- const unsigned int max_per_row);
-
- /**
- * Initialize a square
- * matrix with #m# rows and #m#
- * columns. The maximal number
- * of nonzero entries for each
- * row is given by the
- * #row_lengths# array.
- */
- SparseMatrixStruct (const unsigned int m,
- const vector<unsigned int> &row_lengths);
-
- /**
- * Copy operator. For this the same holds
- * as for the copy constructor: it is
- * declared, defined and fine to be called,
- * but the latter only for empty objects.
- */
- SparseMatrixStruct & operator = (const SparseMatrixStruct &);
-
- /**
- * Make a copy with extra off-diagonals.
- *
- * This constructs objects intended for
- * the application of the ILU(n)-method
- * or other incomplete decompositions.
- * Therefore, additional to the original
- * entry structure, space for
- * #extra_off_diagonals#
- * side-diagonals is provided on both
- * sides of the main diagonal.
- *
- * #max_per_row# is the maximum number of
- * nonzero elements per row which this
- * structure is to hold. It is assumed
- * that this number is sufficiently large
- * to accomodate both the elements in
- * #original# as well as the new
- * off-diagonal elements created by this
- * constructor. You will usually want to
- * give the same number as you gave for
- * #original# plus the number of side
- * diagonals times two. You may however
- * give a larger value if you wish to add
- * further nonzero entries for the
- * decomposition based on other criteria
- * than their being on side-diagonals.
- *
- * This function requires that #original#
- * refer to a square matrix structure.
- * It shall be compressed. The matrix
- * structure is not compressed
- * after this function finishes.
- */
- SparseMatrixStruct(const SparseMatrixStruct& original,
- const unsigned int max_per_row,
- const unsigned int extra_off_diagonals);
-
- /**
- * Destructor.
- */
- ~SparseMatrixStruct ();
-
- /**
- * Reallocate memory and set up data
- * structures for a new matrix with
- * #m# rows and #n# columns,
- * with at most #max_per_row#
- * nonzero entries per row.
- *
- * This function simply maps its
- * operations to the other
- * #reinit# function.
- */
- void reinit (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row);
-
- /**
- * Reallocate memory for a matrix
- * of size #m \times n#. The
- * number of entries for each row
- * is taken from the array
- * #row_lengths# which has to
- * give this number of each row
- * #i=1...m#.
- *
- * If #m*n==0# all memory is freed,
- * resulting in a total reinitialization
- * of the object. If it is nonzero, new
- * memory is only allocated if the new
- * size extends the old one. This is done
- * to save time and to avoid fragmentation
- * of the heap.
- */
- void reinit (const unsigned int m,
- const unsigned int n,
- const vector<unsigned int> &row_lengths);
-
- /**
- * This function compresses the sparsity
- * structure that this object represents.
- * It does so by eliminating unused
- * entries and sorting the remaining
- * ones to allow faster access by usage
- * of binary search algorithms. A special
- * sorting scheme is used for the diagonal
- * entry of square matrices, which is
- * always the first entry of each row.
- *
- * The memory which is no more
- * needed is released.
- *
- * #SparseMatrix# objects require the
- * #SparseMatrixStruct# objects they are
- * initialized with to be compressed, to
- * reduce memory requirements.
- */
- void compress ();
-
- /**
- * Return whether the object is empty. It
- * is empty if no memory is allocated,
- * which is the same as that both
- * dimensions are zero.
- */
- bool empty () const;
-
- /**
- * Return the maximum number of entries per
- * row. Before compression, this equals the
- * number given to the constructor, while
- * after compression, it equals the maximum
- * number of entries actually allocated by
- * the user.
- */
- unsigned int max_entries_per_row () const;
-
- /**
- * Return the index of the matrix
- * element with row number #i# and
- * column number #j#. If the matrix
- * element is not a nonzero one,
- * return -1.
- *
- * This function is usually called
- * by the #operator()# of the
- * #SparseMatrix#. It shall only be
- * called for compressed sparsity
- * patterns, since in this case
- * searching whether the entry
- * exists can be done quite fast
- * with a binary sort algorithm
- * because the column numbers are
- * sorted.
- */
- int operator() (const unsigned int i, const unsigned int j) const;
-
- /**
- * Add a nonzero entry to the matrix.
- * This function may only be called
- * for non-compressed sparsity patterns.
- *
- * If the entry already exists, nothing
- * bad happens.
- */
- void add (const unsigned int i, const unsigned int j);
-
- /**
- * This matrix adds a whole connectivity
- * list to the sparsity structure
- * respresented by this object. It assumes
- * the #rowcols# array to be a list of
- * indices which are all linked together,
- * i.e. all entries
- * #(rowcols[i], rowcols[j])# for all
- * #i,j=0...n# for this sparsity pattern
- * are created. #n# is assumed to be the
- * number of elements pointed to by
- * #rowcols#.
- */
- void add_matrix (const unsigned int n, const int* rowcols);
-
- //////////
- void add_matrix (const unsigned int m, const unsigned int n,
- const int* rows, const int* cols);
-
- /**
- * Print the sparsity of the matrix
- * in a format that #gnuplot# understands
- * and which can be used to plot the
- * sparsity pattern in a graphical
- * way. The format consists of pairs
- * #i j# of nonzero elements, each
- * representing one entry of this
- * matrix, one per line of the output
- * file. Indices are counted from
- * zero on, as usual. Since sparsity
- * patterns are printed in the same
- * way as matrices are displayed, we
- * print the negative of the column
- * index, which means that the
- * #(0,0)# element is in the top left
- * rather than in the bottom left
- * corner.
- *
- * Print the sparsity pattern in
- * gnuplot by setting the data style
- * to dots or points and use the
- * #plot# command.
- */
- void print_gnuplot (ostream &out) const;
-
- /**
- * Return number of rows of this
- * matrix, which equals the dimension
- * of the image space.
- */
- unsigned int n_rows () const;
-
- /**
- * Return number of columns of this
- * matrix, which equals the dimension
- * of the range space.
- */
- unsigned int n_cols () const;
-
- /**
- * Number of entries in a specific row.
- */
- unsigned int row_length (const unsigned int row) const;
-
- /**
- * Access to column number field.
- * Return the column number of
- * the #index#th entry in #row#.
- */
- unsigned int column_number (const unsigned int row,
- const unsigned int index) const;
-
- /**
- * Compute the bandwidth of the matrix
- * represented by this structure. The
- * bandwidth is the maximum of
- * $|i-j|$ for which the index pair
- * $(i,j)$ represents a nonzero entry
- * of the matrix.
- */
- unsigned int bandwidth () 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.
- *
- * This function may only be called if the
- * matrix struct is compressed. It does not
- * make too much sense otherwise anyway.
- */
- unsigned int n_nonzero_elements () const;
-
- /**
- * Return whether the structure is
- * compressed or not.
- */
- bool is_compressed () const;
-
- /**
- * This is kind of an expert mode. Get
- * access to the rowstart array, but
- * read-only.
- *
- * Use of this function is highly
- * deprecated. Use #row_length#
- * and #column_number# instead.
- *
- * Though the return value is declared
- * #const#, you should be aware that it
- * may change if you call any nonconstant
- * function of objects which operate on
- * it.
- *
- * You should use this interface very
- * carefully and only if you are absolutely
- * sure to know what you do. You should
- * also note that the structure of these
- * arrays may change over time.
- * If you change the layout yourself, you
- * should also rename this function to
- * avoid programs relying on outdated
- * information! */
- const unsigned int * get_rowstart_indices () const;
-
- /**
- * This is kind of an expert mode: get
- * access to the colnums array, but
- * readonly.
- *
- * Use of this function is highly
- * deprecated. Use #row_length#
- * and #column_number# instead.
- *
- * Though the return value is declared
- * #const#, you should be aware that it
- * may change if you call any nonconstant
- * function of objects which operate on
- * it.
- *
- * You should use this interface very
- * carefully and only if you are absolutely
- * sure to know what you do. You should
- * also note that the structure of these
- * arrays may change over time.
- * If you change the layout yourself, you
- * should also rename this function to
- * avoid programs relying on outdated
- * information!
- */
- const int * get_column_numbers () const;
-
-
- /**
- * Exception
- */
- DeclException1 (ExcInvalidNumber,
- int,
- << "The provided number is invalid here: " << arg1);
- /**
- * Exception
- */
- DeclException2 (ExcInvalidIndex,
- int, int,
- << "The given index " << arg1
- << " should be less than " << arg2 << ".");
- /**
- * Exception
- */
- DeclException2 (ExcNotEnoughSpace,
- int, int,
- << "Upon entering a new entry to row " << arg1
- << ": there was no free entry any more. " << endl
- << "(Maximum number of entries for this row: "
- << arg2 << "; maybe the matrix is already compressed?)");
- /**
- * Exception
- */
- DeclException0 (ExcNotCompressed);
- /**
- * Exception
- */
- DeclException0 (ExcMatrixIsCompressed);
- /**
- * Exception
- */
- DeclException0 (ExcEmptyObject);
- /**
- * Exception
- */
- DeclException0 (ExcInternalError);
- /**
- * Exception
- */
- DeclException0 (ExcIO);
- /**
- * Exception
- */
- DeclException0 (ExcInvalidConstructorCall);
- /**
- * Exception
- */
- DeclException0 (ExcNotSquare);
-
- private:
- /**
- * Maximum number of rows that can
- * be stored in the #row_start# array.
- * Since reallocation of that array
- * only happens if the present one is
- * too small, but never when the size
- * of this matrix structure shrinks,
- * #max_dim# might be larger than
- * #rows# and in this case #row_start#
- * has more elements than are used.
- */
- unsigned int max_dim;
-
- /**
- * Number of rows that this sparsity
- * structure shall represent.
- */
- unsigned int rows;
-
- /**
- * Number of columns that this sparsity
- * structure shall represent.
- */
- unsigned int cols;
-
- /**
- * Size of the actually allocated array
- * #colnums#. Here, the same applies as
- * for the #rowstart# array, i.e. it
- * may be larger than the actually used
- * part of the array.
- */
- unsigned int max_vec_len;
-
- /**
- * Maximum number of elements per
- * row. This is set to the value
- * given to the #reinit# function
- * (or to the constructor), or to
- * the maximum row length
- * computed from the vectors in
- * case the more flexible
- * constructors or reinit
- * versions are called. Its value
- * is more or less meaningsless
- * after #compress()# has been
- * called.
- */
- unsigned int max_row_length;
-
- /**
- * Array which hold for each row which
- * is the first element in #colnums#
- * belonging to that row. Note that
- * the size of the array is one larger
- * than the number of rows, because
- * the last element is used for
- * #row=rows#, i.e. the row past the
- * last used one. The value of
- * #rowstart[rows]# equals the index
- * of the element past the end in
- * #colnums#; this way, we are able to
- * write loops like
- * #for (i=rowstart[k]; i<rowstart[k+1]; ++i)#
- * also for the last row.
- *
- * Note that the actual size of the
- * allocated memory may be larger than
- * the region that is used. The actual
- * number of elements that was allocated
- * is stored in #max_dim#.
- */
- unsigned int *rowstart;
-
- /**
- * Array of column numbers. In this array,
- * we store for each non-zero element its
- * column number. The column numbers for
- * the elements in row #r# are stored
- * within the index range
- * #rowstart[r]...rowstart[r+1]#. Therefore
- * to find out whether a given element
- * #(r,c)# exists, we have to check
- * whether the column number #c# exists in
- * the abovementioned range within this
- * array. If it exists, say at position
- * #p# within this array, the value of
- * the respective element in the sparse
- * matrix will also be at position #p#
- * of the values array of that class.
- *
- * At the beginning, all elements of
- * this array are set to #-1# indicating
- * invalid (unused) column numbers
- * (however, note that if this object
- * refers to a square matrix, the diagonal
- * elements are preset, see below). Now, if
- * nonzero elements are added, one column
- * number in the row's respective range
- * after the other is set to the column
- * number of the added element. When
- * compress is called, unused elements
- * (indicated by column numbers #-1#)
- * are eliminated by copying the column
- * number of subsequent rows and the
- * column numbers within each row (with
- * the exception of the diagonal element)
- * are sorted, such that finding whether
- * an element exists and determining its
- * position can be done by a binary search.
- *
- * If this object represents a square
- * matrix, the first element in each
- * row always denotes the diagonal
- * element, i.e.
- * #colnums[rowstart[r]]==r#.
- */
- int *colnums;
-
- /**
- * Store whether the #compress# function
- * was called for this object.
- */
- bool compressed;
-
-
- template <typename number> friend class SparseMatrix;
-};
-
+#include <lac/sparsity_pattern.h>
*
* You have to initialize
* the matrix before usage with
- * #reinit(SparseMatrixStruct)#.
+ * #reinit(SparsityPattern)#.
*/
SparseMatrix ();
* only allowed to be called if the matrix
* to be copied is empty. This is for the
* same reason as for the
- * #SparseMatrixStruct#, see there for the
+ * #SparsityPattern#, see there for the
* details.
*
* If you really want to copy a whole
* long as #reinit# is not called with a
* new sparsity structure.
*/
- SparseMatrix (const SparseMatrixStruct &sparsity);
+ SparseMatrix (const SparsityPattern &sparsity);
/**
* Destructor. Free all memory, but do not
* long as #reinit# is not called with a
* new sparsity structure.
*/
- virtual void reinit (const SparseMatrixStruct &sparsity);
+ virtual void reinit (const SparsityPattern &sparsity);
/**
* Release all memory and return to a state
/**
* Return whether the object is empty. It
* is empty if either both dimensions
- * are zero or no #SparseMatrixStruct#
+ * are zero or no #SparsityPattern#
* is associated.
*/
bool empty () const;
* access to the #i#th element of this
* matrix. The elements are stored in
* a consecutive way, refer to the
- * #SparseMatrixStruct# class for more details.
+ * #SparsityPattern# class for more details.
*
* You should use this interface very
* carefully and only if you are absolutely
* function of objects which operate on
* it.
*/
- const SparseMatrixStruct & get_sparsity_pattern () const;
+ const SparsityPattern & get_sparsity_pattern () const;
/**
* Print the matrix to the given stream,
* use, we subscribe to it using the
* #SmartPointer# class.
*/
- SmartPointer<const SparseMatrixStruct> cols;
+ SmartPointer<const SparsityPattern> cols;
/**
* Array of values for all the
/*---------------------- Inline functions -----------------------------------*/
-
-inline
-unsigned int
-SparseMatrixStruct::n_rows () const
-{
- return rows;
-};
-
-
-
-inline
-unsigned int
-SparseMatrixStruct::n_cols () const
-{
- return cols;
-};
-
-
-
-inline
-bool
-SparseMatrixStruct::is_compressed () const
-{
- return compressed;
-};
-
-
-
-inline
-const unsigned int *
-SparseMatrixStruct::get_rowstart_indices () const
-{
- return rowstart;
-};
-
-
-
-inline
-const int *
-SparseMatrixStruct::get_column_numbers () const
-{
- return colnums;
-};
-
-
-inline
-unsigned int
-SparseMatrixStruct::row_length (const unsigned int row) const
-{
- Assert(row<rows, ExcIndexRange(row,0,rows));
- return rowstart[row+1]-rowstart[row];
-}
-
-inline
-unsigned int
-SparseMatrixStruct::column_number (const unsigned int row,
- const unsigned int index) const
-{
- Assert(row<rows, ExcIndexRange(row,0,rows));
- Assert(index<row_length(row), ExcIndexRange(index,0,row_length(row)));
-
- return colnums[rowstart[row]+index];
-}
-
-
-inline
-unsigned int
-SparseMatrixStruct::n_nonzero_elements () const
-{
- Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
- Assert (compressed, ExcNotCompressed());
- return rowstart[rows]-rowstart[0];
-};
template <typename number>
const int index = cols->operator()(i,j);
- if (index >= 0) val[index] = value;
+ if (index >= 0)
+ val[index] = value;
};
const int index = cols->operator()(i,j);
- if (index >= 0) val[index] += value;
+ if (index >= 0)
+ val[index] += value;
};
};
+
template <typename number>
inline
number
Assert(index<cols->row_length(row), ExcIndexRange(index,0,cols->row_length(row)));
return val[cols->rowstart[row]+index];
-}
+};
template <typename number>
-SparseMatrix<number>::SparseMatrix (const SparseMatrixStruct &c) :
+SparseMatrix<number>::SparseMatrix (const SparsityPattern &c) :
cols(&c),
val(0),
max_len(0)
template <typename number>
void
-SparseMatrix<number>::reinit (const SparseMatrixStruct &sparsity)
+SparseMatrix<number>::reinit (const SparsityPattern &sparsity)
{
if (cols != 0)
cols->unsubscribe();
template <typename number>
-const SparseMatrixStruct &
+const SparsityPattern &
SparseMatrix<number>::get_sparsity_pattern () const
{
Assert (cols != 0, ExcMatrixNotInitialized());
// first define an alias to the sparsity
// pattern of the matrix, since this
// will be used quite often
- const SparseMatrixStruct &structure
+ const SparsityPattern &structure
= matrix->get_sparsity_pattern();
map<unsigned int, unsigned int> local_index;
// entries in this row, and
// 2 the position within this
// row (as stored in the
- // sparsematrixstruct object
+ // SparsityPattern object
//
// since we do not explicitely
// consider nonsysmmetric sparsity
// first define an alias to the sparsity
// pattern of the matrix, since this
// will be used quite often
- const SparseMatrixStruct &structure
+ const SparsityPattern &structure
= matrix->get_sparsity_pattern();
// space to be used for local
// entries in this row, and
// 2 the position within this
// row (as stored in the
- // sparsematrixstruct object
+ // SparsityPattern object
//
// since we do not explicitely
// consider nonsysmmetric sparsity
--- /dev/null
+/*---------------------------- sparsity_pattern.h ---------------------------*/
+/* $Id$ */
+#ifndef __sparsity_pattern_H
+#define __sparsity_pattern_H
+/*---------------------------- sparsity_pattern.h ---------------------------*/
+
+
+
+#include <base/exceptions.h>
+#include <base/subscriptor.h>
+#include <lac/forward_declarations.h>
+
+#include <vector>
+
+
+
+
+/**
+ * Structure representing the sparsity pattern of a sparse matrix.
+ *
+ * The following picture will illustrate the relation between the
+ * #SparsityPattern# an the #SparseMatrix#.
+ *
+ * \begin{verbatim}
+ * SparsityPattern: \
+ * |
+ * _________________________ |
+ * rowstart |0 | 4| 8|11|13|.... |
+ * |__|__|__|__|__|__________ |
+ * | \ \ |
+ * | \ \__ |
+ * | \ \ |
+ * | \ \__ |
+ * \ / \ \ |
+ * | \ \__ |
+ * | \ \ |
+ * | \ \__ |
+ * | \ \ |
+ * 0___________4___________8____ \ Position
+ * colnums |3 | 2| 9|17| 1| 4| 6| 8| 4|.. /
+ * /__|/_|__|__|__|__|__|__|__|__ |
+ * / / |
+ * / \______ _____/ \_____ _____/ |
+ * / \/ \/ |
+ * / / row = 0 row = 1 |
+ * / / |
+ * / / |
+ * / / |
+ * / /___colnums[1] |
+ * / |
+ * /_________colnums[0] |
+ * |
+ * /
+ * \end{verbatim}
+ *
+ * \begin{verbatim}
+ * For row = 0
+ *
+ * it exists: (0| 3) = colnums[0]
+ * (0| 2) = colnums[1]
+ * (0| 9) = colnums[2]
+ * (0|17) = colnums[3]
+ *
+ * For row = 1
+ *
+ * it exists: (1| 1) = colnums[4]
+ * (1| 4) = colnums[5]
+ * ....
+ *
+ * \end{verbatim}
+ *
+ * \begin{verbatim}
+ * SparseMatrix: \
+ * |
+ * _____________________________ |
+ * val | | | | | | | | | 3|.. \ Value
+ * |__|__|__|__|__|__|__|__|__|__ /
+ * |
+ * |
+ * /
+ * \end{verbatim}
+ *
+ * If you want to get the #3# you need to get its position in the
+ * table above and its value by returning the value of the element on
+ * which the pointer shows, using #*val#. For example #val[8]=3#. Its
+ * position is #colnums[8]# so #row=2#. In other words, if you want to get
+ * the element #a_{24}# you know that #row=2#. To get the element, a
+ * search of #4# form #colnums[rowstart[2]]# to #colnums[rowstart[3]]# is
+ * needed. Then #a_{24}=val[number of the found element] = 3#.
+ *
+ *
+ * @author Original version by Roland Becker, Guido Kanschat, Franz-Theo Suttmeier; lots of enhancements, reorganisation and documentation by Wolfgang Bangerth; some documentation by Rasched Zamni
+ */
+class SparsityPattern : public Subscriptor
+{
+ public:
+ /**
+ * Initialize the matrix empty,
+ * that is with no memory
+ * allocated. This is useful if
+ * you want such objects as
+ * member variables in other
+ * classes. You can make the
+ * structure usable by calling
+ * the #reinit# function.
+ */
+ SparsityPattern ();
+
+ /**
+ * Copy constructor. This constructor is
+ * only allowed to be called if the matrix
+ * structure to be copied is empty. This is
+ * so in order to prevent involuntary
+ * copies of objects for temporaries, which
+ * can use large amounts of computing time.
+ * However, copy constructors are needed
+ * if yo want to use the STL data types
+ * on classes like this, e.g. to write
+ * such statements like
+ * #v.push_back (SparsityPattern());#,
+ * with #v# a vector of #SparsityPattern#
+ * objects.
+ *
+ * Usually, it is sufficient to use the
+ * explicit keyword to disallow unwanted
+ * temporaries, but for the STL vectors,
+ * this does not work. Since copying a
+ * structure like this is not useful
+ * anyway because multiple matrices can
+ * use the same sparsity structure, copies
+ * are only allowed for empty objects, as
+ * described above.
+ */
+ SparsityPattern (const SparsityPattern &);
+
+ /**
+ * Initialize a rectangular matrix with
+ * #m# rows and #n# columns.
+ * The matrix may contain at most #max_per_row#
+ * nonzero entries per row.
+ */
+ SparsityPattern (const unsigned int m,
+ const unsigned int n,
+ const unsigned int max_per_row);
+
+ /**
+ * Initialize a rectangular
+ * matrix with #m# rows and #n#
+ * columns. The maximal number
+ * of nonzero entries for each
+ * row is given by the
+ * #row_lengths# array.
+ */
+ SparsityPattern (const unsigned int m,
+ const unsigned int n,
+ const vector<unsigned int> &row_lengths);
+
+ /**
+ * Initialize a square matrix of dimension
+ * #n# with at most #max_per_row#
+ * nonzero entries per row.
+ */
+ SparsityPattern (const unsigned int n,
+ const unsigned int max_per_row);
+
+ /**
+ * Initialize a square
+ * matrix with #m# rows and #m#
+ * columns. The maximal number
+ * of nonzero entries for each
+ * row is given by the
+ * #row_lengths# array.
+ */
+ SparsityPattern (const unsigned int m,
+ const vector<unsigned int> &row_lengths);
+
+ /**
+ * Copy operator. For this the same holds
+ * as for the copy constructor: it is
+ * declared, defined and fine to be called,
+ * but the latter only for empty objects.
+ */
+ SparsityPattern & operator = (const SparsityPattern &);
+
+ /**
+ * Make a copy with extra off-diagonals.
+ *
+ * This constructs objects intended for
+ * the application of the ILU(n)-method
+ * or other incomplete decompositions.
+ * Therefore, additional to the original
+ * entry structure, space for
+ * #extra_off_diagonals#
+ * side-diagonals is provided on both
+ * sides of the main diagonal.
+ *
+ * #max_per_row# is the maximum number of
+ * nonzero elements per row which this
+ * structure is to hold. It is assumed
+ * that this number is sufficiently large
+ * to accomodate both the elements in
+ * #original# as well as the new
+ * off-diagonal elements created by this
+ * constructor. You will usually want to
+ * give the same number as you gave for
+ * #original# plus the number of side
+ * diagonals times two. You may however
+ * give a larger value if you wish to add
+ * further nonzero entries for the
+ * decomposition based on other criteria
+ * than their being on side-diagonals.
+ *
+ * This function requires that #original#
+ * refer to a square matrix structure.
+ * It shall be compressed. The matrix
+ * structure is not compressed
+ * after this function finishes.
+ */
+ SparsityPattern (const SparsityPattern& original,
+ const unsigned int max_per_row,
+ const unsigned int extra_off_diagonals);
+
+ /**
+ * Destructor.
+ */
+ ~SparsityPattern ();
+
+ /**
+ * Reallocate memory and set up data
+ * structures for a new matrix with
+ * #m# rows and #n# columns,
+ * with at most #max_per_row#
+ * nonzero entries per row.
+ *
+ * This function simply maps its
+ * operations to the other
+ * #reinit# function.
+ */
+ void reinit (const unsigned int m,
+ const unsigned int n,
+ const unsigned int max_per_row);
+
+ /**
+ * Reallocate memory for a matrix
+ * of size #m \times n#. The
+ * number of entries for each row
+ * is taken from the array
+ * #row_lengths# which has to
+ * give this number of each row
+ * #i=1...m#.
+ *
+ * If #m*n==0# all memory is freed,
+ * resulting in a total reinitialization
+ * of the object. If it is nonzero, new
+ * memory is only allocated if the new
+ * size extends the old one. This is done
+ * to save time and to avoid fragmentation
+ * of the heap.
+ */
+ void reinit (const unsigned int m,
+ const unsigned int n,
+ const vector<unsigned int> &row_lengths);
+
+ /**
+ * This function compresses the sparsity
+ * structure that this object represents.
+ * It does so by eliminating unused
+ * entries and sorting the remaining
+ * ones to allow faster access by usage
+ * of binary search algorithms. A special
+ * sorting scheme is used for the diagonal
+ * entry of square matrices, which is
+ * always the first entry of each row.
+ *
+ * The memory which is no more
+ * needed is released.
+ *
+ * #SparseMatrix# objects require the
+ * #SparsityPattern# objects they are
+ * initialized with to be compressed, to
+ * reduce memory requirements.
+ */
+ void compress ();
+
+ /**
+ * Return whether the object is empty. It
+ * is empty if no memory is allocated,
+ * which is the same as that both
+ * dimensions are zero.
+ */
+ bool empty () const;
+
+ /**
+ * Return the maximum number of entries per
+ * row. Before compression, this equals the
+ * number given to the constructor, while
+ * after compression, it equals the maximum
+ * number of entries actually allocated by
+ * the user.
+ */
+ unsigned int max_entries_per_row () const;
+
+ /**
+ * Return the index of the matrix
+ * element with row number #i# and
+ * column number #j#. If the matrix
+ * element is not a nonzero one,
+ * return -1.
+ *
+ * This function is usually called
+ * by the #operator()# of the
+ * #SparseMatrix#. It shall only be
+ * called for compressed sparsity
+ * patterns, since in this case
+ * searching whether the entry
+ * exists can be done quite fast
+ * with a binary sort algorithm
+ * because the column numbers are
+ * sorted.
+ */
+ int operator() (const unsigned int i, const unsigned int j) const;
+
+ /**
+ * Add a nonzero entry to the matrix.
+ * This function may only be called
+ * for non-compressed sparsity patterns.
+ *
+ * If the entry already exists, nothing
+ * bad happens.
+ */
+ void add (const unsigned int i, const unsigned int j);
+
+ /**
+ * This matrix adds a whole connectivity
+ * list to the sparsity structure
+ * respresented by this object. It assumes
+ * the #rowcols# array to be a list of
+ * indices which are all linked together,
+ * i.e. all entries
+ * #(rowcols[i], rowcols[j])# for all
+ * #i,j=0...n# for this sparsity pattern
+ * are created. #n# is assumed to be the
+ * number of elements pointed to by
+ * #rowcols#.
+ */
+ void add_matrix (const unsigned int n, const int* rowcols);
+
+ //////////
+ void add_matrix (const unsigned int m, const unsigned int n,
+ const int* rows, const int* cols);
+
+ /**
+ * Print the sparsity of the matrix
+ * in a format that #gnuplot# understands
+ * and which can be used to plot the
+ * sparsity pattern in a graphical
+ * way. The format consists of pairs
+ * #i j# of nonzero elements, each
+ * representing one entry of this
+ * matrix, one per line of the output
+ * file. Indices are counted from
+ * zero on, as usual. Since sparsity
+ * patterns are printed in the same
+ * way as matrices are displayed, we
+ * print the negative of the column
+ * index, which means that the
+ * #(0,0)# element is in the top left
+ * rather than in the bottom left
+ * corner.
+ *
+ * Print the sparsity pattern in
+ * gnuplot by setting the data style
+ * to dots or points and use the
+ * #plot# command.
+ */
+ void print_gnuplot (ostream &out) const;
+
+ /**
+ * Return number of rows of this
+ * matrix, which equals the dimension
+ * of the image space.
+ */
+ unsigned int n_rows () const;
+
+ /**
+ * Return number of columns of this
+ * matrix, which equals the dimension
+ * of the range space.
+ */
+ unsigned int n_cols () const;
+
+ /**
+ * Number of entries in a specific row.
+ */
+ unsigned int row_length (const unsigned int row) const;
+
+ /**
+ * Access to column number field.
+ * Return the column number of
+ * the #index#th entry in #row#.
+ */
+ unsigned int column_number (const unsigned int row,
+ const unsigned int index) const;
+
+ /**
+ * Compute the bandwidth of the matrix
+ * represented by this structure. The
+ * bandwidth is the maximum of
+ * $|i-j|$ for which the index pair
+ * $(i,j)$ represents a nonzero entry
+ * of the matrix.
+ */
+ unsigned int bandwidth () 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.
+ *
+ * This function may only be called if the
+ * matrix struct is compressed. It does not
+ * make too much sense otherwise anyway.
+ */
+ unsigned int n_nonzero_elements () const;
+
+ /**
+ * Return whether the structure is
+ * compressed or not.
+ */
+ bool is_compressed () const;
+
+ /**
+ * This is kind of an expert mode. Get
+ * access to the rowstart array, but
+ * read-only.
+ *
+ * Use of this function is highly
+ * deprecated. Use #row_length#
+ * and #column_number# instead.
+ *
+ * Though the return value is declared
+ * #const#, you should be aware that it
+ * may change if you call any nonconstant
+ * function of objects which operate on
+ * it.
+ *
+ * You should use this interface very
+ * carefully and only if you are absolutely
+ * sure to know what you do. You should
+ * also note that the structure of these
+ * arrays may change over time.
+ * If you change the layout yourself, you
+ * should also rename this function to
+ * avoid programs relying on outdated
+ * information! */
+ const unsigned int * get_rowstart_indices () const;
+
+ /**
+ * This is kind of an expert mode: get
+ * access to the colnums array, but
+ * readonly.
+ *
+ * Use of this function is highly
+ * deprecated. Use #row_length#
+ * and #column_number# instead.
+ *
+ * Though the return value is declared
+ * #const#, you should be aware that it
+ * may change if you call any nonconstant
+ * function of objects which operate on
+ * it.
+ *
+ * You should use this interface very
+ * carefully and only if you are absolutely
+ * sure to know what you do. You should
+ * also note that the structure of these
+ * arrays may change over time.
+ * If you change the layout yourself, you
+ * should also rename this function to
+ * avoid programs relying on outdated
+ * information!
+ */
+ const int * get_column_numbers () const;
+
+
+ /**
+ * Exception
+ */
+ DeclException1 (ExcInvalidNumber,
+ int,
+ << "The provided number is invalid here: " << arg1);
+ /**
+ * Exception
+ */
+ DeclException2 (ExcInvalidIndex,
+ int, int,
+ << "The given index " << arg1
+ << " should be less than " << arg2 << ".");
+ /**
+ * Exception
+ */
+ DeclException2 (ExcNotEnoughSpace,
+ int, int,
+ << "Upon entering a new entry to row " << arg1
+ << ": there was no free entry any more. " << endl
+ << "(Maximum number of entries for this row: "
+ << arg2 << "; maybe the matrix is already compressed?)");
+ /**
+ * Exception
+ */
+ DeclException0 (ExcNotCompressed);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcMatrixIsCompressed);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcEmptyObject);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcInternalError);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcIO);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcInvalidConstructorCall);
+ /**
+ * Exception
+ */
+ DeclException0 (ExcNotSquare);
+
+ private:
+ /**
+ * Maximum number of rows that can
+ * be stored in the #row_start# array.
+ * Since reallocation of that array
+ * only happens if the present one is
+ * too small, but never when the size
+ * of this matrix structure shrinks,
+ * #max_dim# might be larger than
+ * #rows# and in this case #row_start#
+ * has more elements than are used.
+ */
+ unsigned int max_dim;
+
+ /**
+ * Number of rows that this sparsity
+ * structure shall represent.
+ */
+ unsigned int rows;
+
+ /**
+ * Number of columns that this sparsity
+ * structure shall represent.
+ */
+ unsigned int cols;
+
+ /**
+ * Size of the actually allocated array
+ * #colnums#. Here, the same applies as
+ * for the #rowstart# array, i.e. it
+ * may be larger than the actually used
+ * part of the array.
+ */
+ unsigned int max_vec_len;
+
+ /**
+ * Maximum number of elements per
+ * row. This is set to the value
+ * given to the #reinit# function
+ * (or to the constructor), or to
+ * the maximum row length
+ * computed from the vectors in
+ * case the more flexible
+ * constructors or reinit
+ * versions are called. Its value
+ * is more or less meaningsless
+ * after #compress()# has been
+ * called.
+ */
+ unsigned int max_row_length;
+
+ /**
+ * Array which hold for each row which
+ * is the first element in #colnums#
+ * belonging to that row. Note that
+ * the size of the array is one larger
+ * than the number of rows, because
+ * the last element is used for
+ * #row=rows#, i.e. the row past the
+ * last used one. The value of
+ * #rowstart[rows]# equals the index
+ * of the element past the end in
+ * #colnums#; this way, we are able to
+ * write loops like
+ * #for (i=rowstart[k]; i<rowstart[k+1]; ++i)#
+ * also for the last row.
+ *
+ * Note that the actual size of the
+ * allocated memory may be larger than
+ * the region that is used. The actual
+ * number of elements that was allocated
+ * is stored in #max_dim#.
+ */
+ unsigned int *rowstart;
+
+ /**
+ * Array of column numbers. In this array,
+ * we store for each non-zero element its
+ * column number. The column numbers for
+ * the elements in row #r# are stored
+ * within the index range
+ * #rowstart[r]...rowstart[r+1]#. Therefore
+ * to find out whether a given element
+ * #(r,c)# exists, we have to check
+ * whether the column number #c# exists in
+ * the abovementioned range within this
+ * array. If it exists, say at position
+ * #p# within this array, the value of
+ * the respective element in the sparse
+ * matrix will also be at position #p#
+ * of the values array of that class.
+ *
+ * At the beginning, all elements of
+ * this array are set to #-1# indicating
+ * invalid (unused) column numbers
+ * (however, note that if this object
+ * refers to a square matrix, the diagonal
+ * elements are preset, see below). Now, if
+ * nonzero elements are added, one column
+ * number in the row's respective range
+ * after the other is set to the column
+ * number of the added element. When
+ * compress is called, unused elements
+ * (indicated by column numbers #-1#)
+ * are eliminated by copying the column
+ * number of subsequent rows and the
+ * column numbers within each row (with
+ * the exception of the diagonal element)
+ * are sorted, such that finding whether
+ * an element exists and determining its
+ * position can be done by a binary search.
+ *
+ * If this object represents a square
+ * matrix, the first element in each
+ * row always denotes the diagonal
+ * element, i.e.
+ * #colnums[rowstart[r]]==r#.
+ */
+ int *colnums;
+
+ /**
+ * Store whether the #compress# function
+ * was called for this object.
+ */
+ bool compressed;
+
+
+ template <typename number> friend class SparseMatrix;
+};
+
+
+
+
+/*---------------------- Inline functions -----------------------------------*/
+
+
+
+inline
+unsigned int
+SparsityPattern::n_rows () const
+{
+ return rows;
+};
+
+
+
+inline
+unsigned int
+SparsityPattern::n_cols () const
+{
+ return cols;
+};
+
+
+
+inline
+bool
+SparsityPattern::is_compressed () const
+{
+ return compressed;
+};
+
+
+
+inline
+const unsigned int *
+SparsityPattern::get_rowstart_indices () const
+{
+ return rowstart;
+};
+
+
+
+inline
+const int *
+SparsityPattern::get_column_numbers () const
+{
+ return colnums;
+};
+
+
+inline
+unsigned int
+SparsityPattern::row_length (const unsigned int row) const
+{
+ Assert(row<rows, ExcIndexRange(row,0,rows));
+ return rowstart[row+1]-rowstart[row];
+}
+
+inline
+unsigned int
+SparsityPattern::column_number (const unsigned int row,
+ const unsigned int index) const
+{
+ Assert(row<rows, ExcIndexRange(row,0,rows));
+ Assert(index<row_length(row), ExcIndexRange(index,0,row_length(row)));
+
+ return colnums[rowstart[row]+index];
+}
+
+
+inline
+unsigned int
+SparsityPattern::n_nonzero_elements () const
+{
+ Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
+ Assert (compressed, ExcNotCompressed());
+ return rowstart[rows]-rowstart[0];
+};
+
+
+
+/*---------------------------- sparsity_pattern.h ---------------------------*/
+/* end of #ifndef __sparsity_pattern_H */
+#endif
+/*---------------------------- sparsity_pattern.h ---------------------------*/
#include <numeric>
-SparseMatrixStruct::SparseMatrixStruct () :
+SparsityPattern::SparsityPattern () :
max_dim(0),
max_vec_len(0),
rowstart(0),
-SparseMatrixStruct::SparseMatrixStruct (const SparseMatrixStruct &s) :
+SparsityPattern::SparsityPattern (const SparsityPattern &s) :
Subscriptor(),
max_dim(0),
max_vec_len(0),
-SparseMatrixStruct::SparseMatrixStruct (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row)
+SparsityPattern::SparsityPattern (const unsigned int m,
+ const unsigned int n,
+ const unsigned int max_per_row)
: max_dim(0),
max_vec_len(0),
rowstart(0),
-SparseMatrixStruct::SparseMatrixStruct (const unsigned int m,
- const unsigned int n,
- const vector<unsigned int> &row_lengths)
+SparsityPattern::SparsityPattern (const unsigned int m,
+ const unsigned int n,
+ const vector<unsigned int> &row_lengths)
: max_dim(0),
max_vec_len(0),
rowstart(0),
-SparseMatrixStruct::SparseMatrixStruct (const unsigned int n,
- const unsigned int max_per_row)
+SparsityPattern::SparsityPattern (const unsigned int n,
+ const unsigned int max_per_row)
: max_dim(0),
max_vec_len(0),
rowstart(0),
-SparseMatrixStruct::SparseMatrixStruct (const unsigned int m,
- const vector<unsigned int> &row_lengths)
+SparsityPattern::SparsityPattern (const unsigned int m,
+ const vector<unsigned int> &row_lengths)
: max_dim(0),
max_vec_len(0),
rowstart(0),
};
-SparseMatrixStruct::SparseMatrixStruct (const SparseMatrixStruct &original,
- const unsigned int max_per_row,
- const unsigned int extra_off_diagonals)
+SparsityPattern::SparsityPattern (const SparsityPattern &original,
+ const unsigned int max_per_row,
+ const unsigned int extra_off_diagonals)
: max_dim(0),
max_vec_len(0),
rowstart(0),
-SparseMatrixStruct::~SparseMatrixStruct ()
+SparsityPattern::~SparsityPattern ()
{
if (rowstart != 0) delete[] rowstart;
if (colnums != 0) delete[] colnums;
-SparseMatrixStruct &
-SparseMatrixStruct::operator = (const SparseMatrixStruct &s)
+SparsityPattern &
+SparsityPattern::operator = (const SparsityPattern &s)
{
Assert (s.rowstart == 0, ExcInvalidConstructorCall());
Assert (s.colnums == 0, ExcInvalidConstructorCall());
void
-SparseMatrixStruct::reinit (const unsigned int m,
- const unsigned int n,
- const unsigned int max_per_row)
+SparsityPattern::reinit (const unsigned int m,
+ const unsigned int n,
+ const unsigned int max_per_row)
{
// simply map this function to the
// other #reinit# function
void
-SparseMatrixStruct::reinit (const unsigned int m,
- const unsigned int n,
- const vector<unsigned int> &row_lengths)
+SparsityPattern::reinit (const unsigned int m,
+ const unsigned int n,
+ const vector<unsigned int> &row_lengths)
{
Assert (((m==0) && (n==0)) || (*max_element(row_lengths.begin(), row_lengths.end()) > 0),
ExcInvalidNumber(*max_element(row_lengths.begin(), row_lengths.end())));
void
-SparseMatrixStruct::compress ()
+SparsityPattern::compress ()
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
bool
-SparseMatrixStruct::empty () const {
+SparsityPattern::empty () const {
// let's try to be on the safe side of
// life by using multiple possibilities in
// the check for emptiness... (sorry for
unsigned int
-SparseMatrixStruct::max_entries_per_row () const
+SparsityPattern::max_entries_per_row () const
{
// if compress() has not yet been
// called, we can get the maximum
int
-SparseMatrixStruct::operator () (const unsigned int i, const unsigned int j) const
+SparsityPattern::operator () (const unsigned int i, const unsigned int j) const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
Assert (i<rows, ExcInvalidIndex(i,rows));
void
-SparseMatrixStruct::add (const unsigned int i, const unsigned int j)
+SparsityPattern::add (const unsigned int i, const unsigned int j)
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
Assert (i<rows, ExcInvalidIndex(i,rows));
void
-SparseMatrixStruct::add_matrix (const unsigned int n, const int* rowcols)
+SparsityPattern::add_matrix (const unsigned int n, const int* rowcols)
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
for (unsigned int i=0; i<n; ++i)
void
-SparseMatrixStruct::add_matrix (const unsigned int m, const unsigned int n,
- const int* rows, const int* cols)
+SparsityPattern::add_matrix (const unsigned int m, const unsigned int n,
+ const int* rows, const int* cols)
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
for (unsigned i=0; i<m; ++i)
void
-SparseMatrixStruct::print_gnuplot (ostream &out) const
+SparsityPattern::print_gnuplot (ostream &out) const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
for (unsigned int i=0; i<rows; ++i)
unsigned int
-SparseMatrixStruct::bandwidth () const
+SparsityPattern::bandwidth () const
{
Assert ((rowstart!=0) && (colnums!=0), ExcEmptyObject());
unsigned int b=0;
return b;
};
-
-
-
#include <grid/tria_iterator.h>
#include <grid/tria_accessor.h>
#include <grid/grid_generator.h>
-#include <lac/sparse_matrix.h>
+#include <lac/sparsity_pattern.h>
#include <base/parameter_handler.h>
#include <dofs/dof_constraints.h>
#include <numerics/dof_renumbering.h>
cout << " Renumbering degrees of freedom..." << endl;
DoFRenumbering::Cuthill_McKee (*dof);
- SparseMatrixStruct sparsity (dof->n_dofs(),
- dof->max_couplings_between_dofs());
+ SparsityPattern sparsity (dof->n_dofs(),
+ dof->max_couplings_between_dofs());
DoFTools::make_sparsity_pattern (*dof, sparsity);
/**
* Sparsity pattern of the system matrix.
*/
- SparseMatrixStruct system_sparsity;
+ SparsityPattern system_sparsity;
/**
* System matrix.
deallog << " Renumbering degrees of freedom..." << endl;
DoFRenumbering::Cuthill_McKee (*dof);
- SparseMatrixStruct sparsity (dof->n_dofs(),
- dof->max_couplings_between_dofs());
+ SparsityPattern sparsity (dof->n_dofs(),
+ dof->max_couplings_between_dofs());
DoFTools::make_sparsity_pattern (*dof, sparsity);
deallog << "DoFs " << size << endl;
deallog << "Levels: " << tr.n_levels() << endl;
- SparseMatrixStruct structure(size, dof.max_couplings_between_dofs());
+ SparsityPattern structure(size, dof.max_couplings_between_dofs());
DoFTools::make_sparsity_pattern(dof, structure);
structure.compress();
solver.solve(A,u,f,precondition);
u = 0.;
- vector<SparseMatrixStruct> mgstruct(tr.n_levels());
+ vector<SparsityPattern> mgstruct(tr.n_levels());
MGMatrix<SparseMatrix<double> > mgA(0,tr.n_levels()-1);
for (unsigned int i=0;i<tr.n_levels();++i)
{
for (unsigned int step=1;step < 5; ++step)
{
deallog << "smoothing-steps" << step << endl;
- SparseMatrixStruct structure(size, dof.max_couplings_between_dofs());
+ SparsityPattern structure(size, dof.max_couplings_between_dofs());
DoFTools::make_sparsity_pattern(dof, structure);
ConstraintMatrix hanging_nodes;
SolverControl control(20, 1.e-12, true);
SolverRichardson<> solver(control, mem);
- vector<SparseMatrixStruct> mgstruct(tr.n_levels());
+ vector<SparsityPattern> mgstruct(tr.n_levels());
MGMatrix<SparseMatrix<double> > mgA(0,tr.n_levels()-1);
for (unsigned int i=0;i<tr.n_levels();++i)
{
const Quadrature<dim> &quadrature;
const Quadrature<dim-1> &quadrature_face;
ConstraintMatrix constraints;
- SparseMatrixStruct system_sparsity;
+ SparsityPattern system_sparsity;
SparseMatrix<double> mass_matrix, laplace_matrix;
Vector<double> u, v;
StatisticData statistic_data;
* The first parameter is simply passed
* down to the base class.
*/
- UserMatrix (const SparseMatrixStruct &sparsity,
+ UserMatrix (const SparsityPattern &sparsity,
Preconditioning p) :
SparseMatrix<double>(sparsity),
preconditioning (p) {};
deallog << "Level " << level << " size " << size << endl;
// Make matrix
- vector<SparseMatrixStruct > structure(maxlevel+1);
+ vector<SparsityPattern> structure(maxlevel+1);
MGMatrix<SparseMatrix<double> > A(minlevel,maxlevel);
FDMatrix testproblem(size, size);
// Make matrix
FDMatrix testproblem(size, size);
- SparseMatrixStruct structure(dim, dim, 5);
+ SparsityPattern structure(dim, dim, 5);
testproblem.build_structure(structure);
structure.compress();
SparseMatrix<double> A(structure);
{}
void
-FDMatrix::build_structure(SparseMatrixStruct& structure) const
+FDMatrix::build_structure(SparsityPattern& structure) const
{
for(unsigned int i=0;i<=ny-2;i++)
{
void
FDMGTransfer::build_matrix(unsigned int nx, unsigned int ny,
- SparseMatrixStruct& structure, SparseMatrix<double>& matrix)
+ SparsityPattern& structure, SparseMatrix<double>& matrix)
{
structure.reinit((nx-1)*(ny-1),(2*nx-1)*(2*ny-1),9);
/**
* Generate the matrix structure.
*/
- void build_structure(SparseMatrixStruct& structure) const;
+ void build_structure(SparsityPattern& structure) const;
/**
* Fill the matrix with values.
/**
* Prolongation matrix structures.
*/
- vector<SparseMatrixStruct > structures;
+ vector<SparsityPattern> structures;
/**
* Prolongation matrices.
*/
* fine to coarse (#vmult#).
*/
void build_matrix(unsigned int nx, unsigned int ny,
- SparseMatrixStruct&, SparseMatrix<double>&);
+ SparsityPattern&, SparseMatrix<double>&);
};