/usr/include/dune/grid/test/staticcheck.hh is in libdune-grid-dev 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
// $Id: gridcheck.cc 6156 2010-01-17 16:40:14Z dedner $
#ifndef DUNE_STATIC_CHECK_HH
#define DUNE_STATIC_CHECK_HH
/** \file
\brief Implements static grid checks
\todo check return types
*/
#include <dune/geometry/type.hh>
#include <dune/grid/common/capabilities.hh>
#include <dune/grid/common/gridenums.hh>
template< class Geometry, int codim, int dim >
struct GeometryInterface
{
static void check ( const Geometry &geo )
{
dune_static_assert( (Geometry::mydimension == dim-codim), "" );
dune_static_assert( (Geometry::dimension == dim), "" );
typedef typename Geometry::ctype ctype DUNE_UNUSED;
geo.type();
geo.affine();
geo.corners();
geo.corner( 0 );
typename Geometry::LocalCoordinate v(0.0);
geo.global(v);
typename Geometry::GlobalCoordinate g(0.0);
geo.local(g);
geo.integrationElement(v);
geo.jacobianTransposed( v );
geo.jacobianInverseTransposed( v );
}
GeometryInterface ()
{
c = check;
}
private:
void (*c)( const Geometry & );
};
// --- compile-time check of entity-interface
// tests that should work on entities of all codimensions
template <class Entity>
void DoEntityInterfaceCheck (Entity &e)
{
// exported types
#if !DISABLE_DEPRECATED_METHOD_CHECK
typedef typename Entity::ctype ctype DUNE_UNUSED;
#endif // !DISABLE_DEPRECATED_METHOD_CHECK
// methods on each entity
e.level();
e.partitionType();
e.geometry();
// check interface of attached element-interface
GeometryInterface< typename Entity::Geometry, Entity::codimension, Entity::dimension >();
}
// recursive check of codim-0-entity methods count(), entity()
template <class Grid, int cd, bool hasEntity>
struct ZeroEntityMethodCheck
{
typedef typename Grid::template Codim<0>::Entity Entity;
static void check(Entity &e)
{
// check types
typedef typename Entity::LeafIntersectionIterator LeafIntersectionIterator DUNE_UNUSED;
typedef typename Entity::LevelIntersectionIterator LevelIntersectionIterator DUNE_UNUSED;
typedef typename Entity::HierarchicIterator HierarchicIterator DUNE_UNUSED;
typedef typename Entity::EntityPointer EntityPointer DUNE_UNUSED;
e.template count<cd>();
e.template subEntity<cd>(0);
// recursively check on
ZeroEntityMethodCheck<Grid, cd - 1,
Dune::Capabilities::hasEntity<Grid, cd - 1>::v >();
}
ZeroEntityMethodCheck ()
{
c = check;
}
void (*c)(Entity &e);
};
// just the recursion if the grid does not know about this codim-entity
template<class Grid, int cd>
struct ZeroEntityMethodCheck<Grid, cd, false>
{
typedef typename Grid::template Codim<0>::Entity Entity;
static void check(Entity &e)
{
// check types
typedef typename Entity::LeafIntersectionIterator LeafIntersectionIterator DUNE_UNUSED;
typedef typename Entity::LevelIntersectionIterator LevelIntersectionIterator DUNE_UNUSED;
typedef typename Entity::HierarchicIterator HierarchicIterator DUNE_UNUSED;
typedef typename Entity::EntityPointer EntityPointer DUNE_UNUSED;
// recursively check on
ZeroEntityMethodCheck<Grid, cd - 1,
Dune::Capabilities::hasEntity<Grid, cd - 1>::v >();
}
ZeroEntityMethodCheck ()
{
c = check;
}
void (*c)(Entity &e);
};
// end recursive checking
template <class Grid>
struct ZeroEntityMethodCheck<Grid, 0, true>
{
typedef typename Grid::template Codim<0>::Entity Entity;
static void check(Entity &e)
{
// check types
typedef typename Entity::LeafIntersectionIterator LeafIntersectionIterator DUNE_UNUSED;
typedef typename Entity::LevelIntersectionIterator LevelIntersectionIterator DUNE_UNUSED;
typedef typename Entity::HierarchicIterator HierarchicIterator DUNE_UNUSED;
typedef typename Entity::EntityPointer EntityPointer DUNE_UNUSED;
e.template count<0>();
e.template subEntity<0>(0);
}
ZeroEntityMethodCheck ()
{
c = check;
}
void (*c)(Entity &e);
};
// end recursive checking - same as true
// ... codim 0 is always needed
template <class Grid>
struct ZeroEntityMethodCheck<Grid, 0, false>
{
typedef typename Grid::template Codim<0>::Entity Entity;
static void check(Entity &e)
{
// check types
typedef typename Entity::LeafIntersectionIterator LeafIntersectionIterator DUNE_UNUSED;
typedef typename Entity::LevelIntersectionIterator LevelIntersectionIterator DUNE_UNUSED;
typedef typename Entity::HierarchicIterator HierarchicIterator DUNE_UNUSED;
typedef typename Entity::EntityPointer EntityPointer DUNE_UNUSED;
e.template count<0>();
e.template subEntity<0>(0);
}
ZeroEntityMethodCheck ()
{
c = check;
}
void (*c)(Entity &e);
};
// IntersectionIterator interface check
template <class Grid,class IntersectionIterator>
struct IntersectionIteratorInterface
{
enum { dim = Grid::dimension };
typedef typename Grid::ctype ct;
static void check (IntersectionIterator &i)
{
// increment / equality / ...
IntersectionIterator j = i;
++j;
{ bool DUNE_UNUSED tmp = (i == j); }
{ bool DUNE_UNUSED tmp = (i != j); }
j = i;
// state
typedef typename IntersectionIterator::Intersection Intersection;
const Intersection &inter = *i;
inter.boundary();
inter.neighbor();
inter.boundarySegmentIndex();
// neighbouring elements
inter.inside();
if(inter.neighbor()) inter.outside();
// geometry
inter.geometryInInside();
if(inter.neighbor()) inter.geometryInOutside();
inter.geometry();
inter.indexInInside();
if(inter.neighbor()) inter.indexInOutside();
typename Intersection::LocalCoordinate v(0);
inter.outerNormal(v);
inter.integrationOuterNormal(v);
inter.unitOuterNormal(v);
}
IntersectionIteratorInterface ()
{
c = check;
}
private:
void (*c)(IntersectionIterator&);
};
// check codim-entity and pass on to codim + 1
template <class Grid, int codim, int dim, bool hasEntity>
struct EntityInterface
{
typedef typename Grid::template Codim<codim>::Entity Entity;
static void check ( const Entity &e )
{
// consistent?
dune_static_assert( (Entity::codimension == codim), "" );
dune_static_assert( (Entity::dimension == dim), "" );
// do the checking
DoEntityInterfaceCheck(e);
// recursively check sub-entities
EntityInterface<Grid, codim + 1, dim,
Dune::Capabilities::hasEntity<Grid, codim + 1>::v >();
}
EntityInterface ()
{
c = check;
}
private:
void (*c)( const Entity & );
};
// just the recursion if the grid does not know about this codim-entity
template <class Grid, int codim, int dim>
struct EntityInterface<Grid, codim, dim, false>
{
typedef typename Grid::template Codim<codim>::Entity Entity;
static void check (Entity &e)
{
// recursively check sub-entities
EntityInterface<Grid, codim + 1, dim,
Dune::Capabilities::hasEntity<Grid, codim + 1>::v >();
}
EntityInterface ()
{
c = check;
}
void (*c)(Entity&);
};
// codim-0 entities have different interface
template <class Grid, int dim>
struct EntityInterface<Grid, 0, dim, true>
{
typedef typename Grid::template Codim<0>::Entity Entity;
static void check ( const Entity &e, bool checkLevelIter = true )
{
// consistent?
dune_static_assert( (Entity::codimension == 0), "" );
dune_static_assert( (Entity::dimension == dim), "" );
// do the common checking
DoEntityInterfaceCheck(e);
// special codim-0-entity methods which are parametrized by a codimension
ZeroEntityMethodCheck
<Grid, dim, Dune::Capabilities::hasEntity<Grid, dim>::v >();
// grid hierarchy
if ( e.hasFather() )
{
const typename Entity::EntityPointer fatherPtr = e.father();
const Entity &father = *fatherPtr;
father.hbegin(0);
e.geometryInFather();
}
// intersection iterator
if (checkLevelIter) {
#if !DISABLE_DEPRECATED_METHOD_CHECK
e.ilevelbegin();
e.ilevelend();
#endif // #if !DISABLE_DEPRECATED_METHOD_CHECK
// #if 0 // WARNING must be updated to new interface
IntersectionIteratorInterface<Grid,typename Grid::LevelIntersectionIterator>();
// #endif
}
#if !DISABLE_DEPRECATED_METHOD_CHECK
e.ileafbegin();
e.ileafend();
#endif // #if !DISABLE_DEPRECATED_METHOD_CHECK
// #if 0 // WARNING must be updated to new interface
if(e.isLeaf())
IntersectionIteratorInterface<Grid,typename Grid::LevelIntersectionIterator>();
// #endif
// hierarchic iterator
e.hbegin(0);
e.hend(0);
// adaption
e.isNew();
e.mightVanish();
// recursively check sub-entities
EntityInterface<Grid, 1, dim,
Dune::Capabilities::hasEntity<Grid, 1>::v >();
}
EntityInterface ()
{
c = check;
}
private:
void (*c)( const Entity &, bool );
};
// non existinng codim-0 entity
template <class Grid, int dim>
struct EntityInterface<Grid, 0, dim, false>
{
typedef typename Grid::template Codim<0>::Entity Entity;
static void check (Entity &e)
{
// recursively check sub-entities
EntityInterface<Grid, 1, dim,
Dune::Capabilities::hasEntity<Grid, 1>::v >();
}
EntityInterface ()
{
c = check;
}
void (*c)(Entity&);
};
// end the recursion over entity-codimensions
template <class Grid, int dim>
struct EntityInterface<Grid, dim, dim, true>
{
typedef typename Grid::template Codim<dim>::Entity Entity;
// end recursion
static void check ( const Entity &e )
{
// consistent?
dune_static_assert( (Entity::codimension == dim), "" );
dune_static_assert( (Entity::dimension == dim), "" );
// run common test
DoEntityInterfaceCheck(e);
}
EntityInterface()
{
c = check;
}
void (*c)( const Entity & );
};
// end the recursion over entity-codimensions
// ... codim dim entity does not exist
template <class Grid, int dim>
struct EntityInterface<Grid, dim, dim, false>
{
typedef typename Grid::template Codim<dim>::Entity Entity;
// end recursion
static void check (Entity &e)
{}
EntityInterface()
{
c = check;
}
void (*c)(Entity&);
};
template<class Grid>
struct LeafInterface
{
static void check(Grid &g)
{
g.template leafbegin<0>();
g.template leafend<0>();
}
LeafInterface()
{
c = check;
}
void (*c)(Grid&);
};
/** \brief Instantiate this class for a full static interface check */
template <class Grid>
struct GridInterface
{
static void check (const Grid &g)
{
// check for exported types
typedef typename Grid::ctype ctype DUNE_UNUSED;
typedef typename Grid::template Codim<0>::LevelIterator LevelIterator DUNE_UNUSED;
typedef typename Grid::template Codim<0>::EntityPointer EntityPointer DUNE_UNUSED;
typedef typename Grid::template Codim<0>::LeafIterator LeafIterator DUNE_UNUSED;
// check for member functions
g.maxLevel();
// number of grid entities of a given codim on a given level
g.size(0,0);
// number of leaf entities per codim in this process
g.size(0);
// number of entities per level and geometry type in this process
g.size(0, Dune::GeometryType(Dune::GeometryType::cube,Grid::dimension));
// number of leaf entities per geometry type in this process
g.size(Dune::GeometryType(Dune::GeometryType::cube,Grid::dimension));
// Check overlap and ghost size on level 0
g.overlapSize(0,0);
g.ghostSize(0,0);
// Check overlap and ghost size on the leaf level
g.overlapSize(0);
g.ghostSize(0);
// check for iterator functions
g.template lbegin<0>(0);
g.template lend<0>(0);
LeafInterface< Grid>();
// Check for index sets
typedef typename Grid::LevelIndexSet LevelIndexSet DUNE_UNUSED;
typedef typename Grid::LeafIndexSet LeafIndexSet DUNE_UNUSED;
typedef typename Grid::LocalIdSet LocalIdSet DUNE_UNUSED;
typedef typename Grid::GlobalIdSet GlobalIdSet DUNE_UNUSED;
g.levelIndexSet(0);
if (g.template lbegin<0>(0) !=g.template lend<0>(0) ) {
// Instantiate all methods of LevelIndexSet
g.levelIndexSet(0).index(*g.template lbegin<0>(0));
/** \todo Test for subindex is missing, because I don't know yet
how to test for the existence of certain codims */
}
g.levelIndexSet(0).
size(Dune::GeometryType(Dune::GeometryType::simplex,Grid::dimension));
for (int codim = 0; codim < Grid::dimension; codim++)
g.levelIndexSet(0).geomTypes(codim);
if (g.template leafbegin<0>() != g.template leafend<0>() )
{
// Instantiate all methods of LeafIndexSet
g.leafIndexSet().index(*g.template leafbegin<0>());
}
/** \todo Test for subindex is missing, because I don't know yet
how to test for the existence of certain codims */
g.leafIndexSet().size(Dune::GeometryType(Dune::GeometryType::simplex,Grid::dimension));
for (int codim = 0; codim < Grid::dimension; codim++)
g.leafIndexSet().geomTypes(codim);
if (g.template lbegin<0>(0) !=g.template lend<0>(0) ) {
// Instantiate all methods of LocalIdSet
/** \todo Test for subindex is missing, because I don't know yet
how to test for the existence of certain codims */
g.localIdSet().id(*g.template lbegin<0>(0));
// Instantiate all methods of GlobalIdSet
/** \todo Test for subindex is missing, because I don't know yet
how to test for the existence of certain codims */
g.globalIdSet().id(*g.template lbegin<0>(0));
}
// recursively check entity-interface
// ... we only allow grids with codim 0 zero entites
dune_static_assert((Dune::Capabilities::hasEntity<Grid, 0>::v),"Grid must have codim 0 entities");
dune_static_assert((Dune::Capabilities::hasEntity<const Grid, 0>::v),"Grid must have codim 0 entities");
EntityInterface< Grid, 0, Grid::dimension, Dune::Capabilities::hasEntity< Grid, 0 >::v >();
// !!! check for parallel grid?
g.template lbegin<0, Dune::Ghost_Partition>(0);
g.template lend<0, Dune::Ghost_Partition>(0);
}
GridInterface()
{
c = check;
}
// member just to avoid "unused variable"-warning in constructor
void (*c)(const Grid&);
};
#endif // #ifndef DUNE_STATIC_CHECK_HH
|