From 96a4e8f2d94fe627a0b8f9283e3c8dc373ca0559 Mon Sep 17 00:00:00 2001 From: wolf Date: Tue, 29 Jun 2004 19:11:39 +0000 Subject: [PATCH] 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 --- .../source/numerics/solution_transfer.cc | 34 ++++++++++++------- 1 file changed, 22 insertions(+), 12 deletions(-) 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 -- 2.39.5