From a47eb43dd25e43bc9cd800db17973596e08693a5 Mon Sep 17 00:00:00 2001 From: Timo Heister Date: Wed, 21 Oct 2015 13:25:31 -0400 Subject: [PATCH] cleanup: add comments, longer typedef name --- .../deal.II/multigrid/mg_transfer.templates.h | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/include/deal.II/multigrid/mg_transfer.templates.h b/include/deal.II/multigrid/mg_transfer.templates.h index 11d5884aa1..4a776673eb 100644 --- a/include/deal.II/multigrid/mg_transfer.templates.h +++ b/include/deal.II/multigrid/mg_transfer.templates.h @@ -188,20 +188,26 @@ MGTransferPrebuilt::copy_to_mg ( MPI_Barrier(MPI_COMM_WORLD); #endif - typedef std::vector >::const_iterator IT; - for (IT i= copy_indices[level].begin(); + typedef std::vector >::const_iterator dof_pair_iterator; + + // first copy local unknowns + for (dof_pair_iterator i= copy_indices[level].begin(); i != copy_indices[level].end(); ++i) dst_level(i->second) = src(i->first); - for (IT i= copy_indices_global_mine[level].begin(); + // Do the same for the indices where the global index is local, + // but the local index is not + for (dof_pair_iterator i= copy_indices_global_mine[level].begin(); i != copy_indices_global_mine[level].end(); ++i) dst_level(i->second) = src(i->first); dst_level.compress(VectorOperation::insert); + #ifdef DEBUG_OUTPUT MPI_Barrier(MPI_COMM_WORLD); std::cout << "copy_to_mg dst " << level << " " << dst_level.l2_norm() << std::endl; #endif + if (!first) { restrict_and_add (level+1, dst[level], dst[level+1]); @@ -234,21 +240,22 @@ MGTransferPrebuilt::copy_from_mg( dst = 0; for (unsigned int level=0; level >::const_iterator IT; #ifdef DEBUG_OUTPUT MPI_Barrier(MPI_COMM_WORLD); std::cout << "copy_from_mg src " << level << " " << src[level].l2_norm() << std::endl; MPI_Barrier(MPI_COMM_WORLD); #endif + typedef std::vector >::const_iterator dof_pair_iterator; + // First copy all indices local to this process - for (IT i= copy_indices[level].begin(); + for (dof_pair_iterator i= copy_indices[level].begin(); i != copy_indices[level].end(); ++i) dst(i->first) = src[level](i->second); // Do the same for the indices where the level index is local, // but the global index is not - for (IT i= copy_indices_level_mine[level].begin(); + for (dof_pair_iterator i= copy_indices_level_mine[level].begin(); i != copy_indices_level_mine[level].end(); ++i) dst(i->first) = src[level](i->second); @@ -286,14 +293,16 @@ MGTransferPrebuilt::copy_from_mg_add ( // functions for (unsigned int level=0; level >::const_iterator IT; - for (IT i= copy_indices[level].begin(); + typedef std::vector >::const_iterator dof_pair_iterator; + + // First add all indices local to this process + for (dof_pair_iterator i= copy_indices[level].begin(); i != copy_indices[level].end(); ++i) dst(i->first) += src[level](i->second); // Do the same for the indices where the level index is local, // but the global index is not - for (IT i= copy_indices_level_mine[level].begin(); + for (dof_pair_iterator i= copy_indices_level_mine[level].begin(); i != copy_indices_level_mine[level].end(); ++i) dst(i->first) += src[level](i->second); } -- 2.39.5