OpenPFC  0.1.4
Phase Field Crystal simulation framework
Loading...
Searching...
No Matches
csys.hpp File Reference

Extensible coordinate system framework. More...

#include "types.hpp"
Include dependency graph for csys.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pfc::csys::CartesianTag
 Tag type for the 3D Cartesian coordinate system. More...
 
struct  pfc::csys::CoordinateSystemDefaults< CartesianTag >
 Default parameters for the 3D Cartesian coordinate system. More...
 
struct  pfc::csys::CoordinateSystem< CartesianTag >
 Specialization of the coordinate system for 3D Cartesian space. More...
 

Typedefs

using pfc::csys::CartesianCS = CoordinateSystem< CartesianTag >
 

Functions

const Real3 & pfc::csys::get_offset (const CartesianCS &cs) noexcept
 Get the offset of the coordinate system.
 
double pfc::csys::get_offset (const CartesianCS &cs, int i)
 Get the offset of the coordinate system in a specific dimension.
 
const Real3 & pfc::csys::get_spacing (const CartesianCS &cs) noexcept
 Get the spacing of the coordinate system.
 
double pfc::csys::get_spacing (const CartesianCS &cs, int i)
 Get the spacing of the coordinate system in a specific dimension.
 
const Bool3 & pfc::csys::get_periodic (const CartesianCS &cs) noexcept
 Get the periodicity of the coordinate system.
 
bool pfc::csys::is_periodic (const CartesianCS &cs, int i)
 Check if the coordinate system is periodic in a specific dimension.
 
const Real3 pfc::csys::to_coords (const CartesianCS &cs, const Int3 &idx) noexcept
 Convert grid indices to physical coordinates.
 
const Int3 pfc::csys::to_index (const CartesianCS &cs, const Real3 &xyz) noexcept
 Convert physical coordinates to grid indices.
 

Detailed Description

Extensible coordinate system framework.

This header defines the CoordinateSystem template framework for defining custom coordinate systems (Cartesian, Polar, Cylindrical, etc.) via compile-time specialization.

Each coordinate system specialization provides:

  • to_physical(Int3) -> Real3: Convert grid indices to physical coordinates
  • to_index(Real3) -> Int3: Convert physical coordinates to grid indices
  • Internal parameters (offset, spacing, etc.)

The design uses template specialization rather than inheritance, enabling zero-cost abstractions and user-defined coordinate systems without modifying OpenPFC source code.

// Use Cartesian coordinate system
Cartesian cs({0, 0, 0}, {1.0, 1.0, 1.0});
auto pos = cs.to_physical({10, 20, 30}); // Physical coordinates
Extensible coordinate system framework.
Primary template for defining coordinate systems by tag.
Definition csys.hpp:87
See also
core/types.hpp for Int3, Real3 definitions
core/world.hpp for coordinate system integration
Author
OpenPFC Development Team
Date
2025

Function Documentation

◆ get_offset() [1/2]

const Real3 & pfc::csys::get_offset ( const CartesianCS cs)
inlinenoexcept

Get the offset of the coordinate system.

Parameters
csCoordinate system object.
Returns
The offset of the coordinate system.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_offset() [2/2]

double pfc::csys::get_offset ( const CartesianCS cs,
int  i 
)
inline

Get the offset of the coordinate system in a specific dimension.

Parameters
csCoordinate system object.
iDimension index.
Returns
The offset in the specified dimension.
Exceptions
std::out_of_rangeif i is not in [0, 2].
Here is the call graph for this function:

◆ get_periodic()

const Bool3 & pfc::csys::get_periodic ( const CartesianCS cs)
inlinenoexcept

Get the periodicity of the coordinate system.

Parameters
csCoordinate system object.
Returns
The periodicity flags.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_spacing() [1/2]

const Real3 & pfc::csys::get_spacing ( const CartesianCS cs)
inlinenoexcept

Get the spacing of the coordinate system.

Parameters
csCoordinate system object.
Returns
The spacing of the coordinate system.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_spacing() [2/2]

double pfc::csys::get_spacing ( const CartesianCS cs,
int  i 
)
inline

Get the spacing of the coordinate system in a specific dimension.

Parameters
csCoordinate system object.
iDimension index.
Returns
The spacing in the specified dimension.
Exceptions
std::out_of_rangeif i is not in [0, 2].
Here is the call graph for this function:

◆ is_periodic()

bool pfc::csys::is_periodic ( const CartesianCS cs,
int  i 
)
inline

Check if the coordinate system is periodic in a specific dimension.

Parameters
csCoordinate system object.
iDimension index.
Returns
True if periodic, false otherwise.
Exceptions
std::out_of_rangeif i is not in [0, 2].
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_coords()

const Real3 pfc::csys::to_coords ( const CartesianCS cs,
const Int3 &  idx 
)
inlinenoexcept

Convert grid indices to physical coordinates.

Parameters
csCoordinate system object.
idxGrid indices.
Returns
The physical coordinates.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ to_index()

const Int3 pfc::csys::to_index ( const CartesianCS cs,
const Real3 &  xyz 
)
inlinenoexcept

Convert physical coordinates to grid indices.

Parameters
csCoordinate system object.
xyzPhysical coordinates.
Returns
The grid indices.
Here is the call graph for this function:
Here is the caller graph for this function: