]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Suns Forte compiler chokes on template argument computations, like in
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 20 Mar 2002 12:39:42 +0000 (12:39 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Wed, 20 Mar 2002 12:39:42 +0000 (12:39 +0000)
/* ----------------------------------------------- */
/* Problem 5 -- no computations with template args */
template <int dim> struct T2 {};
template <int dim> T2<dim-1> g(T2<dim>) {};

Fix this by introducing a new type local to the class that uses it.

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

deal.II/base/include/base/quadrature.h
deal.II/base/include/base/tensor_function.h
deal.II/base/source/quadrature.cc
deal.II/base/source/tensor_function.cc
deal.II/doc/news/2002/c-3-3.html

index de7de07aafbf9d3f6f2af8d16719b925736d6d69..efff37f7f541593a247a7423e8d76b9888dc57c8 100644 (file)
@@ -73,6 +73,15 @@ template <int dim>
 class Quadrature : public Subscriptor
 {
   public:
+                                    /**
+                                     * Define a typedef for a
+                                     * quadrature that acts on an
+                                     * object of one dimension
+                                     * less. For cells, this would
+                                     * then be a face quadrature.
+                                     */
+    typedef Quadrature<dim-1> SubQuadrature;
+    
                                     /**
                                      * Number of quadrature points.
                                      */
@@ -90,8 +99,8 @@ class Quadrature : public Subscriptor
                                      * less than the present and a
                                      * formula in one dimension.
                                      */
-    Quadrature (const Quadrature<dim-1> &,
-               const Quadrature<1>     &);
+    Quadrature (const SubQuadrature &,
+               const Quadrature<1> &);
     
                                     /**
                                      * Construct a quadrature formula
@@ -280,6 +289,15 @@ template <int dim>
 class QProjector
 {
   public:
+                                    /**
+                                     * Define a typedef for a
+                                     * quadrature that acts on an
+                                     * object of one dimension
+                                     * less. For cells, this would
+                                     * then be a face quadrature.
+                                     */
+    typedef Quadrature<dim-1> SubQuadrature;    
+    
                                     /**
                                      * Compute the quadrature points
                                      * on the cell if the given
@@ -288,8 +306,8 @@ class QProjector
                                      * details, see the general doc
                                      * for this class.
                                      */
-    static void project_to_face (const Quadrature<dim-1>  &quadrature,
-                                const unsigned int        face_no,
+    static void project_to_face (const SubQuadrature    &quadrature,
+                                const unsigned int      face_no,
                                 typename std::vector<Point<dim> > &q_points);
 
                                     /**
@@ -301,9 +319,9 @@ class QProjector
                                      * further details, see the
                                      * general doc for this class.
                                      */
-    static void project_to_subface (const Quadrature<dim-1>  &quadrature,
-                                   const unsigned int        face_no,
-                                   const unsigned int        subface_no,
+    static void project_to_subface (const SubQuadrature &quadrature,
+                                   const unsigned int   face_no,
+                                   const unsigned int   subface_no,
                                    typename std::vector<Point<dim> > &q_points);
 
                                     /**
@@ -335,7 +353,7 @@ class QProjector
                                      * later.
                                      */
     static Quadrature<dim>
-    project_to_all_faces (const Quadrature<dim-1> &quadrature);
+    project_to_all_faces (const SubQuadrature &quadrature);
 
                                     /**
                                      * This function is alike the
@@ -346,7 +364,7 @@ class QProjector
                                      * faces of the unit cell.
                                      */
     static Quadrature<dim>
-    project_to_all_subfaces (const Quadrature<dim-1> &quadrature);
+    project_to_all_subfaces (const SubQuadrature &quadrature);
 
                                     /**
                                      * Project a give quadrature
index 5840f901cbfe7b4daa9d5ff2ec63254881fae21e..5b23bee0b4a65e882094ecc4b3b2bf01219a3d37 100644 (file)
@@ -55,6 +55,14 @@ class TensorFunction : public FunctionTime,
                       public Subscriptor
 {
   public:
+                                    /**
+                                     * Define typedefs for the return
+                                     * types of the @p{value} and the
+                                     * @p{gradient} functions.
+                                     */
+    typedef Tensor<rank,dim> value_type;
+    typedef Tensor<rank+1,dim> gradient_type;
+    
                                     /**
                                      * Constructor. May take an
                                      * initial value for the time
@@ -77,7 +85,7 @@ class TensorFunction : public FunctionTime,
                                      * Return the value of the function
                                      * at the given point.
                                      */
-    virtual Tensor<rank, dim> value (const Point<dim> &p) const;
+    virtual value_type value (const Point<dim> &p) const;
 
                                     /**
                                      * Set @p{values} to the point
@@ -88,13 +96,13 @@ class TensorFunction : public FunctionTime,
                                      * size as the @p{points} array.  
                                      */
     virtual void value_list (const typename std::vector<Point<dim> > &points,
-                            typename std::vector<Tensor<rank,dim> > &values) const;
+                            typename std::vector<value_type> &values) const;
 
                                     /**
                                      * Return the gradient of the
                                      * function at the given point.
                                      */
-    virtual Tensor<rank+1,dim> gradient (const Point<dim> &p) const;
+    virtual gradient_type gradient (const Point<dim> &p) const;
 
                                     /**
                                      * Set @p{gradients} to the
@@ -105,7 +113,7 @@ class TensorFunction : public FunctionTime,
                                      * size as the @p{points} array.  
                                      */
     virtual void gradient_list (const typename std::vector<Point<dim> >   &points,
-                               typename std::vector<Tensor<rank+1,dim> > &gradients) const;
+                               typename std::vector<gradient_type> &gradients) const;
 
                                     /**
                                      * Exception
index 3b62588d5d402e9a50501d315294885429932de7..c43175d15c7816d22a437b60ba789f4d2883fb5b 100644 (file)
@@ -96,8 +96,8 @@ Quadrature<1>::Quadrature (const Quadrature<0> &,
 
 
 template <int dim>
-Quadrature<dim>::Quadrature (const Quadrature<dim-1> &q1,
-                            const Quadrature<1>     &q2) :
+Quadrature<dim>::Quadrature (const SubQuadrature &q1,
+                            const Quadrature<1> &q2) :
                n_quadrature_points (q1.n_quadrature_points *
                                     q2.n_quadrature_points),
                quadrature_points (n_quadrature_points),
@@ -575,7 +575,7 @@ QProjector<1>::project_to_all_faces (const Quadrature<0> &)
 
 template <int dim>
 Quadrature<dim>
-QProjector<dim>::project_to_all_faces (const Quadrature<dim-1> &quadrature)
+QProjector<dim>::project_to_all_faces (const SubQuadrature &quadrature)
 {
   const unsigned int n_points = quadrature.n_quadrature_points,
                     n_faces  = GeometryInfo<dim>::faces_per_cell;
@@ -616,7 +616,7 @@ QProjector<1>::project_to_all_subfaces (const Quadrature<0> &)
 
 template <int dim>
 Quadrature<dim>
-QProjector<dim>::project_to_all_subfaces (const Quadrature<dim-1> &quadrature)
+QProjector<dim>::project_to_all_subfaces (const SubQuadrature &quadrature)
 {
   const unsigned int n_points          = quadrature.n_quadrature_points,
                     n_faces           = GeometryInfo<dim>::faces_per_cell,
index 68333f88b665d76cad00d99e6e1dcc505e4ddb9d..8cfcb2f75ba8a45a8e15bfa54fe9ae7b3f04d146 100644 (file)
@@ -36,7 +36,7 @@ TensorFunction<rank, dim>::~TensorFunction ()
 
 
 template <int rank, int dim>
-Tensor<rank,dim>
+typename TensorFunction<rank, dim>::value_type
 TensorFunction<rank, dim>::value (const Point<dim> &) const
 {
   Assert (false, ExcPureFunctionCalled());
@@ -53,7 +53,7 @@ using namespace std;
 template <int rank, int dim>
 void
 TensorFunction<rank, dim>::value_list (const typename std::vector<Point<dim> > &points,
-                                      typename std::vector<Tensor<rank,dim> > &values) const
+                                      typename std::vector<value_type>        &values) const
 {
   Assert (values.size() == points.size(),
          ExcDimensionMismatch(values.size(), points.size()));
@@ -64,7 +64,7 @@ TensorFunction<rank, dim>::value_list (const typename std::vector<Point<dim> > &
 
 
 template <int rank, int dim>
-Tensor<rank+1,dim>
+typename TensorFunction<rank, dim>::gradient_type
 TensorFunction<rank, dim>::gradient (const Point<dim> &) const
 {
   Assert (false, ExcPureFunctionCalled());
@@ -75,7 +75,7 @@ TensorFunction<rank, dim>::gradient (const Point<dim> &) const
 template <int rank, int dim>
 void
 TensorFunction<rank, dim>::gradient_list (const typename std::vector<Point<dim> >   &points,
-                                         typename std::vector<Tensor<rank+1,dim> > &gradients) const
+                                         typename std::vector<gradient_type> &gradients) const
 {
   Assert (gradients.size() == points.size(),
          ExcDimensionMismatch(gradients.size(), points.size()));
index 50c65dc3cd02e85f2f01cf202a58e08903a4281a..5c1003c90f9ee03b49f183e39b79f85b27e5ed40 100644 (file)
@@ -78,6 +78,16 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
 <h3>base</h3>
 
 <ol>
+  <li> <p> 
+       Fixed: The class <code class="class">TensorFunction</code>
+       now uses local types <code class="class">value_type</code> and
+       <code class="class">gradient_type</code> as return values of
+       its member functions. This works around a bug in Sun's Forte
+       C++ compilers.
+       <br>
+       (WB 2002/03/20)
+       </p>
+
   <li> <p> 
        Improved: The <code class="member">AssertThrow</code> macro now
        uses <code class="member">__builtin_expect</code> if the

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.