From: Martin Kronbichler Date: Wed, 7 Aug 2013 09:47:47 +0000 (+0000) Subject: Fix high memory consumption in ChunkSparsityPattern::copy_from by creating the reduce... X-Git-Tag: v8.1.0~1128 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=84c168d98abc173b0c675bce2388a2471d5dc183;p=dealii.git Fix high memory consumption in ChunkSparsityPattern::copy_from by creating the reduced sparsity pattern using a CompressedSimpleSparsityPattern object for gathering the small indices git-svn-id: https://svn.dealii.org/trunk@30244 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/examples/step-51/doc/results.dox b/deal.II/examples/step-51/doc/results.dox index 1b7193f9dc..3ec10ba82d 100644 --- a/deal.II/examples/step-51/doc/results.dox +++ b/deal.II/examples/step-51/doc/results.dox @@ -6,6 +6,7 @@ The program writes convergence tables to the screen while running: @code Q1 elements: +cells dofs val L2 grad L2 val L2-post 16 80 4.570e+00 - 1.221e+01 - 4.333e+00 - 36 168 1.869e+00 2.20 7.299e+00 1.27 1.734e+00 2.26 64 288 7.177e-01 3.33 4.218e+00 1.91 2.538e-01 6.68 @@ -18,6 +19,7 @@ Q1 elements: 9216 37248 4.690e-03 1.97 3.228e-02 1.97 1.600e-04 2.96 Q3 elements: +cells dofs val L2 grad L2 val L2-post 16 160 2.398e-01 - 1.873e+00 - 1.354e-01 - 36 336 5.843e-02 3.48 5.075e-01 3.22 1.882e-02 4.87 64 576 3.466e-02 1.82 2.534e-01 2.41 4.326e-03 5.11 diff --git a/deal.II/examples/step-51/step-51.cc b/deal.II/examples/step-51/step-51.cc index 41d3975d36..281dbfefdd 100644 --- a/deal.II/examples/step-51/step-51.cc +++ b/deal.II/examples/step-51/step-51.cc @@ -339,21 +339,13 @@ Step51::setup_system () constraints.clear (); DoFTools::make_hanging_node_constraints (dof_handler, constraints); - std::map boundary_values; typename FunctionMap::type boundary_functions; Solution solution; boundary_functions[0] = &solution; VectorTools::project_boundary_values (mapping, dof_handler, boundary_functions, QGauss(fe.degree+1), - boundary_values); - for (std::map::iterator it = boundary_values.begin(); - it != boundary_values.end(); ++it) - if (constraints.is_constrained(it->first) == false) - { - constraints.add_line(it->first); - constraints.set_inhomogeneity(it->first, it->second); - } + constraints); constraints.close (); { diff --git a/deal.II/source/lac/chunk_sparsity_pattern.cc b/deal.II/source/lac/chunk_sparsity_pattern.cc index a9e5b9de0b..ef64577192 100644 --- a/deal.II/source/lac/chunk_sparsity_pattern.cc +++ b/deal.II/source/lac/chunk_sparsity_pattern.cc @@ -265,22 +265,26 @@ namespace internal // distinguish between compressed sparsity types that define row_begin() // and SparsityPattern that uses begin() as iterator type template - void copy_row (const Sparsity &csp, - const size_type row, - ChunkSparsityPattern &dst) + void copy_row (const Sparsity &csp, + const size_type row, + const unsigned int chunk_size, + CompressedSimpleSparsityPattern &dst) { typename Sparsity::row_iterator col_num = csp.row_begin (row); + const size_type reduced_row = row/chunk_size; for (; col_num != csp.row_end (row); ++col_num) - dst.add (row, *col_num); + dst.add (reduced_row, *col_num/chunk_size); } - void copy_row (const SparsityPattern &csp, - const size_type row, - ChunkSparsityPattern &dst) + void copy_row (const SparsityPattern &csp, + const size_type row, + const unsigned int chunk_size, + CompressedSimpleSparsityPattern &dst) { SparsityPattern::iterator col_num = csp.begin (row); + const size_type reduced_row = row/chunk_size; for (; col_num != csp.end (row); ++col_num) - dst.add (row, col_num->column()); + dst.add (reduced_row, col_num->column()/chunk_size); } } } @@ -293,22 +297,27 @@ ChunkSparsityPattern::copy_from (const SparsityType &csp, { Assert (chunk_size > 0, ExcInvalidNumber (chunk_size)); - // count number of entries per row, then initialize the underlying sparsity - // pattern - std::vector entries_per_row (csp.n_rows(), 0); - for (size_type row = 0; rowchunk_size = chunk_size; + rows = csp.n_rows(); + cols = csp.n_cols(); + const size_type m_chunks = (csp.n_rows()+chunk_size-1) / chunk_size, + n_chunks = (csp.n_cols()+chunk_size-1) / chunk_size; + CompressedSimpleSparsityPattern temporary_sp(m_chunks, n_chunks); - // then actually fill it for (size_type row = 0; row (const template void SparsityPattern::copy_from (const FullMatrix &, bool); template void SparsityPattern::copy_from (const FullMatrix &, bool); +template void SparsityPattern::copy_from (const SparsityPattern &); template void SparsityPattern::copy_from (const CompressedSparsityPattern &); template void SparsityPattern::copy_from (const CompressedSetSparsityPattern &); template void SparsityPattern::copy_from (const CompressedSimpleSparsityPattern &);