From c5db3e7bdb69801bdf7cb0310bd4b19b2416a497 Mon Sep 17 00:00:00 2001
From: Oliver Sander <sander@igpm.rwth-aachen.de>
Date: Sat, 25 Jul 2015 12:46:13 +0200
Subject: [PATCH] Use the StructuredGridFactory to construct test grids

This simplifies the code a little.  It will also make it easier to
use YaspGrid for testing.
---
 dune/solvers/test/common.hh | 39 +++++++++++--------------------------
 1 file changed, 11 insertions(+), 28 deletions(-)

diff --git a/dune/solvers/test/common.hh b/dune/solvers/test/common.hh
index d269aed8..fde2299d 100644
--- a/dune/solvers/test/common.hh
+++ b/dune/solvers/test/common.hh
@@ -13,7 +13,7 @@
 
 #include <dune/localfunctions/lagrange/pqkfactory.hh>
 
-#include <dune/grid/common/gridfactory.hh>
+#include <dune/grid/utility/structuredgridfactory.hh>
 
 #if HAVE_UG
 #include <dune/grid/uggrid.hh>
@@ -361,40 +361,23 @@ void markBoundaryDOFs(const GridView& gridView, BitVector& isBoundary)
 }
 
 
-template<class GridType>
-GridType* constructCoarseGrid()
+template<class GridType, class TestSuite>
+bool checkWithGrid(TestSuite& suite, int uniformRefinements, std::string name)
 {
     const int dim=GridType::dimension;
-    typename Dune::GridFactory<GridType> gridFactory;
-
-    typename Dune::FieldVector<double,dim> pos(0);
-    gridFactory.insertVertex(pos);
-    for (int i=0; i<dim; i++) {
-        pos = 0;   pos[i] = 1;
-        gridFactory.insertVertex(pos);
-    }
-
-    std::vector<unsigned int> element(dim+1);
-    for (int i=0; i<dim+1; i++)
-        element[i] = i;
+    Dune::FieldVector<double,dim> lower(0);
+    Dune::FieldVector<double,dim> upper(1);
 
-    gridFactory.insertElement( Dune::GeometryType(Dune::GeometryType::simplex,dim), element);
+    std::array<unsigned int,dim> elements;
+    std::fill(elements.begin(), elements.end(), 1);
 
-    return gridFactory.createGrid();
-}
-
-
-template<class GridType, class TestSuite>
-bool checkWithGrid(TestSuite& suite, int uniformRefinements, std::string name)
-{
-    typename std::template auto_ptr<GridType> gridPtr(constructCoarseGrid<GridType>());
-    GridType& grid = *gridPtr;
+    std::shared_ptr<GridType> grid = Dune::StructuredGridFactory<GridType>::createSimplexGrid(lower,upper,elements);
 
-    grid.globalRefine(uniformRefinements);
+    grid->globalRefine(uniformRefinements);
 
-    std::cout << "Running test on " << name << " with " << grid.size(0) << " elements." << std::endl;
+    std::cout << "Running test on " << name << " with " << grid->size(0) << " elements." << std::endl;
 
-    bool passed = suite.check(grid);
+    bool passed = suite.check(*grid);
     if (passed)
         std::cout << "All tests passed with " << name << "." << std::endl;
     return passed;
-- 
GitLab