]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use more efficient algorithms to initialize fields. Also happens to work
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Jun 2004 19:11:39 +0000 (19:11 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 29 Jun 2004 19:11:39 +0000 (19:11 +0000)
around a miscompilation with present gcc mainline :-)

git-svn-id: https://svn.dealii.org/trunk@9484 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/deal.II/source/numerics/solution_transfer.cc

index e5bb7b47140fcba48787b0592e35847329057971..c0fb4fe53a00cc3066a7fa84c3ac27663b5d90e4 100644 (file)
@@ -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<Vector<number> > &all_in
   const unsigned int n_coarsen_fathers = n_cells_to_coarsen /
                                         GeometryInfo<dim>::children_per_cell;
 
-                                  // allocate the needed memory
-  indices_on_cell=std::vector<std::vector<unsigned int> > (
-    n_cells_to_stay_or_refine,
-    std::vector<unsigned int> (dofs_per_cell));
-  
-  dof_values_on_cell=std::vector<std::vector<Vector<number> > > (
-    n_coarsen_fathers,
-    std::vector<Vector<number> > (in_size, Vector<number> (dofs_per_cell)));
-
-  all_pointerstructs=std::vector<Pointerstruct> (
-    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<std::vector<unsigned int> >
+      tmp(n_cells_to_stay_or_refine,
+          std::vector<unsigned int> (dofs_per_cell));
+    indices_on_cell.swap (tmp);
+  }
+  {
+    std::vector<std::vector<Vector<number> > >
+      tmp(n_coarsen_fathers,
+          std::vector<Vector<number> > (in_size,
+                                        Vector<number> (dofs_per_cell)));
+    dof_values_on_cell.swap (tmp);
+  }
+  {
+    std::vector<Pointerstruct>
+      tmp(n_cells_to_stay_or_refine+n_coarsen_fathers);
+    all_pointerstructs.swap (tmp);
+  }
 
 
                                   // we need counters for

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.