7#ifndef DGSPONGELEMENTCOLLECTOR_H_
8#define DGSPONGELEMENTCOLLECTOR_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_NODE_ID_ACCESSOR(pos) \
33 MAIA_CONTAINER_ENSURE(pos >= 0 && pos < noNodesXD(), \
34 "node id " + std::to_string(pos) + " out-of-bounds [0, " + std::to_string(noNodesXD()), \
38#define ENSURE_VALID_ID_ACCESSOR(id) \
41#define ENSURE_VALID_NODE_ID_ACCESSOR(pos) \
53template <MInt nDim,
class SysEqn>
97 template <
class Functor,
class T>
113template <MInt nDim,
class SysEqn>
115 resetStorage(1, m_elementId);
116 resetStorage(noNodesXD(), m_spongeEta);
121template <MInt nDim,
class SysEqn>
124#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
125#error Missing implementation for structure-of-arrays memory layout.
127 ENSURE_VALID_ID_ACCESSOR(
id);
128 return m_elementId[
id];
131template <MInt nDim,
class SysEqn>
134#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
135#error Missing implementation for structure-of-arrays memory layout.
137 ENSURE_VALID_ID_ACCESSOR(
id);
138 return m_elementId[
id];
143template <MInt nDim,
class SysEqn>
146#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
147#error Missing implementation for structure-of-arrays memory layout.
149 ENSURE_VALID_ID_ACCESSOR(
id);
150 return m_spongeEta[
id * noNodesXD()];
153template <MInt nDim,
class SysEqn>
156#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
157#error Missing implementation for structure-of-arrays memory layout.
159 ENSURE_VALID_ID_ACCESSOR(
id);
160 ENSURE_VALID_NODE_ID_ACCESSOR(pos);
161 return m_spongeEta[
id * noNodesXD() + pos];
166template <MInt nDim,
class SysEqn>
169#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
170#error Missing implementation for structure-of-arrays memory layout.
174 fill_invalid(m_elementId, begin, end);
177 fill_invalid(m_spongeEta, begin, end, noNodesXD());
182template <MInt nDim,
class SysEqn>
183template <
class Functor,
class T>
185 const MInt end,
const MInt destination) {
187#ifdef DGCOLLECTOR_SOA_MEMORY_LAYOUT
188#error Missing implementation for structure-of-arrays memory layout.
192 copyData(source.m_elementId, m_elementId, c, begin, end, destination);
195 copyData(source.m_spongeEta, m_spongeEta, c, begin, end, destination, noNodesXD());
200template <MInt nDim,
class SysEqn>
202 const MInt oldMaxPolyDeg = m_maxPolyDeg;
203 m_maxPolyDeg = maxPolyDeg_;
204 m_noNodesXD =
ipow(m_maxPolyDeg + 1, nDim);
205 return oldMaxPolyDeg;
214#undef DGCOLLECTOR_SANITY_CHECKS_ACCESSORS
215#undef ENSURE_VALID_ID_ACCESSOR
216#undef ENSURE_VALID_NODE_ID_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.
MFloat & spongeEta(const MInt id)
Accessor for sponge eta.
Storage< MInt > m_elementId
MInt & elementId(const MInt id)
Accessor for element id.
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
typename maia::dg::collector::Invalid< T > Invalid
void reset()
Reset SpongeElementCollector, re-create data structures.
constexpr MInt noNodesXD() const
Return number of nodes in 2D/3D.
MInt m_noNodesXD
Number of nodes in 2D/3D.
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.
MFloat spongeEta(const MInt id) const
typename Base::template Storage< T > Storage
MInt maxPolyDeg() const
Return maximum polynomial degree.
Storage< MFloat > m_spongeEta
MInt m_maxPolyDeg
Maximum polynomial degree.
constexpr SpongeElementCollector()=default
Default c'tor does nothing.
MInt ipow(MInt base, MInt exp)
Integer exponent function for non-negative exponents.
Namespace for auxiliary functions/classes.