1 #ifndef DUNE_FEM_TEST_TESTGRID_HH 2 #define DUNE_FEM_TEST_TESTGRID_HH 3 4 #include <sstream> 5 #include <string> 6 7 #include <dune/grid/io/file/dgfparser/dgfparser.hh> 8 9 namespace Dune 10 { 11 12 namespace Fem 13 { 14 15 // TestGrid 16 // -------- 17 18 class TestGrid 19 { 20 typedef TestGrid ThisType; 21 public: 22 typedef Dune::GridSelector::GridType HGridType; 23 24 protected: TestGrid(const std::string & name)25 TestGrid ( const std::string& name ) 26 : gridptr_( name ) 27 { 28 gridptr_->loadBalance(); 29 } 30 31 public: 32 TestGrid ( const ThisType & ) = delete; 33 34 ThisType &operator= ( const ThisType & ) = delete; 35 instance(const std::string & name)36 static ThisType &instance ( const std::string& name ) 37 { 38 static ThisType staticInstance( name ); 39 return staticInstance; 40 } 41 grid(const std::string name=macroGridName ())42 static HGridType &grid ( const std::string name = macroGridName() ) 43 { 44 return *(instance( name ).gridptr_); 45 } 46 refineStepsForHalf()47 static int refineStepsForHalf () 48 { 49 return DGFGridInfo< HGridType >::refineStepsForHalf(); 50 } 51 52 protected: macroGridName()53 static std::string macroGridName () 54 { 55 std::ostringstream s; 56 s << HGridType::dimension << "dgrid.dgf"; 57 return s.str(); 58 } 59 60 GridPtr< HGridType > gridptr_; 61 }; 62 63 } // namespace Fem 64 65 } // namespace Dune 66 67 #endif // #ifndef DUNE_FEM_TEST_TESTGRID_HH 68