/usr/include/dune/geometry/quadraturerules.hh is in libdune-geometry-dev 2.4.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 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 | // -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_GEOMETRY_QUADRATURERULES_HH
#define DUNE_GEOMETRY_QUADRATURERULES_HH
#include <algorithm>
#include <iostream>
#include <limits>
#include <mutex>
#include <utility>
#include <vector>
#include <dune/common/fvector.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/stdstreams.hh>
#include <dune/common/stdthread.hh>
#include <dune/common/visibility.hh>
#include <dune/geometry/quadraturerules/nocopyvector.hh>
#include <dune/geometry/type.hh>
#include <dune/geometry/typeindex.hh>
/**
\file
Interface for quadrature points and rules
*/
namespace Dune {
/** \brief Exception thrown if a desired QuadratureRule is not available,
because the requested order is to high
\ingroup Quadrature
*/
class QuadratureOrderOutOfRange : public NotImplemented {};
/** \brief Single evaluation point in a quadrature rule
\ingroup Quadrature
\tparam ct Number type used for both coordinates and the weights
\tparam dim Dimension of the integration domain
*/
template<typename ct, int dim>
class QuadraturePoint {
public:
/** \brief Dimension of the integration domain */
enum { dimension = dim };
/** \brief Number type used for coordinates and quadrature weights */
typedef ct Field;
/** \brief Type used for the position of a quadrature point */
typedef Dune::FieldVector<ct,dim> Vector;
//! set up quadrature of given order in d dimensions
QuadraturePoint (const Vector& x, ct w) : local(x)
{
weight_ = w;
}
//! return local coordinates of integration point i
const Vector& position () const
{
return local;
}
//! return weight associated with integration point i
const ct &weight () const
{
return weight_;
}
protected:
FieldVector<ct, dim> local;
ct weight_;
};
/** \brief Defines an \p enum for currently available quadrature rules.
\ingroup Quadrature
*/
namespace QuadratureType {
enum Enum {
GaussLegendre = 0,
GaussJacobi_1_0 = 1,
GaussJacobi_2_0 = 2,
GaussLobatto = 4,
size
};
}
/** \brief Abstract base class for quadrature rules
\ingroup Quadrature
*/
template<typename ct, int dim>
class QuadratureRule : public std::vector<QuadraturePoint<ct,dim> >
{
public:
/** \brief Default constructor
*
* Create an invalid empty quadrature rule. This must be initialized
* later by copying another quadraturerule before it can be used.
*/
QuadratureRule() : delivered_order(-1) {}
protected:
/** \brief Constructor for a given geometry type. Leaves the quadrature order invalid */
QuadratureRule(GeometryType t) : geometry_type(t), delivered_order(-1) {}
/** \brief Constructor for a given geometry type and a given quadrature order */
QuadratureRule(GeometryType t, int order) : geometry_type(t), delivered_order(order) {}
public:
/** \brief The space dimension */
enum { d=dim };
/** \brief The type used for coordinates */
typedef ct CoordType;
//! return order
virtual int order () const { return delivered_order; }
//! return type of element
virtual GeometryType type () const { return geometry_type; }
virtual ~QuadratureRule(){}
//! this container is always a const container,
//! therefore iterator is the same as const_iterator
typedef typename std::vector<QuadraturePoint<ct,dim> >::const_iterator iterator;
protected:
GeometryType geometry_type;
int delivered_order;
};
// Forward declaration of the factory class,
// needed internally by the QuadratureRules container class.
template<typename ctype, int dim> class QuadratureRuleFactory;
/** \brief A container for all quadrature rules of dimension <tt>dim</tt>
\ingroup Quadrature
*/
template<typename ctype, int dim>
class QuadratureRules {
/** \brief Internal short-hand notation for the type of quadrature rules this container contains */
typedef Dune::QuadratureRule<ctype, dim> QuadratureRule;
//! \brief a quadrature rule (for each quadrature order, geometry type,
//! and quadrature type)
static void initQuadratureRule(QuadratureRule *qr, QuadratureType::Enum qt,
const GeometryType &t, int p)
{
*qr = QuadratureRuleFactory<ctype,dim>::rule(t,p,qt);
}
typedef NoCopyVector<std::pair<std::once_flag, QuadratureRule> >
QuadratureOrderVector; // indexed by quadrature order
//! \brief initialize the vector indexed by the quadrature order (for each
//! geometry type and quadrature type)
static void initQuadratureOrderVector(QuadratureOrderVector *qov,
QuadratureType::Enum qt,
const GeometryType &t)
{
if(dim == 0)
// we only need one quadrature rule for points, not maxint
qov->resize(1);
else
qov->resize(QuadratureRuleFactory<ctype,dim>::maxOrder(t,qt)+1);
}
typedef NoCopyVector<std::pair<std::once_flag, QuadratureOrderVector> >
GeometryTypeVector; // indexed by geometry type
//! \brief initialize the vector indexed by the geometry type (for each
//! quadrature type)
static void initGeometryTypeVector(GeometryTypeVector *gtv)
{
gtv->resize(LocalGeometryTypeIndex::size(dim));
}
//! real rule creator
DUNE_EXPORT const QuadratureRule& _rule(const GeometryType& t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
{
assert(t.dim()==dim);
DUNE_ASSERT_CALL_ONCE();
static NoCopyVector<std::pair< // indexed by quadrature type
std::once_flag,
GeometryTypeVector
> > quadratureCache(QuadratureType::size);
auto & quadratureTypeLevel = quadratureCache[qt];
std::call_once(quadratureTypeLevel.first, initGeometryTypeVector,
&quadratureTypeLevel.second);
auto & geometryTypeLevel =
quadratureTypeLevel.second[LocalGeometryTypeIndex::index(t)];
std::call_once(geometryTypeLevel.first, initQuadratureOrderVector,
&geometryTypeLevel.second, qt, t);
// we only have one quadrature rule for points
auto & quadratureOrderLevel = geometryTypeLevel.second[dim == 0 ? 0 : p];
std::call_once(quadratureOrderLevel.first, initQuadratureRule,
&quadratureOrderLevel.second, qt, t, p);
return quadratureOrderLevel.second;
}
//! singleton provider
DUNE_EXPORT static QuadratureRules& instance()
{
static QuadratureRules instance;
return instance;
}
//! private constructor
QuadratureRules () {}
public:
//! maximum quadrature order for given geometry type and quadrature type
static unsigned
maxOrder(const GeometryType& t,
QuadratureType::Enum qt=QuadratureType::GaussLegendre)
{
return QuadratureRuleFactory<ctype,dim>::maxOrder(t,qt);
}
//! select the appropriate QuadratureRule for GeometryType t and order p
static const QuadratureRule& rule(const GeometryType& t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
{
return instance()._rule(t,p,qt);
}
//! @copydoc rule
static const QuadratureRule& rule(const GeometryType::BasicType t, int p, QuadratureType::Enum qt=QuadratureType::GaussLegendre)
{
GeometryType gt(t,dim);
return instance()._rule(gt,p,qt);
}
};
} // end namespace Dune
#include "quadraturerules/pointquadrature.hh"
namespace Dune {
//! \internal Helper template for the initialization of the quadrature rules
template<typename ct, bool fundamental = std::numeric_limits<ct>::is_specialized>
struct GaussQuadratureInitHelper;
template<typename ct>
struct GaussQuadratureInitHelper<ct, true> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
template<typename ct>
struct GaussQuadratureInitHelper<ct, false> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
//! \brief Gauss quadrature rule in 1D
template<typename ct>
class GaussQuadratureRule1D :
public QuadratureRule<ct,1>
{
public:
// compile time parameters
enum { dim=1 };
enum { highest_order=61 };
~GaussQuadratureRule1D(){}
private:
friend class QuadratureRuleFactory<ct,dim>;
GaussQuadratureRule1D (int p)
: QuadratureRule<ct,1>(GeometryType(GeometryType::cube, 1))
{
//! set up quadrature of given order in d dimensions
std::vector< FieldVector<ct, dim> > _points;
std::vector< ct > _weight;
GaussQuadratureInitHelper<ct>::init
(p, _points, _weight, this->delivered_order);
assert(_points.size() == _weight.size());
for (size_t i = 0; i < _points.size(); i++)
this->push_back(QuadraturePoint<ct,dim>(_points[i], _weight[i]));
}
};
extern template GaussQuadratureRule1D<float>::GaussQuadratureRule1D(int);
extern template GaussQuadratureRule1D<double>::GaussQuadratureRule1D(int);
} // namespace Dune
#define DUNE_INCLUDING_IMPLEMENTATION
#include "quadraturerules/gauss_imp.hh"
namespace Dune {
//! \internal Helper template for the initialization of the quadrature rules
template<typename ct,
bool fundamental = std::numeric_limits<ct>::is_specialized>
struct Jacobi1QuadratureInitHelper;
template<typename ct>
struct Jacobi1QuadratureInitHelper<ct, true> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
template<typename ct>
struct Jacobi1QuadratureInitHelper<ct, false> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
/** \brief Jacobi-Gauss quadrature for alpha=1, beta=0
\ingroup Quadrature
*/
template<typename ct>
class Jacobi1QuadratureRule1D :
public QuadratureRule<ct,1>
{
public:
/** \brief The space dimension */
enum { dim=1 };
/** \brief The highest quadrature order available */
enum { highest_order=61 };
~Jacobi1QuadratureRule1D(){}
private:
friend class QuadratureRuleFactory<ct,dim>;
Jacobi1QuadratureRule1D (int p)
: QuadratureRule<ct,1>(GeometryType(GeometryType::cube, 1))
{
//! set up quadrature of given order in d dimensions
std::vector< FieldVector<ct, dim> > _points;
std::vector< ct > _weight;
int delivered_order;
Jacobi1QuadratureInitHelper<ct>::init
(p, _points, _weight, delivered_order);
this->delivered_order = delivered_order;
assert(_points.size() == _weight.size());
for (size_t i = 0; i < _points.size(); i++)
this->push_back(QuadraturePoint<ct,dim>(_points[i], _weight[i]));
}
};
#ifndef DOXYGEN
extern template Jacobi1QuadratureRule1D<float>::Jacobi1QuadratureRule1D(int);
extern template Jacobi1QuadratureRule1D<double>::Jacobi1QuadratureRule1D(int);
#endif // !DOXYGEN
} // namespace Dune
#define DUNE_INCLUDING_IMPLEMENTATION
#include "quadraturerules/jacobi_1_0_imp.hh"
namespace Dune {
//! \internal Helper template for the initialization of the quadrature rules
template<typename ct,
bool fundamental = std::numeric_limits<ct>::is_specialized>
struct Jacobi2QuadratureInitHelper;
template<typename ct>
struct Jacobi2QuadratureInitHelper<ct, true> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
template<typename ct>
struct Jacobi2QuadratureInitHelper<ct, false> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
/** \brief Jacobi-Gauss quadrature for alpha=2, beta=0
\ingroup Quadrature
*/
template<typename ct>
class Jacobi2QuadratureRule1D :
public QuadratureRule<ct,1>
{
public:
/** \brief The space dimension */
enum { dim=1 };
/** \brief The highest quadrature order available */
enum { highest_order=61 };
~Jacobi2QuadratureRule1D(){}
private:
friend class QuadratureRuleFactory<ct,dim>;
Jacobi2QuadratureRule1D (int p)
: QuadratureRule<ct,1>(GeometryType(GeometryType::cube, 1))
{
//! set up quadrature of given order in d dimensions
std::vector< FieldVector<ct, dim> > _points;
std::vector< ct > _weight;
int delivered_order;
Jacobi2QuadratureInitHelper<ct>::init
(p, _points, _weight, delivered_order);
this->delivered_order = delivered_order;
assert(_points.size() == _weight.size());
for (size_t i = 0; i < _points.size(); i++)
this->push_back(QuadraturePoint<ct,dim>(_points[i], _weight[i]));
}
};
#ifndef DOXYGEN
extern template Jacobi2QuadratureRule1D<float>::Jacobi2QuadratureRule1D(int);
extern template Jacobi2QuadratureRule1D<double>::Jacobi2QuadratureRule1D(int);
#endif // !DOXYGEN
} // namespace Dune
#define DUNE_INCLUDING_IMPLEMENTATION
#include "quadraturerules/jacobi_2_0_imp.hh"
namespace Dune {
//! \internal Helper template for the initialization of the quadrature rules
template<typename ct,
bool fundamental = std::numeric_limits<ct>::is_specialized>
struct GaussLobattoQuadratureInitHelper;
template<typename ct>
struct GaussLobattoQuadratureInitHelper<ct, true> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
template<typename ct>
struct GaussLobattoQuadratureInitHelper<ct, false> {
static void init(int p,
std::vector< FieldVector<ct, 1> > & _points,
std::vector< ct > & _weight,
int & delivered_order);
};
/** \brief Jacobi-Gauss quadrature for alpha=2, beta=0
\ingroup Quadrature
*/
template<typename ct>
class GaussLobattoQuadratureRule1D :
public QuadratureRule<ct,1>
{
public:
/** \brief The space dimension */
enum { dim=1 };
/** \brief The highest quadrature order available */
enum { highest_order=31 };
~GaussLobattoQuadratureRule1D(){}
private:
friend class QuadratureRuleFactory<ct,dim>;
GaussLobattoQuadratureRule1D (int p)
: QuadratureRule<ct,1>(GeometryType(GeometryType::cube, 1))
{
//! set up quadrature of given order in d dimensions
std::vector< FieldVector<ct, dim> > _points;
std::vector< ct > _weight;
int delivered_order;
GaussLobattoQuadratureInitHelper<ct>::init
(p, _points, _weight, delivered_order);
this->delivered_order = delivered_order;
assert(_points.size() == _weight.size());
for (size_t i = 0; i < _points.size(); i++)
this->push_back(QuadraturePoint<ct,dim>(_points[i], _weight[i]));
}
};
#ifndef DOXYGEN
extern template GaussLobattoQuadratureRule1D<float>::GaussLobattoQuadratureRule1D(int);
extern template GaussLobattoQuadratureRule1D<double>::GaussLobattoQuadratureRule1D(int);
#endif // !DOXYGEN
} // namespace Dune
#define DUNE_INCLUDING_IMPLEMENTATION
#include "quadraturerules/gausslobatto_imp.hh"
#include "quadraturerules/tensorproductquadrature.hh"
#include "quadraturerules/simplexquadrature.hh"
namespace Dune {
/***********************************
* quadrature for Prism
**********************************/
/** \todo Please doc me! */
template<int dim>
class PrismQuadraturePoints;
/** \todo Please doc me! */
template<>
class PrismQuadraturePoints<3>
{
public:
enum { MAXP=6};
enum { highest_order=2 };
//! initialize quadrature points on the interval for all orders
PrismQuadraturePoints ()
{
int m = 0;
O[m] = 0;
// polynom degree 0 ???
m = 6;
G[m][0][0] = 0.0;
G[m][0][1] = 0.0;
G[m][0][2] = 0.0;
G[m][1][0] = 1.0;
G[m][1][1] = 0.0;
G[m][1][2] = 0.0;
G[m][2][0] = 0.0;
G[m][2][1] = 1.0;
G[m][2][2] = 0.0;
G[m][3][0] = 0.0;
G[m][3][1] = 0.0;
G[m][3][2] = 1.0;
G[m][4][0] = 1.0;
G[m][4][1] = 0.0;
G[m][4][2] = 1.0;
G[m][5][0] = 0.0;
G[m][5][1] = 0.1;
G[m][5][2] = 1.0;
W[m][0] = 0.16666666666666666 / 2.0;
W[m][1] = 0.16666666666666666 / 2.0;
W[m][2] = 0.16666666666666666 / 2.0;
W[m][3] = 0.16666666666666666 / 2.0;
W[m][4] = 0.16666666666666666 / 2.0;
W[m][5] = 0.16666666666666666 / 2.0;
O[m] = 0; // verify ????????
// polynom degree 2 ???
m = 6;
G[m][0][0] =0.66666666666666666 ;
G[m][0][1] =0.16666666666666666 ;
G[m][0][2] =0.211324865405187 ;
G[m][1][0] = 0.16666666666666666;
G[m][1][1] =0.66666666666666666 ;
G[m][1][2] = 0.211324865405187;
G[m][2][0] = 0.16666666666666666;
G[m][2][1] = 0.16666666666666666;
G[m][2][2] = 0.211324865405187;
G[m][3][0] = 0.66666666666666666;
G[m][3][1] = 0.16666666666666666;
G[m][3][2] = 0.788675134594813;
G[m][4][0] = 0.16666666666666666;
G[m][4][1] = 0.66666666666666666;
G[m][4][2] = 0.788675134594813;
G[m][5][0] = 0.16666666666666666;
G[m][5][1] = 0.16666666666666666;
G[m][5][2] = 0.788675134594813;
W[m][0] = 0.16666666666666666 / 2.0;
W[m][1] = 0.16666666666666666 / 2.0;
W[m][2] = 0.16666666666666666 / 2.0;
W[m][3] = 0.16666666666666666 / 2.0;
W[m][4] = 0.16666666666666666 / 2.0;
W[m][5] = 0.16666666666666666 / 2.0;
O[m] = 2; // verify ????????
}
/** \todo Please doc me! */
FieldVector<double, 3> point(int m, int i)
{
return G[m][i];
}
/** \todo Please doc me! */
double weight (int m, int i)
{
return W[m][i];
}
/** \todo Please doc me! */
int order (int m)
{
return O[m];
}
private:
FieldVector<double, 3> G[MAXP+1][MAXP]; //positions
double W[MAXP+1][MAXP]; // weights associated with points
int O[MAXP+1]; // order of the rule
};
/** \brief Singleton holding the Prism Quadrature points
\ingroup Quadrature
*/
template<int dim>
struct PrismQuadraturePointsSingleton {
static PrismQuadraturePoints<3> prqp;
};
/** \brief Singleton holding the Prism Quadrature points
\ingroup Quadrature
*/
template<>
struct PrismQuadraturePointsSingleton<3> {
static PrismQuadraturePoints<3> prqp;
};
/** \brief Quadrature rules for prisms
\ingroup Quadrature
*/
template<typename ct, int dim>
class PrismQuadratureRule;
/** \brief Quadrature rules for prisms
\ingroup Quadrature
*/
template<typename ct>
class PrismQuadratureRule<ct,3> : public QuadratureRule<ct,3>
{
public:
/** \brief The space dimension */
enum { d = 3 };
/** \brief The highest quadrature order available */
enum { highest_order = 2 };
~PrismQuadratureRule(){}
private:
friend class QuadratureRuleFactory<ct,d>;
PrismQuadratureRule(int p) : QuadratureRule<ct,3>(GeometryType(GeometryType::prism, d))
{
int m=6;
this->delivered_order = PrismQuadraturePointsSingleton<3>::prqp.order(m);
for(int i=0; i<m; ++i)
{
FieldVector<ct,3> local;
for (int k=0; k<d; k++)
local[k] = PrismQuadraturePointsSingleton<3>::prqp.point(m,i)[k];
double weight =
PrismQuadraturePointsSingleton<3>::prqp.weight(m,i);
// put in container
this->push_back(QuadraturePoint<ct,d>(local,weight));
}
}
};
/** \brief Factory class for creation of quadrature rules,
depending on GeometryType, order and QuadratureType.
The whole class is private and can only be accessed
by the singleton container class QuadratureRules.
*/
template<typename ctype, int dim>
class QuadratureRuleFactory {
private:
friend class QuadratureRules<ctype, dim>;
static unsigned maxOrder(const GeometryType &t, QuadratureType::Enum qt)
{
return TensorProductQuadratureRule<ctype,dim>::maxOrder(t.id(), qt);
}
static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
{
return TensorProductQuadratureRule<ctype,dim>(t.id(), p, qt);
}
};
template<typename ctype>
class QuadratureRuleFactory<ctype, 0> {
private:
enum { dim = 0 };
friend class QuadratureRules<ctype, dim>;
static unsigned maxOrder(const GeometryType &t, QuadratureType::Enum qt)
{
if (t.isVertex())
{
return std::numeric_limits<int>::max();
}
DUNE_THROW(Exception, "Unknown GeometryType");
}
static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
{
if (t.isVertex())
{
return PointQuadratureRule<ctype>();
}
DUNE_THROW(Exception, "Unknown GeometryType");
}
};
template<typename ctype>
class QuadratureRuleFactory<ctype, 1> {
private:
enum { dim = 1 };
friend class QuadratureRules<ctype, dim>;
static unsigned maxOrder(const GeometryType &t, QuadratureType::Enum qt)
{
if (t.isLine())
{
switch (qt) {
case QuadratureType::GaussLegendre :
return GaussQuadratureRule1D<ctype>::highest_order;
case QuadratureType::GaussJacobi_1_0 :
return Jacobi1QuadratureRule1D<ctype>::highest_order;
case QuadratureType::GaussJacobi_2_0 :
return Jacobi2QuadratureRule1D<ctype>::highest_order;
case QuadratureType::GaussLobatto :
return GaussLobattoQuadratureRule1D<ctype>::highest_order;
default :
DUNE_THROW(Exception, "Unknown QuadratureType");
}
}
DUNE_THROW(Exception, "Unknown GeometryType");
}
static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
{
if (t.isLine())
{
switch (qt) {
case QuadratureType::GaussLegendre :
return GaussQuadratureRule1D<ctype>(p);
case QuadratureType::GaussJacobi_1_0 :
return Jacobi1QuadratureRule1D<ctype>(p);
case QuadratureType::GaussJacobi_2_0 :
return Jacobi2QuadratureRule1D<ctype>(p);
case QuadratureType::GaussLobatto :
return GaussLobattoQuadratureRule1D<ctype>(p);
default :
DUNE_THROW(Exception, "Unknown QuadratureType");
}
}
DUNE_THROW(Exception, "Unknown GeometryType");
}
};
template<typename ctype>
class QuadratureRuleFactory<ctype, 2> {
private:
enum { dim = 2 };
friend class QuadratureRules<ctype, dim>;
static unsigned maxOrder(const GeometryType &t, QuadratureType::Enum qt)
{
unsigned order =
TensorProductQuadratureRule<ctype,dim>::maxOrder(t.id(), qt);
if (t.isSimplex())
order = std::max
(order, unsigned(SimplexQuadratureRule<ctype,dim>::highest_order));
return order;
}
static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
{
if (t.isSimplex()
&& qt == QuadratureType::GaussLegendre
&& p <= SimplexQuadratureRule<ctype,dim>::highest_order)
{
return SimplexQuadratureRule<ctype,dim>(p);
}
return TensorProductQuadratureRule<ctype,dim>(t.id(), p, qt);
}
};
template<typename ctype>
class QuadratureRuleFactory<ctype, 3> {
private:
enum { dim = 3 };
friend class QuadratureRules<ctype, dim>;
static unsigned maxOrder(const GeometryType &t, QuadratureType::Enum qt)
{
unsigned order =
TensorProductQuadratureRule<ctype,dim>::maxOrder(t.id(), qt);
if (t.isSimplex())
order = std::max
(order, unsigned(SimplexQuadratureRule<ctype,dim>::highest_order));
if (t.isPrism())
order = std::max
(order, unsigned(PrismQuadratureRule<ctype,dim>::highest_order));
return order;
}
static QuadratureRule<ctype, dim> rule(const GeometryType& t, int p, QuadratureType::Enum qt)
{
if (t.isSimplex()
&& qt == QuadratureType::GaussLegendre
&& p <= SimplexQuadratureRule<ctype,dim>::highest_order)
{
return SimplexQuadratureRule<ctype,dim>(p);
}
if (t.isPrism()
&& qt == QuadratureType::GaussLegendre
&& p <= PrismQuadratureRule<ctype,dim>::highest_order)
{
return PrismQuadratureRule<ctype,dim>(p);
}
return TensorProductQuadratureRule<ctype,dim>(t.id(), p, qt);
}
};
} // end namespace
#endif // DUNE_GEOMETRY_QUADRATURERULES_HH
|