visualization.cc 2.06 KB
Newer Older
Peter Bastian's avatar
Peter Bastian committed
1 2 3 4 5 6 7 8
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// $Id$

#include "config.h"
#include <iostream>
#include <iomanip>
#include <stdio.h>
Robert Klöfkorn's avatar
Robert Klöfkorn committed
9 10
#include <dune/common/mpihelper.hh> // include mpi helper class

Peter Bastian's avatar
Peter Bastian committed
11 12 13

#include "elementdata.hh"
#include "vertexdata.hh"
14 15
#include "functors.hh"
#include "unitcube.hh"
Peter Bastian's avatar
Peter Bastian committed
16

17 18 19

#ifdef GRIDDIM
const int dimGrid = GRIDDIM;
20 21
#else
const int dimGrid = 2;
22 23 24
#endif


Peter Bastian's avatar
Peter Bastian committed
25 26
//! supply functor
template<class Grid>
27
void dowork ( Grid &grid, int refSteps = 5 )
Peter Bastian's avatar
Peter Bastian committed
28 29
{
  // make function object
Peter Bastian's avatar
Peter Bastian committed
30
  Exp<typename Grid::ctype,Grid::dimension> f;
Peter Bastian's avatar
Peter Bastian committed
31 32

  // refine the grid
33
  grid.globalRefine( refSteps );
Peter Bastian's avatar
Peter Bastian committed
34 35 36 37 38 39 40 41

  // call the visualization functions
  elementdata(grid,f);
  vertexdata(grid,f);
}

int main(int argc, char **argv)
{
Robert Klöfkorn's avatar
Robert Klöfkorn committed
42 43
  // initialize MPI, finalize is done automatically on exit
  Dune::MPIHelper::instance(argc,argv);
Peter Bastian's avatar
Peter Bastian committed
44

45
  // start try/catch block to get error messages from dune
46 47
  try
  {
48
    /*
49
       UnitCube<Dune::OneDGrid,1> uc0;
50
       UnitCube<Dune::YaspGrid<dimGrid>,1> uc1;
51

52 53 54 55 56 57
       #if HAVE_UG
       UnitCube< Dune::UGGrid< dimGrid >, 2 > uc2;
       dowork( uc2.grid(), 3 );
       #endif

       #if HAVE_ALBERTA
58 59
       {
       UnitCube< Dune::AlbertaGrid< dimGrid, dimGrid >, 1 > unitcube;
60
       // note: The 3d cube cannot be bisected recursively
61 62 63
       dowork( unitcube.grid(), (dimGrid < 3 ? 6 : 0) );
       }
       #endif // #if HAVE_ALBERTA
64
     */
65 66 67

    UnitCube< Dune::SGrid< dimGrid, dimGrid >, 1 > uc4;
    dowork( uc4.grid(), 3 );
Peter Bastian's avatar
Peter Bastian committed
68

69
#if HAVE_ALUGRID
70 71 72 73 74 75
    UnitCube< Dune::ALUSimplexGrid< dimGrid, dimGrid > , 1 > uc5;
    dowork( uc5.grid(), 3 );

#if GRIDDIM == 3
    UnitCube< Dune::ALUCubeGrid< dimGrid, dimGrid > , 1 > uc6;
    dowork( uc6.grid(), 3 );
76 77
#endif // #if GRIDDIM == 3
#endif // #if HAVE_ALUGRID
78 79 80 81 82 83 84 85 86 87 88 89 90
  }
  catch (std::exception & e) {
    std::cout << "STL ERROR: " << e.what() << std::endl;
    return 1;
  }
  catch (Dune::Exception & e) {
    std::cout << "DUNE ERROR: " << e.what() << std::endl;
    return 1;
  }
  catch (...) {
    std::cout << "Unknown ERROR" << std::endl;
    return 1;
  }
Peter Bastian's avatar
Peter Bastian committed
91 92 93 94

  // done
  return 0;
}