20#include "dune/geometry/quadraturerules.hh"
33 template <
class QuadRule>
38 static Rule const&
rule(
const Dune::GeometryType& t,
int p)
62 template<
class ctype,
int dim>
76 Rule const&
rule(Dune::GeometryType
const& t,
int p)
87 if (p==cacheP && t==cacheT)
96 typename DirectMap::const_iterator i = rules[p].find(t);
97 if (i == rules[p].end())
102 cacheRule = &Dune::QuadratureRules<ctype, dim>::rule(t,p);
103 rules[p][t] = cacheRule;
106 cacheRule = i->second;
111 typename OverspillMap::const_iterator i = ruleOverspill.find(std::make_pair(t,p));
112 if (i==ruleOverspill.end())
117 cacheRule = &Dune::QuadratureRules<ctype, dim>::rule(t,p);
118 ruleOverspill[std::make_pair(t,p)] = cacheRule;
121 cacheRule = i->second;
132 static int const pmax = 8;
138 typedef std::map<Dune::GeometryType,Rule const*> DirectMap;
139 typedef std::map<std::pair<Dune::GeometryType,int>,
Rule const*> OverspillMap;
140 DirectMap rules[pmax+1];
141 OverspillMap ruleOverspill;
143 Dune::GeometryType cacheT;
145 Rule const* cacheRule;
std::mutex DuneQuadratureRulesMutex
A global lock for the Dune::QuadratureRules factory, which is not thread-safe as of 2015-01-01.
Rule const & rule(Dune::GeometryType const &t, int p)
Returns a quadrature rule for the given geometry type and integration order.
Dune::QuadratureRule< ctype, dim > Rule
A cache that stores suitable quadrature rules for quick retrieval.
static Rule const & rule(const Dune::GeometryType &t, int p)