/usr/include/dune/localfunctions/lagrange/lobattopoints.hh is in libdune-localfunctions-dev 2.2.1-2.
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 | #ifndef DUNE_LOBATTOBASIS_HH
#define DUNE_LOBATTOBASIS_HH
#include <fstream>
#include <dune/common/forloop.hh>
#include <dune/geometry/topologyfactory.hh>
#include <dune/geometry/quadraturerules/lobattoquadrature.hh>
#include <dune/geometry/referenceelements.hh>
#include <dune/geometry/genericgeometry/referenceelements.hh>
#include <dune/localfunctions/utility/field.hh>
#include <dune/localfunctions/lagrange/lagrangecoefficients.hh>
#include <dune/localfunctions/lagrange/emptypoints.hh>
namespace Dune
{
template< class Field >
struct LobattoPoints
{
LobattoPoints ( unsigned int order )
: points_( 0 )
{
if( order < 2 )
return;
points_.resize(order-1);
#if HAVE_ALGLIB
typedef amp::ampf< Precision< Field >::value > MPField;
#else
typedef Field MPField;
#endif
GenericGeometry::LobattoPoints<MPField> lobatto(order+1);
for (unsigned int i=1;i<order;++i) {
points_[i-1] = field_cast<Field>(lobatto[i].position());
}
}
const unsigned int size()
{
return points_.size();
}
const unsigned int order()
{
return points_.size()+1;
}
const Field &point(int i)
{
return points_[i];
}
std::vector<Field> points_;
};
template <class Field,class Topology>
struct LobattoInnerPoints;
template <class Field>
struct LobattoInnerPoints<Field,GenericGeometry::Point>
{
static const unsigned int dimension = 0;
static unsigned int size(const unsigned int order)
{
return 1;
}
template <unsigned int dim>
static unsigned int setupSimplex(
const unsigned int iup,
const unsigned int dimStart,
unsigned int startPos,
const std::vector<Field> &points1D,
LagrangePoint< Field, dim > *points )
{
const unsigned int order = points1D.size()+1;
unsigned int i = order+1-iup;
if (i-2>=points1D.size())
{
return startPos;
}
for ( unsigned int d=0;d<dimStart;++d )
{
points[startPos].point_[d] = -points1D[i-2];
}
return startPos+1;
}
template <unsigned int dim>
static void setup(const std::vector<Field> &points1D,
LagrangePoint< Field, dim > *points )
{
points->point_[0] = Zero<Field>();
}
};
template <class Field,class Base>
struct LobattoInnerPoints<Field,GenericGeometry::Pyramid<Base> >
{
typedef LobattoInnerPoints<Field,Base> LobattoBase;
static const unsigned int dimension = Base::dimension+1;
static unsigned int size(const unsigned int order)
{
if (order<=dimension) return 0;
unsigned int size=0;
for (unsigned int o=0;o<order-dimension;++o)
size += LobattoBase::size(o+dimension);
return size;
}
template <unsigned int dim>
static unsigned int setupSimplex(
const unsigned int iup,
const unsigned int dimStart,
unsigned int startPos,
const std::vector<Field> &points1D,
LagrangePoint< Field, dim > *points )
{
const unsigned int order = points1D.size()+1;
unsigned int endPos = startPos;
for (unsigned int i=2;i<=order-iup;++i)
{
endPos = LobattoBase::template setupSimplex<dim>(iup+i-1,dimStart,startPos,points1D,points);
for (unsigned int j=startPos;j<endPos;++j)
{
for (unsigned int d=0;d<dimStart;++d)
{
if ( d==dimStart-dimension )
points[j].point_[d] += dimStart*points1D[i-2];
else
points[j].point_[d] -= points1D[i-2];
}
}
startPos = endPos;
}
return endPos;
}
template <unsigned int dim>
static void setup(const std::vector<Field> &points1D,
LagrangePoint< Field, dim > *points )
{
const unsigned int order = points1D.size()+1;
unsigned int startPos=0,endPos=0;
for (unsigned int i=2;i<=order;++i)
{
endPos = LobattoBase::template setupSimplex<dim>(i-1,dimension,startPos,points1D,points);
for (unsigned int j=startPos;j<endPos;++j)
{
for (unsigned int d=0;d<dimension;++d)
{
if ( d==0 )
points[j].point_[d] += 1.+int(dimension)*points1D[i-2];
else
points[j].point_[d] += 1.-points1D[i-2];
points[j].point_[d] /= (dimension+1);
}
}
startPos = endPos;
}
}
};
template <class Field,class Base>
struct LobattoInnerPoints<Field,GenericGeometry::Prism<Base> >
{
typedef LobattoInnerPoints<Field,Base> LobattoBase;
static const unsigned int dimension = Base::dimension+1;
static unsigned int size(const unsigned int order)
{
return LobattoBase::size(order)*(order-1);
}
template <unsigned int dim>
static unsigned int setupSimplex(
const unsigned int iup,
const unsigned int dimStart,
unsigned int startPos,
const std::vector<Field> &points1D,
LagrangePoint< Field, dim > *points )
{
const unsigned int order = points1D.size()+1;
unsigned int endPos = startPos;
for (unsigned int i=2;i<=order-iup;++i)
{
endPos = LobattoBase::template setupSimplex<dim>(iup+i-1,dimStart,startPos,points1D,points);
for (unsigned int j=startPos;j<endPos;++j)
{
for (unsigned int d=0;d<dimStart;++d)
{
if ( d==dimStart-dimension )
points[j].point_[d] += dimStart*points1D[i-2];
else
points[j].point_[d] -= points1D[i-2];
}
}
startPos = endPos;
}
return endPos;
}
template <unsigned int dim>
static void setup(const std::vector<Field> &points1D,
LagrangePoint< Field, dim > *points )
{
const unsigned int order = points1D.size()+1;
assert(dim>=dimension);
assert(points1D.size()==order-1);
LobattoBase::template setup<dim>(points1D,points);
const unsigned int baseSize = LobattoBase::size(order);
for (unsigned int q=0;q<points1D.size();q++)
{
for (unsigned int i=0;i<baseSize;++i)
{
const unsigned int pos = q*baseSize+i;
for (unsigned int d=0;d<dimension-1;++d)
points[pos].point_[d] = points[i].point_[d];
points[pos].point_[dimension-1]=points1D[q];
}
}
}
};
template< class F, unsigned int dim >
struct LobattoPointSet : public EmptyPointSet<F,dim>
{
// friend class LagrangeCoefficientsFactory<LobattoPointSet,dim,F>;
static const unsigned int dimension = dim;
typedef F Field;
typedef EmptyPointSet<F,dim> Base;
typedef typename Base::LagrangePoint Point;
LobattoPointSet(unsigned int order)
: Base(order)
{
}
template< class Topology >
bool build ( )
{
unsigned int order = Base::order();
LobattoPoints<Field> points1D(order);
ForLoop<Setup<Topology>::template InitCodim,0,dimension>::
apply(order,points1D.points_,points_);
return true;
}
template< class Topology >
static bool supports ( unsigned int order )
{
if ( GenericGeometry::IsSimplex< Topology >::value ||
GenericGeometry::IsGeneralizedPrism< Topology >::value )
return true;
else
return false;
}
protected:
using Base::points_;
private:
template <class Topology>
struct Setup
{
template <int pdim>
struct InitCodim
{
static const unsigned int codim = dimension-pdim;
static void apply(const unsigned int order,
const std::vector<Field> &points1D,
std::vector<Point> &points)
{
const unsigned int size = GenericGeometry::Size<Topology,codim>::value;
ForLoop<InitSub,0,size-1>::apply(order,points1D,points);
}
template <int i>
struct InitSub
{
typedef typename GenericGeometry::SubTopology<Topology,codim,i>::type SubTopology;
static void apply(const unsigned int order,
const std::vector<Field> &points1D,
std::vector<Point> &points)
{
Setup<Topology>::template Init<SubTopology>::template apply<i>(order,points1D,points);
}
};
};
template <class SubTopology>
struct Init
{
static const unsigned int codimension = dimension - SubTopology::dimension;
typedef GenericReferenceElements< Field, dimension > RefElements;
typedef GenericReferenceElement< Field, dimension > RefElement;
typedef typename RefElement::template Codim< codimension >::Mapping Mapping;
typedef LobattoInnerPoints<Field,SubTopology> InnerPoints;
template <unsigned int subEntity>
static void apply(const unsigned int order,
const std::vector<Field> &points1D,
std::vector<Point> &points)
{
unsigned int oldSize = points.size();
unsigned int size = InnerPoints::size(order);
if (size==0)
return;
points.resize(oldSize+size);
std::vector< LagrangePoint<Field,dimension-codimension> > subPoints(size);
InnerPoints::template setup<dimension-codimension>( points1D,&(subPoints[0]) );
const GeometryType geoType( Topology::id, dimension );
const RefElement &refElement = RefElements::general( geoType );
const Mapping &mapping = refElement.template mapping< codimension >( subEntity );
LagrangePoint<Field,dimension> *p = &(points[oldSize]);
for ( unsigned int nr = 0; nr<size; ++nr, ++p)
{
p->point_ = mapping.global( subPoints[nr].point_ );
p->localKey_ = LocalKey( subEntity, codimension, nr );
#ifndef NDEBUG
bool test = GenericGeometry::ReferenceElement<Topology,Field>::checkInside(p->point_);
if (!test)
std::cout << "not inside" << std::endl;
#endif
}
}
};
};
};
}
#endif // DUNE_LOBATTOBASIS_HH
|