]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Fix a multithreading problem with the Raviart Thomas polynomials.
authorbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Oct 2008 18:09:20 +0000 (18:09 +0000)
committerbangerth <bangerth@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 13 Oct 2008 18:09:20 +0000 (18:09 +0000)
git-svn-id: https://svn.dealii.org/trunk@17196 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/polynomials_raviart_thomas.h
deal.II/base/source/polynomials_raviart_thomas.cc
deal.II/doc/news/changes.h

index 34cfe921be89f78199e754d496a7c5f18d4655bb..cad7acf20f65cb204c21ef5fc8b2415e7f2bb27a 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 2004, 2005, 2006, 2007, 2008 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -135,22 +135,7 @@ class PolynomialsRaviartThomas
                                      * Number of Raviart-Thomas
                                      * polynomials.
                                      */
-    unsigned int n_pols;
-    
-                                    /**
-                                     * Auxiliary memory.
-                                     */
-    mutable std::vector<double> p_values;    
-    
-                                    /**
-                                     * Auxiliary memory.
-                                     */
-    mutable std::vector<Tensor<1,dim> > p_grads;
-    
-                                    /**
-                                     * Auxiliary memory.
-                                     */
-    mutable std::vector<Tensor<2,dim> > p_grad_grads;
+    const unsigned int n_pols;
 
                                     /**
                                      * A static member function that
index e49a5cfb23f1fded5343afcdb285979b266b937d..17cba34667775e5cb512b98d8a7abdb112e56b96 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 2004, 2005, 2006, 2007 by the deal.II authors
+//    Copyright (C) 2004, 2005, 2006, 2007, 2008 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -13,6 +13,7 @@
 
 #include <base/polynomials_raviart_thomas.h>
 #include <base/quadrature_lib.h>
+#include <base/thread_management.h>
 #include <iostream>
 #include <iomanip>
 
@@ -51,9 +52,9 @@ PolynomialsRaviartThomas<dim>::create_polynomials (const unsigned int k)
 template <int dim>
 void
 PolynomialsRaviartThomas<dim>::compute (const Point<dim>            &unit_point,
-                             std::vector<Tensor<1,dim> > &values,
-                             std::vector<Tensor<2,dim> > &grads,
-                             std::vector<Tensor<3,dim> > &grad_grads) const
+                                       std::vector<Tensor<1,dim> > &values,
+                                       std::vector<Tensor<2,dim> > &grads,
+                                       std::vector<Tensor<3,dim> > &grad_grads) const
 {
   Assert(values.size()==n_pols || values.size()==0,
         ExcDimensionMismatch(values.size(), n_pols));
@@ -62,7 +63,27 @@ PolynomialsRaviartThomas<dim>::compute (const Point<dim>            &unit_point,
   Assert(grad_grads.size()==n_pols|| grad_grads.size()==0,
         ExcDimensionMismatch(grad_grads.size(), n_pols));
 
-  const unsigned int n_sub = polynomial_space.n();
+                                  // have a few scratch
+                                  // arrays. because we don't want to
+                                  // re-allocate them every time this
+                                  // function is called, we make them
+                                  // static. however, in return we
+                                  // have to ensure that the calls to
+                                  // the use of these variables is
+                                  // locked with a mutex. if the
+                                  // mutex is removed, several tests
+                                  // (notably
+                                  // deal.II/create_mass_matrix_05)
+                                  // will start to produce random
+                                  // results in multithread mode
+  static Threads::ThreadMutex mutex;
+  Threads::ThreadMutex::ScopedLock lock(mutex);
+
+  static std::vector<double> p_values;    
+  static std::vector<Tensor<1,dim> > p_grads;
+  static std::vector<Tensor<2,dim> > p_grad_grads;
+
+  const unsigned int n_sub = polynomial_space.n();  
   p_values.resize((values.size() == 0) ? 0 : n_sub);
   p_grads.resize((grads.size() == 0) ? 0 : n_sub);
   p_grad_grads.resize((grad_grads.size() == 0) ? 0 : n_sub);
index dede3f62d47842eb8ef6245ca0ccb180c695e7d6..313d6ee4d7388c03fb0df0566bd1c54f03f9745e 100644 (file)
@@ -196,6 +196,15 @@ inconvenience this causes.
 <h3>base</h3>
 
 <ol>
+  <li>
+  <p>
+  Fixed: The PolynomialsRaviartThomas class had a bug that led to random
+  results when used from multiple threads. As a consequence the FE_RaviartThomas
+  class was unusable in a multithreaded context. This has now been fixed.
+  <br> 
+  (WB 2008/10/13)
+  </p>
+
   <li>
   <p>
   New: There is a new function scalar_product(const Tensor<2,dim> &,

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.