From: bangerth Date: Mon, 18 Jun 2007 14:52:01 +0000 (+0000) Subject: Integrate the CompressedSetSparsityPattern class fully into the library. Create a... X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=69164f2613601469a16e51feceb56f4829874476;p=dealii-svn.git Integrate the CompressedSetSparsityPattern class fully into the library. Create a block version of it. Rename the CompressedBlock* classes to BlockCompressed*. Use the opportunity to significantly expand the documentation of the LAC classes. git-svn-id: https://svn.dealii.org/trunk@14783 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/include/dofs/dof_constraints.h b/deal.II/deal.II/include/dofs/dof_constraints.h index 3b1cfb8d8f..9d815b535c 100644 --- a/deal.II/deal.II/include/dofs/dof_constraints.h +++ b/deal.II/deal.II/include/dofs/dof_constraints.h @@ -30,7 +30,8 @@ class SparsityPattern; class CompressedSparsityPattern; class CompressedSetSparsityPattern; class BlockSparsityPattern; -class CompressedBlockSparsityPattern; +class BlockCompressedSparsityPattern; +class BlockCompressedSetSparsityPattern; template class SparseMatrix; template class BlockSparseMatrix; class BlockIndices; @@ -689,15 +690,20 @@ class ConstraintMatrix : public Subscriptor */ void condense (CompressedSetSparsityPattern &sparsity) const; - void condense_fast (CompressedSparsityPattern &sparsity) const; - /** * Same function as above, but * condenses square compressed * sparsity patterns. */ - void condense (CompressedBlockSparsityPattern &sparsity) const; + void condense (BlockCompressedSparsityPattern &sparsity) const; + /** + * Same function as above, but + * condenses square compressed + * sparsity patterns. + */ + void condense (BlockCompressedSetSparsityPattern &sparsity) const; + /** * Condense a given matrix. The associated diff --git a/deal.II/deal.II/include/dofs/dof_handler.h b/deal.II/deal.II/include/dofs/dof_handler.h index 55283f2cee..b2115f03bd 100644 --- a/deal.II/deal.II/include/dofs/dof_handler.h +++ b/deal.II/deal.II/include/dofs/dof_handler.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -282,7 +282,7 @@ class DoFHandler : public Subscriptor * on the finite element and the maximum * number of cells meeting at a vertex. * The number holds for the constrained - * matrix also. + * matrix as well. * * The determination of the number of * couplings can be done by simple @@ -290,31 +290,27 @@ class DoFHandler : public Subscriptor * found in the implementation of this * function. * - * Note that this function is - * most often used to determine - * the maximal row length for - * sparsity - * patterns. Unfortunately, the - * while the estimates returned - * by this function are rather - * accurate in 1d and 2d, they - * are often significantly too - * high in 3d, leading the - * SparsityPattern class to - * allocate much too much memory - * in some cases. Unless someone - * comes around to improving the - * present function for 3d, there - * is not very much one can do - * about these cases. The typical - * way to work around this - * problem is to use an - * intermediate compressed - * sparsity pattern that only - * allocates memory on - * demand. Refer to the @ref - * step_11 "step-11" example - * program on how to do this. + * Note that this function is most often + * used to determine the maximal row + * length for sparsity + * patterns. Unfortunately, while the + * estimates returned by this function + * are rather accurate in 1d and 2d, they + * are often significantly too high in + * 3d, leading the SparsityPattern class + * to allocate much too much memory in + * some cases. Unless someone comes + * around to improving the present + * function for 3d, there is not very + * much one can do about these cases. The + * typical way to work around this + * problem is to use an intermediate + * compressed sparsity pattern that only + * allocates memory on demand. Refer to + * the @ref step_11 "step-11" example + * program on how to do this. The problem + * is also discussed in the documentation + * of the module on @ref Sparsity. */ unsigned int max_couplings_between_dofs () const; diff --git a/deal.II/deal.II/include/dofs/dof_tools.h b/deal.II/deal.II/include/dofs/dof_tools.h index af9d21d4aa..51048a1c09 100644 --- a/deal.II/deal.II/include/dofs/dof_tools.h +++ b/deal.II/deal.II/include/dofs/dof_tools.h @@ -383,7 +383,8 @@ class DoFTools * SparsityPattern, * CompressedSparsityPattern, * BlockSparsityPattern, - * CompressedBlockSparsityPattern, + * BlockCompressedSparsityPattern, + * BlockCompressedSetSparsityPattern, * or any other class that * satisfies similar * requirements. It is assumed @@ -468,7 +469,8 @@ class DoFTools * SparsityPattern, * CompressedSparsityPattern, * BlockSparsityPattern, - * CompressedBlockSparsityPattern, + * BlockCompressedSparsityPattern, + * BlockCompressedSetSparsityPattern, * or any other class that * satisfies similar * requirements. @@ -560,8 +562,9 @@ class DoFTools * pattern may be SparsityPattern, * CompressedSparsityPattern, * BlockSparsityPattern, - * CompressedBlockSparsityPattern, or any - * other class that satisfies similar + * BlockCompressedSparsityPattern, + * BlockCompressedSetSparsityPattern, or + * any other class that satisfies similar * requirements. It is assumed that the * size of the sparsity pattern is * already correct. diff --git a/deal.II/deal.II/include/hp/dof_handler.h b/deal.II/deal.II/include/hp/dof_handler.h index caea3b6ae3..82014169e4 100644 --- a/deal.II/deal.II/include/hp/dof_handler.h +++ b/deal.II/deal.II/include/hp/dof_handler.h @@ -221,11 +221,13 @@ namespace hp * The number holds for the constrained * matrix also. * - * The determination of the number of - * couplings can be done by simple - * picture drawing. An example can be - * found in the implementation of this - * function. + * As for + * DoFHandler::max_couplings_between_dofs(), + * the result of this function is often + * not very accurate for 3d and/or high + * polynomial degrees. The consequences + * are discussed in the documentation + * of the module on @ref Sparsity. */ unsigned int max_couplings_between_dofs () const; diff --git a/deal.II/deal.II/source/dofs/dof_constraints.cc b/deal.II/deal.II/source/dofs/dof_constraints.cc index a895f2e7df..77aa393b69 100644 --- a/deal.II/deal.II/source/dofs/dof_constraints.cc +++ b/deal.II/deal.II/source/dofs/dof_constraints.cc @@ -1044,104 +1044,6 @@ void ConstraintMatrix::condense (CompressedSparsityPattern &sparsity) const } - -void ConstraintMatrix::condense_fast (CompressedSparsityPattern &sparsity) const -{ - /* - Assert (sorted == true, ExcMatrixNotClosed()); - Assert (sparsity.n_rows() == sparsity.n_cols(), - ExcNotQuadratic()); - - // store for each index whether it must be - // distributed or not. If entry is - // deal_II_numbers::invalid_unsigned_int, - // no distribution is necessary. - // otherwise, the number states which line - // in the constraint matrix handles this - // index - std::vector distribute(sparsity.n_rows(), - deal_II_numbers::invalid_unsigned_int); - - for (unsigned int c=0; c row_cache; - for (unsigned int j=0; j::iterator col_num = row_cache.begin (); - - for (; col_num != row_cache.end (); ++col_num) - { - const unsigned int column = *col_num; - - if (distribute[column] != deal_II_numbers::invalid_unsigned_int) - { - // row - for (unsigned int q=0; - q!=lines[distribute[column]].entries.size(); - ++q) - { - const unsigned int - new_col = lines[distribute[column]].entries[q].first; - - sparsity.add (row, new_col); - }; - }; - } - } - else - // row must be distributed - { - std::set::iterator col_num = row_cache.begin (); - - for (; col_num != row_cache.end (); ++col_num) - { - const unsigned int column = *col_num; - - if (distribute[column] == deal_II_numbers::invalid_unsigned_int) - // 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] - for (unsigned int p=0; p!=lines[distribute[row]].entries.size(); ++p) - for (unsigned int q=0; - q!=lines[distribute[column]] - .entries.size(); ++q) - sparsity.add (lines[distribute[row]].entries[p].first, - lines[distribute[column]] - .entries[q].first); - }; - } - - // Now copy stuff back to sparsity pattern - std::set::iterator col_num = row_cache.begin (); - for (; col_num != row_cache.end (); ++col_num) - { - } - }; - */ -} - - void ConstraintMatrix::condense (CompressedSetSparsityPattern &sparsity) const { Assert (sorted == true, ExcMatrixNotClosed()); @@ -1166,12 +1068,11 @@ void ConstraintMatrix::condense (CompressedSetSparsityPattern &sparsity) const { if (distribute[row] == deal_II_numbers::invalid_unsigned_int) { - // regular line. loop over - // cols. note that as we - // proceed to distribute - // cols, the loop may get - // longer - CompressedSetSparsityPattern::CSSPIterator col_num = sparsity.row_begin (row); + // 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) { @@ -1201,7 +1102,7 @@ void ConstraintMatrix::condense (CompressedSetSparsityPattern &sparsity) const else // row must be distributed { - CompressedSetSparsityPattern::CSSPIterator col_num = sparsity.row_begin (row); + CompressedSetSparsityPattern::row_iterator col_num = sparsity.row_begin (row); for (; col_num != sparsity.row_end (row); ++col_num) { @@ -1360,7 +1261,7 @@ void ConstraintMatrix::condense (BlockSparsityPattern &sparsity) const -void ConstraintMatrix::condense (CompressedBlockSparsityPattern &sparsity) const +void ConstraintMatrix::condense (BlockCompressedSparsityPattern &sparsity) const { Assert (sorted == true, ExcMatrixNotClosed()); Assert (sparsity.n_rows() == sparsity.n_cols(), @@ -1702,8 +1603,12 @@ add_entries_local_to_global (const std::vector (const std::vector &, - CompressedBlockSparsityPattern &, +add_entries_local_to_global (const std::vector &, + BlockCompressedSparsityPattern &, + const bool) const; +template void ConstraintMatrix:: +add_entries_local_to_global (const std::vector &, + BlockCompressedSetSparsityPattern &, const bool) const; diff --git a/deal.II/deal.II/source/dofs/dof_tools.cc b/deal.II/deal.II/source/dofs/dof_tools.cc index 30e0f47869..b6a1d0ffc4 100644 --- a/deal.II/deal.II/source/dofs/dof_tools.cc +++ b/deal.II/deal.II/source/dofs/dof_tools.cc @@ -4972,6 +4972,12 @@ DoFTools::make_sparsity_pattern, CompressedSparsityPattern &sparsity, const ConstraintMatrix &); template void +DoFTools::make_sparsity_pattern, + CompressedSetSparsityPattern> +(const DoFHandler &dof, + CompressedSetSparsityPattern &sparsity, + const ConstraintMatrix &); +template void DoFTools::make_sparsity_pattern, BlockSparsityPattern> (const DoFHandler &dof, @@ -4979,9 +4985,15 @@ DoFTools::make_sparsity_pattern, const ConstraintMatrix &); template void DoFTools::make_sparsity_pattern, - CompressedBlockSparsityPattern> + BlockCompressedSparsityPattern> (const DoFHandler &dof, - CompressedBlockSparsityPattern &sparsity, + BlockCompressedSparsityPattern &sparsity, + const ConstraintMatrix &); +template void +DoFTools::make_sparsity_pattern, + BlockCompressedSetSparsityPattern> +(const DoFHandler &dof, + BlockCompressedSetSparsityPattern &sparsity, const ConstraintMatrix &); template void @@ -5015,9 +5027,15 @@ DoFTools::make_sparsity_pattern, const ConstraintMatrix &); template void DoFTools::make_sparsity_pattern, - CompressedBlockSparsityPattern> + BlockCompressedSparsityPattern> +(const hp::DoFHandler &dof, + BlockCompressedSparsityPattern &sparsity, + const ConstraintMatrix &); +template void +DoFTools::make_sparsity_pattern, + BlockCompressedSetSparsityPattern> (const hp::DoFHandler &dof, - CompressedBlockSparsityPattern &sparsity, + BlockCompressedSetSparsityPattern &sparsity, const ConstraintMatrix &); @@ -5034,6 +5052,12 @@ DoFTools::make_sparsity_pattern, const Table<2,Coupling>&, CompressedSparsityPattern&); template void +DoFTools::make_sparsity_pattern, + CompressedSetSparsityPattern> +(const DoFHandler&, + const Table<2,Coupling>&, + CompressedSetSparsityPattern&); +template void DoFTools::make_sparsity_pattern, BlockSparsityPattern> (const DoFHandler&, @@ -5041,10 +5065,16 @@ DoFTools::make_sparsity_pattern, BlockSparsityPattern&); template void DoFTools::make_sparsity_pattern, - CompressedBlockSparsityPattern> + BlockCompressedSparsityPattern> +(const DoFHandler&, + const Table<2,Coupling>&, + BlockCompressedSparsityPattern&); +template void +DoFTools::make_sparsity_pattern, + BlockCompressedSetSparsityPattern> (const DoFHandler&, const Table<2,Coupling>&, - CompressedBlockSparsityPattern&); + BlockCompressedSetSparsityPattern&); template void @@ -5060,6 +5090,12 @@ DoFTools::make_sparsity_pattern, const Table<2,Coupling>&, CompressedSparsityPattern&); template void +DoFTools::make_sparsity_pattern, + CompressedSetSparsityPattern> +(const hp::DoFHandler&, + const Table<2,Coupling>&, + CompressedSetSparsityPattern&); +template void DoFTools::make_sparsity_pattern, BlockSparsityPattern> (const hp::DoFHandler&, @@ -5067,10 +5103,16 @@ DoFTools::make_sparsity_pattern, BlockSparsityPattern&); template void DoFTools::make_sparsity_pattern, - CompressedBlockSparsityPattern> + BlockCompressedSparsityPattern> +(const hp::DoFHandler&, + const Table<2,Coupling>&, + BlockCompressedSparsityPattern&); +template void +DoFTools::make_sparsity_pattern, + BlockCompressedSetSparsityPattern> (const hp::DoFHandler&, const Table<2,Coupling>&, - CompressedBlockSparsityPattern&); + BlockCompressedSetSparsityPattern&); template void @@ -5086,6 +5128,12 @@ DoFTools::make_sparsity_pattern, const DoFHandler &dof_col, CompressedSparsityPattern &sparsity); template void +DoFTools::make_sparsity_pattern, + CompressedSetSparsityPattern> +(const DoFHandler &dof_row, + const DoFHandler &dof_col, + CompressedSetSparsityPattern &sparsity); +template void DoFTools::make_sparsity_pattern, BlockSparsityPattern> (const DoFHandler &dof_row, @@ -5093,10 +5141,16 @@ DoFTools::make_sparsity_pattern, BlockSparsityPattern &sparsity); template void DoFTools::make_sparsity_pattern, - CompressedBlockSparsityPattern> + BlockCompressedSparsityPattern> +(const DoFHandler &dof_row, + const DoFHandler &dof_col, + BlockCompressedSparsityPattern &sparsity); +template void +DoFTools::make_sparsity_pattern, + BlockCompressedSetSparsityPattern> (const DoFHandler &dof_row, const DoFHandler &dof_col, - CompressedBlockSparsityPattern &sparsity); + BlockCompressedSetSparsityPattern &sparsity); template void DoFTools::make_sparsity_pattern, @@ -5111,6 +5165,12 @@ DoFTools::make_sparsity_pattern, const hp::DoFHandler &dof_col, CompressedSparsityPattern &sparsity); template void +DoFTools::make_sparsity_pattern, + CompressedSetSparsityPattern> +(const hp::DoFHandler &dof_row, + const hp::DoFHandler &dof_col, + CompressedSetSparsityPattern &sparsity); +template void DoFTools::make_sparsity_pattern, BlockSparsityPattern> (const hp::DoFHandler &dof_row, @@ -5118,10 +5178,16 @@ DoFTools::make_sparsity_pattern, BlockSparsityPattern &sparsity); template void DoFTools::make_sparsity_pattern, - CompressedBlockSparsityPattern> + BlockCompressedSparsityPattern> +(const hp::DoFHandler &dof_row, + const hp::DoFHandler &dof_col, + BlockCompressedSparsityPattern &sparsity); +template void +DoFTools::make_sparsity_pattern, + BlockCompressedSetSparsityPattern> (const hp::DoFHandler &dof_row, const hp::DoFHandler &dof_col, - CompressedBlockSparsityPattern &sparsity); + BlockCompressedSetSparsityPattern &sparsity); // #if deal_II_dimension > 1 @@ -5136,15 +5202,25 @@ DoFTools::make_boundary_sparsity_pattern,Compresse const std::vector &, CompressedSparsityPattern &); template void +DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> +(const DoFHandler& dof, + const std::vector &, + CompressedSetSparsityPattern &); +template void DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> (const DoFHandler& dof, const std::vector &, BlockSparsityPattern &); template void -DoFTools::make_boundary_sparsity_pattern,CompressedBlockSparsityPattern> +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> (const DoFHandler& dof, const std::vector &, - CompressedBlockSparsityPattern &); + BlockCompressedSparsityPattern &); +template void +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> +(const DoFHandler& dof, + const std::vector &, + BlockCompressedSetSparsityPattern &); template void DoFTools::make_boundary_sparsity_pattern,SparsityPattern> @@ -5157,15 +5233,25 @@ DoFTools::make_boundary_sparsity_pattern,Compr const std::vector &, CompressedSparsityPattern &); template void +DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> +(const hp::DoFHandler& dof, + const std::vector &, + CompressedSetSparsityPattern &); +template void DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> (const hp::DoFHandler& dof, const std::vector &, BlockSparsityPattern &); template void -DoFTools::make_boundary_sparsity_pattern,CompressedBlockSparsityPattern> +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> (const hp::DoFHandler& dof, const std::vector &, - CompressedBlockSparsityPattern &); + BlockCompressedSparsityPattern &); +template void +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> +(const hp::DoFHandler& dof, + const std::vector &, + BlockCompressedSetSparsityPattern &); template void @@ -5181,17 +5267,29 @@ DoFTools::make_boundary_sparsity_pattern,Compresse const std::vector &dof_to_boundary_mapping, CompressedSparsityPattern &sparsity); template void +DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> +(const DoFHandler& dof, + const FunctionMap::type &boundary_indicators, + const std::vector &dof_to_boundary_mapping, + CompressedSetSparsityPattern &sparsity); +template void DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> (const DoFHandler& dof, const FunctionMap::type &boundary_indicators, const std::vector &dof_to_boundary_mapping, BlockSparsityPattern &sparsity); template void -DoFTools::make_boundary_sparsity_pattern,CompressedBlockSparsityPattern> +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> +(const DoFHandler& dof, + const FunctionMap::type &boundary_indicators, + const std::vector &dof_to_boundary_mapping, + BlockCompressedSparsityPattern &sparsity); +template void +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> (const DoFHandler& dof, const FunctionMap::type &boundary_indicators, const std::vector &dof_to_boundary_mapping, - CompressedBlockSparsityPattern &sparsity); + BlockCompressedSetSparsityPattern &sparsity); template void DoFTools::make_boundary_sparsity_pattern,SparsityPattern> @@ -5206,17 +5304,29 @@ DoFTools::make_boundary_sparsity_pattern,Compr const std::vector &dof_to_boundary_mapping, CompressedSparsityPattern &sparsity); template void +DoFTools::make_boundary_sparsity_pattern,CompressedSetSparsityPattern> +(const hp::DoFHandler& dof, + const FunctionMap::type &boundary_indicators, + const std::vector &dof_to_boundary_mapping, + CompressedSetSparsityPattern &sparsity); +template void DoFTools::make_boundary_sparsity_pattern,BlockSparsityPattern> (const hp::DoFHandler& dof, const FunctionMap::type &boundary_indicators, const std::vector &dof_to_boundary_mapping, BlockSparsityPattern &sparsity); template void -DoFTools::make_boundary_sparsity_pattern,CompressedBlockSparsityPattern> +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSparsityPattern> +(const hp::DoFHandler& dof, + const FunctionMap::type &boundary_indicators, + const std::vector &dof_to_boundary_mapping, + BlockCompressedSparsityPattern &sparsity); +template void +DoFTools::make_boundary_sparsity_pattern,BlockCompressedSetSparsityPattern> (const hp::DoFHandler& dof, const FunctionMap::type &boundary_indicators, const std::vector &dof_to_boundary_mapping, - CompressedBlockSparsityPattern &sparsity); + BlockCompressedSetSparsityPattern &sparsity); template void @@ -5228,13 +5338,21 @@ DoFTools::make_flux_sparsity_pattern,CompressedSpa (const DoFHandler &dof, CompressedSparsityPattern &sparsity); template void +DoFTools::make_flux_sparsity_pattern,CompressedSetSparsityPattern> +(const DoFHandler &dof, + CompressedSetSparsityPattern &sparsity); +template void DoFTools::make_flux_sparsity_pattern,BlockSparsityPattern> (const DoFHandler &dof, BlockSparsityPattern &sparsity); template void -DoFTools::make_flux_sparsity_pattern,CompressedBlockSparsityPattern> +DoFTools::make_flux_sparsity_pattern,BlockCompressedSparsityPattern> (const DoFHandler &dof, - CompressedBlockSparsityPattern &sparsity); + BlockCompressedSparsityPattern &sparsity); +template void +DoFTools::make_flux_sparsity_pattern,BlockCompressedSetSparsityPattern> +(const DoFHandler &dof, + BlockCompressedSetSparsityPattern &sparsity); template void DoFTools::make_flux_sparsity_pattern,SparsityPattern> @@ -5245,13 +5363,21 @@ DoFTools::make_flux_sparsity_pattern,Compresse (const hp::DoFHandler &dof, CompressedSparsityPattern &sparsity); template void +DoFTools::make_flux_sparsity_pattern,CompressedSetSparsityPattern> +(const hp::DoFHandler &dof, + CompressedSetSparsityPattern &sparsity); +template void DoFTools::make_flux_sparsity_pattern,BlockSparsityPattern> (const hp::DoFHandler &dof, BlockSparsityPattern &sparsity); template void -DoFTools::make_flux_sparsity_pattern,CompressedBlockSparsityPattern> +DoFTools::make_flux_sparsity_pattern,BlockCompressedSparsityPattern> +(const hp::DoFHandler &dof, + BlockCompressedSparsityPattern &sparsity); +template void +DoFTools::make_flux_sparsity_pattern,BlockCompressedSetSparsityPattern> (const hp::DoFHandler &dof, - CompressedBlockSparsityPattern &sparsity); + BlockCompressedSetSparsityPattern &sparsity); #if deal_II_dimension > 1 @@ -5268,15 +5394,27 @@ DoFTools::make_flux_sparsity_pattern,CompressedSpa const Table<2,Coupling>&, const Table<2,Coupling>&); template void +DoFTools::make_flux_sparsity_pattern,CompressedSetSparsityPattern> +(const DoFHandler &dof, + CompressedSetSparsityPattern &, + const Table<2,Coupling>&, + const Table<2,Coupling>&); +template void DoFTools::make_flux_sparsity_pattern,BlockSparsityPattern> (const DoFHandler &dof, BlockSparsityPattern &, const Table<2,Coupling>&, const Table<2,Coupling>&); template void -DoFTools::make_flux_sparsity_pattern,CompressedBlockSparsityPattern> +DoFTools::make_flux_sparsity_pattern,BlockCompressedSparsityPattern> +(const DoFHandler &dof, + BlockCompressedSparsityPattern &, + const Table<2,Coupling>&, + const Table<2,Coupling>&); +template void +DoFTools::make_flux_sparsity_pattern,BlockCompressedSetSparsityPattern> (const DoFHandler &dof, - CompressedBlockSparsityPattern &, + BlockCompressedSetSparsityPattern &, const Table<2,Coupling>&, const Table<2,Coupling>&); #endif diff --git a/deal.II/deal.II/source/multigrid/mg_dof_tools.cc b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc index 67b97db72e..808c6baa27 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_tools.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_tools.cc @@ -1532,11 +1532,19 @@ DEAL_II_NAMESPACE_CLOSE #include "mg_tools.pattern.in.h" #undef PATTERN +#define PATTERN CompressedSetSparsityPattern +#include "mg_tools.pattern.in.h" +#undef PATTERN + #define PATTERN BlockSparsityPattern #include "mg_tools.pattern.in.h" #undef PATTERN -#define PATTERN CompressedBlockSparsityPattern +#define PATTERN BlockCompressedSparsityPattern +#include "mg_tools.pattern.in.h" +#undef PATTERN + +#define PATTERN BlockCompressedSetSparsityPattern #include "mg_tools.pattern.in.h" #undef PATTERN diff --git a/deal.II/doc/doxygen/headers/matrices.h b/deal.II/doc/doxygen/headers/matrices.h index 6ccaa3c47a..3c1ade3c03 100644 --- a/deal.II/doc/doxygen/headers/matrices.h +++ b/deal.II/doc/doxygen/headers/matrices.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2006 by the deal.II authors +// Copyright (C) 2003, 2004, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -15,19 +15,25 @@ /** * @defgroup Matrices Matrix classes * - * All matrices in this library have a common minimal interface, defined - * through MATRIX (see Solver documentation). This interface consists of - * functions for multiplication with appropriate vectors. + * deal.II comes with a number of different matrix classes, tailored to the + * various purposes for which matrices are used. For example, there are full + * matrices, sparse matrices using different storage schemes, matrices + * composed of individual blocks, and matrices implemented as interfaces to + * other linear algebra classes. As far as possible, all these implementations + * share a common interface that contains at least the operations necessary to + * write iterative linear solvers (see @ref Solvers), but also element-wise + * access to read from and write to a matrix. * - * We split this module into several parts. Basic matrices are all the matrix - * classes actually storing their entries. Derived matrices use basic - * matrices, but change the meaning of the matrix-vector multiplication. + * This module is split into different parts. @ref Matrix1 "Basic matrices" + * contains all the matrix classes actually storing entries. @ref Matrix2 + * "Derived matrices", on the other hand, only use basic matrices, but + * implement certain operations on them. For example, TransposeMatrix provides + * a matrix-vector multiplication that acts as if the underlying matrix had + * been transposed, without actually ever storing a transposed matrix. * - * Preconditioners are matrix classes as well, since they perform linear + * @ref Preconditioners are matrix classes as well, since they perform linear * operations on vectors. * - * @author Guido Kanschat, 2003 - * * @ingroup LAC */ @@ -36,9 +42,16 @@ * * These are the actual matrix classes provided by deal.II. It is possible to * store values in them and retrieve them. Furthermore, they provide the full - * interface required by linear solvers (see Solver). + * interface required by linear solvers (see @ref Solvers). + * + * Among the matrices in this group are full matrices, different sparse + * matrices, and block matrices. In addition, some of the classes in the + * interfaces to other linear algebra libraries (for example the + * PETScWrappers) are matrices. * - * @author Guido Kanschat, 2003 + * Most of the deal.II sparse matrix classes are separated from their sparsity + * patterns, to make storing several matrices with the same sparsity pattern + * more efficient. See @ref Sparsity for more information. * * @ingroup Matrices */ @@ -48,9 +61,105 @@ * @defgroup Matrix2 Derived matrices * * These matrices are built on top of the basic matrices. They perform special - * operations using the interface defined in Solver. + * operations using the interface defined in @ref Solvers. + * + * @ingroup Matrices + */ + +/** + * @defgroup Sparsity Sparsity patterns + * + * In deal.II, sparsity patterns are typically separated from the actual + * sparse matrices (with the exception of the SparseMatrixEZ class and some + * classes from interfaces to external libraries such as PETSc). The reason is + * that one often has several matrices that share the same sparsity pattern; + * examples include the stiffness and mass matrices necessary for time + * stepping schemes, or the left and right hand side matrix of generalized + * eigenvalue problems. It would therefore be wasteful if each of them had to + * store their sparsity pattern separately. + * + * Consequently, deal.II has sparsity pattern classes that matrix classes + * build on. There are two main groups of sparsity pattern classes, as + * discussed below: + * + * + *

"Static" sparsity patterns

+ * + * The main sparse matrix class in deal.II, SparseMatrix, only stores a value + * for each matrix entry, but not where these entries are located. For this, + * it relies on the information it gets from a sparsity pattern object + * associated with this matrix. This sparsity pattern object must be of type + * SparsityPattern. + * + * Because matrices are large objects and because it is comparatively + * expensive to change them, SparsityPattern objects are built in two phases: + * first, in a "dynamic" phase, one allocates positions where one expects + * matrices built on it to have nonzero entries; in a second "static" phase, + * the representation of these nonzero locations is "compressed" into the + * usual Compressed Row Storage (CSR) format. After this, no new nonzero + * locations can be added any more. Only after compression can a sparsity + * pattern be associated to a matrix, since the latter requires the efficient + * compressed data format of the former. Building a sparsity pattern during + * the dynamic phase often happens with the DoFTools:make_sparsity_pattern() + * function. Although this may appear a restriction, it is typically not a + * significant problem to first build a sparsity pattern and then to write + * into the matrix only in the previously allocated locations, since in finite + * element codes it is normally quite clear which elements of a matrix can + * possibly be nonzero and which are definitely zero. + * + * The advantage of this two-phase generation of a sparsity pattern is that + * when it is actually used with a matrix, a very efficient format is + * available. In particular, the locations of entries are stored in a linear + * array that allows for rapid access friendly to modern CPU types with deep + * hierarchies of caches. Consequently, the static SparsityPattern class is + * the only one on which deal.II's main SparseMatrix class can work. + * + * The main drawback of static sparsity patterns is that their efficient + * construction requires a reasonably good guess how many entries each of the + * rows may maximally have. During the actual construction, for example in the + * DoFTools:make_sparsity_pattern() function, only at most as many entries can + * be allocated as previously stated. This is a problem because it is often + * difficult to estimate the maximal number of entries per row. Consequently, + * a common strategy is to first build and intermediate sparsity pattern that + * uses a less efficient storage scheme during construction of the sparsity + * pattern and later copy it directly into the static, compressed form (see, + * for example the @ref step_11 "step-11", @ref step_18 "step-18", and @ref + * step_27 "step-27" tutorial programs). + * + * + *

"Dynamic" or "compressed" sparsity patterns

+ * + * As explained above, it is often complicated to obtain good estimates for + * the maximal number of entries in each row of a sparsity + * pattern. Consequently, any attempts to allocate a regular SparsityPattern + * with bad estimates requires huge amounts of memory, almost all of which + * will not be used and be de-allocated upon compression. + * + * To avoid this, deal.II contains a number of "dynamic" or "compressed" + * sparsity patterns that only allocate as much memory as necessary to hold + * the currently added entries. While this saves much memory compared to the + * worst-case behavior mentioned above, it requires the use of less efficient + * storage schemes for insertion of elements, and the frequent allocation of + * memory often also takes significant compute time. The tradeoff to avoid + * excessive memory allocation cannot be avoided, however. + * + * In deal.II, the CompressedSparsityPattern and CompressedSetSparsityPattern + * classes implement this "dynamic" memory scheme. They use different storage + * schemes and appear to both have use cases where they are better than the + * respective other. In either case, these classes are typically used in the + * following way: + * @verbatim + * CompressedSparsityPattern compressed_pattern (dof_handler.n_dofs()); + * DoFTools::make_sparsity_pattern (dof_handler, + * compressed_pattern); + * constraints.condense (compressed_pattern); + * + * SparsityPattern finaly_sparsity_pattern; + * final_sparsity_pattern.copy_from (compressed_pattern); + * @endverbatim * - * @author Guido Kanschat, 2003 + * The intermediate, compressed sparsity pattern is directly copied into the + * "compressed" form of the final static pattern. * * @ingroup Matrices */ diff --git a/deal.II/doc/doxygen/headers/preconditioners.h b/deal.II/doc/doxygen/headers/preconditioners.h index 9baa0d8e67..02e01e90e7 100644 --- a/deal.II/doc/doxygen/headers/preconditioners.h +++ b/deal.II/doc/doxygen/headers/preconditioners.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2006 by the deal.II authors +// Copyright (C) 2003, 2004, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -30,4 +30,5 @@ * multiplications, just like the real matrix classes. * * @ingroup LAC + * @ingroup Matrices */ diff --git a/deal.II/doc/doxygen/headers/solvers.h b/deal.II/doc/doxygen/headers/solvers.h index af775e7f42..10b8fa0761 100644 --- a/deal.II/doc/doxygen/headers/solvers.h +++ b/deal.II/doc/doxygen/headers/solvers.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2003, 2004, 2006 by the deal.II authors +// Copyright (C) 2003, 2004, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -14,17 +14,16 @@ * @defgroup Solvers Linear solver classes * * This module groups iterative and direct solvers, eigenvalue solvers, and - * some control classes. All iterative solvers inherit from the class template - * Solver, which provides some basic maintenance methods. + * some control classes. All these classes operate on objects of the + * @ref Matrices "matrix" and @ref Vectors "vector classes" defined in deal.II. * - * The number of iteration steps of iterative solvers is controlled by - * objects of class SolverControl or its derived class - * ReductionControl. - * - * All solvers receive the matrix and vector classes as template - * arguments. Therefore, any objects defining the interface described in the - * documentation of Solver are admissible. These requirements are listed in - * the documentation page of the Solver class. + * In order to work properly, solvers that take matrix and vector classes as + * template arguments require that these classes satisfy a certain minimal + * interface that can be used from inside the solver. For iterative solvers, + * this interface is defined in the Solver class. In addition, solvers are + * controlled using objects of classes that are derived from the SolverControl + * class (for example its derived class ReductionControl), in order to + * determine the maximal number of iterations or a desired tolerance. * * If detected during configuration (see the ReadMe file), some sparse direct * solvers are also supported. diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index e38a0acc2a..8bae2db706 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -745,6 +745,27 @@ inconvenience this causes.

lac

    +
  1. Changed: The CompressedBlockSparsityPattern has been renamed to + BlockCompressedSparsityPattern to be + consistent, since the "block" part builds on the "compressed sparsity + pattern", not the other way around. +
    + (WB 2007/06/17) +

    + +
  2. New: The CompressedSetSparsityPattern + class is an alternative to the CompressedSparsityPattern class that appears to be + better suited for problems that have many entries per row. There is also + a block version, BlockCompressedSetSparsityPattern. The two new + classes can used in all places where a regular compressed sparsity + pattern can also be used. +
    + (Oliver Kayser-Herold, WB 2007/06/03) +

    +
  3. Fixed: The SolverBicgstab class did not handle hitting on the solution early very gracefully (it threw an exception). This is now fixed. diff --git a/deal.II/examples/step-27/step-27.cc b/deal.II/examples/step-27/step-27.cc index 4b571d2f6b..03c210f5c6 100644 --- a/deal.II/examples/step-27/step-27.cc +++ b/deal.II/examples/step-27/step-27.cc @@ -1282,7 +1282,7 @@ void LaplaceProblem<3>::create_coarse_grid () template void LaplaceProblem::run () { - for (unsigned int cycle=0; cycle<30; ++cycle) + for (unsigned int cycle=0; cycle<3; ++cycle) { std::cout << "Cycle " << cycle << ':' << std::endl; diff --git a/deal.II/lac/include/lac/block_sparsity_pattern.h b/deal.II/lac/include/lac/block_sparsity_pattern.h index 3f44fec7ae..2f71b4e46d 100644 --- a/deal.II/lac/include/lac/block_sparsity_pattern.h +++ b/deal.II/lac/include/lac/block_sparsity_pattern.h @@ -21,6 +21,7 @@ #include #include #include +#include #include DEAL_II_NAMESPACE_OPEN @@ -28,22 +29,22 @@ DEAL_II_NAMESPACE_OPEN template class BlockSparseMatrix; class BlockSparsityPattern; -class CompressedBlockSparsityPattern; +class BlockCompressedSparsityPattern; +class BlockCompressedSetSparsityPattern; -/*! @addtogroup Matrix1 +/*! @addtogroup Sparsity *@{ */ /** - * This is the base class for block versions of the sparsity pattern - * and compressed sparsity pattern classes. It has not much - * functionality, but only administrates an array of sparsity pattern - * objects and delegates work to them. It has mostly the same - * interface as has the SparsityPattern and - * CompressedSparsityPattern classes, and simply transforms - * calls to its member functions to calls to the respective member - * functions of the member sparsity patterns. + * This is the base class for block versions of the sparsity pattern and + * compressed sparsity pattern classes. It has not much functionality, but + * only administrates an array of sparsity pattern objects and delegates work + * to them. It has mostly the same interface as has the SparsityPattern, + * CompressedSparsityPattern, and CompressedSetSparsityPattern classes, and + * simply transforms calls to its member functions to calls to the respective + * member functions of the member sparsity patterns. * * The largest difference between the SparsityPattern and * CompressedSparsityPattern classes and this class is that @@ -418,6 +419,8 @@ class BlockSparsityPatternBase : public Subscriptor * adds a few additional member functions, but the main interface * stems from the base class, see there for more information. * + * This class is an example of the "static" type of @ref Sparsity. + * * @author Wolfgang Bangerth, 2000, 2001 */ class BlockSparsityPattern : public BlockSparsityPatternBase @@ -485,7 +488,20 @@ class BlockSparsityPattern : public BlockSparsityPatternBase /** * Copy data from an object of * type - * CompressedBlockSparsityPattern, + * BlockCompressedSparsityPattern, + * i.e. resize this object to the + * size of the given argument, + * and copy over the contents of + * each of the + * subobjects. Previous content + * of this object is lost. + */ + void copy_from (const BlockCompressedSparsityPattern &csp); + + /** + * Copy data from an object of + * type + * BlockCompressedSetSparsityPattern, * i.e. resize this object to the * size of the given argument, * and copy over the contents of @@ -493,19 +509,26 @@ class BlockSparsityPattern : public BlockSparsityPatternBase * subobjects. Previous content * of this object is lost. */ - void copy_from (const CompressedBlockSparsityPattern &csp); + void copy_from (const BlockCompressedSetSparsityPattern &csp); }; /** - * This class extends the base class to implement an array of - * compressed sparsity patterns that can be used to initialize objects - * of type BlockSparsityPattern. It does not add additional - * member functions, but rather acts as a @p typedef to introduce the - * name of this class, without requiring the user to specify the - * templated name of the base class. For information on the interface - * of this class refer to the base class. + * This class extends the base class to implement an array of compressed + * sparsity patterns that can be used to initialize objects of type + * BlockSparsityPattern. It does not add additional member functions, but + * rather acts as a @p typedef to introduce the name of this class, without + * requiring the user to specify the templated name of the base class. For + * information on the interface of this class refer to the base class. The + * individual blocks are based on the CompressedSparistyPattern class. + * + * This class is an example of the "dynamic" type of @ref Sparsity. + * + * Note: This class used to be called + * CompressedBlockSparsityPattern. However, since it's a block wrapper around + * the CompressedSparsityPattern class, this is a misnomer and the class has + * been renamed. * *

    Example

    * Usage of this class is very similar to CompressedSparsityPattern, @@ -521,7 +544,7 @@ class BlockSparsityPattern : public BlockSparsityPatternBase * @skipline dofs_per_block * @until count * - * Now, we are ready to set up the CompressedBlockSparsityPattern. + * Now, we are ready to set up the BlockCompressedSparsityPattern. * * @until collect * @@ -536,7 +559,7 @@ class BlockSparsityPattern : public BlockSparsityPatternBase * * @author Wolfgang Bangerth, 2000, 2001, Guido Kanschat, 2006, 2007 */ -class CompressedBlockSparsityPattern : public BlockSparsityPatternBase +class BlockCompressedSparsityPattern : public BlockSparsityPatternBase { public: @@ -550,7 +573,7 @@ class CompressedBlockSparsityPattern : public BlockSparsityPatternBase& row_block_sizes, + BlockCompressedSparsityPattern (const std::vector& row_block_sizes, const std::vector& col_block_sizes); /** @@ -604,6 +627,120 @@ class CompressedBlockSparsityPattern : public BlockSparsityPatternBaseNote: This class used to be called + * CompressedBlockSparsityPattern. However, since it's a block wrapper around + * the CompressedSetSparsityPattern class, this is a misnomer and the class has + * been renamed. + * + *

    Example

    + * Usage of this class is very similar to CompressedSetSparsityPattern, + * but since the use of block indices causes some additional + * complications, we give a short example. + * + * @dontinclude compressed_block_sparsity_pattern.cc + * + * After the the DoFHandler dof and the ConstraintMatrix + * constraints have been set up with a system element, we + * must count the degrees of freedom in each matrix block: + * + * @skipline dofs_per_block + * @until count + * + * Now, we are ready to set up the BlockCompressedSetSparsityPattern. + * + * @until collect + * + * It is filled as if it were a normal pattern + * + * @until condense + * + * In the end, it is copied to a normal BlockSparsityPattern for later + * use. + * + * @until copy + * + * @author Wolfgang Bangerth, 2000, 2001, Guido Kanschat, 2006, 2007 + */ +class BlockCompressedSetSparsityPattern : public BlockSparsityPatternBase +{ + 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. + */ + BlockCompressedSetSparsityPattern (); + + /** + * Initialize the matrix with the + * given number of block rows and + * columns. The blocks themselves + * are still empty, and you have + * to call collect_sizes() after + * you assign them sizes. + */ + BlockCompressedSetSparsityPattern (const unsigned int n_rows, + const unsigned int n_columns); + + /** + * Initialize the pattern with + * two BlockIndices for the block + * structures of matrix rows and + * columns. This function is + * equivalent to calling the + * previous constructor with the + * length of the two index vector + * and then entering the index + * values. + */ + BlockCompressedSetSparsityPattern (const std::vector& row_block_sizes, + const std::vector& col_block_sizes); + + /** + * Resize the matrix to a tensor + * product of matrices with + * dimensions defined by the + * arguments. + * + * The matrix will have as many + * block rows and columns as + * there are entries in the two + * arguments. The block at + * position (i,j) will + * have the dimensions + * row_block_sizes[i] + * times col_block_sizes[j]. + */ + void reinit (const std::vector< unsigned int > &row_block_sizes, + const std::vector< unsigned int > &col_block_sizes); + + /** + * Allow the use of the reinit + * functions of the base class as + * well. + */ + BlockSparsityPatternBase::reinit; +}; + + /*@}*/ /*---------------------- Template functions -----------------------------------*/ diff --git a/deal.II/lac/include/lac/compressed_set_sparsity_pattern.h b/deal.II/lac/include/lac/compressed_set_sparsity_pattern.h index 63cb2fbaad..90e71ff13c 100644 --- a/deal.II/lac/include/lac/compressed_set_sparsity_pattern.h +++ b/deal.II/lac/include/lac/compressed_set_sparsity_pattern.h @@ -2,7 +2,7 @@ // $Id: compressed_sparsity_pattern.h 14038 2006-10-23 02:46:34Z bangerth $ // Version: $Name$ // -// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -26,7 +26,7 @@ DEAL_II_NAMESPACE_OPEN template class SparseMatrix; -/*! @addtogroup Matrix1 +/*! @addtogroup Sparsity *@{ */ @@ -45,44 +45,12 @@ template class SparseMatrix; * copy the data of this object over to an object of type * SparsityPattern before using it in actual matrices. * - * Another viewpoint is that this class does not need up front - * allocation of a certain amount of memory, but grows as necessary. - * - * - *

    Rationale

    - * - * When constructing the sparsity pattern of a matrix, you usually - * first have to provide an empty sparsity pattern object with a fixed - * maximal number of entries per row. To find out about this maximal - * row length, one usually calls the function - * DoFHandler::max_couplings_between_dofs() which returns an estimate for - * that quantity or DoFTools::compute_row_length_vector(), which gives - * a better estimate for each row. While this estimate is usually - * quite good in 2d and exact in 1d, it is often significantly too - * large in 3d and especially for higher order elements. Furthermore, - * normally only a small fraction of the rows of a matrix will end up - * having the maximal number of nonzero entries per row (usually those - * nodes adjacent to hanging nodes), most have much less. In effect, - * the empty SparsityPattern object has allocated much too much - * memory. Although this unnecessarily allocated memory is later freed - * when SparsityPattern::compress() is called, this overallocation - * has, with higher order elements and in 3d, sometimes been so large - * that the program aborted due to lack of memory. - * - * This class therefore provides an alternative representation of a - * sparsity pattern: we don't specify a maximal row length initially, - * but store a set of column indices indicating possible nonzero - * entries in the sparsity pattern for each row. This is very much - * like the final "compressed" format used in the - * SparsityPattern object after compression, but uses a less - * compact memory storage format, since the exact number of entries - * per row is only known a posteriori and since it may change (for the - * SparsityPattern class, no more changes are allowed after - * compressing it). We can therefore not store all the column indices - * in a big array, but have to use a vector of sets. This can later be - * used to actually initialize a SparsityPattern object with the - * then final set of necessary indices. + * Another viewpoint is that this class does not need up front allocation of a + * certain amount of memory, but grows as necessary. An extensive description + * of sparsity patterns can be found in the documentation of the @ref Sparsity + * module. * + * This class is an example of the "dynamic" type of @ref Sparsity. * *

    Interface

    * @@ -92,20 +60,6 @@ template class SparseMatrix; * function, and the functions inquiring properties of the sparsity * pattern are the same. * - *

    Notes

    - * - * This class is a variation of the CompressedSparsityPattern class. - * Instead of using sorted vectors together with a caching algorithm - * for storing the column indices of NZ entries, the std::set - * container is used. This solution might not be the fastest in - * all situations, but seems to work much better than the - * CompressedSparsityPattern in the context of hp-adaptivity. - * On the other hand, a benchmark where NZ entries were randomly inserted - * into the sparsity pattern revealed that this class is slower - * by a factor 4-6 in this situation. Hence, currently the suggestion - * is to carefully analyse which of the CompressedSparsityPattern - * classes works best in a certain setting. An algorithm which - * performs equally well in all situations still has to be found. * *

    Usage

    * @@ -120,13 +74,37 @@ template class SparseMatrix; * sp.copy_from (compressed_pattern); * @endverbatim * + * See also @ref step_11 "step-11" and @ref step_18 "step-18" for usage + * patterns. + * + *

    Notes

    + * + * This class is a variation of the CompressedSparsityPattern class. + * Instead of using sorted vectors together with a caching algorithm + * for storing the column indices of nonzero entries, the std::set + * container is used. This solution might not be the fastest in + * all situations, but seems to work much better than the + * CompressedSparsityPattern in the context of hp-adaptivity. + * On the other hand, a benchmark where nonzero entries were randomly inserted + * into the sparsity pattern revealed that this class is slower + * by a factor 4-6 in this situation. Hence, currently the suggestion + * is to carefully analyze which of the CompressedSparsityPattern + * classes works best in a certain setting. An algorithm which + * performs equally well in all situations still has to be found. + * * - * @author Wolfgang Bangerth, 2001 + * @author Oliver Kayser-Herold, 2007 */ class CompressedSetSparsityPattern : public Subscriptor { public: - typedef std::set::iterator CSSPIterator; + /** + * An iterator that can be used to + * iterate over the elements of a single + * row. The result of dereferencing such + * an iterator is a column index. + */ + typedef std::set::iterator row_iterator; /** @@ -156,18 +134,6 @@ class CompressedSetSparsityPattern : public Subscriptor * (CompressedSetSparsityPattern());, * with @p v a vector of @p * CompressedSetSparsityPattern 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. */ CompressedSetSparsityPattern (const CompressedSetSparsityPattern &); @@ -177,7 +143,7 @@ class CompressedSetSparsityPattern : public Subscriptor * @p n columns. */ CompressedSetSparsityPattern (const unsigned int m, - const unsigned int n); + const unsigned int n); /** * Initialize a square matrix of @@ -311,8 +277,8 @@ class CompressedSetSparsityPattern : public Subscriptor * Return the column number of * the @p indexth entry in @p row. */ - CSSPIterator row_begin (const unsigned int row) const; - CSSPIterator row_end (const unsigned int row) const; + row_iterator row_begin (const unsigned int row) const; + row_iterator row_end (const unsigned int row) const; /** @@ -327,16 +293,7 @@ class CompressedSetSparsityPattern : public Subscriptor /** * 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. + * allocated through this sparsity pattern. */ unsigned int n_nonzero_elements () const; @@ -354,59 +311,15 @@ class CompressedSetSparsityPattern : public Subscriptor unsigned int cols; /** - * Store some data for each row - * describing which entries of this row - * are nonzero. Data is organized as - * follows: if an entry is added to a - * row, it is first added to the #cache - * variable, irrespective of whether an - * entry with same column number has - * already been added. Only if the cache - * is full do we flush it by removing - * duplicates, removing entries that are - * already stored in the @p entries - * array, sorting everything, and merging - * the two arrays. - * - * The reasoning behind this scheme is - * that memory allocation is expensive, - * and we only want to do it when really - * necessary. Previously (in deal.II - * versions up to 5.0), we used to store - * the column indices inside a std::set, - * but this would allocate 20 bytes each - * time we added an entry. Using the - * present scheme, we only need to - * allocate memory once for every 8 added - * entries, and we waste a lot less - * memory by not using a balanced tree - * for storing column indices. - * - * Since some functions that are @p const - * need to access the data of this - * object, but need to flush caches - * before, the flush_cache() function is - * marked const, and the data members are - * marked @p mutable. - * - * A small testseries about the size of - * the cache showed that the run time of - * a small program just testing the - * compressed sparsity pattern element - * insertion routine ran for 3.6 seconds - * with a cache size of 8, and 4.2 - * seconds with a cache size of 16. We - * deem even smaller cache sizes - * undesirable, since they lead to more - * memory allocations, while larger cache - * sizes lead to waste of memory. The - * original version of this class, with - * one std::set per row took 8.2 seconds - * on the same program. + * For each row of the matrix, store the + * allocated non-zero entries as a + * std::set of column indices. For a + * discussion of storage schemes see the + * CompressedSparsityPattern::Line class. */ struct Line { - std::set entries; + std::set entries; /** * Constructor. @@ -433,6 +346,12 @@ class CompressedSetSparsityPattern : public Subscriptor /*---------------------- Inline functions -----------------------------------*/ +inline +CompressedSetSparsityPattern::Line::Line () +{} + + + inline void CompressedSetSparsityPattern::Line::add (const unsigned int j) @@ -463,7 +382,7 @@ CompressedSetSparsityPattern::n_cols () const inline void CompressedSetSparsityPattern::add (const unsigned int i, - const unsigned int j) + const unsigned int j) { Assert (i class SparseMatrix; -/*! @addtogroup Matrix1 +/*! @addtogroup Sparsity *@{ */ @@ -45,44 +45,12 @@ template class SparseMatrix; * copy the data of this object over to an object of type * SparsityPattern before using it in actual matrices. * - * Another viewpoint is that this class does not need up front - * allocation of a certain amount of memory, but grows as necessary. - * - * - *

    Rationale

    - * - * When constructing the sparsity pattern of a matrix, you usually - * first have to provide an empty sparsity pattern object with a fixed - * maximal number of entries per row. To find out about this maximal - * row length, one usually calls the function - * DoFHandler::max_couplings_between_dofs() which returns an estimate for - * that quantity or DoFTools::compute_row_length_vector(), which gives - * a better estimate for each row. While this estimate is usually - * quite good in 2d and exact in 1d, it is often significantly too - * large in 3d and especially for higher order elements. Furthermore, - * normally only a small fraction of the rows of a matrix will end up - * having the maximal number of nonzero entries per row (usually those - * nodes adjacent to hanging nodes), most have much less. In effect, - * the empty SparsityPattern object has allocated much too much - * memory. Although this unnecessarily allocated memory is later freed - * when SparsityPattern::compress() is called, this overallocation - * has, with higher order elements and in 3d, sometimes been so large - * that the program aborted due to lack of memory. - * - * This class therefore provides an alternative representation of a - * sparsity pattern: we don't specify a maximal row length initially, - * but store a set of column indices indicating possible nonzero - * entries in the sparsity pattern for each row. This is very much - * like the final "compressed" format used in the - * SparsityPattern object after compression, but uses a less - * compact memory storage format, since the exact number of entries - * per row is only known a posteriori and since it may change (for the - * SparsityPattern class, no more changes are allowed after - * compressing it). We can therefore not store all the column indices - * in a big array, but have to use a vector of sets. This can later be - * used to actually initialize a SparsityPattern object with the - * then final set of necessary indices. + * Another viewpoint is that this class does not need up front allocation of a + * certain amount of memory, but grows as necessary. An extensive description + * of sparsity patterns can be found in the documentation of the @ref Sparsity + * module. * + * This class is an example of the "dynamic" type of @ref Sparsity. * *

    Interface

    * @@ -106,6 +74,15 @@ template class SparseMatrix; * sp.copy_from (compressed_pattern); * @endverbatim * + * See also @ref step_11 "step-11" and @ref step_18 "step-18" for usage + * patterns. + * + *

    Notes

    + * + * A variation of this class is the CompressedSetSparsityPattern class that + * appears to be more efficient in some situations, in particular when using + * hp finite elements. See for example the @ref step_27 "step-27" tutorial + * program. * * @author Wolfgang Bangerth, 2001 */ @@ -139,18 +116,6 @@ class CompressedSparsityPattern : public Subscriptor * (CompressedSparsityPattern());, * with @p v a vector of @p * CompressedSparsityPattern 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. */ CompressedSparsityPattern (const CompressedSparsityPattern &); @@ -309,16 +274,7 @@ class CompressedSparsityPattern : public Subscriptor /** * 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. + * allocated through this sparsity pattern. */ unsigned int n_nonzero_elements () const; @@ -357,7 +313,13 @@ class CompressedSparsityPattern : public Subscriptor * versions up to 5.0), we used to store * the column indices inside a std::set, * but this would allocate 20 bytes each - * time we added an entry. Using the + * time we added an entry. (A std::set + * based class has later been revived in + * form of the + * CompressedSetSparsityPattern class, as + * this turned out to be more efficient + * for hp finite element programs such as + * @ref step_27 "step-27"). Using the * present scheme, we only need to * allocate memory once for every 8 added * entries, and we waste a lot less diff --git a/deal.II/lac/include/lac/petsc_block_sparse_matrix.h b/deal.II/lac/include/lac/petsc_block_sparse_matrix.h index 39ffdf70dc..3e83d7c15f 100644 --- a/deal.II/lac/include/lac/petsc_block_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_block_sparse_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -55,6 +55,7 @@ namespace PETScWrappers * matrices. For this, one has to call the collect_sizes() function, for much * the same reason as is documented with the BlockSparsityPattern class. * + * @ingroup Matrix1 * @author Wolfgang Bangerth, 2004 */ class BlockSparseMatrix : public BlockMatrixBase diff --git a/deal.II/lac/include/lac/petsc_block_vector.h b/deal.II/lac/include/lac/petsc_block_vector.h index 9cfb8990a1..97224dab68 100644 --- a/deal.II/lac/include/lac/petsc_block_vector.h +++ b/deal.II/lac/include/lac/petsc_block_vector.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -39,6 +39,7 @@ namespace PETScWrappers * this class handles the actual allocation of vectors and provides functions * that are specific to the underlying vector type. * + * @ingroup Vectors * @author Wolfgang Bangerth, 2004 */ class BlockVector : public BlockVectorBase diff --git a/deal.II/lac/include/lac/petsc_full_matrix.h b/deal.II/lac/include/lac/petsc_full_matrix.h index 900cfefc72..ed89cb741c 100644 --- a/deal.II/lac/include/lac/petsc_full_matrix.h +++ b/deal.II/lac/include/lac/petsc_full_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -39,6 +39,7 @@ namespace PETScWrappers * virtual functions). Only the functions creating a matrix of specific type * differ, and are implemented in this particular class. * + * @ingroup Matrix1 * @author Wolfgang Bangerth, 2004 */ class FullMatrix : public MatrixBase diff --git a/deal.II/lac/include/lac/petsc_matrix_base.h b/deal.II/lac/include/lac/petsc_matrix_base.h index 226871d1e3..aa28eb62bd 100644 --- a/deal.II/lac/include/lac/petsc_matrix_base.h +++ b/deal.II/lac/include/lac/petsc_matrix_base.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -276,6 +276,7 @@ namespace PETScWrappers * before the matrix is actively used. * * @ingroup PETScWrappers + * @ingroup Matrix1 * @author Wolfgang Bangerth, 2004 */ class MatrixBase : public Subscriptor diff --git a/deal.II/lac/include/lac/petsc_parallel_block_sparse_matrix.h b/deal.II/lac/include/lac/petsc_parallel_block_sparse_matrix.h index c7ab820662..6f6dbc1e4a 100644 --- a/deal.II/lac/include/lac/petsc_parallel_block_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_parallel_block_sparse_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -55,6 +55,7 @@ namespace PETScWrappers * matrices. For this, one has to call the collect_sizes() function, for much * the same reason as is documented with the BlockSparsityPattern class. * + * @ingroup Matrix1 * @author Wolfgang Bangerth, 2004 */ class BlockSparseMatrix : public BlockMatrixBase diff --git a/deal.II/lac/include/lac/petsc_parallel_block_vector.h b/deal.II/lac/include/lac/petsc_parallel_block_vector.h index 500a9123f7..a87b9b7361 100644 --- a/deal.II/lac/include/lac/petsc_parallel_block_vector.h +++ b/deal.II/lac/include/lac/petsc_parallel_block_vector.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -49,7 +49,8 @@ namespace PETScWrappers * 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 * @author Wolfgang Bangerth, 2004 */ class BlockVector : public BlockVectorBase diff --git a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h index af4d5afd54..01f40197ea 100644 --- a/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_parallel_sparse_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -104,6 +104,7 @@ namespace PETScWrappers * numbers for all processes available at all processes. * * @ingroup PETScWrappers + * @ingroup Matrix1 * @author Wolfgang Bangerth, 2004 */ class SparseMatrix : public MatrixBase diff --git a/deal.II/lac/include/lac/petsc_parallel_vector.h b/deal.II/lac/include/lac/petsc_parallel_vector.h index d66a9f908f..004784360b 100644 --- a/deal.II/lac/include/lac/petsc_parallel_vector.h +++ b/deal.II/lac/include/lac/petsc_parallel_vector.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -145,6 +145,7 @@ namespace PETScWrappers * necessary. * * @ingroup PETScWrappers + * @ingroup Vectors * @author Wolfgang Bangerth, 2004 */ class Vector : public VectorBase diff --git a/deal.II/lac/include/lac/petsc_sparse_matrix.h b/deal.II/lac/include/lac/petsc_sparse_matrix.h index 1cc9f813dc..7a7de77feb 100644 --- a/deal.II/lac/include/lac/petsc_sparse_matrix.h +++ b/deal.II/lac/include/lac/petsc_sparse_matrix.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -38,6 +38,7 @@ namespace PETScWrappers * differ, and are implemented in this particular class. * * @ingroup PETScWrappers + * @ingroup Matrix1 * @author Wolfgang Bangerth, 2004 */ class SparseMatrix : public MatrixBase diff --git a/deal.II/lac/include/lac/petsc_vector.h b/deal.II/lac/include/lac/petsc_vector.h index 2d02f36801..eb5ce4f0d3 100644 --- a/deal.II/lac/include/lac/petsc_vector.h +++ b/deal.II/lac/include/lac/petsc_vector.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -40,6 +40,7 @@ namespace PETScWrappers * functions). Only the functions creating a vector of specific type differ, * and are implemented in this particular class. * + * @ingroup Vectors * @author Wolfgang Bangerth, 2004 */ class Vector : public VectorBase diff --git a/deal.II/lac/include/lac/petsc_vector_base.h b/deal.II/lac/include/lac/petsc_vector_base.h index eb1b9963a9..a4252f02d3 100644 --- a/deal.II/lac/include/lac/petsc_vector_base.h +++ b/deal.II/lac/include/lac/petsc_vector_base.h @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 2004, 2005, 2006 by the deal.II authors +// Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -35,6 +35,7 @@ template class Vector; * A namespace in which wrapper classes for PETSc objects reside. * * @ingroup PETScWrappers + * @ingroup Vectors * @see @ref SoftwarePETSc * @author Wolfgang Bangerth, 2004 */ diff --git a/deal.II/lac/include/lac/sparsity_pattern.h b/deal.II/lac/include/lac/sparsity_pattern.h index 9af439f4d0..50523baabc 100644 --- a/deal.II/lac/include/lac/sparsity_pattern.h +++ b/deal.II/lac/include/lac/sparsity_pattern.h @@ -33,7 +33,7 @@ class CompressedSetSparsityPattern; -/*! @addtogroup Matrix1 +/*! @addtogroup Sparsity *@{ */ @@ -382,80 +382,10 @@ namespace internals /** * Structure representing the sparsity pattern of a sparse matrix. - * - * The following picture will illustrate the relation between the - * SparsityPattern an the SparseMatrix. * - * @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] | - * | - * / - * @endverbatim - * - * @verbatim - * For row = 0 - * - * there are: (0| 3) = colnums[0] - * (0| 2) = colnums[1] - * (0| 9) = colnums[2] - * (0|17) = colnums[3] - * - * For row = 1 - * - * there are: (1| 1) = colnums[4] - * (1| 4) = colnums[5] - * .... - * - * @endverbatim - * - * @verbatim - * SparseMatrix: \ - * | - * _____________________________ | - * val | | | | | | | | | 3|.. \ Value - * |__|__|__|__|__|__|__|__|__|__ / - * | - * | - * / - * @endverbatim - * - * 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 - * a24 you know that row=2. To get the - * element, a search of 4 form colnums[rowstart[2]] - * to colnums[rowstart[3]] is needed. Then - * a24=val[number of the found element] = - * 3. + * This class is an example of the "static" type of @ref Sparsity. * + * It uses the compressed row storage (CSR) format to store data. * * @author Wolfgang Bangerth, Guido Kanschat and others */ diff --git a/deal.II/lac/source/block_sparsity_pattern.cc b/deal.II/lac/source/block_sparsity_pattern.cc index 68fec80527..7968812b9f 100644 --- a/deal.II/lac/source/block_sparsity_pattern.cc +++ b/deal.II/lac/source/block_sparsity_pattern.cc @@ -282,6 +282,7 @@ BlockSparsityPatternBase::print(std::ostream& out) const template class BlockSparsityPatternBase; template class BlockSparsityPatternBase; +template class BlockSparsityPatternBase; @@ -354,7 +355,7 @@ BlockSparsityPattern::memory_consumption () const void -BlockSparsityPattern::copy_from (const CompressedBlockSparsityPattern &csp) +BlockSparsityPattern::copy_from (const BlockCompressedSparsityPattern &csp) { // delete old content, set block // sizes anew @@ -372,13 +373,32 @@ BlockSparsityPattern::copy_from (const CompressedBlockSparsityPattern &csp) -CompressedBlockSparsityPattern::CompressedBlockSparsityPattern () +void +BlockSparsityPattern::copy_from (const BlockCompressedSetSparsityPattern &csp) +{ + // delete old content, set block + // sizes anew + reinit (csp.n_block_rows(), csp.n_block_cols()); + + // copy over blocks + for (unsigned int i=0; i(n_rows, @@ -386,8 +406,8 @@ CompressedBlockSparsityPattern (const unsigned int n_rows, {} -CompressedBlockSparsityPattern:: -CompressedBlockSparsityPattern (const std::vector& row_indices, +BlockCompressedSparsityPattern:: +BlockCompressedSparsityPattern (const std::vector& row_indices, const std::vector& col_indices) : BlockSparsityPatternBase(row_indices.size(), @@ -401,7 +421,49 @@ CompressedBlockSparsityPattern (const std::vector& row_indices, void -CompressedBlockSparsityPattern::reinit ( +BlockCompressedSparsityPattern::reinit ( + const std::vector< unsigned int > &row_block_sizes, + const std::vector< unsigned int > &col_block_sizes) +{ + this->reinit(row_block_sizes.size(), col_block_sizes.size()); + for (unsigned int i=0;iblock(i,j).reinit(row_block_sizes[i],col_block_sizes[j]); + this->collect_sizes(); +} + + + +BlockCompressedSetSparsityPattern::BlockCompressedSetSparsityPattern () +{} + + + +BlockCompressedSetSparsityPattern:: +BlockCompressedSetSparsityPattern (const unsigned int n_rows, + const unsigned int n_columns) + : + BlockSparsityPatternBase(n_rows, + n_columns) +{} + + +BlockCompressedSetSparsityPattern:: +BlockCompressedSetSparsityPattern (const std::vector& row_indices, + const std::vector& col_indices) + : + BlockSparsityPatternBase(row_indices.size(), + col_indices.size()) +{ + for (unsigned int i=0;iblock(i,j).reinit(row_indices[i],col_indices[j]); + this->collect_sizes(); +} + + +void +BlockCompressedSetSparsityPattern::reinit ( const std::vector< unsigned int > &row_block_sizes, const std::vector< unsigned int > &col_block_sizes) { diff --git a/deal.II/lac/source/sparsity_pattern.cc b/deal.II/lac/source/sparsity_pattern.cc index 05e1d4f348..071ca537ce 100644 --- a/deal.II/lac/source/sparsity_pattern.cc +++ b/deal.II/lac/source/sparsity_pattern.cc @@ -628,7 +628,7 @@ SparsityPattern::copy_from (const CompressedSetSparsityPattern &csp, for (unsigned int row = 0; row &, -// CompressedBlockSparsityPattern &); +// BlockCompressedSparsityPattern &); std::string output_file_name = "dof_tools_01d/output"; @@ -38,7 +38,7 @@ check_this (const DoFHandler &dof_handler) // create sparsity pattern const unsigned int n_components = dof_handler.get_fe().n_components(); - CompressedBlockSparsityPattern sp (n_components, + BlockCompressedSparsityPattern sp (n_components, n_components); std::vector dofs_per_component(n_components); DoFTools::count_dofs_per_component (dof_handler, diff --git a/tests/bits/dof_tools_02d.cc b/tests/bits/dof_tools_02d.cc index 461881f0f2..6e3f9a9cf4 100644 --- a/tests/bits/dof_tools_02d.cc +++ b/tests/bits/dof_tools_02d.cc @@ -19,7 +19,7 @@ // DoFTools:: // make_sparsity_pattern (const DoFHandler &, // std::vector > &, -// CompressedBlockSparsityPattern &); +// BlockCompressedSparsityPattern &); std::string output_file_name = "dof_tools_02d/output"; @@ -45,7 +45,7 @@ check_this (const DoFHandler &dof_handler) return; // create sparsity pattern - CompressedBlockSparsityPattern sp (n_components, + BlockCompressedSparsityPattern sp (n_components, n_components); std::vector dofs_per_component(n_components); DoFTools::count_dofs_per_component (dof_handler, diff --git a/tests/bits/dof_tools_15d.cc b/tests/bits/dof_tools_15d.cc index 5b50ce9962..a79aa86b74 100644 --- a/tests/bits/dof_tools_15d.cc +++ b/tests/bits/dof_tools_15d.cc @@ -19,7 +19,7 @@ // DoFTools:: // make_boundary_sparsity_pattern (const DoFHandler &, // const std::vector & -// CompressedBlockSparsityPattern &); +// BlockCompressedSparsityPattern &); std::string output_file_name = "dof_tools_15d/output"; @@ -38,7 +38,7 @@ check_this (const DoFHandler &dof_handler) const unsigned int n_blocks = std::min (dof_handler.get_fe().n_components(), dof_handler.n_boundary_dofs()); - CompressedBlockSparsityPattern sp (n_blocks, + BlockCompressedSparsityPattern sp (n_blocks, n_blocks); // split dofs almost arbitrarily to // blocks diff --git a/tests/bits/dof_tools_16d.cc b/tests/bits/dof_tools_16d.cc index 66cddda5fb..3b9d1a4955 100644 --- a/tests/bits/dof_tools_16d.cc +++ b/tests/bits/dof_tools_16d.cc @@ -20,7 +20,7 @@ // make_boundary_sparsity_pattern (const DoFHandler &, // const typename FunctionMap::type & // const std::vector & -// CompressedBlockSparsityPattern &); +// BlockCompressedSparsityPattern &); std::string output_file_name = "dof_tools_16d/output"; @@ -44,7 +44,7 @@ check_this (const DoFHandler &dof_handler) const unsigned int n_boundary_dofs = dof_handler.n_boundary_dofs(boundary_ids); const unsigned int n_blocks = std::min (dof_handler.get_fe().n_components(), n_boundary_dofs); - CompressedBlockSparsityPattern sp (n_blocks, + BlockCompressedSparsityPattern sp (n_blocks, n_blocks); // split dofs almost arbitrarily to // blocks diff --git a/tests/bits/dof_tools_17d.cc b/tests/bits/dof_tools_17d.cc index 4413d31fd5..42f5821f7d 100644 --- a/tests/bits/dof_tools_17d.cc +++ b/tests/bits/dof_tools_17d.cc @@ -18,7 +18,7 @@ // check // DoFTools:: // make_flux_sparsity_pattern (const DoFHandler &, -// CompressedBlockSparsityPattern &); +// BlockCompressedSparsityPattern &); std::string output_file_name = "dof_tools_17d/output"; @@ -38,7 +38,7 @@ check_this (const DoFHandler &dof_handler) // create sparsity pattern const unsigned int n_components = dof_handler.get_fe().n_components(); - CompressedBlockSparsityPattern sp (n_components, + BlockCompressedSparsityPattern sp (n_components, n_components); std::vector dofs_per_component(n_components); DoFTools::count_dofs_per_component (dof_handler, diff --git a/tests/bits/dof_tools_18d.cc b/tests/bits/dof_tools_18d.cc index 8bea3e6076..5326a5c27b 100644 --- a/tests/bits/dof_tools_18d.cc +++ b/tests/bits/dof_tools_18d.cc @@ -18,7 +18,7 @@ // check // DoFTools:: // make_flux_sparsity_pattern (const DoFHandler &, -// CompressedBlockSparsityPattern &); +// BlockCompressedSparsityPattern &); std::string output_file_name = "dof_tools_18d/output"; @@ -64,7 +64,7 @@ my_check_this (const DoFHandler &dof_handler) // create sparsity pattern const unsigned int n_components = dof_handler.get_fe().n_components(); - CompressedBlockSparsityPattern sp (n_components, + BlockCompressedSparsityPattern sp (n_components, n_components); std::vector dofs_per_component(n_components); DoFTools::count_dofs_per_component (dof_handler, diff --git a/tests/deal.II/sparsity_pattern.cc b/tests/deal.II/sparsity_pattern.cc index 8ac51a0979..fb9b8decbb 100644 --- a/tests/deal.II/sparsity_pattern.cc +++ b/tests/deal.II/sparsity_pattern.cc @@ -195,7 +195,7 @@ check () sparsity_3.compress (); BlockSparsityPattern sparsity_4; - CompressedBlockSparsityPattern csp_4(2,2); + BlockCompressedSparsityPattern csp_4(2,2); csp_4.block(0,0).reinit (n1,n1); csp_4.block(1,0).reinit (n2,n1); csp_4.block(0,1).reinit (n1,n2); diff --git a/tests/deal.II/sparsity_pattern_01.cc b/tests/deal.II/sparsity_pattern_01.cc index 6457c38c5a..69974e0d75 100644 --- a/tests/deal.II/sparsity_pattern_01.cc +++ b/tests/deal.II/sparsity_pattern_01.cc @@ -195,7 +195,7 @@ check () sparsity_3.compress (); BlockSparsityPattern sparsity_4; - CompressedBlockSparsityPattern csp_4(2,2); + BlockCompressedSparsityPattern csp_4(2,2); csp_4.block(0,0).reinit (n1,n1); csp_4.block(1,0).reinit (n2,n1); csp_4.block(0,1).reinit (n1,n2); diff --git a/tests/deal.II/sparsity_pattern_05.cc b/tests/deal.II/sparsity_pattern_05.cc index c7248150e9..48bd8596e0 100644 --- a/tests/deal.II/sparsity_pattern_05.cc +++ b/tests/deal.II/sparsity_pattern_05.cc @@ -160,7 +160,7 @@ check () sparsity_3.compress (); BlockSparsityPattern sparsity_4; - CompressedBlockSparsityPattern csp_4(2,2); + BlockCompressedSparsityPattern csp_4(2,2); csp_4.block(0,0).reinit (n1,n1); csp_4.block(1,0).reinit (n2,n1); csp_4.block(0,1).reinit (n1,n2);