3#ifndef DUNE_GEOMETRY_REFINEMENT_HCUBE_CC
4#define DUNE_GEOMETRY_REFINEMENT_HCUBE_CC
53 namespace RefinementImp
72 template<
int dimension_,
class CoordType>
80 template<
int codimension>
96 template<
int dimension,
class CoordType>
97 template<
int codimension>
100 class SubEntityIterator;
104 template<
int dimension,
class CoordType>
113 template<
int dimension,
class CoordType>
121 template<
int dimension,
class CoordType>
129 template<
int dimension,
class CoordType>
134 static_assert(dimension >= 0,
135 "Negative dimension given, what the heck is that supposed to mean?");
140 template<
int dimension,
class CoordType>
148 template<
int dimension,
class CoordType>
172 template<
int dimension,
class CoordType,
int codimension>
175 template<
int dimension,
class CoordType,
int codimension>
181 template<
int dimension,
class CoordType>
192 const Common & asCommon()
const
194 return *
static_cast<const Common*
>(
this);
198 template<
int dimension,
class CoordType>
199 typename RefinementSubEntityIteratorSpecial<dimension, CoordType, dimension>::CoordVector
205 for (
int d = 0; d < dimension; d++)
207 c[d] = v[d]*1.0 / asCommon()._nIntervals;
214 template<
int dimension,
class CoordType>
227 const Common & asCommon()
const
229 return *
static_cast<const Common*
>(
this);
233 template<
int dimension,
class CoordType>
234 typename RefinementSubEntityIteratorSpecial<dimension, CoordType, 0>::IndexVector
238 enum {
nIndices = (1 << dimension) };
249 for (
int d = 0; d < dimension; d++) {
250 vec[
i] += (alpha[d] + e[d]) * base;
251 base *= asCommon()._nIntervals+1;
257 template<
int dimension,
class CoordType>
264 for (
int d=0; d<dimension; d++)
266 c[d] = (v[d]*1.0 + 0.5) / asCommon()._nIntervals;
272 template<
int dimension,
class CoordType>
273 template<
int codimension>
276 CoordType>::template Codim<codimension>::SubEntityIterator, int>,
293 unsigned int _nIntervals;
296 cellCoord(
unsigned int idx)
const
298 return idx2coord(
idx, _nIntervals);
302 vertexCoord(
unsigned int idx)
const
304 return idx2coord(
idx, _nIntervals+1u);
310 return cellCoord(_index);
316 return vertexCoord(_index);
320 idx2coord(
unsigned int idx,
unsigned int w)
const
323 for (
unsigned int d = 0; d <
dimension; d++)
335 for (
unsigned int d =
dimension; d > 0; d--)
344 idx2multiidx(
unsigned int idx)
const
347 for (
unsigned int i = 0; i <
dimension; ++i)
348 alpha[i] = (idx >> i) & 1u;
354 template<
int dimension,
class CoordType>
355 template<
int codimension>
356 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
357 SubEntityIterator(
unsigned int index,
unsigned int nIntervals)
358 : _index(
index), _nIntervals(nIntervals)
361 template<
int dimension,
class CoordType>
362 template<
int codimension>
364 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
365 equals(
const This &other)
const
367 return ((_index == other._index) && (_nIntervals == other._nIntervals));
370 template<
int dimension,
class CoordType>
371 template<
int codimension>
373 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
379 template<
int dimension,
class CoordType>
380 template<
int codimension>
382 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::
388 template<
int dimension,
class CoordType>
389 template<
int codimension>
390 typename RefinementImp<dimension, CoordType>::template Codim<codimension>::Geometry
391 RefinementImp<dimension, CoordType>::Codim<codimension>::SubEntityIterator::geometry ()
const
398 assert(codimension == 0 or codimension ==
dimension);
400 if constexpr (codimension == 0) {
403 lower[j] = double(intCoords[j]) / double(_nIntervals);
404 upper[j] = double(intCoords[j] + 1) / double(_nIntervals);
411 lower[j] = upper[j] =
double(intCoords[j]) / double(_nIntervals);
428 template<
unsigned topologyId,
class CoordType,
unsigned coerceToId,
431 topologyId, CoordType, coerceToId,
dim,
432 typename
std::enable_if<
434 (GeometryTypes::cube(dim).id() >> 1) ==
436 (GeometryTypes::cube(dim).id() >> 1) ==
441 typedef HCube::RefinementImp<dim, CoordType> Imp;
A geometry implementation for axis-aligned hypercubes.
This file contains the parts independent of a particular Refinement implementation.
static constexpr auto eval(const T &a)
std::ptrdiff_t index() const
constexpr FieldMatrix()=default
A geometry implementation for axis-aligned hypercubes.
Definition axisalignedcubegeometry.hh:48
Static tag representing a codimension.
Definition dimension.hh:22
Refinement implementation for hypercubes
Definition hcube.cc:74
Codim< 0 >::SubEntityIterator ElementIterator
Definition hcube.cc:84
@ dimension
Definition hcube.cc:76
static ElementIterator eEnd(unsigned nIntervals)
Definition hcube.cc:151
static unsigned nVertices(unsigned nIntervals)
Definition hcube.cc:107
static VertexIterator vEnd(unsigned nIntervals)
Definition hcube.cc:124
Codim< dimension >::SubEntityIterator VertexIterator
Definition hcube.cc:82
FieldVector< CoordType, dimension > CoordVector
Definition hcube.cc:83
static unsigned nElements(unsigned nIntervals)
Definition hcube.cc:132
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:78
static ElementIterator eBegin(unsigned nIntervals)
Definition hcube.cc:143
static VertexIterator vBegin(unsigned nIntervals)
Definition hcube.cc:116
Dune::AxisAlignedCubeGeometry< CoordType, dimension-codimension, dimension > Geometry
Definition hcube.cc:101
SubEntityIterator base class for hypercube refinement.
Definition hcube.cc:173
Refinement::CoordVector CoordVector
Definition hcube.cc:187
Refinement::template Codim< dimension >::SubEntityIterator Common
Definition hcube.cc:186
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:185
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:218
Refinement::template Codim< 0 >::SubEntityIterator Common
Definition hcube.cc:219
Refinement::CoordVector CoordVector
Definition hcube.cc:221
Refinement::IndexVector IndexVector
Definition hcube.cc:220
SubEntityIterator(unsigned int index, unsigned int nIntervals)
bool equals(const This &other) const
Geometry geometry() const
RefinementImp< dimension, CoordType > Refinement
Definition hcube.cc:280
Refinement::template Codim< codimension >::SubEntityIterator This
Definition hcube.cc:281