dgfgridtype.hh File Reference


Detailed Description

A simple strategy for defining a grid type depending on defines set during the make proecess:.

Author:
Robert Kloefkorn
 #if defined ALBERTAGRID && HAVE_ALBERTA
  typedef Dune::AlbertaGrid<dimworld,dimworld> GridType;
 #elif defined ALUGRID_CUBE && HAVE_ALUGRID
  typedef Dune::ALUCubeGrid<dimworld,dimworld> GridType;
 #elif defined ALUGRID_SIMPLEX && HAVE_ALUGRID
  typedef Dune::ALUSimplexGrid<dimworld,dimworld> GridType;
 #elif defined ONEDGRID
   typedef Dune::OneDGrid GridType;
 #elif defined SGRID
  typedef Dune::SGrid<dimworld,dimworld> GridType;
 #elif defined YASPGRID
  typedef Dune::YaspGrid<dimworld,dimworld> GridType;
 #else
  // default GridType is YaspGrid 
  typedef Dune::YaspGrid<dimworld,dimworld> GridType;
 #endif
The variable dimworld is determined by
   // default value is 2
   const int dimworld = GRIDDIM;
Remark:
  1. By defauly Dune::YaspGrid<2,2> is used.
  2. For ALBERTAGRID or ALUGRID with dimworld=1 Dune::OneDGrid is used.
To reduce differences between seriell and parallel runs as much as possible additional the Dune::MPIHelper class is used to toggle between serial and parallel runs via specialization of this class for runs using MPI und such that doesn't. To use this feature, the following code should always be called at the beginning of the function main:
 #include <dune/grid/io/file/dgfparser/dgfgridtype.hh>
 
 ...

 int main(int argc, char ** argv, char ** envp) {

   // get reference to the singelton MPIHelper 
   MPIHelper & mpiHelper = MPIHelper::instance(argc,argv);

   // optional one can get rank and size from this little helper class
   int myrank = mpiHelper.rank();
   int mysize = mpiHelper.size();

   ...
   // construct the grid
   GridPtr<GridType> grid(argv[1], mpiHelper.getCommunicator() );   

   GridType & grid = *gridptr;
   ...

   // as the MPIHelper is a singleton, on it's destruction the
   // MPI_Finalize() command is called. 
 }
To make use of this feature, one has to configure DUNE by using the --with-grid-dim=1|2|3 and optional --with-grid-type=ALBERTAGRID | ALUGRID_CUBE | ALUGRID_SIMPLEX | ONEDGRID | SGRID | UGGRID | YASPGRID. This will add the following to the ALL_PKG_CPPFLAGS
 -DGRIDDIM=$(GRIDDIM) -DGRIDTYPE=$(GRIDTYPE) 
No by adding the ALL_PKG_CPPFLAGS or GRIDDIM_CPPFLAGS to the programs CXXFLAGS one can choose the grids dimension and type by invoking the following make command
  make GRIDDIM=3 GRIDTYPE=ALBERTAGRID myprogram
Here the value 3 for grid dimension and ALBERTAGRID for grid type are passed as pre-processoer variables to gridtype.hh and are then used to define the typedef GridType.

#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
#include <dune/grid/utility/gridtype.hh>

Go to the source code of this file.

Generated on 6 Nov 2008 with Doxygen (ver 1.5.6) [logfile].