Mundy: Multibody Nonlocal Dynamics Version of the Day
Loading...
Searching...
No Matches
mundy::metric Class Reference

Runtime-polymorphic metric (stk::topology-style value class). More...

#include <periodicity.hpp>

Public Member Functions

Configuration
void set_cell_widths (const Vector3< double > &cell_widths)
 Set cell widths. Only valid for ORTHORHOMBIC_* types.
void set_cell_matrix (const Matrix3< double > &h)
 Set cell matrix. Only valid for TRICLINIC_* types.

Type aliases

enum  metric_t : unsigned {
  INVALID_METRIC = 0 , FREE_SPACE , ORTHORHOMBIC_X , ORTHORHOMBIC_Y ,
  ORTHORHOMBIC_Z , ORTHORHOMBIC_XY , ORTHORHOMBIC_XZ , ORTHORHOMBIC_YZ ,
  ORTHORHOMBIC_XYZ , TRICLINIC_X , TRICLINIC_Y , TRICLINIC_Z ,
  TRICLINIC_XY , TRICLINIC_XZ , TRICLINIC_YZ , TRICLINIC_XYZ ,
  NUM_METRIC_TYPES
}
static constexpr metric_t ORTHORHOMBIC = ORTHORHOMBIC_XYZ
 Alias for the common fully-periodic case.
static constexpr metric_t TRICLINIC = TRICLINIC_XYZ
 Alias for the common fully-periodic case.
static constexpr metric_t ORTHORHOMBIC_START = ORTHORHOMBIC_X
 First orthorhombic enum value (range sentinel).
static constexpr metric_t ORTHORHOMBIC_END = ORTHORHOMBIC_XYZ
 Last orthorhombic enum value (range sentinel).
static constexpr metric_t TRICLINIC_START = TRICLINIC_X
 First triclinic enum value (range sentinel).
static constexpr metric_t TRICLINIC_END = TRICLINIC_XYZ
 Last triclinic enum value (range sentinel).

Visitation

template<typename Functor>
void visit (Functor &&f) const
 Dispatch to a concrete metric type and invoke f with it.

Constructors

 metric ()=default
 metric (metric_t m)
static metric from_string (std::string_view name)
 Construct from a string name. Throws std::invalid_argument on unrecognized input. Recognised names are the enum spellings plus "ORTHORHOMBIC" / "TRICLINIC" as aliases for ORTHORHOMBIC_XYZ and TRICLINIC_XYZ respectively.

Queries

bool is_valid () const
metric_t value () const
std::string_view name () const
 Canonical string name. Round-trips through from_string.
bool is_periodic (unsigned dim) const
 True if the given dimension is periodic under this metric. For orthorhombic metrics, dim maps to Cartesian x/y/z. For triclinic metrics, dim maps to the first/second/third lattice vector direction.
std::ostream & operator<< (std::ostream &os, const metric &m)

Detailed Description

Holds a metric_t type tag plus cell parameters as an inline flat array. Construct from an enum or a string, inspect with is_periodic() / name(), stream with <<, and dispatch to a concrete metric type with visit().

mundy::metric m(mundy::metric::ORTHORHOMBIC_XYZ); m.set_cell_widths({10.0, 10.0, 10.0}); std::cout << m << "\n"; // prints "ORTHORHOMBIC_XYZ" m.visit([&](auto&& concrete) { // concrete is OrthorhombicMetric<AXIS_XYZ, double> Kokkos::parallel_for(n, MyFunctor{positions, concrete}); });

All cell parameters and concrete metrics produced by visit() are double-precision. Scalar-typed concrete metrics are not supported at the runtime level; obtain them directly from OrthorhombicMetric<> or TriclinicMetric<> if float precision is needed.

This class is host-only. Device kernels should receive concrete metric types directly so the compiler can inline all operations.

Member Enumeration Documentation

◆ metric_t

enum mundy::metric::metric_t : unsigned
Enumerator
INVALID_METRIC 

Default-constructed sentinel; metric is not yet configured.

FREE_SPACE 

Non-periodic, Euclidean metric.

ORTHORHOMBIC_X 

Axis-aligned cell, periodic along X only.

ORTHORHOMBIC_Y 

Axis-aligned cell, periodic along Y only.

ORTHORHOMBIC_Z 

Axis-aligned cell, periodic along Z only.

ORTHORHOMBIC_XY 

Axis-aligned cell, periodic along X and Y.

ORTHORHOMBIC_XZ 

Axis-aligned cell, periodic along X and Z.

ORTHORHOMBIC_YZ 

Axis-aligned cell, periodic along Y and Z.

ORTHORHOMBIC_XYZ 

Axis-aligned cell, periodic along all three axes.

TRICLINIC_X 

Tilted cell, periodic along first lattice vector only.

TRICLINIC_Y 

Tilted cell, periodic along second lattice vector only.

TRICLINIC_Z 

Tilted cell, periodic along third lattice vector only.

TRICLINIC_XY 

Tilted cell, periodic along first and second lattice vectors.

TRICLINIC_XZ 

Tilted cell, periodic along first and third lattice vectors.

TRICLINIC_YZ 

Tilted cell, periodic along second and third lattice vectors.

TRICLINIC_XYZ 

Tilted cell, periodic along all three lattice vectors.

NUM_METRIC_TYPES 

Constructor & Destructor Documentation

◆ metric() [1/2]

mundy::metric::metric ( )
default

◆ metric() [2/2]

mundy::metric::metric ( metric_t m)
inlineexplicit

Member Function Documentation

◆ from_string()

metric mundy::metric::from_string ( std::string_view name)
inlinestatic

◆ is_valid()

bool mundy::metric::is_valid ( ) const
inline

◆ value()

metric_t mundy::metric::value ( ) const
inline

◆ name()

std::string_view mundy::metric::name ( ) const
inline

◆ is_periodic()

bool mundy::metric::is_periodic ( unsigned dim) const
inline

◆ set_cell_widths()

void mundy::metric::set_cell_widths ( const Vector3< double > & cell_widths)
inline

◆ set_cell_matrix()

void mundy::metric::set_cell_matrix ( const Matrix3< double > & h)
inline

◆ visit()

template<typename Functor>
void mundy::metric::visit ( Functor && f) const

f receives one of: FreeSpaceMetric<double>, OrthorhombicMetric<axes, double>, TriclinicMetric<axes, double>. The switch is a one-time cost; the compiler inlines f for each arm. Asserts is_valid() before dispatching.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const metric & m )
friend

Member Data Documentation

◆ ORTHORHOMBIC

metric_t mundy::metric::ORTHORHOMBIC = ORTHORHOMBIC_XYZ
staticconstexpr

◆ TRICLINIC

metric_t mundy::metric::TRICLINIC = TRICLINIC_XYZ
staticconstexpr

◆ ORTHORHOMBIC_START

metric_t mundy::metric::ORTHORHOMBIC_START = ORTHORHOMBIC_X
staticconstexpr

◆ ORTHORHOMBIC_END

metric_t mundy::metric::ORTHORHOMBIC_END = ORTHORHOMBIC_XYZ
staticconstexpr

◆ TRICLINIC_START

metric_t mundy::metric::TRICLINIC_START = TRICLINIC_X
staticconstexpr

◆ TRICLINIC_END

metric_t mundy::metric::TRICLINIC_END = TRICLINIC_XYZ
staticconstexpr