MAIA bb96820c
Multiphysics at AIA
Loading...
Searching...
No Matches
rigidbodiescollector.h
Go to the documentation of this file.
1// Copyright (C) 2024 The m-AIA AUTHORS
2//
3// This file is part of m-AIA (https://git.rwth-aachen.de/aia/m-AIA/m-AIA)
4//
5// SPDX-License-Identifier: LGPL-3.0-only
6
7#ifndef RBCOLLECTOR_H_
8#define RBCOLLECTOR_H_
9
10#include <algorithm>
11#include <limits>
12#include <numeric>
13#include <type_traits>
14#include <vector>
15#include "INCLUDE/maiamacro.h"
16#include "INCLUDE/maiatypes.h"
17#include "MEMORY/container.h"
18#include "UTIL/functions.h"
19#include "compiler_config.h"
20
21// The following macro enables the "Structure-of-Arrays" memory layout for multi-dimensional node
22// variables. This might be beneficial for GPU computation. Default is "Array-of-Structures".
23// Examples (for nodes nN with four children cM each)
24// Array-of-Structures (AOS): n0c0, n0c1, n0c2, n0c3, n1c0, n1c1, n1c2, n1c3, n2c0, n2c1, ...
25// Structure-of-Arrays (SOA): n0c0, n1c0, n2c0, n3c0, ..., n0c1, n1c1, n2c1, n3c1, ..., n0c2, ...
26// #define RBCOLLECTOR_SOA_MEMORY_LAYOUT
27
28// The macro 'RBCOLLECTOR_SANITY_CHECKS_ACCESSORS' enables (potentially very expensive) sanity
29// checks
30// for all accessors. It is enabled for build type "extra_debug".
31//#ifdef MAIA_EXTRA_DEBUG
32// NOTE: enable checks in normal debug mode until everything is working correctly!
33#ifndef NDEBUG
34#define RBCOLLECTOR_SANITY_CHECKS_ACCESSORS
35#endif
36
37// Sanity-checking macros for accessors
38#if defined(RBCOLLECTOR_SANITY_CHECKS_ACCESSORS) || defined(MAIA_ASSERT_ACCESSORS)
39#define ENSURE_VALID_ID(id) \
40 do { \
41 MAIA_CONTAINER_ENSURE_VALID_ID(id); \
42 } while(false)
43#define ENSURE_VALID_DIM(id) \
44 do { \
45 MAIA_CONTAINER_ENSURE(id >= 0 && id < nDim, \
46 "dim id " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nDim) + ")", AT_); \
47 } while(false)
48#define ENSURE_VALID_ROT(id) \
49 do { \
50 MAIA_CONTAINER_ENSURE(id >= 0 && id < nRot, \
51 "rot id " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nRot) + ")", AT_); \
52 } while(false)
53#define ENSURE_VALID_QUAT(id) \
54 do { \
55 MAIA_CONTAINER_ENSURE(id >= 0 && id < nQuat, \
56 "quat id " + std::to_string(id) + " out-of-bounds [0, " + std::to_string(nQuat) + ")", AT_); \
57 } while(false)
58#define ENSURE_CONDITION(condition, message) \
59 do { \
60 MAIA_CONTAINER_ENSURE(condition, message, AT_); \
61 } while(false)
62#else
63#define ENSURE_VALID_ID(id) \
64 do { \
65 } while(false)
66#define ENSURE_VALID_DIM(id) \
67 do { \
68 } while(false)
69#define ENSURE_VALID_ROT(id) \
70 do { \
71 } while(false)
72#define ENSURE_VALID_QUAT(id) \
73 do { \
74 } while(false)
75#define ENSURE_CONDITION(condition, message) \
76 do { \
77 } while(false)
78#endif
79
80
82namespace maia {
83namespace rb {
84namespace collector {
85
86// Type traits for invalid values. These values are used to initialize/erase nodes
87template <class T>
88struct Invalid {};
89
90// Invalid value for ids is 'INT_MIN'
91template <>
92struct Invalid<MInt> {
93 static constexpr MInt value() { return std::numeric_limits<MInt>::min(); }
94};
95
96// Invalid value for longs is 'INT_MIN'
97template <>
98struct Invalid<MLong> {
99 static constexpr MLong value() { return std::numeric_limits<MLong>::min(); }
100};
101
102// Invalid value for floats is 'NaN'
103template <>
105 static constexpr MFloat value() {
106#ifdef MAIA_PGI_COMPILER
107 return std::numeric_limits<MFloat>::quiet_NaN();
108#else
109 return std::numeric_limits<MFloat>::signaling_NaN();
110#endif
111 }
112};
113
114// Body status. Used for paralellization
115enum class Status : MInt { local, remote, invalid };
116// Default (or invalidated) value
117template <>
119 static constexpr Status value() { return Status::invalid; }
120};
121
122
124template <MInt nDim>
125class RigidBodyCollector : public maia::container::Container<RigidBodyCollector<nDim>, Invalid> {
126 // Necessary for CRTP
128
129 // Make base class functions known to use without this pointer
131 using Base::resetStorage;
132 template <class T>
133 using Storage = typename Base::template Storage<T>;
134
135 public:
136 // Types
137 template <class T>
139
140 // Constructor
142 constexpr RigidBodyCollector() = default;
143
144 // Ensure that base class method is found when called from outside
145 using Base::copyData;
146 using Base::fill_invalid;
147 using Base::reset;
148
149
150 // Accessors
151 MFloat& bodyCenter(const MInt id, const MInt dim);
152 MFloat bodyCenter(const MInt id, const MInt dim) const;
153 MFloat& bodyVelocity(const MInt id, const MInt dim);
154 MFloat bodyVelocity(const MInt id, const MInt dim) const;
155 MFloat& bodyAcceleration(const MInt id, const MInt dim);
156 MFloat bodyAcceleration(const MInt id, const MInt dim) const;
157 MFloat& bodyTemperature(const MInt id);
158 MFloat bodyTemperature(const MInt id) const;
159 MFloat& bodyCenterOld(const MInt id, const MInt dim);
160 MFloat bodyCenterOld(const MInt id, const MInt dim) const;
161 MFloat& bodyVelocityOld(const MInt id, const MInt dim);
162 MFloat bodyVelocityOld(const MInt id, const MInt dim) const;
163 MFloat& bodyAccelerationOld(const MInt id, const MInt dim);
164 MFloat bodyAccelerationOld(const MInt id, const MInt dim) const;
165 MFloat& bodyTemperatureOld(const MInt id);
166 MFloat bodyTemperatureOld(const MInt id) const;
167 MFloat& bodyQuaternionT1B2(const MInt id, const MInt dim);
168 MFloat bodyQuaternionT1B2(const MInt id, const MInt dim) const;
169 MFloat& bodyQuaternionT1(const MInt id, const MInt dim);
170 MFloat bodyQuaternionT1(const MInt id, const MInt dim) const;
171 MFloat& angularVelocityT1(const MInt id, const MInt dim);
172 MFloat angularVelocityT1(const MInt id, const MInt dim) const;
173 MFloat& angularVelocityBodyT1(const MInt id, const MInt dim);
174 MFloat angularVelocityBodyT1(const MInt id, const MInt dim) const;
175 MFloat& angularVelocityT1B2(const MInt id, const MInt dim);
176 MFloat angularVelocityT1B2(const MInt id, const MInt dim) const;
177 MFloat& angularVelocityBodyT1B2(const MInt id, const MInt dim);
178 MFloat angularVelocityBodyT1B2(const MInt id, const MInt dim) const;
179 MFloat& angularAccelerationT1(const MInt id, const MInt dim);
180 MFloat angularAccelerationT1(const MInt id, const MInt dim) const;
181 MFloat& angularAccelerationBody(const MInt id, const MInt dim);
182 MFloat angularAccelerationBody(const MInt id, const MInt dim) const;
183 MFloat& torqueT1(const MInt id, const MInt dim);
184 MFloat torqueT1(const MInt id, const MInt dim) const;
185 MFloat& bodyForce(const MInt id, const MInt dim);
186 MFloat bodyForce(const MInt id, const MInt dim) const;
187 MFloat& bodyHeatFlux(const MInt id);
188 MFloat bodyHeatFlux(const MInt id) const;
189 MFloat& bodyDensityRatio(const MInt id);
190 MFloat bodyDensityRatio(const MInt id) const;
191 MFloat& bodyInertia(const MInt id, const MInt dim);
192 MFloat bodyInertia(const MInt id, const MInt dim) const;
193 MFloat& bodyRadius(const MInt id);
194 MFloat bodyRadius(const MInt id) const;
195 MFloat& bodyRadii(const MInt id, const MInt dim);
196 MFloat bodyRadii(const MInt id, const MInt dim) const;
197
198 Status& status(const MInt id);
199 Status status(const MInt id) const;
200
201 // Auxiliary methods
202 void advanceBodies();
203
204 private:
205 // Methods required by base class for CRTP
206 void reset();
207 void invalidate(const MInt begin, const MInt end);
208 template <class Functor, class T>
209 void rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end, const MInt destination);
210
211 private:
212 // Member variables
213 static constexpr MInt nRot = (nDim == 3) ? 3 : 1;
214 static constexpr MInt nQuat = (nDim == 3) ? 4 : 0;
215
216 // Data containers
217
218 // Body data current timestep
222
224
225 // Body data old timestep
229
231
232 // Rotational data
235
240
243
245
248
251
254
256};
257
263template <MInt nDim>
265 m_bodyCenterOld = m_bodyCenter;
266 m_bodyVelocityOld = m_bodyVelocity;
267 m_bodyAccelerationOld = m_bodyAcceleration;
268
269 m_bodyTemperatureOld = m_bodyTemperature;
270}
271
272
274template <MInt nDim>
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);
300}
301
303template <MInt nDim>
304void RigidBodyCollector<nDim>::invalidate(const MInt begin, const MInt end) {
305// Prevent accidental compilation without support for SoA layout
306#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
307#error Missing implementation for structure-of-arrays memory layout.
308#endif
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);
333}
334
335
337template <MInt nDim>
338template <class Functor, class T>
339void RigidBodyCollector<nDim>::rawCopyGeneric(Functor&& c, const T& source, const MInt begin, const MInt end,
340 const MInt destination) {
341// Prevent accidental compilation without support for SoA layout
342#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
343#error Missing implementation for structure-of-arrays memory layout.
344#endif
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);
369}
370
372template <MInt nDim>
374// Prevent accidental compilation without support for SoA layout
375#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
376#error Missing implementation for structure-of-arrays memory layout.
377#endif
378 ENSURE_VALID_ID(id);
379 ENSURE_VALID_DIM(dim);
380 return m_bodyCenter[id * nDim + dim];
381}
383template <MInt nDim>
385// Prevent accidental compilation without support for SoA layout
386#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
387#error Missing implementation for structure-of-arrays memory layout.
388#endif
389 ENSURE_VALID_ID(id);
390 ENSURE_VALID_DIM(dim);
391 return m_bodyCenter[id * nDim + dim];
392}
393
395template <MInt nDim>
397// Prevent accidental compilation without support for SoA layout
398#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
399#error Missing implementation for structure-of-arrays memory layout.
400#endif
401 ENSURE_VALID_ID(id);
402 ENSURE_VALID_DIM(dim);
403 return m_bodyCenterOld[id * nDim + dim];
404}
406template <MInt nDim>
408// Prevent accidental compilation without support for SoA layout
409#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
410#error Missing implementation for structure-of-arrays memory layout.
411#endif
412 ENSURE_VALID_ID(id);
413 ENSURE_VALID_DIM(dim);
414 return m_bodyCenterOld[id * nDim + dim];
415}
416
418template <MInt nDim>
420// Prevent accidental compilation without support for SoA layout
421#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
422#error Missing implementation for structure-of-arrays memory layout.
423#endif
424 ENSURE_VALID_ID(id);
425 ENSURE_VALID_DIM(dim);
426 return m_bodyVelocity[id * nDim + dim];
427}
429template <MInt nDim>
431// Prevent accidental compilation without support for SoA layout
432#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
433#error Missing implementation for structure-of-arrays memory layout.
434#endif
435 ENSURE_VALID_ID(id);
436 ENSURE_VALID_DIM(dim);
437 return m_bodyVelocity[id * nDim + dim];
438}
439
441template <MInt nDim>
443// Prevent accidental compilation without support for SoA layout
444#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
445#error Missing implementation for structure-of-arrays memory layout.
446#endif
447 ENSURE_VALID_ID(id);
448 ENSURE_VALID_DIM(dim);
449 return m_bodyVelocityOld[id * nDim + dim];
450}
452template <MInt nDim>
454// Prevent accidental compilation without support for SoA layout
455#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
456#error Missing implementation for structure-of-arrays memory layout.
457#endif
458 ENSURE_VALID_ID(id);
459 ENSURE_VALID_DIM(dim);
460 return m_bodyVelocityOld[id * nDim + dim];
461}
462
464template <MInt nDim>
466// Prevent accidental compilation without support for SoA layout
467#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
468#error Missing implementation for structure-of-arrays memory layout.
469#endif
470 ENSURE_VALID_ID(id);
471 ENSURE_VALID_DIM(dim);
472 return m_bodyAcceleration[id * nDim + dim];
473}
475template <MInt nDim>
477// Prevent accidental compilation without support for SoA layout
478#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
479#error Missing implementation for structure-of-arrays memory layout.
480#endif
481 ENSURE_VALID_ID(id);
482 ENSURE_VALID_DIM(dim);
483 return m_bodyAcceleration[id * nDim + dim];
484}
485
487template <MInt nDim>
489// Prevent accidental compilation without support for SoA layout
490#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
491#error Missing implementation for structure-of-arrays memory layout.
492#endif
493 ENSURE_VALID_ID(id);
494 ENSURE_VALID_DIM(dim);
495 return m_bodyAccelerationOld[id * nDim + dim];
496}
498template <MInt nDim>
500// Prevent accidental compilation without support for SoA layout
501#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
502#error Missing implementation for structure-of-arrays memory layout.
503#endif
504 ENSURE_VALID_ID(id);
505 ENSURE_VALID_DIM(dim);
506 return m_bodyAccelerationOld[id * nDim + dim];
507}
508
510template <MInt nDim>
512// Prevent accidental compilation without support for SoA layout
513#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
514#error Missing implementation for structure-of-arrays memory layout.
515#endif
516 ENSURE_VALID_ID(id);
517 ENSURE_VALID_DIM(dim);
518 return m_bodyForce[id * nDim + dim];
519}
521template <MInt nDim>
523// Prevent accidental compilation without support for SoA layout
524#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
525#error Missing implementation for structure-of-arrays memory layout.
526#endif
527 ENSURE_VALID_ID(id);
528 ENSURE_VALID_DIM(dim);
529 return m_bodyForce[id * nDim + dim];
530}
531
533template <MInt nDim>
535// Prevent accidental compilation without support for SoA layout
536#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
537#error Missing implementation for structure-of-arrays memory layout.
538#endif
539 ENSURE_VALID_ID(id);
540 return m_bodyTemperature[id];
541}
543template <MInt nDim>
545// Prevent accidental compilation without support for SoA layout
546#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
547#error Missing implementation for structure-of-arrays memory layout.
548#endif
549 ENSURE_VALID_ID(id);
550 return m_bodyTemperature[id];
551}
552
554template <MInt nDim>
556// Prevent accidental compilation without support for SoA layout
557#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
558#error Missing implementation for structure-of-arrays memory layout.
559#endif
560 ENSURE_VALID_ID(id);
561 return m_bodyTemperatureOld[id];
562}
564template <MInt nDim>
566// Prevent accidental compilation without support for SoA layout
567#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
568#error Missing implementation for structure-of-arrays memory layout.
569#endif
570 ENSURE_VALID_ID(id);
571 return m_bodyTemperatureOld[id];
572}
573
575template <MInt nDim>
577// Prevent accidental compilation without support for SoA layout
578#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
579#error Missing implementation for structure-of-arrays memory layout.
580#endif
581 ENSURE_VALID_ID(id);
582 return m_bodyHeatFlux[id];
583}
585template <MInt nDim>
587// Prevent accidental compilation without support for SoA layout
588#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
589#error Missing implementation for structure-of-arrays memory layout.
590#endif
591 ENSURE_VALID_ID(id);
592 return m_bodyHeatFlux[id];
593}
594
596template <MInt nDim>
598// Prevent accidental compilation without support for SoA layout
599#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
600#error Missing implementation for structure-of-arrays memory layout.
601#endif
602 ENSURE_VALID_ID(id);
603 return m_bodyDensityRatio[id];
604}
606template <MInt nDim>
608// Prevent accidental compilation without support for SoA layout
609#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
610#error Missing implementation for structure-of-arrays memory layout.
611#endif
612 ENSURE_VALID_ID(id);
613 return m_bodyDensityRatio[id];
614}
615
617template <MInt nDim>
619// Prevent accidental compilation without support for SoA layout
620#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
621#error Missing implementation for structure-of-arrays memory layout.
622#endif
623 ENSURE_VALID_ID(id);
624 ENSURE_VALID_ROT(dim);
625 return m_bodyInertia[id * nRot + dim];
626}
628template <MInt nDim>
630// Prevent accidental compilation without support for SoA layout
631#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
632#error Missing implementation for structure-of-arrays memory layout.
633#endif
634 ENSURE_VALID_ID(id);
635 ENSURE_VALID_ROT(dim);
636 return m_bodyInertia[id * nRot + dim];
637}
638
640template <MInt nDim>
642// Prevent accidental compilation without support for SoA layout
643#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
644#error Missing implementation for structure-of-arrays memory layout.
645#endif
646 ENSURE_VALID_ID(id);
647 return m_bodyRadius[id];
648}
650template <MInt nDim>
652// Prevent accidental compilation without support for SoA layout
653#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
654#error Missing implementation for structure-of-arrays memory layout.
655#endif
656 ENSURE_VALID_ID(id);
657 return m_bodyRadius[id];
658}
659
661template <MInt nDim>
663// Prevent accidental compilation without support for SoA layout
664#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
665#error Missing implementation for structure-of-arrays memory layout.
666#endif
667 ENSURE_VALID_ID(id);
668 ENSURE_VALID_DIM(dim);
669 return m_bodyRadii[id * nDim + dim];
670}
672template <MInt nDim>
674// Prevent accidental compilation without support for SoA layout
675#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
676#error Missing implementation for structure-of-arrays memory layout.
677#endif
678 ENSURE_VALID_ID(id);
679 ENSURE_VALID_DIM(dim);
680 return m_bodyRadii[id * nDim + dim];
681}
682
684template <MInt nDim>
686// Prevent accidental compilation without support for SoA layout
687#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
688#error Missing implementation for structure-of-arrays memory layout.
689#endif
690 ENSURE_VALID_ID(id);
691 ENSURE_VALID_QUAT(dim);
692 return m_bodyQuaternionT1[id * nQuat + dim];
693}
695template <MInt nDim>
697// Prevent accidental compilation without support for SoA layout
698#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
699#error Missing implementation for structure-of-arrays memory layout.
700#endif
701 ENSURE_VALID_ID(id);
702 ENSURE_VALID_QUAT(dim);
703 return m_bodyQuaternionT1[id * nQuat + dim];
704}
705
707template <MInt nDim>
709// Prevent accidental compilation without support for SoA layout
710#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
711#error Missing implementation for structure-of-arrays memory layout.
712#endif
713 ENSURE_VALID_ID(id);
714 ENSURE_VALID_QUAT(dim);
715 return m_bodyQuaternionT1B2[id * nQuat + dim];
716}
718template <MInt nDim>
720// Prevent accidental compilation without support for SoA layout
721#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
722#error Missing implementation for structure-of-arrays memory layout.
723#endif
724 ENSURE_VALID_ID(id);
725 ENSURE_VALID_QUAT(dim);
726 return m_bodyQuaternionT1B2[id * nQuat + dim];
727}
728
730template <MInt nDim>
732// Prevent accidental compilation without support for SoA layout
733#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
734#error Missing implementation for structure-of-arrays memory layout.
735#endif
736 ENSURE_VALID_ID(id);
737 ENSURE_VALID_ROT(dim);
738 return m_angularVelocityT1[id * nRot + dim];
739}
741template <MInt nDim>
743// Prevent accidental compilation without support for SoA layout
744#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
745#error Missing implementation for structure-of-arrays memory layout.
746#endif
747 ENSURE_VALID_ID(id);
748 ENSURE_VALID_ROT(dim);
749 return m_angularVelocityT1[id * nRot + dim];
750}
751
753template <MInt nDim>
755// Prevent accidental compilation without support for SoA layout
756#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
757#error Missing implementation for structure-of-arrays memory layout.
758#endif
759 ENSURE_VALID_ID(id);
760 ENSURE_VALID_ROT(dim);
761 return m_angularVelocityT1B2[id * nRot + dim];
762}
764template <MInt nDim>
766// Prevent accidental compilation without support for SoA layout
767#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
768#error Missing implementation for structure-of-arrays memory layout.
769#endif
770 ENSURE_VALID_ID(id);
771 ENSURE_VALID_ROT(dim);
772 return m_angularVelocityT1B2[id * nRot + dim];
773}
774
776template <MInt nDim>
778// Prevent accidental compilation without support for SoA layout
779#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
780#error Missing implementation for structure-of-arrays memory layout.
781#endif
782 ENSURE_VALID_ID(id);
783 ENSURE_VALID_ROT(dim);
784 return m_angularVelocityBodyT1[id * nRot + dim];
785}
787template <MInt nDim>
789// Prevent accidental compilation without support for SoA layout
790#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
791#error Missing implementation for structure-of-arrays memory layout.
792#endif
793 ENSURE_VALID_ID(id);
794 ENSURE_VALID_ROT(dim);
795 return m_angularVelocityBodyT1[id * nRot + dim];
796}
797
799template <MInt nDim>
801// Prevent accidental compilation without support for SoA layout
802#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
803#error Missing implementation for structure-of-arrays memory layout.
804#endif
805 ENSURE_VALID_ID(id);
806 ENSURE_VALID_ROT(dim);
807 return m_angularVelocityBodyT1B2[id * nRot + dim];
808}
810template <MInt nDim>
812// Prevent accidental compilation without support for SoA layout
813#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
814#error Missing implementation for structure-of-arrays memory layout.
815#endif
816 ENSURE_VALID_ID(id);
817 ENSURE_VALID_ROT(dim);
818 return m_angularVelocityBodyT1B2[id * nRot + dim];
819}
820
822template <MInt nDim>
824// Prevent accidental compilation without support for SoA layout
825#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
826#error Missing implementation for structure-of-arrays memory layout.
827#endif
828 ENSURE_VALID_ID(id);
829 ENSURE_VALID_ROT(dim);
830 return m_angularAccelerationBody[id * nRot + dim];
831}
833template <MInt nDim>
835// Prevent accidental compilation without support for SoA layout
836#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
837#error Missing implementation for structure-of-arrays memory layout.
838#endif
839 ENSURE_VALID_ID(id);
840 ENSURE_VALID_ROT(dim);
841 return m_angularAccelerationBody[id * nRot + dim];
842}
843
845template <MInt nDim>
847// Prevent accidental compilation without support for SoA layout
848#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
849#error Missing implementation for structure-of-arrays memory layout.
850#endif
851 ENSURE_VALID_ID(id);
852 ENSURE_VALID_ROT(dim);
853 return m_angularAccelerationT1[id * nRot + dim];
854}
856template <MInt nDim>
858// Prevent accidental compilation without support for SoA layout
859#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
860#error Missing implementation for structure-of-arrays memory layout.
861#endif
862 ENSURE_VALID_ID(id);
863 ENSURE_VALID_ROT(dim);
864 return m_angularAccelerationT1[id * nRot + dim];
865}
866
868template <MInt nDim>
870// Prevent accidental compilation without support for SoA layout
871#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
872#error Missing implementation for structure-of-arrays memory layout.
873#endif
874 ENSURE_VALID_ID(id);
875 ENSURE_VALID_ROT(dim);
876 return m_torqueT1[id * nRot + dim];
877}
879template <MInt nDim>
881// Prevent accidental compilation without support for SoA layout
882#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
883#error Missing implementation for structure-of-arrays memory layout.
884#endif
885 ENSURE_VALID_ID(id);
886 ENSURE_VALID_ROT(dim);
887 return m_torqueT1[id * nRot + dim];
888}
889
891template <MInt nDim>
893// Prevent accidental compilation without support for SoA layout
894#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
895#error Missing implementation for structure-of-arrays memory layout.
896#endif
897 ENSURE_VALID_ID(id);
898 return m_status[id];
899}
901template <MInt nDim>
903// Prevent accidental compilation without support for SoA layout
904#ifdef RBCOLLECTOR_SOA_MEMORY_LAYOUT
905#error Missing implementation for structure-of-arrays memory layout.
906#endif
907 ENSURE_VALID_ID(id);
908 return m_status[id];
909}
910
911} // namespace collector
912} // namespace rb
913} // namespace maia
914
915// Undefine macros that should not be used outside this file
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
922
923#endif // ifndef DGELEMENTCOLLECTOR_H_
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.
Definition: container.h:138
void fill_invalid(Container_ &c, const MInt begin, const MInt end, const MInt solverSize=1, const T value=Invalid< T >::value())
Definition: container.h:131
void resetStorage(const MInt n, Storage< T > &c)
Create new container with given size and replace original one.
Definition: container.h:420
void reset(const MInt capacity)
Reset tree, re-create data structures with given capacity, and set size to zero.
Definition: container.h:187
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.
MFloat & bodyTemperatureOld(const MInt id)
Accessor for the old body temperature.
MFloat & bodyHeatFlux(const MInt id)
Accessor for the body heat flux.
MFloat & bodyAcceleration(const MInt id, const MInt dim)
Accessor for the current body acceleration.
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
MFloat & bodyVelocity(const MInt id, const MInt dim)
Accessor for the current body velocity.
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
void invalidate(const MInt begin, const MInt end)
Erase range of nodes such that they contain no sensible values anymore.
MFloat & bodyCenter(const MInt id, const MInt dim)
Accessor for the current body center.
Status & status(const MInt id)
Accessor for the body status.
MFloat & bodyInertia(const MInt id, const MInt dim)
Accessor for the body inertia.
MFloat & angularVelocityT1(const MInt id, const MInt dim)
Accessor for the angular velocity T1.
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.
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.
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.
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.
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.
int32_t MInt
Definition: maiatypes.h:62
double MFloat
Definition: maiatypes.h:52
int64_t MLong
Definition: maiatypes.h:64
MInt id
Definition: maiatypes.h:71
Namespace for auxiliary functions/classes.