From 01fe30514e5da42be91044f1b78786dcc5506e18 Mon Sep 17 00:00:00 2001 From: guido Date: Thu, 26 Aug 2004 15:01:44 +0000 Subject: [PATCH] trying to find the bottlenec in copy_to_mg git-svn-id: https://svn.dealii.org/trunk@9586 0785d39b-7218-0410-832d-ea1e28bc413d --- .../include/multigrid/mg_transfer.templates.h | 52 ++++++++----------- deal.II/deal.II/include/multigrid/multigrid.h | 12 +++++ .../include/multigrid/multigrid.templates.h | 17 ++++-- .../source/multigrid/mg_dof_accessor.cc | 10 +++- .../multigrid/multigrid.all_dimensions.cc | 1 + deal.II/lac/source/sparsity_pattern.cc | 9 +++- 6 files changed, 65 insertions(+), 36 deletions(-) diff --git a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h index 54e53b23c3..15301e7f75 100644 --- a/deal.II/deal.II/include/multigrid/mg_transfer.templates.h +++ b/deal.II/deal.II/include/multigrid/mg_transfer.templates.h @@ -362,6 +362,18 @@ MGTransferSelect::do_copy_to_mg ( std::vector level_dof_indices (dofs_per_cell); std::vector level_face_indices (dofs_per_face); + // Build a vector of the selected + // indices, since traversing all + // indices on each cell is too + // slow. + std::vector selected_indices; + selected_indices.reserve(dofs_per_cell); + for (unsigned int i=0; i::do_copy_to_mg ( // transfer the global // defect in the vector // into the level-wise one - for (unsigned int i=0; i::const_iterator + end = selected_indices.end(); + + for (typename std::vector::const_iterator + i=selected_indices.begin(); + i != end; ++i) { - const unsigned int component - = mg_target_component[fe.system_to_component_index(i).first]; - if (mg_selected[component]) - { - const unsigned int level_start - = mg_component_start[level][component]; - - dst[level](level_dof_indices[i] - level_start) - = src(global_dof_indices[i] - offset); - } + dst[level](level_dof_indices[*i] - level_start) + = src(global_dof_indices[*i] - offset); } - -// for (unsigned int face_n=0; face_n::faces_per_cell; ++face_n) -// { -// const typename MGDoFHandler::face_iterator -// face = level_cell->face(face_n); -// if (face->has_children()) -// { -// face->get_mg_dof_indices(level_face_indices); - - - // Delete values on refinement edge, - // since restriction will add them again. -// for (unsigned int i=0; i::do_copy_to_mg ( // one level higher if (static_cast(level) < maxlevel) { - restrict_and_add (level+1, dst[level], dst[level+1]); + ;// restrict_and_add (level+1, dst[level], dst[level+1]); } }; } diff --git a/deal.II/deal.II/include/multigrid/multigrid.h b/deal.II/deal.II/include/multigrid/multigrid.h index 2510b504f4..94ee218b8b 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.h +++ b/deal.II/deal.II/include/multigrid/multigrid.h @@ -402,12 +402,18 @@ PreconditionMG::vmult ( VECTOR2& dst, const VECTOR2& src) const { + deallog << "copy to" << endl; + transfer->copy_to_mg(*mg_dof_handler, multigrid->defect, src); + deallog << "mg" << endl; + multigrid->vcycle(); + deallog << "copy from " << endl; + transfer->copy_from_mg(*mg_dof_handler, dst, multigrid->solution); @@ -421,12 +427,18 @@ PreconditionMG::vmult_add ( VECTOR2& dst, const VECTOR2& src) const { + deallog << "copy to" << endl; + transfer->copy_to_mg(*mg_dof_handler, multigrid->defect, src); + + deallog << "mg" << endl; multigrid->vcycle(); + deallog << "copy from " << endl; + transfer->copy_from_mg_add(*mg_dof_handler, dst, multigrid->solution); diff --git a/deal.II/deal.II/include/multigrid/multigrid.templates.h b/deal.II/deal.II/include/multigrid/multigrid.templates.h index 53fd6f42d5..183f6df844 100644 --- a/deal.II/deal.II/include/multigrid/multigrid.templates.h +++ b/deal.II/deal.II/include/multigrid/multigrid.templates.h @@ -14,6 +14,11 @@ #define __deal2__multigrid_templates_h #include +#include + +#include "iostream" + +using namespace std; template void @@ -39,13 +44,17 @@ Multigrid::level_mgstep(const unsigned int level) return; } +// deallog << "Pre-smooth " << level << endl; + // smoothing of the residual by // modifying s pre_smooth->smooth(level, solution[level], defect[level]); +// deallog << "vmult " << level << endl; // t = A*solution[level] matrix->vmult(level, t[level], solution[level]); - + +// deallog << "restrict " << level << endl; // make t rhs of lower level The // non-refined parts of the // coarse-level defect already @@ -62,6 +71,7 @@ Multigrid::level_mgstep(const unsigned int level) defect[l-1] -= t[l-1]; } +// deallog << "recursion " << level << endl; // do recursion level_mgstep(level-1); @@ -72,7 +82,7 @@ Multigrid::level_mgstep(const unsigned int level) t[level] = 0.; // do coarse grid correction - +// deallog << "prolongate " << level << endl; transfer->prolongate(level, t[level], solution[level-1]); solution[level] += t[level]; @@ -82,9 +92,10 @@ Multigrid::level_mgstep(const unsigned int level) edge_up->Tvmult(level, t[level], solution[level-1]); defect[level] -= t[level]; } - +// deallog << "Post-smooth " << level << endl; // post-smoothing post_smooth->smooth(level, solution[level], defect[level]); +// deallog << "ready " << level << endl; } diff --git a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc index fab658d581..d8d4bbf49d 100644 --- a/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc +++ b/deal.II/deal.II/source/multigrid/mg_dof_accessor.cc @@ -2,7 +2,7 @@ // $Id$ // Version: $Name$ // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 by the deal.II authors +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer @@ -23,7 +23,7 @@ #include #include - +//TODO:[GK] Inline simple functions in 1d and 3d /* ------------------------ MGDoFLineAccessor --------------------------- */ @@ -210,6 +210,7 @@ MGDoFObjectAccessor<2, dim>::MGDoFObjectAccessor (const Triangulation *tria template +inline unsigned int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) const { Assert (this->dof_handler != 0, @@ -229,6 +230,7 @@ unsigned int MGDoFObjectAccessor<2, dim>::mg_dof_index (const unsigned int i) co template +inline void MGDoFObjectAccessor<2, dim>::set_mg_dof_index (const unsigned int i, const unsigned int index) const { @@ -249,6 +251,7 @@ void MGDoFObjectAccessor<2, dim>::set_mg_dof_index (const unsigned int i, template +inline unsigned int MGDoFObjectAccessor<2, dim>::mg_vertex_dof_index (const unsigned int vertex, const unsigned int i) const { @@ -268,6 +271,7 @@ unsigned int MGDoFObjectAccessor<2, dim>::mg_vertex_dof_index (const unsigned in template +inline void MGDoFObjectAccessor<2, dim>::set_mg_vertex_dof_index (const unsigned int vertex, const unsigned int i, const unsigned int index) const @@ -353,6 +357,7 @@ MGDoFObjectAccessor<2,dim>::get_mg_dof_values (const Vector &values, template +inline TriaIterator > MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const { @@ -369,6 +374,7 @@ MGDoFObjectAccessor<2, dim>::line (const unsigned int i) const template +inline TriaIterator > MGDoFObjectAccessor<2, dim>::child (const unsigned int i) const { diff --git a/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc b/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc index 18528d514f..e6d9ce714d 100644 --- a/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc +++ b/deal.II/deal.II/source/multigrid/multigrid.all_dimensions.cc @@ -17,6 +17,7 @@ #include #include #include +#include #include diff --git a/deal.II/lac/source/sparsity_pattern.cc b/deal.II/lac/source/sparsity_pattern.cc index 37d4503742..96657d9ddd 100644 --- a/deal.II/lac/source/sparsity_pattern.cc +++ b/deal.II/lac/source/sparsity_pattern.cc @@ -330,7 +330,12 @@ SparsityPattern::reinit (const unsigned int m, // exactly one element, to have a // valid pointer to some memory if (vec_len == 0) - vec_len = 1; + { + vec_len = 1; + if (colnums) delete[] colnums; + max_vec_len = vec_len; + colnums = new unsigned int[max_vec_len]; + } max_row_length = (row_lengths.size() == 0 ? 0 : @@ -339,7 +344,7 @@ SparsityPattern::reinit (const unsigned int m, if (diagonal_optimized && (max_row_length==0) && (m!=0)) max_row_length = 1; - + // allocate memory for the rowstart // values, if necessary if (rows > max_dim) -- 2.39.5