]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
We may not be allowed to initialize Null-references directly, but we can initialize...
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 Jul 2001 12:31:06 +0000 (12:31 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Tue, 3 Jul 2001 12:31:06 +0000 (12:31 +0000)
git-svn-id: https://svn.dealii.org/trunk@4807 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/source/thread_management.cc
deal.II/deal.II/include/numerics/vectors.h
deal.II/deal.II/source/numerics/error_estimator.cc
deal.II/deal.II/source/numerics/vectors.all_dimensions.cc

index 8b1430eea211dac14fe2f4b617e1f34bcd1d5266..756f08f0b0252cb3e186ddab98a29d5771992e1f 100644 (file)
@@ -114,7 +114,8 @@ namespace Threads
                                     // present. return dummy value
                                     // instead
     Assert (false, ExcNotImplemented());
-    return *static_cast<const FunEncapsulation *>(0);
+    const FunEncapsulation * const p = 0;
+    return *p;
   };
 
 
index 17d34967dda5145d260d7ef0dd92ee455d3c9b4a..7b97842570966c1592973f690731e6a83f0a93d3 100644 (file)
@@ -407,6 +407,10 @@ class VectorTools
                                      * of the previous function for
                                      * 1d. At present, it is not
                                      * implemented.
+                                     *
+                                     * The default value of the
+                                     * quadrature formula is an
+                                     * invalid object.
                                      */
     static void project (const Mapping<1>         &mapping,
                         const DoFHandler<1>      &dof,
@@ -415,7 +419,7 @@ class VectorTools
                         const Function<1>        &function,
                         Vector<double>           &vec,
                         const bool                enforce_zero_boundary = false,
-                        const Quadrature<0>      &q_boundary = *static_cast<const Quadrature<0>*>(0),
+                        const Quadrature<0>      &q_boundary = *invalid_face_quadrature,
                         const bool                project_to_boundary_first = false);
     
                                     /**
@@ -797,7 +801,15 @@ class VectorTools
                                     /**
                                      * Exception
                                      */
-  DeclException0 (ExcNonInterpolatingFE);
+    DeclException0 (ExcNonInterpolatingFE);
+
+  private:
+                                    /**
+                                     * Null pointer used to 
+                                     * denote invalid face 
+                                     * quadrature formulas in 1d.
+                                     */
+    static const Quadrature<0> * const invalid_face_quadrature;
 };
 
 
index 5f2c29f46e0ecdcbf46ecbe701d60a5eae0caad5..9d2a56849aa3a6421839e381a3157b4836edba11 100644 (file)
@@ -49,6 +49,19 @@ double sqr (const double x)
 
 #if deal_II_dimension == 1
 
+// provide zero pointers to be used in the initialization of 
+// invalid references
+namespace 
+{
+  const Mapping<1> * const           invalid_mapping         = 0;
+  const DoFHandler<1> * const        invalid_dof_handler     = 0;
+  const Quadrature<0> * const        invalid_face_quadrature = 0;
+  const FunctionMap<1>::type * const invalid_function_map    = 0;
+  const std::vector<const Vector<double> *> * const invalid_solutions = 0;
+  KellyErrorEstimator<1>::FaceIntegrals * const invalid_face_integrals = 0;
+}
+
+
 template <>
 KellyErrorEstimator<1>::Data::Data(const Mapping<1>                    &,
                                   const DoFHandler<1>                 &,
@@ -59,14 +72,14 @@ KellyErrorEstimator<1>::Data::Data(const Mapping<1>                    &,
                                   const Function<1>                   *,
                                   const unsigned int                   ,
                                   FaceIntegrals                       &):
-               mapping(* static_cast <const Mapping<1> *> (0)),
-               dof_handler(* static_cast <const DoFHandler<1> *> (0)),
-               quadrature(* static_cast <const Quadrature<0> *> (0)),
-               neumann_bc(* static_cast <const FunctionMap<1>::type *> (0)),
-               solutions(* static_cast <const std::vector<const Vector<double>*> *> (0)),
+               mapping(*invalid_mapping),
+               dof_handler(*invalid_dof_handler),
+               quadrature(*invalid_face_quadrature),
+               neumann_bc(*invalid_function_map),
+               solutions(*invalid_solutions),
                n_threads (0),
                n_solution_vectors (0),
-               face_integrals (* static_cast<FaceIntegrals*> (0))
+               face_integrals (*invalid_face_integrals)
 {
   Assert (false, ExcInternalError());
 }
index 1321f0c47152490a64802af4bfc3e5fda22e22e7..09bde2bdbb231f1fd04c2d0ab4a956d56b590e2f 100644 (file)
 #include <numerics/vectors.h>
 
 
+
+// allocate storage and initialize static variables
+const Quadrature<0> * const VectorTools::invalid_face_quadrature = 0;
+
+
+
 void
 VectorTools::subtract_mean_value(Vector<double>     &v,
                                 const std::vector<bool> &p_select)

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.