]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Make a function a bit more abstract by doing away with concrete
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 16 Jul 2009 23:01:34 +0000 (23:01 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Thu, 16 Jul 2009 23:01:34 +0000 (23:01 +0000)
template parameters and deducing them from other template arguments.

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

deal.II/deal.II/source/grid/grid_tools.cc

index b43ced022a017c48776fa7b246bed04d476bc468..c69e9145c7977c6272492aabe621ecf37e7cbdb3 100644 (file)
@@ -1243,11 +1243,15 @@ namespace internal
   {
     namespace FixUpDistortedChildCells
     {
-      template <int dim, int spacedim>
+      template <typename Iterator, int spacedim>
       double
-      objective_function (const typename dealii::Triangulation<dim,spacedim>::cell_iterator &cell,
+      objective_function (const Iterator &cell,
                          const Point<spacedim> &cell_mid_point)
       {
+       const unsigned int dim = Iterator::AccessorType::structure_dimension;
+       Assert (spacedim == Iterator::AccessorType::dimension,
+               ExcInternalError());
+       
                                         // everything below is wrong
                                         // if not for the following
                                         // condition
@@ -1371,18 +1375,16 @@ namespace internal
       
                                             // compute the objective
                                             // function and its derivative
-           const double val = objective_function<dim,spacedim> (cell, cell_mid_point);
+           const double val = objective_function (cell, cell_mid_point);
 
            Tensor<1,dim> gradient;
            for (unsigned int d=0; d<dim; ++d)
              {
                Point<dim> h;
                h[d] = step_length/2;
-               gradient[d] = (objective_function<dim,spacedim> (cell,
-                                                                cell_mid_point + h)
+               gradient[d] = (objective_function (cell, cell_mid_point + h)
                               -
-                              objective_function<dim,spacedim> (cell,
-                                                                cell_mid_point - h))
+                              objective_function (cell, cell_mid_point - h))
                              /
                              step_length;
              }

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.