Orrery
A GPU-accelerated N-body gravitational simulator
Loading...
Searching...
No Matches
vec3_span.hpp File Reference

Three parallel component arrays, viewed as one sequence of 3-vectors. More...

#include <span>
#include <type_traits>
#include "orrery/core/types.hpp"
#include "orrery/core/vec3.hpp"

Go to the source code of this file.

Classes

struct  orrery::core::Vec3Span< T >
 A view of three component arrays of equal length. More...

Detailed Description

Three parallel component arrays, viewed as one sequence of 3-vectors.

The storage layout keeps the x, y and z components of a vector quantity in separate arrays (ADR-0004), which is what the force kernel wants and what everything else finds awkward. This view is the bridge. It carries the three spans together, so that a function taking a vector quantity takes one argument whose parts cannot be mismatched, and it offers element access in terms of Vec3 for the code that thinks in vectors rather than in components.

Kernels use the spans directly and ignore the element access, which is the intended division: get and set are a gather and a scatter, and doing either one per particle inside a loop would defeat the layout they are built on.