5#ifndef DUNE_GEOMETRY_REFINEMENT_HCUBE_CC
6#define DUNE_GEOMETRY_REFINEMENT_HCUBE_CC
54 namespace RefinementImp
73 template<
int dimension_,
class CoordType>
82 template<
int codimension>
98 template<
int dimension,
class CoordType>
99 template<
int codimension>
102 class SubEntityIterator;
106 template<
int dimension,
class CoordType>
115 template<
int dimension,
class CoordType>
123 template<
int dimension,
class CoordType>
131 template<
int dimension,
class CoordType>
136 static_assert(dimension >= 0,
137 "Negative dimension given, what the heck is that supposed to mean?");
142 template<
int dimension,
class CoordType>
150 template<
int dimension,
class CoordType>
174 template<
int dimension,
class CoordType,
int codimension>
177 template<
int dimension,
class CoordType,
int codimension>
183 template<
int dimension,
class CoordType>
194 const Common & asCommon()
const
196 return *
static_cast<const Common*
>(
this);
200 template<
int dimension,
class CoordType>
201 typename RefinementSubEntityIteratorSpecial<dimension, CoordType, dimension>::CoordVector
207 for (
int d = 0; d < dimension; d++)
209 c[d] = v[d]*1.0 / asCommon()._nIntervals;
216 template<
int dimension,
class CoordType>
229 const Common & asCommon()
const
231 return *
static_cast<const Common*
>(
this);
235 template<
int dimension,
class CoordType>
236 typename RefinementSubEntityIteratorSpecial<dimension, CoordType, 0>::IndexVector
240 constexpr static int nIndices = 1 << dimension;
251 for (
int d = 0; d < dimension; d++) {
252 vec[
i] += (alpha[d] + e[d]) * base;
253 base *= asCommon()._nIntervals+1;
259 template<
int dimension,
class CoordType>
266 for (
int d=0; d<dimension; d++)
268 c[d] = (v[d]*1.0 + 0.5) / asCommon()._nIntervals;
274 template<
int dimension,
class CoordType>
275 template<
int codimension>
278 CoordType>::template Codim<codimension>::SubEntityIterator, int>,
295 unsigned int _nIntervals;
298 cellCoord(
unsigned int idx)
const
300 return idx2coord(
idx, _nIntervals);
304 vertexCoord(
unsigned int idx)
const
306 return idx2coord(
idx, _nIntervals+1u);
312 return cellCoord(_index);
318 return vertexCoord(_index);
322 idx2coord(
unsigned int idx,
unsigned int w)
const
325 for (
unsigned int d = 0; d <
dimension; d++)
337 for (
unsigned int d =
dimension; d > 0; d--)
346 idx2multiidx(
unsigned int idx)
const
349 for (
unsigned int i = 0; i <
dimension; ++i)
350 alpha[i] = (idx >> i) & 1u;
356 template<
int dimension,
class CoordType>
357 template<
int codimension>
358 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
359 SubEntityIterator(
unsigned int index,
unsigned int nIntervals)
360 : _index(
index), _nIntervals(nIntervals)
363 template<
int dimension,
class CoordType>
364 template<
int codimension>
366 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
367 equals(
const This &other)
const
369 return ((_index == other._index) && (_nIntervals == other._nIntervals));
372 template<
int dimension,
class CoordType>
373 template<
int codimension>
375 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
381 template<
int dimension,
class CoordType>
382 template<
int codimension>
384 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
390 template<
int dimension,
class CoordType>
391 template<
int codimension>
392 typename RefinementImp<dimension, CoordType>::template Codim<codimension>::Geometry
393 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::geometry ()
const
400 assert(codimension == 0 or codimension ==
dimension);
402 if constexpr (codimension == 0) {
405 lower[j] = double(intCoords[j]) / double(_nIntervals);
406 upper[j] = double(intCoords[j] + 1) / double(_nIntervals);
413 lower[j] = upper[j] =
double(intCoords[j]) / double(_nIntervals);
430 template<
unsigned topologyId,
class CoordType,
unsigned coerceToId,
433 topologyId, CoordType, coerceToId,
dim,
434 typename
std::enable_if<
436 (GeometryTypes::cube(dim).id() >> 1) ==
438 (GeometryTypes::cube(dim).id() >> 1) ==
443 typedef HCube::RefinementImp<dim, CoordType> Imp;
A geometry implementation for axis-aligned hypercubes.
This file contains the parts independent of a particular Refinement implementation.
std::ptrdiff_t index() const
constexpr Base power(Base m, Exponent p)
constexpr FieldMatrix()=default
A geometry implementation for axis-aligned hypercubes.
Definition axisalignedcubegeometry.hh:50
Static tag representing a codimension.
Definition dimension.hh:24
Refinement implementation for hypercubes
Definition hcube.cc:75
Codim< 0 >::SubEntityIterator ElementIterator
Definition hcube.cc:86
static ElementIterator eEnd(unsigned nIntervals)
Definition hcube.cc:153
static unsigned nVertices(unsigned nIntervals)
Definition hcube.cc:109
static VertexIterator vEnd(unsigned nIntervals)
Definition hcube.cc:126
Codim< dimension >::SubEntityIterator VertexIterator
Definition hcube.cc:84
FieldVector< CoordType, dimension > CoordVector
Definition hcube.cc:85
static unsigned nElements(unsigned nIntervals)
Definition hcube.cc:134
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:80
static ElementIterator eBegin(unsigned nIntervals)
Definition hcube.cc:145
static constexpr int dimension
Know your own dimension.
Definition hcube.cc:78
static VertexIterator vBegin(unsigned nIntervals)
Definition hcube.cc:118
Dune::AxisAlignedCubeGeometry< CoordType, dimension-codimension, dimension > Geometry
Definition hcube.cc:103
SubEntityIterator base class for hypercube refinement.
Definition hcube.cc:175
Refinement::CoordVector CoordVector
Definition hcube.cc:189
Refinement::template Codim< dimension >::SubEntityIterator Common
Definition hcube.cc:188
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:187
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:220
Refinement::template Codim< 0 >::SubEntityIterator Common
Definition hcube.cc:221
Refinement::CoordVector CoordVector
Definition hcube.cc:223
Refinement::IndexVector IndexVector
Definition hcube.cc:222
SubEntityIterator(unsigned int index, unsigned int nIntervals)
bool equals(const This &other) const
Geometry geometry() const
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:282
Refinement::template Codim< codimension >::SubEntityIterator This
Definition hcube.cc:283