~ubuntu-branches/ubuntu/utopic/dune-grid/utopic-proposed

« back to all changes in this revision

Viewing changes to dune/grid/test/test-geogrid.cc

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2012-04-06 11:31:20 UTC
  • Revision ID: package-import@ubuntu.com-20120406113120-x0z4e0qqgfhmaj2a
Tags: upstream-2.2~svn7982
ImportĀ upstreamĀ versionĀ 2.2~svn7982

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <config.h>
 
2
 
 
3
#ifdef COORDFUNCTION
 
4
 
 
5
#include <dune/common/poolallocator.hh>
 
6
#include <dune/grid/geometrygrid.hh>
 
7
#include <dune/grid/geometrygrid/cachedcoordfunction.hh>
 
8
#include <dune/grid/io/file/dgfparser/dgfgeogrid.hh>
 
9
 
 
10
#include "functions.hh"
 
11
 
 
12
#include "gridcheck.cc"
 
13
#include "checkcommunicate.cc"
 
14
#include "checkgeometryinfather.cc"
 
15
#include "checkintersectionit.cc"
 
16
#include "checkiterators.cc"
 
17
#include "checkpartition.cc"
 
18
#include "checkgeometry.cc"
 
19
 
 
20
 
 
21
namespace Dune
 
22
{
 
23
 
 
24
  template< int dim, int dimworld >
 
25
  class AlbertaGrid;
 
26
 
 
27
}
 
28
 
 
29
 
 
30
template< int dim, int dimworld >
 
31
struct EnableLevelIntersectionIteratorCheck< Dune::AlbertaGrid< dim, dimworld > >
 
32
{
 
33
  static const bool v = false;
 
34
};
 
35
 
 
36
template< class HostGrid, class CoordFunction >
 
37
struct EnableLevelIntersectionIteratorCheck< Dune::GeometryGrid< HostGrid, CoordFunction > >
 
38
{
 
39
  static const bool v = EnableLevelIntersectionIteratorCheck< HostGrid >::v;
 
40
};
 
41
 
 
42
 
 
43
typedef Dune::COORDFUNCTION AnalyticalCoordFunction;
 
44
 
 
45
typedef Dune::GridSelector::GridType Grid;
 
46
 
 
47
#if CACHECOORDFUNCTION
 
48
typedef Dune::CachedCoordFunction< Grid, AnalyticalCoordFunction > CoordFunction;
 
49
#else
 
50
typedef AnalyticalCoordFunction CoordFunction;
 
51
#endif
 
52
 
 
53
typedef Dune::GeometryGrid< Grid, CoordFunction > GeometryGrid;
 
54
typedef Dune::GeometryGrid< Grid, CoordFunction, Dune::PoolAllocator< char, 16384 > > GeometryGridWithPoolAllocator;
 
55
 
 
56
 
 
57
template <class GeometryGridType>
 
58
void test(const std::string& gridfile)
 
59
{
 
60
  Dune::GridPtr< GeometryGridType > pgeogrid(gridfile);
 
61
  GeometryGridType &geogrid = *pgeogrid;
 
62
 
 
63
  geogrid.globalRefine( 1 );
 
64
  geogrid.loadBalance();
 
65
  
 
66
  std::cerr << "Checking grid..." << std::endl;
 
67
  gridcheck( geogrid );
 
68
 
 
69
  std::cerr << "Checking geometry... " << std::endl;
 
70
  checkGeometry( geogrid.leafView() );
 
71
  for( int i = 0; i <= geogrid.maxLevel(); ++i )
 
72
    checkGeometry( geogrid.levelView( i ) );
 
73
 
 
74
  std::cerr << "Checking geometry in father..." << std::endl;
 
75
  checkGeometryInFather( geogrid );
 
76
  std::cerr << "Checking intersections..." << std::endl;
 
77
  checkIntersectionIterator( geogrid, !EnableLevelIntersectionIteratorCheck< Grid >::v );
 
78
 
 
79
  checkIterators( geogrid.leafView() );
 
80
  for( int i = 0; i <= geogrid.maxLevel(); ++i )
 
81
    checkIterators( geogrid.levelView( i ) );
 
82
 
 
83
  checkPartitionType( geogrid.leafView() );
 
84
  for( int i = 0; i <= geogrid.maxLevel(); ++i )
 
85
    checkPartitionType( geogrid.levelView( i ) );
 
86
 
 
87
  std::cerr << "Checking geometry lifetime..." << std::endl;
 
88
  checkGeometryLifetime( geogrid.leafView() );
 
89
 
 
90
  std::cerr << "Checking communication..." << std::endl;
 
91
  checkCommunication( geogrid, -1, std::cout );
 
92
  if( EnableLevelIntersectionIteratorCheck< Grid >::v )
 
93
  {
 
94
    for( int i = 0; i <= geogrid.maxLevel(); ++i )
 
95
      checkCommunication( geogrid, i, std::cout );
 
96
  }
 
97
   
 
98
}
 
99
 
 
100
int main ( int argc, char **argv )
 
101
try
 
102
{
 
103
  Dune::MPIHelper::instance( argc, argv );
 
104
 
 
105
  std::string gridfile = DUNE_GRID_EXAMPLE_GRIDS_PATH "dgf/cube-2.dgf";
 
106
  if(argc >= 2)
 
107
  {
 
108
      gridfile = argv[1];
 
109
  }
 
110
 
 
111
  test<GeometryGrid>(gridfile);
 
112
  // commented out, because it is not working
 
113
  //test<GeometryGridWithPoolAllocator>(gridfile);
 
114
 
 
115
  return 0;
 
116
}
 
117
catch( const Dune::Exception &e )
 
118
{
 
119
  std::cerr << e << std::endl;
 
120
  return 1;
 
121
}
 
122
catch( ... )
 
123
{
 
124
  std::cerr << "Unknown exception raised." << std::endl;
 
125
  return 1;
 
126
}
 
127
 
 
128
#else
 
129
#error "COORDFUNCTION not defined (e.g., Helix, Circle; see functions.hh)"
 
130
#endif