]> https://gitweb.dealii.org/ - dealii-svn.git/commitdiff
Use Table objects instead of vectors of vectors.
authorwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 21 Oct 2002 14:17:31 +0000 (14:17 +0000)
committerwolf <wolf@0785d39b-7218-0410-832d-ea1e28bc413d>
Mon, 21 Oct 2002 14:17:31 +0000 (14:17 +0000)
git-svn-id: https://svn.dealii.org/trunk@6692 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/base/include/base/data_out_base.h
deal.II/base/source/data_out_base.cc
deal.II/base/source/polynomial_space.cc
deal.II/base/source/table_handler.cc
deal.II/base/source/tensor_product_polynomials.cc

index 48c88b07552d26879713343be800360e2d09a2ce..aab724c0ec47e05710c91483bb1327debdd30392 100644 (file)
@@ -18,6 +18,7 @@
 #include <base/point.h>
 #include <base/table.h>
 #include <grid/geometry_info.h>
+
 #include <vector>
 #include <string>
 
@@ -1529,15 +1530,16 @@ class DataOutBase
                                      * thus moved into this separate
                                      * function.
                                      *
-                                     * Note that because of the close
-                                     * similarity of the two formats,
+                                     * Note that because of the
+                                     * similarity of the formats,
                                      * this function is also used by
-                                     * the Vtk output function.
+                                     * the Vtk and Tecplot output
+                                     * functions.
                                      */
     template <int dim, int spacedim>
     static void
     write_gmv_reorder_data_vectors (const std::vector<Patch<dim,spacedim> > &patches,
-                                   std::vector<std::vector<double> >       &data_vectors);
+                                   Table<2,double>                         &data_vectors);
 
 };
 
index 34bd75ee8e143644eb8e1a25b42db56a97f516ce..8a192e48bb355a5a2dae000c9d808266ca616717 100644 (file)
@@ -2086,11 +2086,10 @@ void DataOutBase::write_gmv (const std::vector<Patch<dim,spacedim> > &patches,
                                   // separate thread and when wanting
                                   // to write out the data, we wait
                                   // for that thread to finish
-  std::vector<std::vector<double> > data_vectors (n_data_sets,
-                                                 std::vector<double> (n_nodes));
+  Table<2,double> data_vectors (n_data_sets, n_nodes);
   Threads::ThreadManager thread_manager;
   void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &,
-                  std::vector<std::vector<double> >                &)
+                  Table<2,double> &)
     = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
   Threads::spawn (thread_manager,
                  Threads::encapsulate (fun_ptr)
@@ -2443,229 +2442,229 @@ void DataOutBase::write_tecplot (const std::vector<Patch<dim,spacedim> > &patche
       };
   };
 
-
-                                   // in Tecplot FEBLOCK format the vertex
-                                   // coordinates and the data have an
-                                   // order that is a bit unpleasant
-                                   // (first all x coordinates, then
-                                   // all y coordinate, ...; first all
-                                   // data of variable 1, then
-                                   // variable 2, etc), so we have to
-                                   // copy the data vectors a bit around
-                                   //
-                                   // note that we copy vectors when
-                                   // looping over the patches since we
-                                   // have to write them one variable
-                                   // at a time and don't want to use
-                                   // more than one loop
-                                   //
-                                   // this copying of data vectors can
-                                   // be done while we already output
-                                   // the vertices, so do this on a
-                                   // separate thread and when wanting
-                                   // to write out the data, we wait
-                                   // for that thread to finish
   
-   std::vector<std::vector<double> > data_vectors (n_data_sets,
-                                                  std::vector<double> (n_nodes));
-   Threads::ThreadManager thread_manager;
-   void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &,
-                   std::vector<std::vector<double> >                &)
-     = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
-   Threads::spawn (thread_manager,
-                  Threads::encapsulate (fun_ptr)
-                  .collect_args(patches, data_vectors));
+                                   // in Tecplot FEBLOCK format the vertex
+                                   // coordinates and the data have an
+                                   // order that is a bit unpleasant
+                                   // (first all x coordinates, then
+                                   // all y coordinate, ...; first all
+                                   // data of variable 1, then
+                                   // variable 2, etc), so we have to
+                                   // copy the data vectors a bit around
+                                   //
+                                   // note that we copy vectors when
+                                   // looping over the patches since we
+                                   // have to write them one variable
+                                   // at a time and don't want to use
+                                   // more than one loop
+                                   //
+                                   // this copying of data vectors can
+                                   // be done while we already output
+                                   // the vertices, so do this on a
+                                   // separate thread and when wanting
+                                   // to write out the data, we wait
+                                   // for that thread to finish
+  
+  Table<2,double> data_vectors (n_data_sets, n_nodes);
 
-                                   ///////////////////////////////
-                                   // first make up a list of used
-                                   // vertices along with their
-                                   // coordinates
+  Threads::ThreadManager thread_manager;
+  void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &,
+                   Table<2,double> &)
+    = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
+  Threads::spawn (thread_manager,
+                  Threads::encapsulate (fun_ptr)
+                  .collect_args(patches, data_vectors));
+
+                                   ///////////////////////////////
+                                   // first make up a list of used
+                                   // vertices along with their
+                                   // coordinates
 
   
-   for (unsigned int d=1; d<=spacedim; ++d)
-     {       
+  for (unsigned int d=1; d<=spacedim; ++d)
+    {       
           
-       for (typename std::vector<Patch<dim,spacedim> >::const_iterator patch=patches.begin();
-           patch!=patches.end(); ++patch)
-        {
-          const unsigned int n_subdivisions = patch->n_subdivisions;
+      for (typename std::vector<Patch<dim,spacedim> >::const_iterator patch=patches.begin();
+           patch!=patches.end(); ++patch)
+        {
+          const unsigned int n_subdivisions = patch->n_subdivisions;
          
-          switch (dim)
-            {
-              case 1:
-              {
-                for (unsigned int i=0; i<n_subdivisions+1; ++i)
-                  out << ((patch->vertices[1](0) * i / n_subdivisions) +
-                          (patch->vertices[0](0) * (n_subdivisions-i) / n_subdivisions))
-                      << '\n';
-                break;
-              };
+          switch (dim)
+            {
+              case 1:
+              {
+                for (unsigned int i=0; i<n_subdivisions+1; ++i)
+                  out << ((patch->vertices[1](0) * i / n_subdivisions) +
+                          (patch->vertices[0](0) * (n_subdivisions-i) / n_subdivisions))
+                      << '\n';
+                break;
+              };
              
-              case 2:
-              {
-                for (unsigned int i=0; i<n_subdivisions+1; ++i)
-                  for (unsigned int j=0; j<n_subdivisions+1; ++j)
-                    {
-                      const double x_frac = i * 1./n_subdivisions,
-                                   y_frac = j * 1./n_subdivisions;
+              case 2:
+              {
+                for (unsigned int i=0; i<n_subdivisions+1; ++i)
+                  for (unsigned int j=0; j<n_subdivisions+1; ++j)
+                    {
+                      const double x_frac = i * 1./n_subdivisions,
+                                   y_frac = j * 1./n_subdivisions;
                      
-                                                       // compute coordinates for
-                                                       // this patch point
-
-                      out << (((patch->vertices[1](d-1) * x_frac) +
-                               (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
-                              ((patch->vertices[2](d-1) * x_frac) +
-                               (patch->vertices[3](d-1) * (1-x_frac))) * y_frac)
-                          << '\n';
-                    };
-                break;
-              };
+                                                       // compute coordinates for
+                                                       // this patch point
+
+                      out << (((patch->vertices[1](d-1) * x_frac) +
+                               (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
+                              ((patch->vertices[2](d-1) * x_frac) +
+                               (patch->vertices[3](d-1) * (1-x_frac))) * y_frac)
+                          << '\n';
+                    };
+                break;
+              };
              
-              case 3:
-              {
-                for (unsigned int i=0; i<n_subdivisions+1; ++i)
-                  for (unsigned int j=0; j<n_subdivisions+1; ++j)
-                    for (unsigned int k=0; k<n_subdivisions+1; ++k)
-                      {
-                                                         // note the broken
-                                                         // design of hexahedra
-                                                         // in deal.II, where
-                                                         // first the z-component
-                                                         // is counted up, before
-                                                         // increasing the y-
-                                                         // coordinate
-                        const double x_frac = i * 1./n_subdivisions,
-                                     y_frac = k * 1./n_subdivisions,
-                                     z_frac = j * 1./n_subdivisions;
+              case 3:
+              {
+                for (unsigned int i=0; i<n_subdivisions+1; ++i)
+                  for (unsigned int j=0; j<n_subdivisions+1; ++j)
+                    for (unsigned int k=0; k<n_subdivisions+1; ++k)
+                      {
+                                                         // note the broken
+                                                         // design of hexahedra
+                                                         // in deal.II, where
+                                                         // first the z-component
+                                                         // is counted up, before
+                                                         // increasing the y-
+                                                         // coordinate
+                        const double x_frac = i * 1./n_subdivisions,
+                                     y_frac = k * 1./n_subdivisions,
+                                     z_frac = j * 1./n_subdivisions;
                        
-                                                         // compute coordinates for
-                                                         // this patch point
+                                                         // compute coordinates for
+                                                         // this patch point
                         
-                        out << ((((patch->vertices[1](d-1) * x_frac) +
-                                  (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
-                                 ((patch->vertices[2](d-1) * x_frac) +
-                                  (patch->vertices[3](d-1) * (1-x_frac))) * y_frac)   * (1-z_frac) +
-                                (((patch->vertices[5](d-1) * x_frac) +
-                                  (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) +
-                                 ((patch->vertices[6](d-1) * x_frac) +
-                                  (patch->vertices[7](d-1) * (1-x_frac))) * y_frac)   * z_frac)
-                            << '\n';
-                      };
-                break;
-              };
+                        out << ((((patch->vertices[1](d-1) * x_frac) +
+                                  (patch->vertices[0](d-1) * (1-x_frac))) * (1-y_frac) +
+                                 ((patch->vertices[2](d-1) * x_frac) +
+                                  (patch->vertices[3](d-1) * (1-x_frac))) * y_frac)   * (1-z_frac) +
+                                (((patch->vertices[5](d-1) * x_frac) +
+                                  (patch->vertices[4](d-1) * (1-x_frac))) * (1-y_frac) +
+                                 ((patch->vertices[6](d-1) * x_frac) +
+                                  (patch->vertices[7](d-1) * (1-x_frac))) * y_frac)   * z_frac)
+                            << '\n';
+                      };
+                break;
+              };
              
-              default:
-                    Assert (false, ExcNotImplemented());
-            };
-        };
-       out << std::endl;
-     };
+              default:
+                    Assert (false, ExcNotImplemented());
+            };
+        };
+      out << std::endl;
+    };
 
 
-                                   ///////////////////////////////////////
-                                   // data output.
-                                   //
-                                   // now write the data vectors to
-                                   // @p{out} first make sure that all
-                                   // data is in place
-   thread_manager.wait ();
+                                   ///////////////////////////////////////
+                                   // data output.
+                                   //
+                                   // now write the data vectors to
+                                   // @p{out} first make sure that all
+                                   // data is in place
+  thread_manager.wait ();
 
-                                   // then write data.
-   for (unsigned int data_set=0; data_set<n_data_sets; ++data_set)
-     {
+                                   // then write data.
+  for (unsigned int data_set=0; data_set<n_data_sets; ++data_set)
+    {
        
-       copy(data_vectors[data_set].begin(),
-           data_vectors[data_set].end(),
-           std::ostream_iterator<double>(out, "\n"));
-       out << std::endl;
-     };
+      copy(data_vectors[data_set].begin(),
+           data_vectors[data_set].end(),
+           std::ostream_iterator<double>(out, "\n"));
+      out << std::endl;
+    };
 
   
-                                   /////////////////////////////////
-                                   // now for the cells. note that
-                                   // vertices are counted from 1 onwards
+                                   /////////////////////////////////
+                                   // now for the cells. note that
+                                   // vertices are counted from 1 onwards
 
-   unsigned int first_vertex_of_patch = 0;
+  unsigned int first_vertex_of_patch = 0;
       
-   for (typename std::vector<Patch<dim,spacedim> >::const_iterator patch=patches.begin();
-       patch!=patches.end(); ++patch)
-     {
-       const unsigned int n_subdivisions = patch->n_subdivisions;
+  for (typename std::vector<Patch<dim,spacedim> >::const_iterator patch=patches.begin();
+       patch!=patches.end(); ++patch)
+    {
+      const unsigned int n_subdivisions = patch->n_subdivisions;
       
-                                       // write out the cells making
-                                       // up this patch
-       switch (dim)
-        {
-          case 1:
-          {
-            break;
-          };
-          case 2:
-          {
-            for (unsigned int i=0; i<n_subdivisions; ++i)
-              for (unsigned int j=0; j<n_subdivisions; ++j)
-                {
-
-                  out << first_vertex_of_patch+i*(n_subdivisions+1)+j+1 << ' '
-                      << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1 << ' '
-                      << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1+1 << ' '
-                      << first_vertex_of_patch+i*(n_subdivisions+1)+j+1+1
-                      << std::endl;
-                };
-            break;
-          };
+                                       // write out the cells making
+                                       // up this patch
+      switch (dim)
+        {
+          case 1:
+          {
+            break;
+          };
+          case 2:
+          {
+            for (unsigned int i=0; i<n_subdivisions; ++i)
+              for (unsigned int j=0; j<n_subdivisions; ++j)
+                {
+
+                  out << first_vertex_of_patch+i*(n_subdivisions+1)+j+1 << ' '
+                      << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1 << ' '
+                      << first_vertex_of_patch+(i+1)*(n_subdivisions+1)+j+1+1 << ' '
+                      << first_vertex_of_patch+i*(n_subdivisions+1)+j+1+1
+                      << std::endl;
+                };
+            break;
+          };
              
-          case 3:
-          {
-            for (unsigned int i=0; i<n_subdivisions; ++i)
-              for (unsigned int j=0; j<n_subdivisions; ++j)
-                for (unsigned int k=0; k<n_subdivisions; ++k)
-                  {
-                                                     // note: vertex indices start with 1!
+          case 3:
+          {
+            for (unsigned int i=0; i<n_subdivisions; ++i)
+              for (unsigned int j=0; j<n_subdivisions; ++j)
+                for (unsigned int k=0; k<n_subdivisions; ++k)
+                  {
+                                                     // note: vertex indices start with 1!
                     
-                    out << first_vertex_of_patch+(i*(n_subdivisions+1)+j      )*(n_subdivisions+1)+k  +1 << ' '
-                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j  )*(n_subdivisions+1)+k  +1 << ' '
-                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k  +1 << ' '
-                        << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1    )*(n_subdivisions+1)+k  +1 << ' '
-                        << first_vertex_of_patch+(i*(n_subdivisions+1)+j      )*(n_subdivisions+1)+k+1+1 << ' '
-                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j  )*(n_subdivisions+1)+k+1+1 << ' '
-                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1+1 << ' '
-                        << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1    )*(n_subdivisions+1)+k+1+1 << ' '
-                        << std::endl;
-                  };
-            break;
-          };
-
-          default:
-                Assert (false, ExcNotImplemented());
-        };
-
-
-                                       // finally update the number
-                                       // of the first vertex of this patch
-       switch (dim)
-        {
-          case 1:
-                first_vertex_of_patch += n_subdivisions+1;
-                break;
-          case 2:
-                first_vertex_of_patch += (n_subdivisions+1) *
-                                         (n_subdivisions+1);
-                break;
-          case 3:
-                first_vertex_of_patch += (n_subdivisions+1) *
-                                         (n_subdivisions+1) *
-                                         (n_subdivisions+1);
-                break;
-          default:
-                Assert (false, ExcNotImplemented());
-        };
+                    out << first_vertex_of_patch+(i*(n_subdivisions+1)+j      )*(n_subdivisions+1)+k  +1 << ' '
+                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j  )*(n_subdivisions+1)+k  +1 << ' '
+                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k  +1 << ' '
+                        << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1    )*(n_subdivisions+1)+k  +1 << ' '
+                        << first_vertex_of_patch+(i*(n_subdivisions+1)+j      )*(n_subdivisions+1)+k+1+1 << ' '
+                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j  )*(n_subdivisions+1)+k+1+1 << ' '
+                        << first_vertex_of_patch+((i+1)*(n_subdivisions+1)+j+1)*(n_subdivisions+1)+k+1+1 << ' '
+                        << first_vertex_of_patch+(i*(n_subdivisions+1)+j+1    )*(n_subdivisions+1)+k+1+1 << ' '
+                        << std::endl;
+                  };
+            break;
+          };
+
+          default:
+                Assert (false, ExcNotImplemented());
+        };
+
+
+                                       // finally update the number
+                                       // of the first vertex of this patch
+      switch (dim)
+        {
+          case 1:
+                first_vertex_of_patch += n_subdivisions+1;
+                break;
+          case 2:
+                first_vertex_of_patch += (n_subdivisions+1) *
+                                         (n_subdivisions+1);
+                break;
+          case 3:
+                first_vertex_of_patch += (n_subdivisions+1) *
+                                         (n_subdivisions+1) *
+                                         (n_subdivisions+1);
+                break;
+          default:
+                Assert (false, ExcNotImplemented());
+        };
        
-     };
+    };
 
   
-                                   // assert the stream is still ok
-   AssertThrow (out, ExcIO());
+                                   // assert the stream is still ok
+  AssertThrow (out, ExcIO());
 };
 
 
@@ -2893,11 +2892,11 @@ void DataOutBase::write_tecplot_binary (const std::vector<Patch<dim,spacedim> >
                                    // to write out the data, we wait
                                    // for that thread to finish
   
-   std::vector<std::vector<double> > data_vectors (n_data_sets,
-                                                  std::vector<double> (n_nodes));
+  Table<2,double> data_vectors (n_data_sets, n_nodes);
+
    Threads::ThreadManager thread_manager;
    void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &,
-                   std::vector<std::vector<double> >                &)
+                   Table<2,dim> &)
      = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
    Threads::spawn (thread_manager,
                   Threads::encapsulate (fun_ptr)
@@ -3217,11 +3216,11 @@ void DataOutBase::write_vtk (const std::vector<Patch<dim,spacedim> > &patches,
                                   // separate thread and when wanting
                                   // to write out the data, we wait
                                   // for that thread to finish
-  std::vector<std::vector<double> > data_vectors (n_data_sets,
-                                                 std::vector<double> (n_nodes));
+  Table<2,double> data_vectors (n_data_sets, n_nodes);
+
   Threads::ThreadManager thread_manager;
   void (*fun_ptr) (const std::vector<Patch<dim,spacedim> > &,
-                  std::vector<std::vector<double> >                &)
+                  Table<2,double> &)
     = &DataOutBase::template write_gmv_reorder_data_vectors<dim,spacedim>;
   Threads::spawn (thread_manager,
                  Threads::encapsulate (fun_ptr)
@@ -3456,7 +3455,7 @@ void DataOutBase::write_vtk (const std::vector<Patch<dim,spacedim> > &patches,
 template <int dim, int spacedim>
 void
 DataOutBase::write_gmv_reorder_data_vectors (const std::vector<Patch<dim,spacedim> > &patches,
-                                            std::vector<std::vector<double> >       &data_vectors)
+                                            Table<2,double>                         &data_vectors)
 {
                                   // unlike in the main function, we
                                   // don't have here the data_names
@@ -3467,7 +3466,7 @@ DataOutBase::write_gmv_reorder_data_vectors (const std::vector<Patch<dim,spacedi
                                   // in the main function.
   const unsigned int n_data_sets = patches[0].data.n_rows();
 
-  Assert (data_vectors.size() == n_data_sets,
+  Assert (data_vectors.size()[0] == n_data_sets,
          ExcInternalError());
   
                                   // loop over all patches
index 50e9453f26b20f448b445d5b841eb63f41fe3965..fbda5c562daec007fe1659cafdbbb4609db7bb2c 100644 (file)
@@ -12,8 +12,9 @@
 //----------------------  polynomial_space.cc  ------------
 
 
-#include <base/exceptions.h>
 #include <base/polynomial_space.h>
+#include <base/exceptions.h>
+#include <base/table.h>
 
 
 template <int dim>
@@ -167,23 +168,18 @@ void PolynomialSpace<dim>::compute(
     }
 
                                   // Store data in a single
-                                  // vector. Access is by
+                                  // object. Access is by
                                   // v[d][n][o]
                                   //  d: coordinate direction
                                   //  n: number of 1d polynomial
                                   //  o: order of derivative
-  std::vector<std::vector<std::vector<double> > >
-    v(dim,
-      std::vector<std::vector<double> > (n_1d,
-                                        std::vector<double> (v_size, 0.)));
-
-  for (unsigned int d=0; d<dim; ++d)
-    {
-      std::vector<std::vector<double> >& v_d=v[d];
-      Assert(v_d.size()==n_1d, ExcInternalError());
-      for (unsigned int i=0; i<n_1d; ++i)
-       polynomials[i].value(p(d), v_d[i]);
-    }
+  Table<2,std::vector<double> > v(dim, n_1d);
+  for (unsigned int d=0; d<v.size()[0]; ++d)
+    for (unsigned int i=0; i<v.size()[1]; ++i)
+      {
+        v(d,i).resize (v_size, 0.);
+        polynomials[i].value(p(d), v(d,i));
+      };
 
   if (update_values)
     {
@@ -207,8 +203,8 @@ void PolynomialSpace<dim>::compute(
            {
              for (unsigned int d=0;d<dim;++d)
                grads[k][d] = v[0][ix][(d==0) ? 1 : 0]
-    * ((dim>1) ? v[1][iy][(d==1) ? 1 : 0] : 1.)
-    * ((dim>2) ? v[2][iz][(d==2) ? 1 : 0] : 1.);
+                              * ((dim>1) ? v[1][iy][(d==1) ? 1 : 0] : 1.)
+                              * ((dim>2) ? v[2][iz][(d==2) ? 1 : 0] : 1.);
              ++k;
            }
     }
index 4009e03d170a059cbe34e905e7859e25165c6f80..934431d84f3ee0acb27b453767ee28d66ffa601c 100644 (file)
@@ -13,6 +13,7 @@
 
 
 #include <base/table_handler.h>
+#include <base/table.h>
 
 #ifdef HAVE_STD_STRINGSTREAM
 #  include <sstream>
@@ -123,8 +124,8 @@ void TableHandler::add_column_to_supercolumn (const std::string &key,
 
   if (!supercolumns.count(superkey))
     {
-      std::pair<std::string, std::vector<std::string> > new_column(superkey,
-                                                                  std::vector<std::string>());
+      std::pair<std::string, std::vector<std::string> >
+        new_column(superkey, std::vector<std::string>());
       supercolumns.insert(new_column);
                                       // replace key in column_order
                                       // by superkey
@@ -225,8 +226,7 @@ void TableHandler::write_text(std::ostream &out) const
                                   // first compute the widths of each
                                   // entry of the table, in order to
                                   // have a nicer alignement
-  std::vector<std::vector<unsigned int> >
-    entry_widths (nrows, std::vector<unsigned int>(n_cols));
+  Table<2,unsigned int> entry_widths (nrows, n_cols);
   for (unsigned int i=0; i<nrows; ++i)
     for (unsigned int j=0; j<n_cols; ++j)
       {
index a22a476790a0217d81223d222bce2070f2dc2165..8c4a42b6e6202971c833fedf05a80097133282a3 100644 (file)
 //----------------------  tensor_product_polynomials.cc  ------------
 
 
-#include <base/exceptions.h>
 #include <base/tensor_product_polynomials.h>
+#include <base/exceptions.h>
+#include <base/table.h>
+
 
 
 
@@ -50,9 +52,12 @@ TensorProductPolynomials<dim>::compute_grad(const unsigned int i,
                                            const Point<dim> &p) const
 {
   const unsigned int n_pols=polynomials.size();
-  
-  std::vector<std::vector<double> > v(dim, std::vector<double> (2));
 
+                                   // compute values and
+                                   // uni-directional derivatives at
+                                   // the given point in each
+                                   // co-ordinate direction
+  std::vector<std::vector<double> > v(dim, std::vector<double> (2));
   for (unsigned int d=0; d<dim; ++d)
     polynomials[(i/n_pols_to[d])%n_pols].value(p(d), v[d]);
   
@@ -140,16 +145,13 @@ void TensorProductPolynomials<dim>::compute(
       v_size=3;
     }
 
-  std::vector<std::vector<std::vector<double> > > v(
-    dim, std::vector<std::vector<double> > (n_pols, std::vector<double> (v_size)));
-
-  for (unsigned int d=0; d<dim; ++d)
-    {
-      std::vector<std::vector<double> > &v_d=v[d];
-      Assert(v_d.size()==n_pols, ExcInternalError());
-      for (unsigned int i=0; i<n_pols; ++i)
-       polynomials[i].value(p(d), v_d[i]);
-    }
+  Table<2,std::vector<double> > v(dim, n_pols);
+  for (unsigned int d=0; d<v.size()[0]; ++d)
+    for (unsigned int i=0; i<v.size()[1]; ++i)
+      {
+        v(d,i).resize (v_size, 0.);
+        polynomials[i].value(p(d), v(d,i));
+      };
   
   if (update_values)
     {

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.