dune-grid  2.1.1
dgfug.hh
Go to the documentation of this file.
00001 #ifndef DUNE_DGFPARSERUG_HH
00002 #define DUNE_DGFPARSERUG_HH
00003 
00004 // only include if UG is used 
00005 #if defined ENABLE_UG 
00006 #include <dune/grid/uggrid.hh>
00007 #endif 
00008 
00009 #include "dgfparser.hh"
00010 namespace Dune
00011 {
00012 
00013 namespace dgf {
00014 
00030 class UGGridParameterBlock
00031 : public GridParameterBlock
00032 {
00033 protected:
00034   bool _noClosure;  // no closure for UGGrid 
00035   bool _noCopy;     // no copies  for UGGrid
00036   size_t _heapsize; // heap size  for UGGrid 
00037 
00038 public:
00040   UGGridParameterBlock(std::istream &in) 
00041     : GridParameterBlock( in ),
00042       _noClosure( false ),      // default value
00043       _noCopy( true ),          // default value
00044       _heapsize( 500 )          // default value (see UGGrid constructor)
00045   {
00046     // check closure 
00047     if (findtoken( "closure") )
00048     {
00049       std::string clo;
00050       if( getnextentry(clo) )
00051       {
00052         makeupcase(clo);
00053         if(clo == "NONE" )
00054         {
00055           _noClosure = true ;
00056         }
00057       }
00058     }
00059     else 
00060     {
00061       dwarn << "UGGridParameterBlock: Parameter 'closure' not specified, "
00062             << "defaulting to 'GREEN'." << std::endl;
00063     }
00064 
00065     if (findtoken( "copies") )
00066     {
00067       std::string copies;
00068       if( getnextentry(copies) )
00069       {
00070         makeupcase(copies);
00071         if(copies == "YES" )
00072         {
00073           _noCopy = false ;
00074         }
00075       }
00076     }
00077     else 
00078     {
00079       dwarn << "UGGridParameterBlock: Parameter 'copies' not specified, "
00080             << "no copies will be generated." << std::endl;
00081     }
00082 
00083     bool foundHeapSize = false ;
00084     if (findtoken( "heapsize") )
00085     {
00086       int heap;
00087       if( getnextentry( heap ) )
00088       {
00089         if( heap > 0 ) 
00090         {
00091           _heapsize = heap;
00092           foundHeapSize = true ;
00093         }
00094       }
00095     }
00096 
00097     if( ! foundHeapSize ) 
00098     {
00099       dwarn << "UGGridParameterBlock: Parameter 'heapsize' not specified, "
00100             << "defaulting to '500' MB." << std::endl;
00101     }
00102   }
00103 
00105   bool noClosure () const
00106   {
00107     return _noClosure;
00108   }
00109 
00111   bool noCopy () const
00112   {
00113     return _noCopy;
00114   }
00115 
00117   size_t heapSize() const 
00118   {
00119     return _heapsize;
00120   }
00121 };
00122 
00123 } // end namespace dgf 
00124 
00125 #if defined ENABLE_UG 
00126 
00127 template <int dim>
00128 class MacroGrid::Impl<UGGrid<dim> > {
00129   typedef MPIHelper::MPICommunicator MPICommunicatorType;
00130 public:
00131   static UGGrid<dim>* generate(MacroGrid& mg,
00132      const char* filename, MPICommunicatorType MPICOMM = MPIHelper::getCommunicator() );
00133 };
00134 template <int dimw>
00135 struct DGFGridInfo< UGGrid<dimw> > {
00136     static int refineStepsForHalf() {return 1;}
00137     static double refineWeight() {return -1.;}
00138 };
00140 #endif
00141 
00142 }
00143 
00144 #if defined ENABLE_UG 
00145 #include "dgfug.cc"
00146 #endif
00147 
00148 #endif