Data and domains

These types describe global geometry and commonly used data containers. Start with Domain, decomposition, and FFT for a runnable introduction.

pfc::Domain

struct Domain

The global Cartesian simulation domain.

Immutable value type (constructed once via domain::create, then read-only). Members are public so it is an aggregate with brace initialization; prefer the validated domain::create(...) factories for construction.

Public Members

Int3 size

Global grid size {nx, ny, nz} (> 0).

Real3 spacing

Grid spacing per axis (> 0).

Real3 origin

Physical coordinate of index (0,0,0).

Bool3 periodic

Per-axis periodicity (consumed).

pfc::Box3i

struct Box3i

Inclusive integer index box [low, high] with per-axis size.

Invariant (when built via from_bounds): size[d] == high[d] - low[d] + 1.

Public Functions

inline constexpr bool is_consistent() const

True iff size is consistent with high - low + 1 and positive.

inline constexpr long long count() const

Total number of index points.

inline constexpr bool contains(const std::array<int, 3> &idx) const

True iff index idx lies within [low, high] on every axis.

inline constexpr long long to_linear(const std::array<int, 3> &idx) const

Row-major x-fastest linear index of idx relative to low.

Public Static Functions

static inline constexpr Box3i from_bounds(const std::array<int, 3> &lo, const std::array<int, 3> &hi)

Construct from inclusive corners, computing size (>= 1 per axis).

Strong geometry values

struct GridSize

Grid dimensions (number of grid points per dimension)

Represents the size of the computational grid in each dimension. Use this instead of raw Int3 for function parameters to make intent clear and catch argument order mistakes.

GridSize size({64, 64, 64});  // 64³ grid

// Explicit conversion methods (preferred over implicit conversion)
Int3 raw = size.to_vector3();
GridSize size2 = GridSize::from_vector3(raw);

Note

Zero-cost: sizeof(GridSize) == sizeof(Int3)

Note

Trivially copyable: No heap allocation or deep copy

Public Functions

inline explicit GridSize(const Int3 &v)

Construct from Int3 (explicit construction)

Parameters:

v – Grid dimensions

inline const Int3 &get() const noexcept

Get underlying value.

Returns:

Reference to underlying Int3

inline Int3 to_vector3() const noexcept

Explicit conversion to Int3.

Returns:

Copy of underlying Int3

auto operator<=>(const GridSize &other) const noexcept = default

Lexicographic comparison of underlying grid dimensions.

Public Members

Int3 value

Underlying array value.

Public Static Functions

static inline GridSize from_vector3(const Int3 &v) noexcept

Create from Int3 (explicit factory method)

Parameters:

v – Grid dimensions

Returns:

GridSize instance

struct GridSpacing

Physical spacing between grid points.

Represents the physical distance between adjacent grid points in each dimension. Defines the resolution of the computational grid in physical units.

GridSpacing spacing({1.0, 1.0, 1.0});  // 1 unit spacing

// Explicit conversion methods (preferred over implicit conversion)
Real3 raw = spacing.to_vector3();
GridSpacing spacing2 = GridSpacing::from_vector3(raw);

Note

Zero-cost: sizeof(GridSpacing) == sizeof(Real3)

Note

Trivially copyable: No heap allocation or deep copy

Public Functions

inline explicit GridSpacing(const Real3 &v)

Construct from Real3 (explicit construction)

Parameters:

v – Spacing in each dimension

inline const Real3 &get() const noexcept

Get underlying value.

Returns:

Reference to underlying Real3

inline Real3 to_vector3() const noexcept

Explicit conversion to Real3.

Returns:

Copy of underlying Real3

auto operator<=>(const GridSpacing &other) const noexcept = default

Lexicographic comparison of underlying spacing.

Public Members

Real3 value

Underlying array value.

Public Static Functions

static inline GridSpacing from_vector3(const Real3 &v) noexcept

Create from Real3 (explicit factory method)

Parameters:

v – Spacing in each dimension

Returns:

GridSpacing instance

struct PhysicalOrigin

Physical origin of coordinate system.

Represents the physical location of the coordinate system origin. Defines where (0,0,0) in index space maps to in physical space.

PhysicalOrigin origin({-10.0, -10.0, -10.0});  // Centered domain

// Explicit conversion methods (preferred over implicit conversion)
Real3 raw = origin.to_vector3();
PhysicalOrigin origin2 = PhysicalOrigin::from_vector3(raw);

Note

Zero-cost: sizeof(PhysicalOrigin) == sizeof(Real3)

Note

Trivially copyable: No heap allocation or deep copy

Public Functions

inline explicit PhysicalOrigin(const Real3 &v)

Construct from Real3 (explicit construction)

Parameters:

v – Origin coordinates

inline const Real3 &get() const noexcept

Get underlying value.

Returns:

Reference to underlying Real3

inline Real3 to_vector3() const noexcept

Explicit conversion to Real3.

Returns:

Copy of underlying Real3

auto operator<=>(const PhysicalOrigin &other) const noexcept = default

Lexicographic comparison of underlying coordinates.

Public Members

Real3 value

Underlying array value.

Public Static Functions

static inline PhysicalOrigin from_vector3(const Real3 &v) noexcept

Create from Real3 (explicit factory method)

Parameters:

v – Origin coordinates

Returns:

PhysicalOrigin instance