SHiP Field Service
Framework-agnostic C++20 library exposing SHiP magnetic field maps.
Loading...
Searching...
No Matches
SHiP::detail Namespace Reference

Classes

struct  GridSpec
 Axis-aligned grid: n[i] samples spanning [min[i], max[i]] (mm). More...
 

Typedefs

using array_backend_t = covfie::backend::array< covfie::vector::float3 >
 
using stored_vector_t = array_backend_t::vector_t
 One stored node: {Bx, By, Bz} in Tesla.
 
using stored_backend_t = covfie::backend::strided< covfie::vector::size3, array_backend_t >
 
using reader_field_t = covfie::field< covfie::backend::affine< covfie::backend::clamp< covfie::backend::linear< stored_backend_t > > > >
 
using writer_field_t = covfie::field< covfie::backend::affine< covfie::backend::clamp< covfie::backend::nearest_neighbour< stored_backend_t > > > >
 

Functions

void validate (GridSpec const &spec)
 Throw if spec cannot produce a well-formed grid: every axis needs at least two samples (n - 1 underflows for n == 0 and divides by zero in grid_pos/the affine scale for n == 1) and a positive extent (max > min, otherwise the affine scale is non-positive or infinite).
 
float grid_pos (float min, float max, std::size_t n, std::size_t i)
 Position of sample i on an axis with n samples spanning [min, max].
 
covfie::algebra::affine< 3 > make_affine (GridSpec const &spec)
 World (mm) to fractional grid index: node i on each axis maps to i.
 
template<typename clamp_cfg_t >
clamp_cfg_t make_clamp (GridSpec const &spec)
 Clamp fractional grid indices to the mapped box.
 
writer_field_t make_writer_field (GridSpec const &spec)
 Build an empty writer-chain field over spec, ready to be filled via writer_field_t::view_t::at(x, y, z) at grid_pos sample positions.
 
reader_field_t make_reader_field (GridSpec const &spec, std::unique_ptr< stored_vector_t[]> values)
 Build a reader-chain field over spec that adopts values: one node per grid point, n[0] * n[1] * n[2] of them in strided order (x-major, z fastest).
 

Typedef Documentation

◆ array_backend_t

using SHiP::detail::array_backend_t = typedef covfie::backend::array<covfie::vector::float3>

◆ reader_field_t

using SHiP::detail::reader_field_t = typedef covfie::field< covfie::backend::affine<covfie::backend::clamp<covfie::backend::linear<stored_backend_t> >> >

◆ stored_backend_t

using SHiP::detail::stored_backend_t = typedef covfie::backend::strided<covfie::vector::size3, array_backend_t>

◆ stored_vector_t

using SHiP::detail::stored_vector_t = typedef array_backend_t::vector_t

One stored node: {Bx, By, Bz} in Tesla.

◆ writer_field_t

using SHiP::detail::writer_field_t = typedef covfie::field<covfie::backend::affine< covfie::backend::clamp<covfie::backend::nearest_neighbour<stored_backend_t> >> >

Function Documentation

◆ grid_pos()

float SHiP::detail::grid_pos ( float  min,
float  max,
std::size_t  n,
std::size_t  i 
)
inline

Position of sample i on an axis with n samples spanning [min, max].

Must be used by writers so fill positions land exactly on the grid indices produced by the affine transform. n >= 2 is a precondition (see validate).

◆ make_affine()

covfie::algebra::affine< 3 > SHiP::detail::make_affine ( GridSpec const &  spec)
inline

World (mm) to fractional grid index: node i on each axis maps to i.

◆ make_clamp()

template<typename clamp_cfg_t >
clamp_cfg_t SHiP::detail::make_clamp ( GridSpec const &  spec)

Clamp fractional grid indices to the mapped box.

The upper bound sits one float ULP below n-1 because the trilinear interpolator always reads cell i+1; nearest_neighbour still rounds it back to n-1, so writer fills at the max corner are unaffected.

◆ make_reader_field()

reader_field_t SHiP::detail::make_reader_field ( GridSpec const &  spec,
std::unique_ptr< stored_vector_t[]>  values 
)
inline

Build a reader-chain field over spec that adopts values: one node per grid point, n[0] * n[1] * n[2] of them in strided order (x-major, z fastest).

◆ make_writer_field()

writer_field_t SHiP::detail::make_writer_field ( GridSpec const &  spec)
inline

Build an empty writer-chain field over spec, ready to be filled via writer_field_t::view_t::at(x, y, z) at grid_pos sample positions.

◆ validate()

void SHiP::detail::validate ( GridSpec const &  spec)
inline

Throw if spec cannot produce a well-formed grid: every axis needs at least two samples (n - 1 underflows for n == 0 and divides by zero in grid_pos/the affine scale for n == 1) and a positive extent (max > min, otherwise the affine scale is non-positive or infinite).