]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Don't use static variables for anything that depends on some input parameter
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 11 Apr 2009 00:03:21 +0000 (00:03 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Sat, 11 Apr 2009 00:03:21 +0000 (00:03 +0000)
and/or may be non-constant. The use of static variables otherwise leads to
surprising results if the same code is run twice within the same program
execution but using different input files, and it is dangerous if code is run
in a multi-threaded context.

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

deal.II/examples/step-34/step-34.cc

index d1491ce28b4202f412731acb36476d90ff0dee95..602ca7163f3cd4d344558aea34f995cc330b0835 100644 (file)
@@ -398,7 +398,7 @@ void BEMProblem<dim>::read_parameters(std::string filename) {
                                          "d simulation");
 
     prm.enter_subsection("Quadrature rules");
-    static QuadratureSelector<dim-1> quadrature
+    QuadratureSelector<dim-1> quadrature
                       (prm.get("Quadrature type"),
                        prm.get_integer("Quadrature order"));
     singular_quadrature_order = prm.get_integer("Singular quadrature order");
@@ -490,8 +490,7 @@ void BEMProblem<dim>::read_domain() {
     // template parameter that specifies the embedding space
     // dimension. 
     
-    Point<dim> p;
-    static HyperBallBoundary<dim-1, dim> boundary(p,1.);    
+    static HyperBallBoundary<dim-1, dim> boundary(Point<dim>(),1.);    
 
     GridIn<dim-1, dim> gi;
     gi.attach_triangulation (tria);
@@ -721,8 +720,8 @@ void BEMProblem<dim>::assemble_system() {
 
                         fe_v_singular.reinit(cell);
                     
-                        static std::vector<Vector<double> > singular_cell_wind( (*singular_quadrature).size(), 
-                                                                           Vector<double>(dim) );
+                        std::vector<Vector<double> > singular_cell_wind( (*singular_quadrature).size(), 
+                                                                        Vector<double>(dim) );
         
                         const std::vector<Point<dim> > &singular_normals = fe_v_singular.get_cell_normal_vectors();
                         const std::vector<Point<dim> > &singular_q_points = fe_v_singular.get_quadrature_points();

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.