utility/gridtype.hh File Reference


Detailed Description

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

Author:
Andreas Dedner
 #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> GridType;
 #else
  // default GridType is YaspGrid 
  typedef Dune::YaspGrid<dimworld> GridType;
 #endif
The variable dimworld is determined by
   // default value is 2
   const int dimworld = GRIDDIM;
Remark:
  1. By defauly Dune::YaspGrid<2> is used.
  2. For ALBERTAGRID or ALUGRID with dimworld=1 Dune::OneDGrid is used.
To reduce differences between serial and parallel runs as much as possible, the Dune::MPIHelper class is used to toggle these runs. To use this feature, the following code should always be called at the beginning of the function main:
 #include <dune/grid/utility/gridtype.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, see documentation for constructors 
   GridType grid; 
   ...

   // 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/utility/griddim.hh>
#include <dune/grid/yaspgrid.hh>

Go to the source code of this file.


Generated on Tue Mar 3 12:06:54 2009 for dune-grid by  doxygen 1.5.6