/usr/include/dune/pdelab/common/referenceelements.hh is in libdune-pdelab-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 | #ifndef DUNE_PDELAB_COMMON_REFERENCEELEMENTS_HH
#define DUNE_PDELAB_COMMON_REFERENCEELEMENTS_HH
#include <dune/geometry/quadraturerules.hh>
#include <dune/geometry/referenceelements.hh>
namespace Dune {
namespace PDELab {
//! Wrapper for Dune::ReferenceElement with value semantics.
/**
* This class wraps a Dune::ReferenceElement and exposes the relevant parts
* of its interface. Note, however, that its signature is different, so code
* that relies on partial specialization of the reference element type will
* not work with the wrapper.
*
* For the exact documentation of the individual members, please see the documentation
* of Dune::ReferenceElement.
*
* This class exports three additional items of static information:
*
* - `CoordinateField` denotes the field type of the spatial coordinates of the
* reference element.
* - `Coordinate` denotes the type of spatial coordinate vectors.
* - `dimension` denotes the dimension of the element.
*
* \note Users will normally not construct a ReferenceWrapper directly, but
* obtain the rule by calling Dune::PDELab::referenceElement().
*
* \sa Dune::ReferenceElement.
*
*/
template<typename RE>
class ReferenceElementWrapper
{
public:
template<int codim>
using Codim = typename RE::template Codim<codim>;
//! The coordinate field type.
using ctype = typename Codim<0>::Geometry::ctype;
//! The coordinate field type.
using CoordinateField = ctype;
//! The dimension of the reference element.
static const std::size_t dimension = Codim<0>::Geometry::coorddimension;
//! The coordinate type of the reference element.
using Coordinate = FieldVector<CoordinateField,dimension>;
int size(int c) const
{
return _ref_el->size(c);
}
int size(int i, int c, int cc) const
{
return _ref_el->size(i,c,cc);
}
int subEntity(int i, int c, int ii, int cc) const
{
return _ref_el->subEntity(i,c,ii,cc);
}
GeometryType type(int i, int c) const
{
return _ref_el->type(i,c);
}
GeometryType type() const
{
return _ref_el->type();
}
const Coordinate& position(int i, int c) const
{
return _ref_el->position(i,c);
}
bool checkInside(const Coordinate& local) const
{
return _ref_el->checkInside(local);
}
template<int codim>
typename Codim<codim>::Geometry geometry(int i) const
{
return _ref_el->geometry(i);
}
CoordinateField volume() const
{
return _ref_el->volume();
}
const Coordinate& integrationOuterNormal(int face) const
{
return _ref_el->integrationOuterNormal(face);
}
#ifndef DOXYGEN
ReferenceElementWrapper(const RE& ref_el)
: _ref_el(&ref_el)
{}
#endif // DOXYGEN
private:
const RE* _ref_el;
};
//! Returns the reference element for the given geometry.
/**
* This function returns the reference element for the given geometry `geo`.
*
* This function should be used unqualified, e.g.
*
* ```c++
* auto rule = quadratureRule(geo,4);
* ```
*
* \warning Do *not* add `Dune::PDELab` in front of it, as that might cause compiler
* errors with future versions of the core modules.
*
* The function wraps the reference element in a ReferenceElementWrapper to provide value
* semantics.
*
* \param geo The geometry for which to obtain the reference element.
*/
template<typename Geometry>
ReferenceElementWrapper<
ReferenceElement<
typename Geometry::ctype,
Geometry::mydimension
>
>
referenceElement(const Geometry& geo)
{
return { ReferenceElements<typename Geometry::ctype,Geometry::mydimension>::general(geo.type()) };
}
} // namespace PDELab
// inject the function into the Dune namespace to enable ADL.
// TODO: Remove this injection once the core modules gain their own version of this function!
using Dune::PDELab::referenceElement;
} // namespace Dune
#endif // DUNE_PDELAB_COMMON_REFERENCEELEMENTS_HH
|