41using pfc::types::Real3;
75template <
typename T>
inline Int3 get_size(
const World<T> &world)
noexcept {
106template <
typename T>
inline int get_size(
const World<T> &world,
int index) {
107 return get_size(world).at(index);
140template <
typename T>
inline size_t get_total_size(
const World<T> &world)
noexcept {
141 return get_size(world, 0) * get_size(world, 1) * get_size(world, 2);
227inline const Real3 &get_spacing(
const CartesianWorld &world)
noexcept {
255inline double get_spacing(
const CartesianWorld &world,
int index)
noexcept {
290inline const Real3 &get_origin(
const CartesianWorld &world)
noexcept {
317inline double get_origin(
const CartesianWorld &world,
int index)
noexcept {
366inline auto to_coords(
const World<T> &world,
const Int3 &indices)
noexcept {
421inline auto to_indices(
const World<T> &world,
const Real3 &coords)
noexcept {
450 const auto spacing = get_spacing(world);
451 const auto size = get_size(world);
452 return spacing[0] * spacing[1] * spacing[2] * size[0] * size[1] * size[2];
472 const auto size = get_size(world);
473 return (size[0] > 1) && (size[1] == 1) && (size[2] == 1);
493 const auto size = get_size(world);
494 return (size[0] > 1) && (size[1] > 1) && (size[2] == 1);
514 const auto size = get_size(world);
515 return (size[0] > 1) && (size[1] > 1) && (size[2] > 1);
536 if (
is_3d(world))
return 3;
537 if (
is_2d(world))
return 2;
538 if (
is_1d(world))
return 1;
559 return to_coords(world, {0, 0, 0});
579 const auto size = get_size(world);
580 return to_coords(world, {size[0] - 1, size[1] - 1, size[2] - 1});
607inline std::array<std::vector<double>, 3>
608coordinates(
const World<T> &world)
noexcept {
609 std::array<std::vector<double>, 3> result;
610 const auto size = get_size(world);
611 const auto origin = get_origin(world);
613 for (
int d = 0; d < 3; ++d) {
614 result[d].resize(size[d]);
615 for (
int i = 0; i < size[d]; ++i) {
616 result[d][i] = origin[d] + i * spacing[d];
std::array< int, 3 > Int3
Type aliases for clarity.
Definition types.hpp:45
Extensible coordinate system framework.
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 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_3d(const World< T > &world) noexcept
Check if domain is 3D (all dimensions have > 1 point)
Definition world_queries.hpp:513
int dimensionality(const World< T > &world) noexcept
Get dimensionality as integer.
Definition world_queries.hpp:535
bool is_1d(const World< T > &world) noexcept
Check if domain is 1D (only x-direction has > 1 point)
Definition world_queries.hpp:471
const auto & get_upper(const CartesianWorld &world) noexcept
Get the upper bounds of the world in a specific dimension.
Definition world_queries.hpp:168
const auto & get_lower(const CartesianWorld &world) noexcept
Get the lower bounds of the world.
Definition world_queries.hpp:149
Real3 get_lower_bounds(const World< T > &world) noexcept
Get physical lower bounds (origin corner)
Definition world_queries.hpp:558
World< CartesianTag > CartesianWorld
Type alias for Cartesian 3D World (most common usage)
Definition world.hpp:134
bool is_2d(const World< T > &world) noexcept
Check if domain is 2D (x and y have > 1 point, z has 1)
Definition world_queries.hpp:492
double physical_volume(const World< T > &world) noexcept
Compute physical volume of domain.
Definition world_queries.hpp:449
const auto & get_coordinate_system(const World< T > &world) noexcept
Get the coordinate system of the world.
Definition world_queries.hpp:192
Real3 get_upper_bounds(const World< T > &world) noexcept
Get physical upper bounds (far corner)
Definition world_queries.hpp:578
Primary template for defining coordinate systems by tag.
Definition csys.hpp:87
Represents the global simulation domain (the "world").
Definition world.hpp:91
const Int3 m_lower
Lower index bounds.
Definition world.hpp:92
const CoordinateSystem< T > m_cs
Coordinate system.
Definition world.hpp:95
const Int3 m_upper
Upper index bounds.
Definition world.hpp:93
const Int3 m_size
Grid dimensions: {nx, ny, nz}.
Definition world.hpp:94
Common type aliases used throughout OpenPFC.
World class definition and unified interface.