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 auto pos = name.find_last_of(
"\\/") + 1;
57 vtkWriter.write( name.substr(pos, name.size() - pos) );
61void test ( Grid &grid )
66 std::cout <<
" CHECKING: geometry in father" << std::endl;
67 checkGeometryInFather( grid );
69 std::cout <<
" CHECKING: intersections" << std::endl;
70 bool skip = ! EnableLevelIntersectionIteratorCheck< Grid >::v;
71 checkIntersectionIterator( grid, skip );
74template<
typename Gr
idType>
75void runDGFTest(
int argc,
char ** argv)
80 MPIHelper & mpiHelper = MPIHelper::instance(argc,argv);
90 std::stringstream namestr;
91#ifdef DGFTEST_USE_GMSH
92 namestr <<
"hybrid-testgrid-" << GridType::dimension <<
"d.msh";
93 filename = std::string( DUNE_GRID_EXAMPLE_GRIDS_PATH ) +
"gmsh/" + namestr.str();
95 namestr <<
"test" << GridType::dimension <<
"d.dgf";
96 filename = std::string( DUNE_GRID_EXAMPLE_GRIDS_PATH ) +
"dgf/" + namestr.str();
100 std::cout <<
"tester: start grid reading; file " << filename << std::endl;
102 typedef typename GridType::LeafGridView
GridView;
107 size_t nofElParams( 0 ), nofVtxParams( 0 );
108 std::vector< double > eldat( 0 ), vtxdat( 0 );
112 gridPtr.loadBalance();
114 GridView gridView = gridPtr->leafGridView();
115 const IndexSetType &indexSet = gridView.
indexSet();
116 nofElParams = gridPtr.nofParameters( 0 );
117 if( nofElParams > 0 )
119 std::cout <<
"Reading Element Parameters:" << std::endl;
120 eldat.resize( indexSet.size(0) * nofElParams );
122 typedef typename GridView::template
Codim< 0 >::template Partition< partType >::Iterator Iterator;
123 const Iterator enditer = gridView.template end< 0, partType >();
124 for( Iterator iter = gridView.template begin< 0, partType >(); iter != enditer; ++iter )
126 const std::vector< double > ¶m = gridPtr.parameters( *iter );
127 assert( param.size() == nofElParams );
128 for(
size_t i = 0; i < nofElParams; ++i )
131 eldat[ indexSet.index(*iter) * nofElParams + i ] = param[ i ];
137 nofVtxParams = gridPtr.nofParameters( (
int) GridType::dimension );
138 if( nofVtxParams > 0 )
140 std::cout <<
"Reading Vertex Parameters:" << std::endl;
141 vtxdat.resize( indexSet.size( GridType::dimension ) * nofVtxParams );
142 for(
const auto & e :
elements(gridView ))
144 const std::vector< double > ¶m = gridPtr.parameters( e );
145 assert( param.size() == nofVtxParams );
146 for(
size_t i = 0; i < nofVtxParams; ++i )
148 vtxdat[ indexSet.index(e) * nofVtxParams + i ] = param[ i ];
159 grid = gridPtr.release();
162 GridView gridView = grid->leafGridView();
163 std::cout <<
"Grid size: " << grid->
size(0) << std::endl;
165 display( filename , gridView, eldat, nofElParams, vtxdat, nofVtxParams );
168 std::cout <<
"tester: refine grid" << std::endl;
170 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:169
static MPICommunicator getCommunicator()
get the default communicator
Definition: mpihelper.hh:190
Writer for the ouput of grid functions in the vtk format.
Definition: vtkwriter.hh:91
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:14
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.