dgfalu.hh
00001 #ifndef DUNE_DGFPARSERALU_HH
00002 #define DUNE_DGFPARSERALU_HH
00003
00004
00005 #if defined ENABLE_ALUGRID
00006
00007 #include <dune/grid/alugrid.hh>
00008 #include <dune/grid/io/file/dgfparser/dgfparser.hh>
00009
00010 namespace Dune
00011 {
00012
00013 template <int dim,int dimworld>
00014 class MacroGrid::Impl<ALUCubeGrid<dim,dimworld> > {
00015 typedef MPIHelper::MPICommunicator MPICommunicatorType;
00016 public:
00017 static ALUCubeGrid<dim,dimworld>*
00018 generate(MacroGrid& mg,
00019 const char* filename,
00020 MPICommunicatorType MPICOMM = MPIHelper::getCommunicator() );
00021
00022 private:
00023 inline void
00024 generateAlu3d(MacroGrid& mg,
00025 const char* filename, std::string& str, MPICommunicatorType MPICOMM );
00026
00027 static bool fileExists ( const char *fileName )
00028 {
00029 std :: ifstream testfile( fileName );
00030 if( !testfile )
00031 return false;
00032 testfile.close();
00033 return true;
00034 }
00035 };
00036
00037
00038 template <int dim,int dimworld>
00039 class MacroGrid::Impl<ALUSimplexGrid<dim,dimworld> > {
00040 typedef MPIHelper::MPICommunicator MPICommunicatorType;
00041 friend class MacroGrid::Impl<ALUConformGrid<dim,dimworld> >;
00042 public:
00043 static ALUSimplexGrid<dim,dimworld>*
00044 generate(MacroGrid& mg,
00045 const char* filename,
00046 MPICommunicatorType MPICOMM = MPIHelper::getCommunicator() );
00047
00048 private:
00049 inline void
00050 generateAlu3d(MacroGrid& mg,
00051 const char* filename, std::string& str, MPICommunicatorType MPICOMM );
00052
00053 static bool fileExists ( const char *fileName )
00054 {
00055 std :: ifstream testfile( fileName );
00056 if( !testfile )
00057 return false;
00058 testfile.close();
00059 return true;
00060 }
00061
00062
00063 };
00064
00065
00066
00067 template <int dim,int dimworld>
00068 class MacroGrid::Impl<ALUConformGrid<dim,dimworld> > {
00069 typedef MPIHelper::MPICommunicator MPICommunicatorType;
00070 public:
00071 static ALUConformGrid<dim,dimworld>*
00072 generate(MacroGrid& mg,
00073 const char* filename,
00074 MPICommunicatorType MPICOMM = MPIHelper::getCommunicator() );
00075 private:
00076 inline void
00077 generateAlu3d(MacroGrid& mg,
00078 const char* filename, std::string& str, MPICommunicatorType MPICOMM );
00079 };
00080 template <>
00081 struct DGFGridInfo<ALUCubeGrid<3,3> > {
00082 static int refineStepsForHalf() {return 1;}
00083 static double refineWeight() {return pow(0.5,3);}
00084 };
00085 template <int dimworld>
00086 struct DGFGridInfo< ALUSimplexGrid<dimworld,dimworld> > {
00087 static int refineStepsForHalf() {return 1;}
00088 static double refineWeight() {return pow(0.5,dimworld);}
00089 };
00090 template <>
00091 struct DGFGridInfo< Dune::ALUConformGrid<2,2> > {
00092 static int refineStepsForHalf() { return 2; }
00093 static double refineWeight() { return 0.5; }
00094 };
00095 }
00096 #include "dgfalu.cc"
00097 #endif
00098
00099 #endif