]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Use a fixed size data structure for MappingQGeneric::InternalData::unit_tangentials.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Sun, 3 Apr 2016 15:07:09 +0000 (10:07 -0500)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 7 Apr 2016 11:19:18 +0000 (06:19 -0500)
include/deal.II/fe/mapping_q_generic.h
source/fe/mapping_q_generic.cc

index 4ba02f3ee4bb115191b8bab11d502bc8d3c8a76e..54010338a625ae6d8c6ac16f4eb2776a0b2e458d 100644 (file)
@@ -25,6 +25,8 @@
 #include <deal.II/fe/mapping.h>
 #include <deal.II/fe/fe_q.h>
 
+#include <deal.II/base/std_cxx11/array.h>
+
 #include <cmath>
 
 DEAL_II_NAMESPACE_OPEN
@@ -360,7 +362,7 @@ public:
      * Unit tangential vectors. Used for the computation of boundary forms and
      * normal vectors.
      *
-     * This vector has (dim-1)GeometryInfo::faces_per_cell entries. The first
+     * This array has (dim-1)*GeometryInfo::faces_per_cell entries. The first
      * GeometryInfo::faces_per_cell contain the vectors in the first
      * tangential direction for each face; the second set of
      * GeometryInfo::faces_per_cell entries contain the vectors in the second
@@ -369,7 +371,7 @@ public:
      *
      * Filled once.
      */
-    std::vector<std::vector<Tensor<1,dim> > > unit_tangentials;
+    std_cxx11::array<std::vector<Tensor<1,dim> >, GeometryInfo<dim>::faces_per_cell *(dim-1)> unit_tangentials;
 
     /**
      * The polynomial degree of the mapping. Since the objects here are also
index 080b049ffed9b7b8448a9c88f33d66f927672907..6f8261582329684d06575a091ba3fe3ee3542ab1 100644 (file)
@@ -764,24 +764,22 @@ initialize_face (const UpdateFlags      update_flags,
         {
           aux.resize (dim-1, std::vector<Tensor<1,spacedim> > (n_original_q_points));
 
-          // Compute tangentials to the
-          // unit cell.
-          const unsigned int nfaces = GeometryInfo<dim>::faces_per_cell;
-          unit_tangentials.resize (nfaces*(dim-1),
-                                   std::vector<Tensor<1,dim> > (n_original_q_points));
+          // Compute tangentials to the unit cell.
+          for (unsigned int i=0; i<unit_tangentials.size(); ++i)
+            unit_tangentials[i].resize (n_original_q_points);
           switch (dim)
             {
             case 2:
             {
-              // ensure a counterclockwise
-              // orientation of tangentials
+              // ensure a counterclockwise orientation of tangentials
               static const int tangential_orientation[4]= {-1,1,1,-1};
-              for (unsigned int i=0; i<nfaces; ++i)
+              for (unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
                 {
                   Tensor<1,dim> tang;
-                  tang[1-i/2]=tangential_orientation[i];
+                  tang[1-i/2] = tangential_orientation[i];
                   std::fill (unit_tangentials[i].begin(),
-                             unit_tangentials[i].end(), tang);
+                             unit_tangentials[i].end(),
+                             tang);
                 }
 
               break;
@@ -789,7 +787,7 @@ initialize_face (const UpdateFlags      update_flags,
 
             case 3:
             {
-              for (unsigned int i=0; i<nfaces; ++i)
+              for (unsigned int i=0; i<GeometryInfo<dim>::faces_per_cell; ++i)
                 {
                   Tensor<1,dim> tang1, tang2;
 
@@ -811,9 +809,11 @@ initialize_face (const UpdateFlags      update_flags,
                   // for all quadrature
                   // points on this face
                   std::fill (unit_tangentials[i].begin(),
-                             unit_tangentials[i].end(), tang1);
-                  std::fill (unit_tangentials[nfaces+i].begin(),
-                             unit_tangentials[nfaces+i].end(), tang2);
+                             unit_tangentials[i].end(),
+                             tang1);
+                  std::fill (unit_tangentials[GeometryInfo<dim>::faces_per_cell+i].begin(),
+                             unit_tangentials[GeometryInfo<dim>::faces_per_cell+i].end(),
+                             tang2);
                 }
 
               break;

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.