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

4
#include <config.h>
Peter Bastian's avatar
Peter Bastian committed
5 6 7
#include <iostream>
#include <iomanip>
#include <stdio.h>
8
#include <dune/common/parallel/mpihelper.hh> // include mpi helper class
9
#include <dune/grid/io/file/dgfparser/dgfparser.hh>
Robert Klöfkorn's avatar
Robert Klöfkorn committed
10

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 50 51 52 53 54 55
    if( argc > 1 )
    {
      typedef Dune::GridSelector::GridType DGFGridType;
      // create grid pointer
      Dune :: GridPtr< DGFGridType > gridPtr( argv[ 1 ] );
      dowork( *gridPtr, 3 );
    }

56
    /*
57
       UnitCube<Dune::OneDGrid,1> uc0;
58 59
     */

60
       UnitCube<Dune::YaspGrid<dimGrid>,1> uc1;
61
       dowork( uc1.grid(), 3 );
62

63
    /*
64 65 66 67 68 69
       #if HAVE_UG
       UnitCube< Dune::UGGrid< dimGrid >, 2 > uc2;
       dowork( uc2.grid(), 3 );
       #endif

       #if HAVE_ALBERTA
70 71
       {
       UnitCube< Dune::AlbertaGrid< dimGrid, dimGrid >, 1 > unitcube;
72
       // note: The 3d cube cannot be bisected recursively
73 74 75
       dowork( unitcube.grid(), (dimGrid < 3 ? 6 : 0) );
       }
       #endif // #if HAVE_ALBERTA
76
     */
77

78
#if HAVE_DUNE_ALUGRID
79 80
    UnitCube< Dune::ALUGrid< dimGrid, dimGrid, Dune::simplex,
            Dune::nonconforming > , 1 > uc5;
81 82
    dowork( uc5.grid(), 3 );

83
#if GRIDDIM == 2 || GRIDDIM == 3
84 85
    UnitCube< Dune::ALUGrid< dimGrid, dimGrid, Dune::cube,
            Dune::nonconforming > , 1 > uc6;
86
    dowork( uc6.grid(), 3 );
87
#endif // #if GRIDDIM == 2 || GRIDDIM == 3
88
#endif // #if HAVE_DUNE_ALUGRID
89 90
  }
  catch (std::exception & e) {
91
    std::cout << "ERROR: " << e.what() << std::endl;
92 93 94 95 96 97
    return 1;
  }
  catch (...) {
    std::cout << "Unknown ERROR" << std::endl;
    return 1;
  }
Peter Bastian's avatar
Peter Bastian committed
98 99 100 101

  // done
  return 0;
}