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.
 

Private Attributes

std::function< void(const tensorium::Vector< T > &, tensorium::Tensor< T, 2 > &) custom_metric_fn ) = nullptr
 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)

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 alpha, beta, gamma, and X().

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

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 gamma.

Referenced by 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 chi, gamma, and tensorium::Tensor< K, Rank >::resize().

Referenced by 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(), theta, and X().

Referenced by tensorium_RG::Metric< T >::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 tensorium_RG::Metric< T >::a, Delta, tensorium::Tensor< K, Rank >::fill(), tensorium_RG::Metric< T >::M, tensorium::Tensor< K, Rank >::resize(), Sigma, theta, and X().

Referenced by tensorium_RG::Metric< T >::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 tensorium_RG::Metric< T >::a, tensorium::Tensor< K, Rank >::fill(), tensorium_RG::Metric< T >::kerr_schild_radius(), tensorium_RG::Metric< T >::M, mu, nu, tensorium::Tensor< K, Rank >::resize(), and X().

Referenced by tensorium_RG::Metric< T >::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 tensorium_RG::Metric< T >::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 f(), tensorium::Tensor< K, Rank >::fill(), tensorium_RG::Metric< T >::M, tensorium::Tensor< K, Rank >::resize(), theta, and X().

Referenced by tensorium_RG::Metric< T >::operator()().

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 tensorium_RG::Metric< T >::a.

Referenced by tensorium_RG::Metric< T >::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 tensorium_RG::Metric< T >::compute_flrw(), tensorium_RG::Metric< T >::compute_kerr(), tensorium_RG::Metric< T >::compute_kerr_schild(), tensorium_RG::Metric< T >::compute_minkowski(), tensorium_RG::Metric< T >::compute_schwarzschild(), tensorium_RG::Metric< T >::custom_metric_fn, tensorium_RG::Metric< T >::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 tensorium_RG::Metric< T >::custom_metric_fn, and tensorium_RG::Metric< T >::type.

Member Data Documentation

◆ a

◆ custom_metric_fn

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

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

Referenced by tensorium_RG::Metric< T >::operator()(), and tensorium_RG::Metric< T >::set_custom().

◆ M

◆ type

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

The documentation for this class was generated from the following file: