/usr/include/dune/geometry/quadraturerules/genericquadrature.hh is in libdune-geometry-dev 2.2.1-2ubuntu2.
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 | #ifndef DUNE_GEOMETRY_QUADRATURERULES_GENERICQUADRATURE_HH
#define DUNE_GEOMETRY_QUADRATURERULES_GENERICQUADRATURE_HH
#include <vector>
#include <dune/common/fvector.hh>
#include <dune/geometry/type.hh>
#include <dune/geometry/topologyfactory.hh>
#include <dune/geometry/quadraturerules.hh>
#include <dune/geometry/genericgeometry/conversion.hh>
#include <dune/geometry/genericgeometry/topologytypes.hh>
namespace Dune
{
namespace GenericGeometry
{
// Quadrature
// ----------
/**
* @brief Base class for the generic quadrature implementations.
* Field type and dimension are
* template argument construction is through a topology id.
**/
template< class F, unsigned int dim >
class Quadrature
{
typedef Quadrature< F, dim > This;
public:
typedef F Field;
static const unsigned int dimension = dim;
typedef Dune::QuadraturePoint< Field, dimension > QuadraturePoint;
typedef typename QuadraturePoint::Vector Vector;
typedef typename std::vector< QuadraturePoint >::const_iterator Iterator;
protected:
//! Constructor taking topology id
Quadrature ( const unsigned int topologyId, unsigned int order )
: type_( topologyId, dim ),
order_( order )
{}
public:
//! Copy constructor
template< class Q >
Quadrature ( const Q &q )
: type_( q.type() ),
order_ (q.order() )
{
points_.reserve( q.size() );
const typename Q::Iterator end = q.end();
for( typename Q::Iterator it = q.begin(); it != end; ++it )
points_.push_back( *it );
}
//! Access a quadrature point
const QuadraturePoint &operator[] ( const unsigned int i ) const
{
return points_[ i ];
}
//! start iterator over the quadrature points
Iterator begin () const
{
return points_.begin();
}
//! end iterator over the quadrature points
Iterator end () const
{
return points_.end();
}
//! access the coordinates of a quadrature point
const Vector &position ( const unsigned int i ) const
{
return (*this)[ i ].position();
}
//! access the weight of a quadrature point
const Field &weight ( const unsigned int i ) const
{
return (*this)[ i ].weight();
}
//! topology id of the quadrature
unsigned int topologyId () const DUNE_DEPRECATED
{
return type_.id();
}
//! order of the quadrature
unsigned int order () const
{
return order_;
}
//! geometry type of the quadrature
GeometryType type () const
{
return type_;
}
//! number of quadrature points
size_t size () const
{
return points_.size();
}
protected:
void insert ( const QuadraturePoint &point )
{
points_.push_back( point );
}
void insert ( const Vector &position, const Field &weight )
{
insert( QuadraturePoint( position, weight ) );
}
template< unsigned int d, class QC >
friend struct SubQuadratureCreator;
private:
std::vector< QuadraturePoint > points_;
GeometryType type_;
unsigned int order_;
};
// GenericQuadrature
// -----------------
/**
* @brief extends a 1d quadrature to a generic reference elemenet
*
* \tparam Topology the topology of the reference element
* \tparam OneDQuad a quadrature for [0,1]
*
* The 1d quadrature must be a std::vector-like container with a constructor
* taking an order parameter
**/
template< class Topology, class OneDQuad >
class GenericQuadrature;
/** \brief Generic Quadrature for Point
**/
template< class OneDQuad >
class GenericQuadrature< Point, OneDQuad >
: public Quadrature< typename OneDQuad::Field, 0 >
{
typedef typename OneDQuad::Field F;
typedef GenericQuadrature< Point, OneDQuad > This;
typedef Quadrature< F, 0 > Base;
public:
typedef Point Topology;
typedef F Field;
static const unsigned int dimension = Base::dimension;
typedef typename Base::Vector Vector;
explicit GenericQuadrature ( unsigned int order )
: Base( Topology::id, order )
{
Base::insert( Vector( Field( 0 ) ), 1 );
}
};
/** \brief Generic Quadrature for Prisms
**/
template< class BaseTopology, class OneDQuad >
class GenericQuadrature< Prism< BaseTopology >, OneDQuad >
: public Quadrature< typename OneDQuad::Field, Prism< BaseTopology >::dimension >
{
typedef typename OneDQuad::Field F;
typedef GenericQuadrature< Prism< BaseTopology >, OneDQuad > This;
typedef Quadrature< F, Prism< BaseTopology >::dimension > Base;
public:
typedef Prism< BaseTopology > Topology;
typedef F Field;
static const unsigned int dimension = Base::dimension;
typedef typename Base::Vector Vector;
private:
typedef OneDQuad OneDQuadrature;
typedef GenericQuadrature< BaseTopology, OneDQuadrature > BaseQuadrature;
public:
explicit GenericQuadrature ( unsigned int order )
: Base( Topology::id, order )
{
OneDQuadrature onedQuad( OneDQuadrature::minPoints(order) );
BaseQuadrature baseQuad( order );
const unsigned int baseQuadSize = baseQuad.size();
for( unsigned int bqi = 0; bqi < baseQuadSize; ++bqi )
{
const typename BaseQuadrature::Vector &basePoint = baseQuad[bqi].position( );
const Field &baseWeight = baseQuad[bqi].weight( );
Vector point;
for( unsigned int i = 0; i < dimension-1; ++i )
point[ i ] = basePoint[ i ];
const unsigned int onedQuadSize = onedQuad.size();
for( unsigned int oqi = 0; oqi < onedQuadSize; ++oqi )
{
point[ dimension-1 ] = onedQuad[oqi].position()[ 0 ];
Base::insert( point, baseWeight * onedQuad[oqi].weight( ) );
}
}
}
};
/** \brief Generic Quadrature for Pyramids
*
* This quadrature for \f$B^\circ\f$ is generated from a quadrature for
* \f$B\f$ and a 1D quadrature by the so-called Duffy-Transformation
* \f$y(x,z) = ((1-z)x,y)^T\f$. Hence, we have
* \f[
* \int_{B^\circ} f( y )\,\mathrm{d}y
* = \int_0^1 \int_B f( (1-z)x, z )\,\mathrm{d}x\,(1-z)^{\dim B}\,\mathrm{d}z.
* \f]
* Therefore, the 1D quadrature must be at least \f$\dim B\f$ orders higher
* than the quadrature for \f$B\f$.
*
* Question: If the polynomials are created via Duffy Transformation, do we
* really need a higher quadrature order?
*/
template< class BaseTopology, class OneDQuad >
class GenericQuadrature< Pyramid< BaseTopology >, OneDQuad >
: public Quadrature< typename OneDQuad::Field, Pyramid< BaseTopology >::dimension >
{
typedef typename OneDQuad::Field F;
typedef GenericQuadrature< Pyramid< BaseTopology >, OneDQuad > This;
typedef Quadrature< F, Pyramid< BaseTopology >::dimension > Base;
public:
typedef Pyramid< BaseTopology > Topology;
typedef F Field;
static const unsigned int dimension = Base::dimension;
typedef typename Base::Vector Vector;
private:
typedef OneDQuad OneDQuadrature;
typedef GenericQuadrature< BaseTopology, OneDQuadrature > BaseQuadrature;
public:
explicit GenericQuadrature ( unsigned int order )
: Base( Topology::id, order )
{
OneDQuadrature onedQuad( OneDQuadrature::minPoints(order + dimension-1 ) );
BaseQuadrature baseQuad( order );
const unsigned int baseQuadSize = baseQuad.size();
for( unsigned int bqi = 0; bqi < baseQuadSize; ++bqi )
{
const typename BaseQuadrature::Vector &basePoint = baseQuad[bqi].position( );
const Field &baseWeight = baseQuad[bqi].weight( );
const unsigned int onedQuadSize = onedQuad.size();
for( unsigned int oqi = 0; oqi < onedQuadSize; ++oqi )
{
Vector point;
point[ dimension-1 ] = onedQuad[oqi].position( )[ 0 ];
const Field scale = Field( 1 ) - point[ dimension-1 ];
for( unsigned int i = 0; i < dimension-1; ++i )
point[ i ] = scale * basePoint[ i ];
Field weight = baseWeight * onedQuad[oqi].weight( );
for ( unsigned int p = 0; p<dimension-1; ++p)
weight *= scale; // pow( scale, dimension-1 );
Base::insert( point, weight );
}
}
}
};
/**
* @brief Factory for the generic quadratures
*
* This is a Dune::GenericGeometry::TopologyFactory creating
* GenericQuadrature from a given 1d quadrature
*
* \tparam dim dimension of the reference elements contained in the factory
* \tparam F field in which weight and point of the quadrature are stored
* \tparam OneDQuad the underlying 1d quadrature
*
* Note: the computation of the quadrature points and weights are
* carried out in the field type of the 1d quadrature which can differ from F.
**/
template< int dim, class F, class OneDQuad >
struct GenericQuadratureFactory;
template< int dim, class F, class OneDQuad >
struct GenericQuadratureFactoryTraits
{
static const unsigned int dimension = dim;
typedef unsigned int Key;
typedef const Quadrature<F,dim> Object;
typedef GenericQuadratureFactory<dim,F,OneDQuad> Factory;
};
template< int dim, class F, class OneDQuad >
struct GenericQuadratureFactory :
public TopologyFactory< GenericQuadratureFactoryTraits<dim,F,OneDQuad> >
{
static const unsigned int dimension = dim;
typedef F Field;
typedef GenericQuadratureFactoryTraits<dim,F,OneDQuad> Traits;
typedef typename Traits::Key Key;
typedef typename Traits::Object Object;
template< class Topology >
static Object* createObject ( const Key &order )
{
return new Object( GenericQuadrature< Topology, OneDQuad >( order ) );
}
};
// GenericQuadratureProvider
// ---------------------
/**
* @brief Singleton factory for the generic quadratures
*
* Wrapper for the Dune::GenericGeometry::GenericQuadratureFactory providing
* singleton storage.
*
* \tparam dim dimension of the reference elements contained in the factory
* \tparam F field in which weight and point of the quadrature are stored
* \tparam OneDQuad the underlying 1d quadrature
**/
template< int dim, class F, class OneDQuad >
struct GenericQuadratureProvider
: public TopologySingletonFactory< GenericQuadratureFactory< dim, F, OneDQuad > >
{};
}
}
#endif // #ifndef DUNE_GEOMETRY_QUADRATURERULES_GENERICQUADRATURE_HH
|