6#ifndef DUNE_GRID_TEST_CHECKDGF_HH
7#define DUNE_GRID_TEST_CHECKDGF_HH
11#ifndef DUNE_GRID_EXAMPLE_GRIDS_PATH
12#define DUNE_GRID_EXAMPLE_GRIDS_PATH
19#include <dune/grid/common/rangegenerators.hh>
21#include <dune/grid/test/gridcheck.hh>
22#include <dune/grid/test/checkgeometryinfather.hh>
23#include <dune/grid/test/checkintersectionit.hh>
25#include <dune/grid/io/file/dgfparser.hh>
26#include <dune/grid/io/file/dgfparser/gridptr.hh>
33 template<
int dim,
int dimworld >
38template<
int dim,
int dimworld >
39struct EnableLevelIntersectionIteratorCheck<
Dune::AlbertaGrid< dim, dimworld > >
41 static const bool v =
false;
44template<
class Gr
idView >
45void display (
const std::string &name,
47 std::vector< double > &elDat,
int nofElParams,
48 std::vector< double > &vtxDat,
int nofVtxParams )
52 if( nofElParams + nofVtxParams > 0 )
54 vtkWriter.addCellData( elDat,
"el. Parameters", nofElParams );
55 vtkWriter.addVertexData( vtxDat,
"vtx. Parameters", nofVtxParams );
57 auto pos = name.find_last_of(
"\\/") + 1;
58 vtkWriter.write( name.substr(pos, name.size() - pos) );
62void test ( Grid &grid )
67 std::cout <<
" CHECKING: geometry in father" << std::endl;
68 checkGeometryInFather( grid );
70 std::cout <<
" CHECKING: intersections" << std::endl;
71 bool skip = ! EnableLevelIntersectionIteratorCheck< Grid >::v;
72 checkIntersectionIterator( grid, skip );
75template<
typename Gr
idType>
76void runDGFTest(
int argc,
char ** argv)
81 MPIHelper & mpiHelper = MPIHelper::instance(argc,argv);
91 std::stringstream namestr;
92#ifdef DGFTEST_USE_GMSH
93 namestr <<
"hybrid-testgrid-" << GridType::dimension <<
"d.msh";
94 filename = std::string( DUNE_GRID_EXAMPLE_GRIDS_PATH ) +
"gmsh/" + namestr.str();
96 namestr <<
"test" << GridType::dimension <<
"d.dgf";
97 filename = std::string( DUNE_GRID_EXAMPLE_GRIDS_PATH ) +
"dgf/" + namestr.str();
101 std::cout <<
"tester: start grid reading; file " << filename << std::endl;
103 typedef typename GridType::LeafGridView
GridView;
108 size_t nofElParams( 0 ), nofVtxParams( 0 );
109 std::vector< double > eldat( 0 ), vtxdat( 0 );
113 gridPtr.loadBalance();
115 GridView gridView = gridPtr->leafGridView();
116 const IndexSetType &indexSet = gridView.
indexSet();
117 nofElParams = gridPtr.nofParameters( 0 );
118 if( nofElParams > 0 )
120 std::cout <<
"Reading Element Parameters:" << std::endl;
121 eldat.resize( indexSet.size(0) * nofElParams );
123 typedef typename GridView::template
Codim< 0 >::template Partition< partType >::Iterator Iterator;
124 const Iterator enditer = gridView.template end< 0, partType >();
125 for( Iterator iter = gridView.template begin< 0, partType >(); iter != enditer; ++iter )
127 const std::vector< double > ¶m = gridPtr.parameters( *iter );
128 assert( param.size() == nofElParams );
129 for(
size_t i = 0; i < nofElParams; ++i )
132 eldat[ indexSet.index(*iter) * nofElParams + i ] = param[ i ];
138 nofVtxParams = gridPtr.nofParameters( (
int) GridType::dimension );
139 if( nofVtxParams > 0 )
141 std::cout <<
"Reading Vertex Parameters:" << std::endl;
142 vtxdat.resize( indexSet.size( GridType::dimension ) * nofVtxParams );
143 for(
const auto & e :
elements(gridView ))
145 const std::vector< double > ¶m = gridPtr.parameters( e );
146 assert( param.size() == nofVtxParams );
147 for(
size_t i = 0; i < nofVtxParams; ++i )
149 vtxdat[ indexSet.index(e) * nofVtxParams + i ] = param[ i ];
160 grid = gridPtr.release();
163 GridView gridView = grid->leafGridView();
164 std::cout <<
"Grid size: " << grid->
size(0) << std::endl;
166 display( filename , gridView, eldat, nofElParams, vtxdat, nofVtxParams );
169 std::cout <<
"tester: refine grid" << std::endl;
171 std::cout <<
"Grid size: " << grid->size(0) << std::endl;
Grid view abstract base class.
Definition: gridview.hh:66
A real mpi helper.
Definition: mpihelper.hh:179
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:198
Writer for the ouput of grid functions in the vtk format.
Definition: vtkwriter.hh:95
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:191
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:86
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridview.hh:197
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:13
Static tag representing a codimension.
Definition: dimension.hh:24
Some simple static information for a given GridType.
Definition: dgfparser.hh:56
Class for constructing grids from DGF files.
Definition: gridptr.hh:66
Provides subsampled file i/o for the visualization toolkit.
Provides file i/o for the visualization toolkit.