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 validateddomain::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).
-
Int3 size
pfc::Box3i¶
-
struct Box3i
Inclusive integer index box
[low, high]with per-axissize.Invariant (when built via
from_bounds):size[d] == high[d] - low[d] + 1.Public Functions
-
inline constexpr bool is_consistent() const
True iff
sizeis consistent withhigh - low + 1and 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
idxlies within[low, high]on every axis.
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).
-
inline constexpr bool is_consistent() const
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
Int3for 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
-
inline explicit GridSize(const Int3 &v)
-
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
-
inline explicit GridSpacing(const Real3 &v)
-
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
-
inline explicit PhysicalOrigin(const Real3 &v)
pfc::Array¶
-
template<typename T, size_t D>
class Array Public Functions
-
inline Array(const std::array<int, D> &dimensions, const std::array<int, D> &offsets = {0})
Constructs an Array object with the specified dimensions and offsets.
- Parameters:
dimensions – The dimensions of the array.
offsets – The offsets of the array.
-
inline Array(const Decomposition &decomp)
Constructs an Array object from Decomposition object. Array dimension and offset depends from the type T of array. If the type of array is double, i.e. T = double, then inbox_size and inbox_offset is used. If the type of array is complex, i.e. T = std::complex<double>, then outbox_size and oubox_offset is used.
- Parameters:
decomp – The Decomposition object.
-
inline const MultiIndex<D> &get_index() const
Get the index object.
- Returns:
const MultiIndex<D>&
-
inline std::vector<T> &get_data()
Get the data object.
- Returns:
std::vector<T>&
-
inline const std::vector<T> &get_data() const
Get the data object.
- Returns:
const std::vector<T>&
-
inline std::array<int, D> get_size() const
Get the size object.
- Returns:
std::array<int, D>
-
inline std::array<int, D> get_offset() const
Get the offset object.
- Returns:
std::array<int, D>
-
inline bool inbounds(const std::array<int, D> &indices)
Checks if the specified indices are in bounds.
- Parameters:
indices – The indices to check.
- Returns:
true
- Returns:
false
-
template<typename Func>
inline void apply(Func &&func) Applies the specified function to each element of the array.
- Template Parameters:
Func –
- Parameters:
func – A function that takes std::array<int, D> as an argument and returns a type convertible to T.
-
inline operator std::vector<T>&()
Convert Array<T, D> to std::vector<T>.
- Returns:
A reference to underlying data.
-
inline Array(const std::array<int, D> &dimensions, const std::array<int, D> &offsets = {0})