Tensorium
Loading...
Searching...
No Matches
tensorium_RG::Metric< T > Class Template Reference

A callable 4D metric class for general relativity (Minkowski, Schwarzschild, Kerr, etc.). More...

#include <Metric.hpp>

Collaboration diagram for tensorium_RG::Metric< T >:

Public Member Functions

 Metric (const std::string &metric_type="minkowski", T mass=T(1.0), T spin=T(0.0))
 Constructor.
void operator() (const tensorium::Vector< T > &X, tensorium::Tensor< T, 2 > &g) const
 Evaluate the metric tensor \( g_{\mu\nu}(X^\lambda) \).
void BSSN (const tensorium::Vector< T > &X, T &alpha, tensorium::Vector< T > &beta, tensorium::Tensor< T, 2 > &gamma) const
 Extract BSSN 3+1 variables (lapse, shift, and spatial metric).
compute_conformal_factor (const tensorium::Tensor< T, 2 > &gamma) const
void compute_conformal_metric (const tensorium::Tensor< T, 2 > &gamma, T chi, tensorium::Tensor< T, 2 > &gamma_tilde) const

Public Attributes

std::string type
M = T(1.0)
a = T(0.935)

Private Member Functions

void set_custom (std::function< void(const tensorium::Vector< T > &, tensorium::Tensor< T, 2 > &)> fn)
 Set a custom metric callable function.
void compute_minkowski (tensorium::Tensor< T, 2 > &g) const
 Minkowski metric in Cartesian coordinates.
void compute_schwarzschild (const tensorium::Vector< T > &X, tensorium::Tensor< T, 2 > &g) const
 Schwarzschild metric in spherical coordinates.
void compute_kerr (const tensorium::Vector< T > &X, tensorium::Tensor< T, 2 > &g) const
 Kerr metric in Boyer–Lindquist coordinates.
void compute_flrw (const tensorium::Vector< T > &X, tensorium::Tensor< T, 2 > &g) const
 Flat FLRW metric in comoving spherical coordinates.
kerr_schild_radius (T x, T y, T z) const
 Kerr–Schild radius extraction helper.
void compute_kerr_schild (const tensorium::Vector< T > &X, tensorium::Tensor< T, 2 > &g) const
 Kerr–Schild metric in Cartesian coordinates.
tensorium::Vector< T > convert_to_metric_coordinates (const tensorium::Vector< T > &X) const
tensorium::Tensor< T, 2 > invert_metric_tensor (const tensorium::Tensor< T, 2 > &g) const
tensorium::Tensor< T, 2 > invert_spatial_metric (const tensorium::Tensor< T, 2 > &gamma) const
void validate_adm_split (const tensorium::Tensor< T, 2 > &g, const tensorium::Tensor< T, 2 > &gamma, const tensorium::Vector< T > &beta, T alpha) const

Private Attributes

std::function< void(const tensorium::Vector< T > &, tensorium::Tensor< T, 2 > &)> custom_metric_fn
 Optional user-defined metric function (must accept X and fill g).

Detailed Description

template<typename T>
class tensorium_RG::Metric< T >

A callable 4D metric class for general relativity (Minkowski, Schwarzschild, Kerr, etc.).

This class provides access to several pre-implemented metrics (Minkowski, Schwarzschild, Kerr, Kerr–Schild, FLRW), and supports user-defined metrics via a custom callable.

It supports:

  • Direct evaluation of the metric tensor \( g_{\mu\nu}(X^\lambda) \)
  • Extraction of ADM variables for BSSN formalism: lapse \( \alpha \), shift \( \beta^i \), and spatial metric \( \gamma_{ij} \)

The class is callable via operator() and adapts to the type of metric selected by type.

Template Parameters
TScalar type (e.g., float or double)

Constructor & Destructor Documentation

◆ Metric()

template<typename T>
tensorium_RG::Metric< T >::Metric ( const std::string & metric_type = "minkowski",
T mass = T(1.0),
T spin = T(0.0) )
inline

Constructor.

Parameters
metric_typeName of the metric ("minkowski", "schwarzschild", "kerr", etc.)
massCentral mass (default = 1.0)
spinSpin parameter (only relevant for Kerr/Kerr–Schild)

References a, M, and type.

Member Function Documentation

◆ BSSN()

template<typename T>
void tensorium_RG::Metric< T >::BSSN ( const tensorium::Vector< T > & X,
T & alpha,
tensorium::Vector< T > & beta,
tensorium::Tensor< T, 2 > & gamma ) const
inline

Extract BSSN 3+1 variables (lapse, shift, and spatial metric).

Decomposes the 4D metric at point X into ADM form:

\[ds^2 = -\alpha^2 dt^2 + \gamma_{ij} (dx^i + \beta^i dt)(dx^j + \beta^j dt) \]

Parameters
X4D coordinate vector \( X^\mu \)
alphaOutput scalar lapse function \( \alpha \)
betaOutput shift vector \( \beta^i \)
gammaOutput 3x3 spatial metric \( \gamma_{ij} \)

References convert_to_metric_coordinates(), invert_metric_tensor(), invert_spatial_metric(), tensorium::Tensor< K, Rank >::resize(), tensorium::Vector< K >::resize(), validate_adm_split(), and X().

Referenced by tensorium_RG::BSSNContractedGamma< T >::compute(), tensorium_RG::ChiContext< T >::compute(), tensorium_RG::BSSNContractedGamma< T >::compute_contracted_christoffel(), tensorium_RG::compute_dt_gamma_from_metric(), tensorium_RG::RicciTildeTensor< T >::compute_laplacian_term(), tensorium_RG::generate_conformal_metric_field(), tensorium_RG::BSSN< T >::init_BSSN(), and tensorium_RG::bssn::split_3p1().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_conformal_factor()

template<typename T>
T tensorium_RG::Metric< T >::compute_conformal_factor ( const tensorium::Tensor< T, 2 > & gamma) const
inline

References tensorium::Tensor< K, Rank >::dimensions.

Referenced by tensorium::compute_conformal_factor(), tensorium_RG::generate_conformal_metric_field(), and tensorium_RG::BSSN< T >::init_BSSN().

Here is the caller graph for this function:

◆ compute_conformal_metric()

template<typename T>
void tensorium_RG::Metric< T >::compute_conformal_metric ( const tensorium::Tensor< T, 2 > & gamma,
T chi,
tensorium::Tensor< T, 2 > & gamma_tilde ) const
inline

References tensorium::Tensor< K, Rank >::resize().

Referenced by tensorium::compute_conformal_metric(), and tensorium_RG::generate_conformal_metric_field().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_flrw()

template<typename T>
void tensorium_RG::Metric< T >::compute_flrw ( const tensorium::Vector< T > & X,
tensorium::Tensor< T, 2 > & g ) const
inlineprivate

Flat FLRW metric in comoving spherical coordinates.

References tensorium::Tensor< K, Rank >::fill(), tensorium::Tensor< K, Rank >::resize(), and X().

Referenced by operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_kerr()

template<typename T>
void tensorium_RG::Metric< T >::compute_kerr ( const tensorium::Vector< T > & X,
tensorium::Tensor< T, 2 > & g ) const
inlineprivate

Kerr metric in Boyer–Lindquist coordinates.

References a, tensorium::Tensor< K, Rank >::fill(), M, tensorium::Tensor< K, Rank >::resize(), and X().

Referenced by operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_kerr_schild()

template<typename T>
void tensorium_RG::Metric< T >::compute_kerr_schild ( const tensorium::Vector< T > & X,
tensorium::Tensor< T, 2 > & g ) const
inlineprivate

Kerr–Schild metric in Cartesian coordinates.

References a, tensorium::Tensor< K, Rank >::fill(), kerr_schild_radius(), M, tensorium::Tensor< K, Rank >::resize(), and X().

Referenced by operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_minkowski()

template<typename T>
void tensorium_RG::Metric< T >::compute_minkowski ( tensorium::Tensor< T, 2 > & g) const
inlineprivate

Minkowski metric in Cartesian coordinates.

References tensorium::Tensor< K, Rank >::fill(), and tensorium::Tensor< K, Rank >::resize().

Referenced by operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compute_schwarzschild()

template<typename T>
void tensorium_RG::Metric< T >::compute_schwarzschild ( const tensorium::Vector< T > & X,
tensorium::Tensor< T, 2 > & g ) const
inlineprivate

Schwarzschild metric in spherical coordinates.

References tensorium::Tensor< K, Rank >::fill(), M, tensorium::Tensor< K, Rank >::resize(), and X().

Referenced by operator()().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ convert_to_metric_coordinates()

template<typename T>
tensorium::Vector< T > tensorium_RG::Metric< T >::convert_to_metric_coordinates ( const tensorium::Vector< T > & X) const
inlineprivate

References type, and X().

Referenced by BSSN().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invert_metric_tensor()

template<typename T>
tensorium::Tensor< T, 2 > tensorium_RG::Metric< T >::invert_metric_tensor ( const tensorium::Tensor< T, 2 > & g) const
inlineprivate

References tensorium::Tensor< K, Rank >::dimensions, and tensorium::Matrix< K, RowMajor >::inverse().

Referenced by BSSN().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ invert_spatial_metric()

template<typename T>
tensorium::Tensor< T, 2 > tensorium_RG::Metric< T >::invert_spatial_metric ( const tensorium::Tensor< T, 2 > & gamma) const
inlineprivate

References tensorium::Matrix< K, RowMajor >::inverse().

Referenced by BSSN().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ kerr_schild_radius()

template<typename T>
T tensorium_RG::Metric< T >::kerr_schild_radius ( T x,
T y,
T z ) const
inlineprivate

Kerr–Schild radius extraction helper.

References a.

Referenced by compute_kerr_schild().

Here is the caller graph for this function:

◆ operator()()

template<typename T>
void tensorium_RG::Metric< T >::operator() ( const tensorium::Vector< T > & X,
tensorium::Tensor< T, 2 > & g ) const
inline

Evaluate the metric tensor \( g_{\mu\nu}(X^\lambda) \).

Dispatches to the appropriate metric implementation based on type. Throws an exception if the type is unknown and no custom function is set.

Parameters
X4D coordinate vector \( (t, r, \theta, \phi) \) or Cartesian if Kerr–Schild
gOutput tensor to be filled with \( g_{\mu\nu} \)

References compute_flrw(), compute_kerr(), compute_kerr_schild(), compute_minkowski(), compute_schwarzschild(), custom_metric_fn, type, and X().

Here is the call graph for this function:

◆ set_custom()

template<typename T>
void tensorium_RG::Metric< T >::set_custom ( std::function< void(const tensorium::Vector< T > &, tensorium::Tensor< T, 2 > &)> fn)
inlineprivate

Set a custom metric callable function.

References custom_metric_fn, and type.

◆ validate_adm_split()

template<typename T>
void tensorium_RG::Metric< T >::validate_adm_split ( const tensorium::Tensor< T, 2 > & g,
const tensorium::Tensor< T, 2 > & gamma,
const tensorium::Vector< T > & beta,
T alpha ) const
inlineprivate

References tensorium::Tensor< K, Rank >::fill().

Referenced by BSSN().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ a

template<typename T>
T tensorium_RG::Metric< T >::a = T(0.935)

◆ custom_metric_fn

template<typename T>
std::function<void(const tensorium::Vector<T> &, tensorium::Tensor<T, 2> &)> tensorium_RG::Metric< T >::custom_metric_fn
private
Initial value:
=
nullptr

Optional user-defined metric function (must accept X and fill g).

Referenced by operator()(), and set_custom().

◆ M

template<typename T>
T tensorium_RG::Metric< T >::M = T(1.0)

◆ type

template<typename T>
std::string tensorium_RG::Metric< T >::type

The documentation for this class was generated from the following file:
  • includes/Tensorium/Physics/DiffGeometry/Metric.hpp