From: Wolfgang Bangerth Date: Tue, 29 Jun 2004 19:11:39 +0000 (+0000) Subject: Use more efficient algorithms to initialize fields. Also happens to work X-Git-Tag: v8.0.0~14980 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b77f2f39e1bc354991e7aa7f56dab0829d7a4e1e;p=dealii.git Use more efficient algorithms to initialize fields. Also happens to work around a miscompilation with present gcc mainline :-) git-svn-id: https://svn.dealii.org/trunk@9484 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/deal.II/source/numerics/solution_transfer.cc b/deal.II/deal.II/source/numerics/solution_transfer.cc index e5bb7b4714..c0fb4fe53a 100644 --- a/deal.II/deal.II/source/numerics/solution_transfer.cc +++ b/deal.II/deal.II/source/numerics/solution_transfer.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 @@ -197,17 +197,27 @@ prepare_for_coarsening_and_refinement(const std::vector > &all_in const unsigned int n_coarsen_fathers = n_cells_to_coarsen / GeometryInfo::children_per_cell; - // allocate the needed memory - indices_on_cell=std::vector > ( - n_cells_to_stay_or_refine, - std::vector (dofs_per_cell)); - - dof_values_on_cell=std::vector > > ( - n_coarsen_fathers, - std::vector > (in_size, Vector (dofs_per_cell))); - - all_pointerstructs=std::vector ( - n_cells_to_stay_or_refine+n_coarsen_fathers); + // allocate the needed memory. initialize + // the following arrays in an efficient + // way, without copying much + { + std::vector > + tmp(n_cells_to_stay_or_refine, + std::vector (dofs_per_cell)); + indices_on_cell.swap (tmp); + } + { + std::vector > > + tmp(n_coarsen_fathers, + std::vector > (in_size, + Vector (dofs_per_cell))); + dof_values_on_cell.swap (tmp); + } + { + std::vector + tmp(n_cells_to_stay_or_refine+n_coarsen_fathers); + all_pointerstructs.swap (tmp); + } // we need counters for