4#ifndef DUNE_GRID_TEST_CHECKDGF_HH
5#define DUNE_GRID_TEST_CHECKDGF_HH
7#define DISABLE_DEPRECATED_METHOD_CHECK 1
10#ifndef DUNE_GRID_EXAMPLE_GRIDS_PATH
11#define DUNE_GRID_EXAMPLE_GRIDS_PATH
18#include <dune/grid/common/rangegenerators.hh>
20#include <dune/grid/test/gridcheck.hh>
21#include <dune/grid/test/checkgeometryinfather.hh>
22#include <dune/grid/test/checkintersectionit.hh>
24#include <dune/grid/io/file/dgfparser.hh>
25#include <dune/grid/io/file/dgfparser/gridptr.hh>
32 template<
int dim,
int dimworld >
37template<
int dim,
int dimworld >
38struct EnableLevelIntersectionIteratorCheck<
Dune::AlbertaGrid< dim, dimworld > >
40 static const bool v =
false;
43template<
class Gr
idView >
44void display (
const std::string &name,
46 std::vector< double > &elDat,
int nofElParams,
47 std::vector< double > &vtxDat,
int nofVtxParams )
51 if( nofElParams + nofVtxParams > 0 )
53 vtkWriter.addCellData( elDat,
"el. Parameters", nofElParams );
54 vtkWriter.addVertexData( vtxDat,
"vtx. Parameters", nofVtxParams );
56 vtkWriter.write( name );
60void test ( Grid &grid )
65 std::cout <<
" CHECKING: geometry in father" << std::endl;
66 checkGeometryInFather( grid );
68 std::cout <<
" CHECKING: intersections" << std::endl;
69 bool skip = ! EnableLevelIntersectionIteratorCheck< Grid >::v;
70 checkIntersectionIterator( grid, skip );
73template<
typename Gr
idType>
74void runDGFTest(
int argc,
char ** argv)
79 MPIHelper & mpiHelper = MPIHelper::instance(argc,argv);
89 std::stringstream namestr;
90 namestr <<
"test" << GridType::dimension <<
"d.dgf";
91 filename = std::string( DUNE_GRID_EXAMPLE_GRIDS_PATH ) +
"dgf/" + namestr.str();
94 std::cout <<
"tester: start grid reading; file " << filename << std::endl;
96 typedef typename GridType::LeafGridView
GridView;
101 size_t nofElParams( 0 ), nofVtxParams( 0 );
102 std::vector< double > eldat( 0 ), vtxdat( 0 );
106 gridPtr.loadBalance();
108 GridView gridView = gridPtr->leafGridView();
109 const IndexSetType &indexSet = gridView.
indexSet();
110 nofElParams = gridPtr.nofParameters( 0 );
111 if( nofElParams > 0 )
113 std::cout <<
"Reading Element Parameters:" << std::endl;
114 eldat.resize( indexSet.size(0) * nofElParams );
116 typedef typename GridView::template
Codim< 0 >::template Partition< partType >::Iterator Iterator;
117 const Iterator enditer = gridView.template end< 0, partType >();
118 for( Iterator iter = gridView.template begin< 0, partType >(); iter != enditer; ++iter )
120 const std::vector< double > ¶m = gridPtr.parameters( *iter );
121 assert( param.size() == nofElParams );
122 for(
size_t i = 0; i < nofElParams; ++i )
125 eldat[ indexSet.index(*iter) * nofElParams + i ] = param[ i ];
131 nofVtxParams = gridPtr.nofParameters( (
int) GridType::dimension );
132 if( nofVtxParams > 0 )
134 std::cout <<
"Reading Vertex Parameters:" << std::endl;
135 vtxdat.resize( indexSet.size( GridType::dimension ) * nofVtxParams );
136 for(
const auto & e :
elements(gridView ))
138 const std::vector< double > ¶m = gridPtr.parameters( e );
139 assert( param.size() == nofVtxParams );
140 for(
size_t i = 0; i < nofVtxParams; ++i )
142 vtxdat[ indexSet.index(e) * nofVtxParams + i ] = param[ i ];
153 grid = gridPtr.release();
156 GridView gridView = grid->leafGridView();
157 std::cout <<
"Grid size: " << grid->
size(0) << std::endl;
159 display( filename , gridView, eldat, nofElParams, vtxdat, nofVtxParams );
162 std::cout <<
"tester: refine grid" << std::endl;
164 std::cout <<
"Grid size: " << grid->size(0) << std::endl;
Grid view abstract base class.
Definition: gridview.hh:60
A real mpi helper.
Definition: mpihelper.hh:165
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:186
Writer for the ouput of grid functions in the vtk format.
Definition: vtkwriter.hh:88
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:172
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:80
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridview.hh:178
IteratorRange<... > elements(const GV &gv)
Iterates over all elements / cells (entities with codimension 0) of a GridView.
Helpers for dealing with MPI.
Dune namespace.
Definition: alignedallocator.hh:10
Static tag representing a codimension.
Definition: dimension.hh:22
Some simple static information for a given GridType.
Definition: dgfparser.hh:51
Class for constructing grids from DGF files.
Definition: gridptr.hh:61
Provides subsampled file i/o for the visualization toolkit.
Provides file i/o for the visualization toolkit.