45using pfc::types::Bool3;
47using pfc::types::Real3;
115template <
typename CoordTag>
166 static constexpr Real3 offset = {0.0, 0.0, 0.0};
167 static constexpr Real3 spacing = {1.0, 1.0, 1.0};
168 static constexpr Bool3 periodic = {
true,
true,
true};
169 std::size_t dimensions = 3;
209 : m_offset(offset), m_spacing(spacing), m_periodic(periodic) {
210 for (std::size_t
i = 0;
i < 3; ++
i) {
211 if (spacing[
i] <= 0.0) {
212 throw std::invalid_argument(
"Spacing must be positive.");
218 return m_offset ==
other.m_offset && m_spacing ==
other.m_spacing &&
219 m_periodic ==
other.m_periodic;
223 return !(*
this ==
other);
227using CartesianCS = CoordinateSystem<CartesianTag>;
264 return cs.m_spacing.at(
i);
273 return cs.m_periodic;
295 for (
int i = 0;
i < 3; ++
i) {
311 for (
int i = 0;
i < 3; ++
i) {
312 idx[
i] =
static_cast<int>((
xyz[
i] - offset[
i]) / spacing[
i]);
std::array< int, 3 > Int3
Type aliases for clarity.
Definition types.hpp:45
const Real3 & get_spacing(const CartesianCS &cs) noexcept
Get the spacing of the coordinate system.
Definition csys.hpp:252
const Int3 to_index(const CartesianCS &cs, const Real3 &xyz) noexcept
Convert physical coordinates to grid indices.
Definition csys.hpp:307
const Bool3 & get_periodic(const CartesianCS &cs) noexcept
Get the periodicity of the coordinate system.
Definition csys.hpp:272
const Real3 to_coords(const CartesianCS &cs, const Int3 &idx) noexcept
Convert grid indices to physical coordinates.
Definition csys.hpp:291
const Real3 & get_offset(const CartesianCS &cs) noexcept
Get the offset of the coordinate system.
Definition csys.hpp:234
bool is_periodic(const CartesianCS &cs, int i)
Check if the coordinate system is periodic in a specific dimension.
Definition csys.hpp:283
Tag type for the 3D Cartesian coordinate system.
Definition csys.hpp:147
Trait class for providing default parameters for coordinate systems.
Definition csys.hpp:116
Specialization of the coordinate system for 3D Cartesian space.
Definition csys.hpp:199
CoordinateSystem(const Real3 &offset=CoordinateSystemDefaults< CartesianTag >::offset, const Real3 &spacing=CoordinateSystemDefaults< CartesianTag >::spacing, const Bool3 &periodic=CoordinateSystemDefaults< CartesianTag >::periodic)
Constructs a 3D Cartesian coordinate system.
Definition csys.hpp:205
const Bool3 m_periodic
Periodicity flags for each dimension.
Definition csys.hpp:202
const Real3 m_offset
Physical coordinate of grid index (0, 0, 0)
Definition csys.hpp:200
const Real3 m_spacing
Physical spacing between grid points.
Definition csys.hpp:201
Primary template for defining coordinate systems by tag.
Definition csys.hpp:87
Represents the global simulation domain (the "world").
Definition world.hpp:91
Common type aliases used throughout OpenPFC.