7#ifndef DGHELEMENTCOLLECTOR_H_
8#define DGHELEMENTCOLLECTOR_H_
21#ifdef MAIA_EXTRA_DEBUG
22#define DGCOLLECTOR_SANITY_CHECKS_ACCESSORS
26#if defined(DGCOLLECTOR_SANITY_CHECKS_ACCESSORS) || defined(MAIA_ASSERT_ACCESSORS)
27#define ENSURE_VALID_ID_ACCESSOR(id) \
29 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
31#define ENSURE_VALID_SURFACE_DIR_ACCESSOR(dir) \
33 MAIA_CONTAINER_ENSURE( \
34 dir >= 0 && dir < noDirs(), \
35 "surface direction " + std::to_string(dir) + " out-of-bounds [0, " + std::to_string(noDirs()) + ")", AT_); \
37#define ENSURE_VALID_SURFACE_POS_ACCESSOR(pos) \
39 MAIA_CONTAINER_ENSURE(pos >= 0 && pos < noHrefSurfaces(), \
40 "surface position out-of-bounds [0, " + std::to_string(noHrefSurfaces()) + ")", AT_); \
43#define ENSURE_VALID_ID_ACCESSOR(id) \
46#define ENSURE_VALID_SURFACE_DIR_ACCESSOR(dir) \
49#define ENSURE_VALID_SURFACE_POS_ACCESSOR(pos) \
61template <MInt nDim,
class SysEqn>
106 template <
class Functor,
class T>
116template <MInt nDim,
class SysEqn>
118 resetStorage(1, m_elementId);
119 resetStorage(noHrefSurfaceIds(), m_hrefSurfaceIds);
124template <MInt nDim,
class SysEqn>
127#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
128#error Missing implementation for structure-of-arrays memory layout.
130 ENSURE_VALID_ID_ACCESSOR(
id);
131 return m_elementId[
id];
134template <MInt nDim,
class SysEqn>
137#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
138#error Missing implementation for structure-of-arrays memory layout.
140 ENSURE_VALID_ID_ACCESSOR(
id);
141 return m_elementId[
id];
146template <MInt nDim,
class SysEqn>
149#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
150#error Missing implementation for structure-of-arrays memory layout.
152 ENSURE_VALID_ID_ACCESSOR(
id);
153 ENSURE_VALID_SURFACE_DIR_ACCESSOR(dir);
154 ENSURE_VALID_SURFACE_POS_ACCESSOR(pos);
155 return m_hrefSurfaceIds[
id * noHrefSurfaceIds() + dir * noHrefSurfaces() + pos];
158template <MInt nDim,
class SysEqn>
161#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
162#error Missing implementation for structure-of-arrays memory layout.
164 ENSURE_VALID_ID_ACCESSOR(
id * noHrefSurfaceIds());
165 ENSURE_VALID_SURFACE_DIR_ACCESSOR(dir);
166 ENSURE_VALID_SURFACE_POS_ACCESSOR(pos);
167 return m_hrefSurfaceIds[
id * noHrefSurfaceIds() + dir * noHrefSurfaces() + pos];
172template <MInt nDim,
class SysEqn>
175#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
176#error Missing implementation for structure-of-arrays memory layout.
180 fill_invalid(m_elementId, begin, end);
183 fill_invalid(m_hrefSurfaceIds, begin, end, noHrefSurfaceIds());
188template <MInt nDim,
class SysEqn>
189template <
class Functor,
class T>
191 const MInt destination) {
193#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
194#error Missing implementation for structure-of-arrays memory layout.
198 copyData(source.m_elementId, m_elementId, c, begin, end, destination);
201 copyData(source.m_hrefSurfaceIds, m_hrefSurfaceIds, c, begin, end, destination, noHrefSurfaceIds());
210#undef DGCOLLECTOR_SANITY_CHECKS_ACCESSORS
211#undef ENSURE_VALID_ID_ACCESSOR
212#undef ENSURE_VALID_SURFACE_DIR_ACCESSOR
213#undef ENSURE_VALID_SURFACE_POS_ACCESSOR
void copyData(const Container_ &source, Container_ &target, Functor &&f, const MInt begin, const MInt end, const MInt dest, const MInt solverSize=1)
Copy [begin, end) range with given solver size from source to dest position of target.
void fill_invalid(Container_ &c, const MInt begin, const MInt end, const MInt solverSize=1, const T value=Invalid< T >::value())
void resetStorage(const MInt n, Storage< T > &c)
Create new container with given size and replace original one.
void reset(const MInt capacity)
Reset tree, re-create data structures with given capacity, and set size to zero.
Class that represents DG element collector.
Storage< MInt > m_hrefSurfaceIds
static constexpr MInt noHrefSurfaceIds()
void reset()
Reset HElementCollector, re-create data structures.
static constexpr MInt noHrefSurfaces()
Return number of h-refined surfaces.
constexpr HElementCollector()=default
Default c'tor does nothing.
MInt & hrefSurfaceIds(const MInt id, const MInt dir, const MInt pos)
Accessor for h-refined surface ids.
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
static constexpr MInt noDirs()
Return number of directions.
Storage< MInt > m_elementId
MInt & elementId(const MInt id)
Accessor for element id.
void rawCopyGeneric(Functor &&c, const T &source, const MInt begin, const MInt end, const MInt destination)
Helper function for rawCopy(). Destination may refer to beginning or end of target range.
typename maia::dg::collector::Invalid< T > Invalid
typename Base::template Storage< T > Storage
Namespace for auxiliary functions/classes.