4#ifndef DUNE_GRID_TEST_CHECKDGF_HH
5#define DUNE_GRID_TEST_CHECKDGF_HH
9#ifndef DUNE_GRID_EXAMPLE_GRIDS_PATH
10#define DUNE_GRID_EXAMPLE_GRIDS_PATH
17#include <dune/grid/common/rangegenerators.hh>
19#include <dune/grid/test/gridcheck.hh>
20#include <dune/grid/test/checkgeometryinfather.hh>
21#include <dune/grid/test/checkintersectionit.hh>
23#include <dune/grid/io/file/dgfparser.hh>
24#include <dune/grid/io/file/dgfparser/gridptr.hh>
31 template<
int dim,
int dimworld >
36template<
int dim,
int dimworld >
37struct EnableLevelIntersectionIteratorCheck<
Dune::AlbertaGrid< dim, dimworld > >
39 static const bool v =
false;
42template<
class Gr
idView >
43void display (
const std::string &name,
45 std::vector< double > &elDat,
int nofElParams,
46 std::vector< double > &vtxDat,
int nofVtxParams )
50 if( nofElParams + nofVtxParams > 0 )
52 vtkWriter.addCellData( elDat,
"el. Parameters", nofElParams );
53 vtkWriter.addVertexData( vtxDat,
"vtx. Parameters", nofVtxParams );
55 auto pos = name.find_last_of(
"\\/") + 1;
56 vtkWriter.write( name.substr(pos, name.size() - pos) );
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#ifdef DGFTEST_USE_GMSH
91 namestr <<
"hybrid-testgrid-" << GridType::dimension <<
"d.msh";
92 filename = std::string( DUNE_GRID_EXAMPLE_GRIDS_PATH ) +
"gmsh/" + namestr.str();
94 namestr <<
"test" << GridType::dimension <<
"d.dgf";
95 filename = std::string( DUNE_GRID_EXAMPLE_GRIDS_PATH ) +
"dgf/" + namestr.str();
99 std::cout <<
"tester: start grid reading; file " << filename << std::endl;
101 typedef typename GridType::LeafGridView
GridView;
106 size_t nofElParams( 0 ), nofVtxParams( 0 );
107 std::vector< double > eldat( 0 ), vtxdat( 0 );
111 gridPtr.loadBalance();
113 GridView gridView = gridPtr->leafGridView();
114 const IndexSetType &indexSet = gridView.
indexSet();
115 nofElParams = gridPtr.nofParameters( 0 );
116 if( nofElParams > 0 )
118 std::cout <<
"Reading Element Parameters:" << std::endl;
119 eldat.resize( indexSet.size(0) * nofElParams );
121 typedef typename GridView::template
Codim< 0 >::template Partition< partType >::Iterator Iterator;
122 const Iterator enditer = gridView.template end< 0, partType >();
123 for( Iterator iter = gridView.template begin< 0, partType >(); iter != enditer; ++iter )
125 const std::vector< double > ¶m = gridPtr.parameters( *iter );
126 assert( param.size() == nofElParams );
127 for(
size_t i = 0; i < nofElParams; ++i )
130 eldat[ indexSet.index(*iter) * nofElParams + i ] = param[ i ];
136 nofVtxParams = gridPtr.nofParameters( (
int) GridType::dimension );
137 if( nofVtxParams > 0 )
139 std::cout <<
"Reading Vertex Parameters:" << std::endl;
140 vtxdat.resize( indexSet.size( GridType::dimension ) * nofVtxParams );
141 for(
const auto & e :
elements(gridView ))
143 const std::vector< double > ¶m = gridPtr.parameters( e );
144 assert( param.size() == nofVtxParams );
145 for(
size_t i = 0; i < nofVtxParams; ++i )
147 vtxdat[ indexSet.index(e) * nofVtxParams + i ] = param[ i ];
158 grid = gridPtr.release();
161 GridView gridView = grid->leafGridView();
162 std::cout <<
"Grid size: " << grid->
size(0) << std::endl;
164 display( filename , gridView, eldat, nofElParams, vtxdat, nofVtxParams );
167 std::cout <<
"tester: refine grid" << std::endl;
169 std::cout <<
"Grid size: " << grid->size(0) << std::endl;
Grid view abstract base class.
Definition: gridview.hh:63
A real mpi helper.
Definition: mpihelper.hh:175
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:196
Writer for the ouput of grid functions in the vtk format.
Definition: vtkwriter.hh:93
const IndexSet & indexSet() const
obtain the index set
Definition: gridview.hh:175
Traits::IndexSet IndexSet
type of the index set
Definition: gridview.hh:83
int size(int codim) const
obtain number of entities in a given codimension
Definition: gridview.hh:181
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:11
Static tag representing a codimension.
Definition: dimension.hh:22
Some simple static information for a given GridType.
Definition: dgfparser.hh:54
Class for constructing grids from DGF files.
Definition: gridptr.hh:64
Provides subsampled file i/o for the visualization toolkit.
Provides file i/o for the visualization toolkit.