34#define RBCOLLECTOR_SANITY_CHECKS_ACCESSORS
38#if defined(RBCOLLECTOR_SANITY_CHECKS_ACCESSORS) || defined(MAIA_ASSERT_ACCESSORS)
39#define ENSURE_VALID_ID(id) \
41 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
43#define ENSURE_VALID_DIM(id) \
45 MAIA_CONTAINER_ENSURE(id >= 0 && id < nDim, \
46 "dim id " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nDim) + ")", AT_); \
48#define ENSURE_VALID_ROT(id) \
50 MAIA_CONTAINER_ENSURE(id >= 0 && id < nRot, \
51 "rot id " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nRot) + ")", AT_); \
53#define ENSURE_VALID_QUAT(id) \
55 MAIA_CONTAINER_ENSURE(id >= 0 && id < nQuat, \
56 "quat id " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nQuat) + ")", AT_); \
58#define ENSURE_CONDITION(condition, message) \
60 MAIA_CONTAINER_ENSURE(condition, message, AT_); \
63#define ENSURE_VALID_ID(id) \
66#define ENSURE_VALID_DIM(id) \
69#define ENSURE_VALID_ROT(id) \
72#define ENSURE_VALID_QUAT(id) \
75#define ENSURE_CONDITION(condition, message) \
93 static constexpr MInt value() {
return std::numeric_limits<MInt>::min(); }
99 static constexpr MLong value() {
return std::numeric_limits<MLong>::min(); }
106#ifdef MAIA_PGI_COMPILER
107 return std::numeric_limits<MFloat>::quiet_NaN();
109 return std::numeric_limits<MFloat>::signaling_NaN();
208 template <
class Functor,
class T>
265 m_bodyCenterOld = m_bodyCenter;
266 m_bodyVelocityOld = m_bodyVelocity;
267 m_bodyAccelerationOld = m_bodyAcceleration;
269 m_bodyTemperatureOld = m_bodyTemperature;
276 resetStorage(nDim, m_bodyCenter);
277 resetStorage(nDim, m_bodyVelocity);
278 resetStorage(nDim, m_bodyAcceleration);
279 resetStorage(1, m_bodyTemperature);
280 resetStorage(nDim, m_bodyCenterOld);
281 resetStorage(nDim, m_bodyVelocityOld);
282 resetStorage(nDim, m_bodyAccelerationOld);
283 resetStorage(1, m_bodyTemperatureOld);
284 resetStorage(nQuat, m_bodyQuaternionT1B2);
285 resetStorage(nQuat, m_bodyQuaternionT1);
286 resetStorage(nRot, m_angularVelocityT1);
287 resetStorage(nRot, m_angularVelocityBodyT1);
288 resetStorage(nRot, m_angularVelocityT1B2);
289 resetStorage(nRot, m_angularVelocityBodyT1B2);
290 resetStorage(nRot, m_angularAccelerationT1);
291 resetStorage(nRot, m_angularAccelerationBody);
292 resetStorage(nRot, m_torqueT1);
293 resetStorage(nDim, m_bodyForce);
294 resetStorage(1, m_bodyHeatFlux);
295 resetStorage(1, m_bodyDensityRatio);
296 resetStorage(nRot, m_bodyInertia);
297 resetStorage(1, m_bodyRadius);
298 resetStorage(nDim, m_bodyRadii);
299 resetStorage(1, m_status);
306#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
307#error Missing implementation for structure-of-arrays memory layout.
309 fill_invalid(m_bodyCenter, begin, end, nDim);
310 fill_invalid(m_bodyVelocity, begin, end, nDim);
311 fill_invalid(m_bodyAcceleration, begin, end, nDim);
312 fill_invalid(m_bodyTemperature, begin, end, 1);
313 fill_invalid(m_bodyCenterOld, begin, end, nDim);
314 fill_invalid(m_bodyVelocityOld, begin, end, nDim);
315 fill_invalid(m_bodyAccelerationOld, begin, end, nDim);
316 fill_invalid(m_bodyTemperatureOld, begin, end, 1);
317 fill_invalid(m_bodyQuaternionT1B2, begin, end, nQuat);
318 fill_invalid(m_bodyQuaternionT1, begin, end, nQuat);
319 fill_invalid(m_angularVelocityT1, begin, end, nRot);
320 fill_invalid(m_angularVelocityBodyT1, begin, end, nRot);
321 fill_invalid(m_angularVelocityT1B2, begin, end, nRot);
322 fill_invalid(m_angularVelocityBodyT1B2, begin, end, nRot);
323 fill_invalid(m_angularAccelerationT1, begin, end, nRot);
324 fill_invalid(m_angularAccelerationBody, begin, end, nRot);
325 fill_invalid(m_torqueT1, begin, end, nRot);
326 fill_invalid(m_bodyForce, begin, end, nDim);
327 fill_invalid(m_bodyHeatFlux, begin, end, 1);
328 fill_invalid(m_bodyDensityRatio, begin, end, 1);
329 fill_invalid(m_bodyInertia, begin, end, nRot);
330 fill_invalid(m_bodyRadius, begin, end, 1);
331 fill_invalid(m_bodyRadii, begin, end, nDim);
332 fill_invalid(m_status, begin, end, 1);
338template <
class Functor,
class T>
340 const MInt destination) {
342#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
343#error Missing implementation for structure-of-arrays memory layout.
345 copyData(source.m_bodyCenter, m_bodyCenter, c, begin, end, destination, nDim);
346 copyData(source.m_bodyVelocity, m_bodyVelocity, c, begin, end, destination, nDim);
347 copyData(source.m_bodyAcceleration, m_bodyAcceleration, c, begin, end, destination, nDim);
348 copyData(source.m_bodyTemperature, m_bodyTemperature, c, begin, end, destination, 1);
349 copyData(source.m_bodyCenterOld, m_bodyCenterOld, c, begin, end, destination, nDim);
350 copyData(source.m_bodyVelocityOld, m_bodyVelocityOld, c, begin, end, destination, nDim);
351 copyData(source.m_bodyAccelerationOld, m_bodyAccelerationOld, c, begin, end, destination, nDim);
352 copyData(source.m_bodyTemperatureOld, m_bodyTemperatureOld, c, begin, end, destination, 1);
353 copyData(source.m_bodyQuaternionT1B2, m_bodyQuaternionT1B2, c, begin, end, destination, nQuat);
354 copyData(source.m_bodyQuaternionT1, m_bodyQuaternionT1, c, begin, end, destination, nQuat);
355 copyData(source.m_angularVelocityT1, m_angularVelocityT1, c, begin, end, destination, nRot);
356 copyData(source.m_angularVelocityBodyT1, m_angularVelocityBodyT1, c, begin, end, destination, nRot);
357 copyData(source.m_angularVelocityT1B2, m_angularVelocityT1B2, c, begin, end, destination, nRot);
358 copyData(source.m_angularVelocityBodyT1B2, m_angularVelocityBodyT1B2, c, begin, end, destination, nRot);
359 copyData(source.m_angularAccelerationT1, m_angularAccelerationT1, c, begin, end, destination, nRot);
360 copyData(source.m_angularAccelerationBody, m_angularAccelerationBody, c, begin, end, destination, nRot);
361 copyData(source.m_torqueT1, m_torqueT1, c, begin, end, destination, nRot);
362 copyData(source.m_bodyForce, m_bodyForce, c, begin, end, destination, nDim);
363 copyData(source.m_bodyHeatFlux, m_bodyHeatFlux, c, begin, end, destination, 1);
364 copyData(source.m_bodyDensityRatio, m_bodyDensityRatio, c, begin, end, destination, 1);
365 copyData(source.m_bodyInertia, m_bodyInertia, c, begin, end, destination, nRot);
366 copyData(source.m_bodyRadius, m_bodyRadius, c, begin, end, destination, 1);
367 copyData(source.m_bodyRadii, m_bodyRadii, c, begin, end, destination, nDim);
368 copyData(source.m_status, m_status, c, begin, end, destination, 1);
375#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
376#error Missing implementation for structure-of-arrays memory layout.
379 ENSURE_VALID_DIM(dim);
380 return m_bodyCenter[
id * nDim + dim];
386#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
387#error Missing implementation for structure-of-arrays memory layout.
390 ENSURE_VALID_DIM(dim);
391 return m_bodyCenter[
id * nDim + dim];
398#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
399#error Missing implementation for structure-of-arrays memory layout.
402 ENSURE_VALID_DIM(dim);
403 return m_bodyCenterOld[
id * nDim + dim];
409#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
410#error Missing implementation for structure-of-arrays memory layout.
413 ENSURE_VALID_DIM(dim);
414 return m_bodyCenterOld[
id * nDim + dim];
421#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
422#error Missing implementation for structure-of-arrays memory layout.
425 ENSURE_VALID_DIM(dim);
426 return m_bodyVelocity[
id * nDim + dim];
432#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
433#error Missing implementation for structure-of-arrays memory layout.
436 ENSURE_VALID_DIM(dim);
437 return m_bodyVelocity[
id * nDim + dim];
444#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
445#error Missing implementation for structure-of-arrays memory layout.
448 ENSURE_VALID_DIM(dim);
449 return m_bodyVelocityOld[
id * nDim + dim];
455#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
456#error Missing implementation for structure-of-arrays memory layout.
459 ENSURE_VALID_DIM(dim);
460 return m_bodyVelocityOld[
id * nDim + dim];
467#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
468#error Missing implementation for structure-of-arrays memory layout.
471 ENSURE_VALID_DIM(dim);
472 return m_bodyAcceleration[
id * nDim + dim];
478#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
479#error Missing implementation for structure-of-arrays memory layout.
482 ENSURE_VALID_DIM(dim);
483 return m_bodyAcceleration[
id * nDim + dim];
490#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
491#error Missing implementation for structure-of-arrays memory layout.
494 ENSURE_VALID_DIM(dim);
495 return m_bodyAccelerationOld[
id * nDim + dim];
501#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
502#error Missing implementation for structure-of-arrays memory layout.
505 ENSURE_VALID_DIM(dim);
506 return m_bodyAccelerationOld[
id * nDim + dim];
513#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
514#error Missing implementation for structure-of-arrays memory layout.
517 ENSURE_VALID_DIM(dim);
518 return m_bodyForce[
id * nDim + dim];
524#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
525#error Missing implementation for structure-of-arrays memory layout.
528 ENSURE_VALID_DIM(dim);
529 return m_bodyForce[
id * nDim + dim];
536#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
537#error Missing implementation for structure-of-arrays memory layout.
540 return m_bodyTemperature[
id];
546#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
547#error Missing implementation for structure-of-arrays memory layout.
550 return m_bodyTemperature[
id];
557#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
558#error Missing implementation for structure-of-arrays memory layout.
561 return m_bodyTemperatureOld[
id];
567#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
568#error Missing implementation for structure-of-arrays memory layout.
571 return m_bodyTemperatureOld[
id];
578#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
579#error Missing implementation for structure-of-arrays memory layout.
582 return m_bodyHeatFlux[
id];
588#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
589#error Missing implementation for structure-of-arrays memory layout.
592 return m_bodyHeatFlux[
id];
599#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
600#error Missing implementation for structure-of-arrays memory layout.
603 return m_bodyDensityRatio[
id];
609#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
610#error Missing implementation for structure-of-arrays memory layout.
613 return m_bodyDensityRatio[
id];
620#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
621#error Missing implementation for structure-of-arrays memory layout.
624 ENSURE_VALID_ROT(dim);
625 return m_bodyInertia[
id * nRot + dim];
631#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
632#error Missing implementation for structure-of-arrays memory layout.
635 ENSURE_VALID_ROT(dim);
636 return m_bodyInertia[
id * nRot + dim];
643#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
644#error Missing implementation for structure-of-arrays memory layout.
647 return m_bodyRadius[
id];
653#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
654#error Missing implementation for structure-of-arrays memory layout.
657 return m_bodyRadius[
id];
664#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
665#error Missing implementation for structure-of-arrays memory layout.
668 ENSURE_VALID_DIM(dim);
669 return m_bodyRadii[
id * nDim + dim];
675#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
676#error Missing implementation for structure-of-arrays memory layout.
679 ENSURE_VALID_DIM(dim);
680 return m_bodyRadii[
id * nDim + dim];
687#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
688#error Missing implementation for structure-of-arrays memory layout.
691 ENSURE_VALID_QUAT(dim);
692 return m_bodyQuaternionT1[
id * nQuat + dim];
698#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
699#error Missing implementation for structure-of-arrays memory layout.
702 ENSURE_VALID_QUAT(dim);
703 return m_bodyQuaternionT1[
id * nQuat + dim];
710#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
711#error Missing implementation for structure-of-arrays memory layout.
714 ENSURE_VALID_QUAT(dim);
715 return m_bodyQuaternionT1B2[
id * nQuat + dim];
721#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
722#error Missing implementation for structure-of-arrays memory layout.
725 ENSURE_VALID_QUAT(dim);
726 return m_bodyQuaternionT1B2[
id * nQuat + dim];
733#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
734#error Missing implementation for structure-of-arrays memory layout.
737 ENSURE_VALID_ROT(dim);
738 return m_angularVelocityT1[
id * nRot + dim];
744#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
745#error Missing implementation for structure-of-arrays memory layout.
748 ENSURE_VALID_ROT(dim);
749 return m_angularVelocityT1[
id * nRot + dim];
756#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
757#error Missing implementation for structure-of-arrays memory layout.
760 ENSURE_VALID_ROT(dim);
761 return m_angularVelocityT1B2[
id * nRot + dim];
767#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
768#error Missing implementation for structure-of-arrays memory layout.
771 ENSURE_VALID_ROT(dim);
772 return m_angularVelocityT1B2[
id * nRot + dim];
779#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
780#error Missing implementation for structure-of-arrays memory layout.
783 ENSURE_VALID_ROT(dim);
784 return m_angularVelocityBodyT1[
id * nRot + dim];
790#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
791#error Missing implementation for structure-of-arrays memory layout.
794 ENSURE_VALID_ROT(dim);
795 return m_angularVelocityBodyT1[
id * nRot + dim];
802#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
803#error Missing implementation for structure-of-arrays memory layout.
806 ENSURE_VALID_ROT(dim);
807 return m_angularVelocityBodyT1B2[
id * nRot + dim];
813#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
814#error Missing implementation for structure-of-arrays memory layout.
817 ENSURE_VALID_ROT(dim);
818 return m_angularVelocityBodyT1B2[
id * nRot + dim];
825#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
826#error Missing implementation for structure-of-arrays memory layout.
829 ENSURE_VALID_ROT(dim);
830 return m_angularAccelerationBody[
id * nRot + dim];
836#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
837#error Missing implementation for structure-of-arrays memory layout.
840 ENSURE_VALID_ROT(dim);
841 return m_angularAccelerationBody[
id * nRot + dim];
848#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
849#error Missing implementation for structure-of-arrays memory layout.
852 ENSURE_VALID_ROT(dim);
853 return m_angularAccelerationT1[
id * nRot + dim];
859#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
860#error Missing implementation for structure-of-arrays memory layout.
863 ENSURE_VALID_ROT(dim);
864 return m_angularAccelerationT1[
id * nRot + dim];
871#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
872#error Missing implementation for structure-of-arrays memory layout.
875 ENSURE_VALID_ROT(dim);
876 return m_torqueT1[
id * nRot + dim];
882#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
883#error Missing implementation for structure-of-arrays memory layout.
886 ENSURE_VALID_ROT(dim);
887 return m_torqueT1[
id * nRot + dim];
894#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
895#error Missing implementation for structure-of-arrays memory layout.
904#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
905#error Missing implementation for structure-of-arrays memory layout.
916#undef RBCOLLECTOR_SANITY_CHECKS_ACCESSORS
917#undef ENSURE_VALID_ID
918#undef ENSURE_VALID_DIM
919#undef ENSURE_VALID_ROT
920#undef ENSURE_VALID_QUAT
921#undef ENSURE_CONDITION
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 & bodyForce(const MInt id, const MInt dim)
Accessor for the body force.
MFloat & angularVelocityBodyT1B2(const MInt id, const MInt dim)
Accessor for the angular velocity of the body T1B2.
Storage< MFloat > m_bodyInertia
MFloat & bodyTemperatureOld(const MInt id)
Accessor for the old body temperature.
static constexpr MInt nQuat
MFloat & bodyHeatFlux(const MInt id)
Accessor for the body heat flux.
Storage< Status > m_status
Storage< MFloat > m_angularVelocityT1
MFloat & bodyAcceleration(const MInt id, const MInt dim)
Accessor for the current body acceleration.
Storage< MFloat > m_bodyVelocityOld
void reset()
Reset, re-create data structures with given capacity, and set size to zero.
MFloat & torqueT1(const MInt id, const MInt dim)
Accessor for the torque.
MFloat & bodyVelocityOld(const MInt id, const MInt dim)
Accessor for the old body velocity.
typename Base::template Storage< T > Storage
Storage< MFloat > m_bodyHeatFlux
MFloat & bodyVelocity(const MInt id, const MInt dim)
Accessor for the current body velocity.
Storage< MFloat > m_bodyDensityRatio
Storage< MFloat > m_bodyAccelerationOld
MFloat & bodyAccelerationOld(const MInt id, const MInt dim)
Accessor for the old body acceleration.
constexpr RigidBodyCollector()=default
Default c'tor does nothing.
typename maia::rb::collector::Invalid< T > Invalid
Storage< MFloat > m_bodyTemperature
Storage< MFloat > m_angularAccelerationBody
Storage< MFloat > m_torqueT1
Storage< MFloat > m_bodyCenter
Storage< MFloat > m_bodyTemperatureOld
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
Storage< MFloat > m_angularAccelerationT1
MFloat & bodyCenter(const MInt id, const MInt dim)
Accessor for the current body center.
Status & status(const MInt id)
Accessor for the body status.
Storage< MFloat > m_bodyAcceleration
MFloat & bodyInertia(const MInt id, const MInt dim)
Accessor for the body inertia.
Storage< MFloat > m_angularVelocityT1B2
MFloat & angularVelocityT1(const MInt id, const MInt dim)
Accessor for the angular velocity T1.
Storage< MFloat > m_bodyCenterOld
Storage< MFloat > m_angularVelocityBodyT1B2
MFloat & angularVelocityT1B2(const MInt id, const MInt dim)
Accessor for the angular velocity T1B2.
MFloat & angularVelocityBodyT1(const MInt id, const MInt dim)
Accessor for the angular velocity of the body T1.
MFloat & bodyQuaternionT1B2(const MInt id, const MInt dim)
Accessor for the body bodyQuaternion T1B2.
MFloat & angularAccelerationT1(const MInt id, const MInt dim)
Accessor for the angular acceleration T1.
Storage< MFloat > m_bodyForce
MFloat & bodyQuaternionT1(const MInt id, const MInt dim)
Accessor for the body bodyQuaternion T1.
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.
static constexpr MInt nRot
MFloat & angularAccelerationBody(const MInt id, const MInt dim)
Accessor for the angular acceleration.
MFloat & bodyCenterOld(const MInt id, const MInt dim)
Accessor for the old body center.
Storage< MFloat > m_angularVelocityBodyT1
Storage< MFloat > m_bodyQuaternionT1
MFloat & bodyRadii(const MInt id, const MInt dim)
Accessor for the body radii.
MFloat & bodyTemperature(const MInt id)
Accessor for the body temperature.
MFloat & bodyDensityRatio(const MInt id)
Accessor for the body density ratio.
Storage< MFloat > m_bodyRadii
Storage< MFloat > m_bodyVelocity
void advanceBodies()
Copy the body data for time t to t-1 to prepare the next timestep.
MFloat & bodyRadius(const MInt id)
Accessor for the body radius.
Storage< MFloat > m_bodyQuaternionT1B2
Storage< MFloat > m_bodyRadius
Namespace for auxiliary functions/classes.
static constexpr MFloat value()
static constexpr MInt value()
static constexpr MLong value()