SpECTRE  v2024.09.29
Tensor

Namespaces

namespace  Frame
 Indicates the Frame that a TensorIndexType is in.
 
namespace  TensorMetafunctions
 Contains all metafunctions related to Tensor manipulations.
 
namespace  tnsr
 Type aliases to construct common Tensors.
 

Classes

struct  Frame::FrameIsPhysical
 Marks a Frame as being "physical" in the sense that it is meaningful to evaluate an analytic solution in that frame. More...
 
struct  tt::is_tensor_index_type< T >
 Inherits from std::true_type if T is a TensorIndexType. More...
 
class  Tensor< X, Symm, IndexList< Indices... > >
 Represents an object with multiple components. More...
 
struct  TensorMetafunctions::replace_frame_in_tag< Tag, NewFrame >
 Replaces Tag with an equivalent Tag but in frame NewFrame. More...
 

Typedefs

template<typename CheckFrame >
using Frame::is_frame_physical = std::integral_constant< bool, std::is_base_of< FrameIsPhysical, CheckFrame >::value >
 Returns std::true_type if the frame is "physical" in the sense that it is meaningful to evaluate an analytic solution in that frame. More...
 
template<size_t SpatialDim, UpLo Ul, typename Fr >
using SpatialIndex = Tensor_detail::TensorIndexType< SpatialDim, Ul, Fr, IndexType::Spatial >
 A SpatialIndex holds information about the number of spatial dimensions, whether the index is covariant or contravariant (UpLo), and the Frame the index is in. More...
 
template<size_t SpatialDim, UpLo Ul, typename Fr >
using SpacetimeIndex = Tensor_detail::TensorIndexType< SpatialDim, Ul, Fr, IndexType::Spacetime >
 A SpacetimeIndex holds information about the number of spatial dimensions, whether the index is covariant or contravariant (UpLo), and the Frame the index is in. More...
 
template<typename Index >
using change_index_up_lo = Tensor_detail::TensorIndexType< Index::index_type==IndexType::Spatial ? Index::value :Index::value - 1, Index::ul==UpLo::Up ? UpLo::Lo :UpLo::Up, typename Index::Frame, Index::index_type >
 Change the TensorIndexType to be covariant if it's contravariant and vice-versa. More...
 
template<typename Index >
using change_index_type = Tensor_detail::TensorIndexType< Index::index_type==IndexType::Spatial ? Index::dim :Index::dim - 1, Index::ul, typename Index::Frame, Index::index_type==IndexType::Spatial ? IndexType::Spacetime :IndexType::Spatial >
 Change the TensorIndexType to be spacetime if it's spatial and vice versa. More...
 
template<typename Symm , typename... IndexPack>
using TensorMetafunctions::check_index_symmetry = typename detail::check_index_symmetry_impl< tmpl::size< Symm >::value==0 or tmpl::size< Symm >::value==1 ? 0 :2 >::template f< Symm, tmpl::map<>, IndexPack... >
 Check that each of symmetric indices is in the same frame and have the same dimensionality.
 
template<typename TheTensor , std::size_t VolumeDim, UpLo Ul, typename Fr = Frame::Grid>
using TensorMetafunctions::prepend_spatial_index = ::Tensor< typename TheTensor::type, tmpl::push_front< typename TheTensor::symmetry, tmpl::int32_t< 1+tmpl::fold< typename TheTensor::symmetry, tmpl::int32_t< 0 >, tmpl::max< tmpl::_state, tmpl::_element > >::value > >, tmpl::push_front< typename TheTensor::index_list, SpatialIndex< VolumeDim, Ul, Fr > > >
 Add a spatial index to the front of a Tensor. More...
 
template<typename TheTensor , std::size_t VolumeDim, UpLo Ul, typename Fr = Frame::Grid>
using TensorMetafunctions::prepend_spacetime_index = ::Tensor< typename TheTensor::type, tmpl::push_front< typename TheTensor::symmetry, tmpl::int32_t< 1+tmpl::fold< typename TheTensor::symmetry, tmpl::int32_t< 0 >, tmpl::max< tmpl::_state, tmpl::_element > >::value > >, tmpl::push_front< typename TheTensor::index_list, SpacetimeIndex< VolumeDim, Ul, Fr > > >
 Add a spacetime index to the front of a Tensor. More...
 
template<typename TheTensor >
using TensorMetafunctions::remove_first_index = ::Tensor< typename TheTensor::type, tmpl::pop_front< typename TheTensor::symmetry >, tmpl::pop_front< typename TheTensor::index_list > >
 remove the first index of a tensor More...
 
template<typename TheTensor >
using TensorMetafunctions::change_all_valences = ::Tensor< typename TheTensor::type, typename TheTensor::symmetry, tmpl::transform< typename TheTensor::index_list, tmpl::bind< change_index_up_lo, tmpl::_1 > > >
 Swap the valences of all indices on a Tensor.
 
template<typename NewType , typename TheTensor >
using TensorMetafunctions::swap_type = ::Tensor< NewType, typename TheTensor::symmetry, typename TheTensor::index_list >
 Swap the data type of a tensor for a new type. More...
 
template<typename TheTensor , typename Frame >
using TensorMetafunctions::any_index_in_frame = tmpl::any< typename TheTensor::index_list, tmpl::bind< detail::frame_is_the_same, tmpl::_1, Frame > >
 Return tmpl::true_type if any indices of the Tensor are in the frame Frame.
 
template<std::int32_t... T>
using Symmetry = typename detail::SymmetryImpl< std::make_index_sequence< sizeof...(T)>, tmpl::integral_list< std::int32_t, T... > >::type
 Computes the canonical symmetry from the integers T More...
 
template<typename T >
using Scalar = Tensor< T, Symmetry<>, index_list<> >
 Scalar type.
 
template<typename Tag , typename NewFrame >
using TensorMetafunctions::replace_frame_in_tag_t = typename replace_frame_in_tag< Tag, NewFrame >::type
 Replaces Tag with an equivalent Tag but in frame NewFrame.
 
template<typename TagList , typename NewFrame >
using TensorMetafunctions::replace_frame_in_taglist = tmpl::transform< TagList, tmpl::bind< replace_frame_in_tag_t, tmpl::_1, NewFrame > >
 Replaces every Tag in Taglist with an equivalent Tag but in frame NewFrame.
 

Enumerations

enum class  UpLo { UpLo::Up , UpLo::Lo }
 Whether a TensorIndexType is covariant or contravariant. More...
 
enum class  IndexType : char { IndexType::Spatial , IndexType::Spacetime }
 Indicates whether the TensorIndexType is Spatial or Spacetime. More...
 

Functions

template<size_t SpatialDim, UpLo Ul, typename Frame , typename DataType , typename SymmList , typename IndexList >
void combine_spacetime_view (gsl::not_null< TensorMetafunctions::prepend_spacetime_index< Tensor< DataType, SymmList, IndexList >, SpatialDim, Ul, Frame > * > spacetime_tensor, const Tensor< DataType, SymmList, IndexList > &time_tensor, const TensorMetafunctions::prepend_spatial_index< Tensor< DataType, SymmList, IndexList >, SpatialDim, Ul, Frame > &spatial_tensor)
 Combines a time component of a tensor with spatial components to produce a spacetime tensor. More...
 
template<size_t NumIndicesToContract, typename LhsTensor , typename T1 , typename T2 >
void contract_first_n_indices (const gsl::not_null< LhsTensor * > lhs_tensor, const T1 &tensor1, const T2 &tensor2)
 Contract the first N indices of two Tensors. More...
 
template<size_t NumIndicesToContract, typename T1 , typename T2 >
auto contract_first_n_indices (const T1 &tensor1, const T2 &tensor2)
 Contract the first N indices of two Tensors. More...
 
template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< Index > > cross_product (const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector_b)
 Compute the Euclidean cross product of two vectors or one forms. More...
 
template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > cross_product (const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &vector_b)
 Compute the Euclidean cross product of a vector and a one form. More...
 
template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< Index > > cross_product (const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector_b, const Tensor< DataType, Symmetry< 1, 1 >, index_list< Index, Index > > &metric_or_inverse_metric, const Scalar< DataType > &metric_determinant)
 Compute the cross product of two vectors or one forms. More...
 
template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > cross_product (const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &vector_b, const Tensor< DataType, Symmetry< 1, 1 >, index_list< Index, Index > > &metric_or_inverse_metric, const Scalar< DataType > &metric_determinant)
 Compute the cross product of a vector and a one form. More...
 
template<typename DataType , typename Symm , typename IndexList >
double l2_norm (const Tensor< DataType, Symm, IndexList > &tensor)
 Compute Euclidean \(L^2\)-norm of arbitrary Tensors reduced over an element. More...
 
template<size_t Dim, typename DataType >
tnsr::Ij< DataType, Dim, Frame::NoFrameidentity (const DataType &used_for_type)
 returns the Identity matrix
 
template<typename Fr >
std::string Frame::prefix ()
 The frame-dependent prefix used when constructing the string returned by the name function of a tag. More...
 
template<int I, class... Ts>
constexpr size_t index_dim (const Tensor< Ts... > &)
 Get dimensionality of i'th tensor index. More...
 

Variables

template<typename CheckFrame >
constexpr bool Frame::is_frame_physical_v = is_frame_physical<CheckFrame>::value
 Returns true if the frame is "physical" in the sense that it is meaningful to evaluate an analytic solution in that frame. More...
 
template<typename TheTensor , typename Frame >
constexpr bool TensorMetafunctions::any_index_in_frame_v
 Return true if any indices of the Tensor are in the frame Frame. More...
 
template<typename T , typename Symm , typename Index0 , typename Index1 >
void determinant (const gsl::not_null< Scalar< T > * > det_tensor, const Tensor< T, Symm, index_list< Index0, Index1 > > &tensor)
 Computes the determinant of a rank-2 Tensor tensor. More...
 
template<typename T , typename Symm , typename Index0 , typename Index1 >
Scalar< T > determinant (const Tensor< T, Symm, index_list< Index0, Index1 > > &tensor)
 Computes the determinant of a rank-2 Tensor tensor. More...
 
template<typename T , typename Symm , typename Index0 , typename Index1 >
void determinant_and_inverse (const gsl::not_null< Scalar< T > * > det, const gsl::not_null< Tensor< T, Symm, tmpl::list< change_index_up_lo< Index1 >, change_index_up_lo< Index0 > > > * > inv, const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &tensor)
 Computes the determinant and inverse of a rank-2 Tensor. More...
 
template<typename T , typename Symm , typename Index0 , typename Index1 >
auto determinant_and_inverse (const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &tensor) -> std::pair< Scalar< T >, Tensor< T, Symm, tmpl::list< change_index_up_lo< Index1 >, change_index_up_lo< Index0 > > > >
 Computes the determinant and inverse of a rank-2 Tensor. More...
 
template<typename DetTag , typename InvTag , typename T , typename Symm , typename Index0 , typename Index1 >
void determinant_and_inverse (const gsl::not_null< Variables< tmpl::list< DetTag, InvTag > > * > det_and_inv, const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &tensor)
 Computes the determinant and inverse of a rank-2 Tensor. More...
 
template<typename DetTag , typename InvTag , typename T , typename Symm , typename Index0 , typename Index1 >
auto determinant_and_inverse (const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &tensor) -> Variables< tmpl::list< DetTag, InvTag > >
 Computes the determinant and inverse of a rank-2 Tensor. More...
 
template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
void dot_product (const gsl::not_null< Scalar< DataTypeResult > * > dot_product, const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &vector_b)
 Compute the Euclidean dot product of two vectors or one forms. More...
 
template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
Scalar< DataTypeResult > dot_product (const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &vector_b)
 Compute the Euclidean dot product of two vectors or one forms. More...
 
template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
void dot_product (const gsl::not_null< Scalar< DataTypeResult > * > dot_product, const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &vector_b)
 Compute the dot product of a vector and a one form. More...
 
template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
Scalar< DataTypeResult > dot_product (const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &vector_b)
 Compute the dot product of a vector and a one form. More...
 
template<typename DataTypeLhs , typename DataTypeRhs , typename DataTypeMetric , typename Index , typename DataTypeResult = decltype(blaze::evaluate( DataTypeLhs() * DataTypeRhs() * DataTypeMetric()))>
void dot_product (const gsl::not_null< Scalar< DataTypeResult > * > dot_product, const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &vector_b, const Tensor< DataTypeMetric, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &metric)
 Compute the dot_product of two vectors or one forms. More...
 
template<typename DataTypeLhs , typename DataTypeRhs , typename DataTypeMetric , typename Index , typename DataTypeResult = decltype(blaze::evaluate( DataTypeLhs() * DataTypeRhs() * DataTypeMetric()))>
Scalar< DataTypeResult > dot_product (const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &vector_a, const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &vector_b, const Tensor< DataTypeMetric, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &metric)
 Compute the dot_product of two vectors or one forms. More...
 
template<typename DataType , typename Index >
Scalar< DataType > magnitude (const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector)
 Compute the Euclidean magnitude of a rank-1 tensor. More...
 
template<typename DataType , typename Index >
void magnitude (const gsl::not_null< Scalar< DataType > * > magnitude, const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector)
 Compute the Euclidean magnitude of a rank-1 tensor. More...
 
template<typename DataType , typename Index >
Scalar< DataType > magnitude (const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector, const Tensor< DataType, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &metric)
 Compute the magnitude of a rank-1 tensor. More...
 
template<typename DataType , typename Index >
void magnitude (const gsl::not_null< Scalar< DataType > * > magnitude, const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &vector, const Tensor< DataType, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &metric)
 Compute the magnitude of a rank-1 tensor. More...
 
template<typename DataType , typename Symm , typename IndexList >
Scalar< DataType > pointwise_l2_norm (const Tensor< DataType, Symm, IndexList > &tensor)
 Compute point-wise Euclidean \(L^2\)-norm of arbitrary Tensors. More...
 
template<typename DataType , typename Symm , typename IndexList >
void pointwise_l2_norm (const gsl::not_null< Scalar< DataType > * > norm, const Tensor< DataType, Symm, IndexList > &tensor)
 Compute point-wise Euclidean \(L^2\)-norm of arbitrary Tensors. More...
 
template<typename DataType , size_t VolumeDim, typename Frame >
void orthonormal_oneform (gsl::not_null< tnsr::i< DataType, VolumeDim, Frame > * > orthonormal_form, const tnsr::i< DataType, VolumeDim, Frame > &unit_form, const tnsr::II< DataType, VolumeDim, Frame > &inv_spatial_metric)
 Compute a spatial one-form orthonormal to the given unit form. More...
 
template<typename DataType , size_t VolumeDim, typename Frame >
tnsr::i< DataType, VolumeDim, Frame > orthonormal_oneform (const tnsr::i< DataType, VolumeDim, Frame > &unit_form, const tnsr::II< DataType, VolumeDim, Frame > &inv_spatial_metric)
 Compute a spatial one-form orthonormal to the given unit form. More...
 
template<typename DataType , typename Frame >
void orthonormal_oneform (gsl::not_null< tnsr::i< DataType, 3, Frame > * > orthonormal_form, const tnsr::i< DataType, 3, Frame > &first_unit_form, const tnsr::i< DataType, 3, Frame > &second_unit_form, const tnsr::ii< DataType, 3, Frame > &spatial_metric, const Scalar< DataType > &det_spatial_metric)
 Compute a spatial one-form orthonormal to two given unit forms. More...
 
template<typename DataType , typename Frame >
tnsr::i< DataType, 3, Frame > orthonormal_oneform (const tnsr::i< DataType, 3, Frame > &first_unit_form, const tnsr::i< DataType, 3, Frame > &second_unit_form, const tnsr::ii< DataType, 3, Frame > &spatial_metric, const Scalar< DataType > &det_spatial_metric)
 Compute a spatial one-form orthonormal to two given unit forms. More...
 
template<typename DataTypeLhs , typename SymmLhs , typename IndicesLhs , typename DataTypeRhs , typename SymmRhs , typename IndicesRhs , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
void outer_product (const gsl::not_null< OuterProductResultTensor< DataTypeResult, SymmLhs, IndicesLhs, SymmRhs, IndicesRhs > * > result, const Tensor< DataTypeLhs, SymmLhs, IndicesLhs > &lhs, const Tensor< DataTypeRhs, SymmRhs, IndicesRhs > &rhs)
 The outer product (or tensor product) of two tensors. More...
 
template<typename DataTypeLhs , typename SymmLhs , typename IndicesLhs , typename DataTypeRhs , typename SymmRhs , typename IndicesRhs , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
auto outer_product (const Tensor< DataTypeLhs, SymmLhs, IndicesLhs > &lhs, const Tensor< DataTypeRhs, SymmRhs, IndicesRhs > &rhs) -> OuterProductResultTensor< DataTypeResult, SymmLhs, IndicesLhs, SymmRhs, IndicesRhs >
 The outer product (or tensor product) of two tensors. More...
 

Detailed Description

Tensor use documentation.

Typedef Documentation

◆ change_index_type

template<typename Index >
using change_index_type = Tensor_detail::TensorIndexType< Index::index_type == IndexType::Spatial ? Index::dim : Index::dim - 1, Index::ul, typename Index::Frame, Index::index_type == IndexType::Spatial ? IndexType::Spacetime : IndexType::Spatial>

Change the TensorIndexType to be spacetime if it's spatial and vice versa.

Template Parameters
Indexthe TensorIndexType to change

◆ change_index_up_lo

template<typename Index >
using change_index_up_lo = Tensor_detail::TensorIndexType< Index::index_type == IndexType::Spatial ? Index::value : Index::value - 1, Index::ul == UpLo::Up ? UpLo::Lo : UpLo::Up, typename Index::Frame, Index::index_type>

Change the TensorIndexType to be covariant if it's contravariant and vice-versa.

Here is an example of how to use change_index_up_lo

using UpIndex = change_index_up_lo<Index>;
static_assert(std::is_same_v<UpIndex, SpatialIndex<3, UpLo::Up, Frame::Grid>>,
"Failed testing change_index_up_lo");
An integer multi-index.
Definition: Index.hpp:31
Tensor_detail::TensorIndexType< SpatialDim, Ul, Fr, IndexType::Spatial > SpatialIndex
A SpatialIndex holds information about the number of spatial dimensions, whether the index is covaria...
Definition: IndexType.hpp:206
Tensor_detail::TensorIndexType< Index::index_type==IndexType::Spatial ? Index::value :Index::value - 1, Index::ul==UpLo::Up ? UpLo::Lo :UpLo::Up, typename Index::Frame, Index::index_type > change_index_up_lo
Change the TensorIndexType to be covariant if it's contravariant and vice-versa.
Definition: IndexType.hpp:254
Template Parameters
Indexthe TensorIndexType to change

◆ is_frame_physical

template<typename CheckFrame >
using Frame::is_frame_physical = typedef std::integral_constant<bool, std::is_base_of<FrameIsPhysical, CheckFrame>::value>

Returns std::true_type if the frame is "physical" in the sense that it is meaningful to evaluate an analytic solution in that frame.

Example

static_assert(not Frame::is_frame_physical_v<Frame::BlockLogical>,
"Failed testing Frame::is_frame_physical");
static_assert(not Frame::is_frame_physical_v<Frame::ElementLogical>,
"Failed testing Frame::is_frame_physical");
static_assert(not Frame::is_frame_physical_v<Frame::Distorted>,
"Failed testing Frame::is_frame_physical");
static_assert(not Frame::is_frame_physical_v<Frame::Grid>,
"Failed testing Frame::is_frame_physical");
static_assert(Frame::is_frame_physical_v<Frame::Inertial>,
"Failed testing Frame::is_frame_physical");

◆ prepend_spacetime_index

template<typename TheTensor , std::size_t VolumeDim, UpLo Ul, typename Fr = Frame::Grid>
using TensorMetafunctions::prepend_spacetime_index = typedef ::Tensor< typename TheTensor::type, tmpl::push_front< typename TheTensor::symmetry, tmpl::int32_t< 1 + tmpl::fold<typename TheTensor::symmetry, tmpl::int32_t<0>, tmpl::max<tmpl::_state, tmpl::_element> >::value> >, tmpl::push_front<typename TheTensor::index_list, SpacetimeIndex<VolumeDim, Ul, Fr> >>

Add a spacetime index to the front of a Tensor.

Template Parameters
TheTensorthe tensor type to which the new index is prepended
VolumeDimthe volume dimension of the tensor index to prepend
Frthe Frame of the tensor index to prepend

◆ prepend_spatial_index

template<typename TheTensor , std::size_t VolumeDim, UpLo Ul, typename Fr = Frame::Grid>
using TensorMetafunctions::prepend_spatial_index = typedef ::Tensor< typename TheTensor::type, tmpl::push_front< typename TheTensor::symmetry, tmpl::int32_t< 1 + tmpl::fold<typename TheTensor::symmetry, tmpl::int32_t<0>, tmpl::max<tmpl::_state, tmpl::_element> >::value> >, tmpl::push_front<typename TheTensor::index_list, SpatialIndex<VolumeDim, Ul, Fr> >>

Add a spatial index to the front of a Tensor.

Template Parameters
TheTensorthe tensor type to which the new index is prepended
VolumeDimthe volume dimension of the tensor index to prepend
Frthe Frame of the tensor index to prepend

◆ remove_first_index

template<typename TheTensor >
using TensorMetafunctions::remove_first_index = typedef ::Tensor<typename TheTensor::type, tmpl::pop_front<typename TheTensor::symmetry>, tmpl::pop_front<typename TheTensor::index_list> >

remove the first index of a tensor

Template Parameters
TheTensorthe tensor type whose first index is removed

◆ SpacetimeIndex

template<size_t SpatialDim, UpLo Ul, typename Fr >
using SpacetimeIndex = Tensor_detail::TensorIndexType<SpatialDim, Ul, Fr, IndexType::Spacetime>

A SpacetimeIndex holds information about the number of spatial dimensions, whether the index is covariant or contravariant (UpLo), and the Frame the index is in.

Template Parameters
SpatialDimthe spatial dimensionality of the TensorIndexType
Uleither UpLo::Up or UpLo::Lo for contra or covariant
Frthe Frame the TensorIndexType is in

◆ SpatialIndex

template<size_t SpatialDim, UpLo Ul, typename Fr >
using SpatialIndex = Tensor_detail::TensorIndexType<SpatialDim, Ul, Fr, IndexType::Spatial>

A SpatialIndex holds information about the number of spatial dimensions, whether the index is covariant or contravariant (UpLo), and the Frame the index is in.

Template Parameters
SpatialDimthe spatial dimensionality of the TensorIndexType
Uleither UpLo::Up or UpLo::Lo for contra or covariant
Frthe Frame the TensorIndexType is in

◆ swap_type

template<typename NewType , typename TheTensor >
using TensorMetafunctions::swap_type = typedef ::Tensor<NewType, typename TheTensor::symmetry, typename TheTensor::index_list>

Swap the data type of a tensor for a new type.

Template Parameters
NewTypethe new data type
TheTensorthe tensor from which to keep symmetry and index information

◆ Symmetry

template<std::int32_t... T>
using Symmetry = typename detail::SymmetryImpl< std::make_index_sequence<sizeof...(T)>, tmpl::integral_list<std::int32_t, T...> >::type

Computes the canonical symmetry from the integers T

Details

Compute the canonical symmetry typelist given a set of integers, T. The resulting typelist is in ascending order of the integers, from right to left. For example, the result of Symmetry<1, 2, 1, 3> is integral_list<int32_t, 2, 3, 2, 1>. Anti-symmetries are not currently supported.

Template Parameters
Tthe integers denoting the symmetry of the Tensor

Enumeration Type Documentation

◆ IndexType

enum class IndexType : char
strong

Indicates whether the TensorIndexType is Spatial or Spacetime.

Enumerator
Spatial 

The TensorIndexType is purely spatial.

Spacetime 

The TensorIndexType is a spacetime index.

◆ UpLo

enum class UpLo
strong

Whether a TensorIndexType is covariant or contravariant.

Enumerator
Up 

Contravariant, or Upper index.

Lo 

Covariant, or Lower index.

Function Documentation

◆ combine_spacetime_view()

template<size_t SpatialDim, UpLo Ul, typename Frame , typename DataType , typename SymmList , typename IndexList >
void combine_spacetime_view ( gsl::not_null< TensorMetafunctions::prepend_spacetime_index< Tensor< DataType, SymmList, IndexList >, SpatialDim, Ul, Frame > * >  spacetime_tensor,
const Tensor< DataType, SymmList, IndexList > &  time_tensor,
const TensorMetafunctions::prepend_spatial_index< Tensor< DataType, SymmList, IndexList >, SpatialDim, Ul, Frame > &  spatial_tensor 
)

Combines a time component of a tensor with spatial components to produce a spacetime tensor.

Details

Combines a time component of a tensor with spatial components to produce a spacetime tensor. Specifically, the components of the result are views to the inputs. Can do so for a tensor of any rank, but requires that the new index is the first index of the resulting tensor, replacing the position of the spatial index in the input spatial tensor. For instance, it may combine \( \phi \) with \( A^i \) into \( A^a = \left(\phi, A^i\right) \), or it may combine \( A^a{}_b{}_c \) with \( B_i{}^a{}_b{}_c \) into \( C_a{}^b{}_c{}_d = \left(A^b{}_c{}_d, B_i{}^b{}_c{}_d\right)\), but it may not combine \( A^i{}_a \) with \( B^i{}_j{}_a \) to produce a tensor of the form \( C^i{}_a{}_b \).

Template Parameters
SpatialDimthe number of spatial dimensions in the input and output tensors
Ulwhether the new index is covariant or contravariant (must match that of the spatial index of the input spatial tensor)
Framethe frame of the new spacetime index (must match that of the spatial index of the input spatial tensor)

◆ contract_first_n_indices() [1/2]

template<size_t NumIndicesToContract, typename LhsTensor , typename T1 , typename T2 >
void contract_first_n_indices ( const gsl::not_null< LhsTensor * >  lhs_tensor,
const T1 &  tensor1,
const T2 &  tensor2 
)

Contract the first N indices of two Tensors.

Details

The indices of lhs_tensor should be the concatenation of the uncontracted indices of tensor1 and the uncontracted indices of tensor2, in this order. For example, if tensor1 is rank 3, tensor2 is rank 4, and we want to contract the first two indices, the indices of lhs_tensor need to be the last index of tensor1 followed by the 3rd index and then the 4th index of tensor2.

The index types (spatial or spacetime) must be the same for the two indices in a pair of indices being contracted. Support can be added to this function to automatically contract the spatial indices of a spacetime index with a spatial index.

Template Parameters
NumIndicesToContractthe number of indices to contract
Parameters
lhs_tensorthe result LHS Tensor
tensor1the first Tensor of the two to contract
tensor2the second Tensor of the two to contract

◆ contract_first_n_indices() [2/2]

template<size_t NumIndicesToContract, typename T1 , typename T2 >
auto contract_first_n_indices ( const T1 &  tensor1,
const T2 &  tensor2 
)

Contract the first N indices of two Tensors.

Details

The indices of the returned Tensor will be the concatenation of the uncontracted indices of tensor1 and the uncontracted indices of tensor2, in this order. For example, if tensor1 is rank 3, tensor2 is rank 4, and we want to contract the first two indices, the indices of the returned Tensor will be the last index of tensor1 followed by the 3rd index and then the 4th index of tensor2.

The index types (spatial or spacetime) must be the same for the two indices in a pair of indices being contracted. Support can be added to this function to automatically contract the spatial indices of a spacetime index with a spatial index.

Template Parameters
NumIndicesToContractthe number of indices to contract
Parameters
tensor1the first Tensor of the two to contract
tensor2the second Tensor of the two to contract

◆ cross_product() [1/4]

template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > cross_product ( const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &  vector_b 
)

Compute the Euclidean cross product of a vector and a one form.

Details

Returns \(A^j B_l \delta^{lk} \epsilon_{ijk}\) for input vector \(A^j\) and input one form \(B_l\) or \(A_j B^l \delta_{lk} \epsilon^{ijk}\) for input one form \(A_j\) and input vector \(B^l\). Note that this function returns a vector if vector_b is a vector and a one form if vector_b is a one form.

◆ cross_product() [2/4]

template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > cross_product ( const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataType, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &  vector_b,
const Tensor< DataType, Symmetry< 1, 1 >, index_list< Index, Index > > &  metric_or_inverse_metric,
const Scalar< DataType > &  metric_determinant 
)

Compute the cross product of a vector and a one form.

Details

Returns \(\sqrt{g} A^j B_l g^{lk} \epsilon_{ijk}\) for input vector \(A^j\) and input one form \(B_l\). In this case, the argument vector_a should be a vector, vector_b should be a one form, metric_or_inverse_metric should be the inverse spatial metric \(g^{ij}\), and metric_determinant should be the determinant of the spatial metric \(\det(g_{ij})\). Or, returns \(\sqrt{g}^{-1} A_j B^l g_{lk} \epsilon^{ijk}\) for input one form \(A_j\) and input vector \(B^l\). In this case, the argument vector_a should be a one form, vector_b should be a vector, metric_or_inverse_metric should be the spatial metric \(g_{ij}\), and metric_determinant should be the determinant of the spatial metric \(\det(g_{ij})\). Note that this function returns a vector if vector_b is a vector and a one form if vector_b is a one form.

◆ cross_product() [3/4]

template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< Index > > cross_product ( const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector_b 
)

Compute the Euclidean cross product of two vectors or one forms.

Details

Returns \(A^j B^k \epsilon_{ljk} \delta^{il}\) for input vectors \(A^j\) and \(B^k\) or \(A_j B_k \epsilon^{ljk} \delta_{il}\) for input one forms \(A_j\) and \(B_k\).

◆ cross_product() [4/4]

template<typename DataType , typename Index >
Tensor< DataType, Symmetry< 1 >, index_list< Index > > cross_product ( const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector_b,
const Tensor< DataType, Symmetry< 1, 1 >, index_list< Index, Index > > &  metric_or_inverse_metric,
const Scalar< DataType > &  metric_determinant 
)

Compute the cross product of two vectors or one forms.

Details

Returns \(\sqrt{g} g^{li} A^j B^k \epsilon_{ljk}\), where \(A^j\) and \(B^k\) are vectors and \(g^{li}\) and \(g\) are the inverse and determinant, respectively, of the spatial metric (computed via determinant_and_inverse). In this case, the arguments vector_a and vector_b should be vectors, the argument metric_or_inverse_metric should be the inverse spatial metric \(g^{ij}\), and the argument metric_determinant should be the determinant of the spatial metric \(\det(g_{ij})\). Or, returns \(\sqrt{g}^{-1} g_{li} A_j B_k \epsilon^{ljk}\), where \(A_j\) and \(B_k\) are one forms and \(g_{li}\) and \(g\) are the spatial metric and its determinant. In this case, the arguments vector_a and vector_b should be one forms, the argument metric_or_inverse_metric should be the spatial metric \(g_{ij}\), and the argument metric_determinant should be the determinant of the spatial metric \(\det(g_{ij})\).

◆ determinant() [1/2]

template<typename T , typename Symm , typename Index0 , typename Index1 >
void determinant ( const gsl::not_null< Scalar< T > * >  det_tensor,
const Tensor< T, Symm, index_list< Index0, Index1 > > &  tensor 
)

Computes the determinant of a rank-2 Tensor tensor.

Requires: That tensor be a rank-2 Tensor, with both indices sharing the same dimension and type.

◆ determinant() [2/2]

template<typename T , typename Symm , typename Index0 , typename Index1 >
Scalar< T > determinant ( const Tensor< T, Symm, index_list< Index0, Index1 > > &  tensor)

Computes the determinant of a rank-2 Tensor tensor.

Requires: That tensor be a rank-2 Tensor, with both indices sharing the same dimension and type.

◆ determinant_and_inverse() [1/4]

template<typename T , typename Symm , typename Index0 , typename Index1 >
void determinant_and_inverse ( const gsl::not_null< Scalar< T > * >  det,
const gsl::not_null< Tensor< T, Symm, tmpl::list< change_index_up_lo< Index1 >, change_index_up_lo< Index0 > > > * >  inv,
const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &  tensor 
)

Computes the determinant and inverse of a rank-2 Tensor.

Computes the determinant and inverse together, because this leads to fewer operations compared to computing the determinant independently.

Details

Treats the input rank-2 tensor as a matrix. The first (second) index of the tensor corresponds to the rows (columns) of the matrix. The determinant is a scalar tensor. The inverse is a rank-2 tensor whose indices are reversed and of opposite valence relative to the input tensor, i.e. given \(T_a^b\) returns \((Tinv)_b^a\).

Note
When inverting a 4x4 spacetime metric, it is typically more efficient to use the 3+1 decomposition of the 4-metric in terms of lapse, shift, and spatial 3-metric, in which only the spatial 3-metric needs to be inverted.

◆ determinant_and_inverse() [2/4]

template<typename DetTag , typename InvTag , typename T , typename Symm , typename Index0 , typename Index1 >
void determinant_and_inverse ( const gsl::not_null< Variables< tmpl::list< DetTag, InvTag > > * >  det_and_inv,
const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &  tensor 
)

Computes the determinant and inverse of a rank-2 Tensor.

Computes the determinant and inverse together, because this leads to fewer operations compared to computing the determinant independently.

Template Parameters
DetTagthe Tag for the determinant of input Tensor.
InvTagthe Tag for the inverse of input Tensor.

Details

See determinant_and_inverse().

◆ determinant_and_inverse() [3/4]

template<typename T , typename Symm , typename Index0 , typename Index1 >
auto determinant_and_inverse ( const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &  tensor) -> std::pair<Scalar<T>, Tensor<T, Symm, tmpl::list<change_index_up_lo<Index1>, change_index_up_lo<Index0>>>>

Computes the determinant and inverse of a rank-2 Tensor.

Computes the determinant and inverse together, because this leads to fewer operations compared to computing the determinant independently.

Details

Treats the input rank-2 tensor as a matrix. The first (second) index of the tensor corresponds to the rows (columns) of the matrix. The determinant is a scalar tensor. The inverse is a rank-2 tensor whose indices are reversed and of opposite valence relative to the input tensor, i.e. given \(T_a^b\) returns \((Tinv)_b^a\).

Note
When inverting a 4x4 spacetime metric, it is typically more efficient to use the 3+1 decomposition of the 4-metric in terms of lapse, shift, and spatial 3-metric, in which only the spatial 3-metric needs to be inverted.

◆ determinant_and_inverse() [4/4]

template<typename DetTag , typename InvTag , typename T , typename Symm , typename Index0 , typename Index1 >
auto determinant_and_inverse ( const Tensor< T, Symm, tmpl::list< Index0, Index1 > > &  tensor) -> Variables<tmpl::list<DetTag, InvTag>>

Computes the determinant and inverse of a rank-2 Tensor.

Computes the determinant and inverse together, because this leads to fewer operations compared to computing the determinant independently.

Template Parameters
DetTagthe Tag for the determinant of input Tensor.
InvTagthe Tag for the inverse of input Tensor.

Details

See determinant_and_inverse().

◆ dot_product() [1/6]

template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
void dot_product ( const gsl::not_null< Scalar< DataTypeResult > * >  dot_product,
const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &  vector_b 
)

Compute the dot product of a vector and a one form.

Details

Returns \(A^a B_b \delta_{a}^b\) for input vector \(A^a\) and input one form \(B_b\) or \(A_a B^b \delta^a_b\) for input one form \(A_a\) and input vector \(B^b\).

◆ dot_product() [2/6]

template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
void dot_product ( const gsl::not_null< Scalar< DataTypeResult > * >  dot_product,
const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &  vector_b 
)

Compute the Euclidean dot product of two vectors or one forms.

Details

Returns \(A^a B^b \delta_{ab}\) for input vectors \(A^a\) and \(B^b\) or \(A_a B_b \delta^{ab}\) for input one forms \(A_a\) and \(B_b\).

◆ dot_product() [3/6]

template<typename DataTypeLhs , typename DataTypeRhs , typename DataTypeMetric , typename Index , typename DataTypeResult = decltype(blaze::evaluate( DataTypeLhs() * DataTypeRhs() * DataTypeMetric()))>
void dot_product ( const gsl::not_null< Scalar< DataTypeResult > * >  dot_product,
const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &  vector_b,
const Tensor< DataTypeMetric, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &  metric 
)

Compute the dot_product of two vectors or one forms.

Details

Returns \(g_{ab} A^a B^b\), where \(g_{ab}\) is the metric, \(A^a\) is vector_a, and \(B^b\) is vector_b. Or, returns \(g^{ab} A_a B_b\) when given one forms \(A_a\) and \(B_b\) with an inverse metric \(g^{ab}\).

◆ dot_product() [4/6]

template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
Scalar< DataTypeResult > dot_product ( const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< change_index_up_lo< Index > > > &  vector_b 
)

Compute the dot product of a vector and a one form.

Details

Returns \(A^a B_b \delta_{a}^b\) for input vector \(A^a\) and input one form \(B_b\) or \(A_a B^b \delta^a_b\) for input one form \(A_a\) and input vector \(B^b\).

◆ dot_product() [5/6]

template<typename DataTypeLhs , typename DataTypeRhs , typename Index , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
Scalar< DataTypeResult > dot_product ( const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &  vector_b 
)

Compute the Euclidean dot product of two vectors or one forms.

Details

Returns \(A^a B^b \delta_{ab}\) for input vectors \(A^a\) and \(B^b\) or \(A_a B_b \delta^{ab}\) for input one forms \(A_a\) and \(B_b\).

◆ dot_product() [6/6]

template<typename DataTypeLhs , typename DataTypeRhs , typename DataTypeMetric , typename Index , typename DataTypeResult = decltype(blaze::evaluate( DataTypeLhs() * DataTypeRhs() * DataTypeMetric()))>
Scalar< DataTypeResult > dot_product ( const Tensor< DataTypeLhs, Symmetry< 1 >, index_list< Index > > &  vector_a,
const Tensor< DataTypeRhs, Symmetry< 1 >, index_list< Index > > &  vector_b,
const Tensor< DataTypeMetric, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &  metric 
)

Compute the dot_product of two vectors or one forms.

Details

Returns \(g_{ab} A^a B^b\), where \(g_{ab}\) is the metric, \(A^a\) is vector_a, and \(B^b\) is vector_b. Or, returns \(g^{ab} A_a B_b\) when given one forms \(A_a\) and \(B_b\) with an inverse metric \(g^{ab}\).

◆ index_dim()

template<int I, class... Ts>
constexpr size_t index_dim ( const Tensor< Ts... > &  )
constexpr

Get dimensionality of i'th tensor index.

index_list<SpacetimeIndex<2, UpLo::Up, Frame::Inertial>,
const T t{};
CHECK(index_dim<0>(t) == 3);
CHECK(index_dim<1>(t) == 1);
CHECK(index_dim<2>(t) == 2);
CHECK(T::index_dim(0) == 3);
CHECK(T::index_dim(1) == 1);
CHECK(T::index_dim(2) == 2);
CHECK(T::index_dims() == std::array<size_t, 3>{{3, 1, 2}});
Definition: ContractFirstNIndices.hpp:16
constexpr size_t index_dim(const Tensor< Ts... > &)
Get dimensionality of i'th tensor index.
Definition: Tensor.hpp:574

◆ l2_norm()

template<typename DataType , typename Symm , typename IndexList >
double l2_norm ( const Tensor< DataType, Symm, IndexList > &  tensor)

Compute Euclidean \(L^2\)-norm of arbitrary Tensors reduced over an element.

Details

Computes the RMS value of the point-wise Frobenius norm of a given Tensor with arbitrary rank over all grid points in an element. If the Tensor \(A\) has rank \(n\) and dimensionality \(D\), and the element (of order \(N\)) has \(N+1\) points, then its element-reduced Frobenius norm is computed as:

\begin{equation} ||A||_2 = \left(\frac{1}{N+1}\sum^{N}_{p=0} \left(\sum^{D-1}_{i_1=0}\sum^{D-1}_{i_2=0}\cdots \sum^{D-1}_{i_n=0} |A^p_{i_1 i_2 \cdots i_n}|^2 \right) \right)^{1/2}, \end{equation}

where both contra-variant and co-variant indices are shown as lower indices, and \(p\) indexes grid points in the element.

Warning
This function reduces the Frobenius norm over the element, not the whole domain.

◆ magnitude() [1/4]

template<typename DataType , typename Index >
void magnitude ( const gsl::not_null< Scalar< DataType > * >  magnitude,
const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector 
)

Compute the Euclidean magnitude of a rank-1 tensor.

Details

Computes the square root of the sum of the squares of the components of the rank-1 tensor.

◆ magnitude() [2/4]

template<typename DataType , typename Index >
void magnitude ( const gsl::not_null< Scalar< DataType > * >  magnitude,
const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector,
const Tensor< DataType, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &  metric 
)

Compute the magnitude of a rank-1 tensor.

Details

Returns the square root of the input tensor contracted twice with the given metric.

◆ magnitude() [3/4]

template<typename DataType , typename Index >
Scalar< DataType > magnitude ( const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector)

Compute the Euclidean magnitude of a rank-1 tensor.

Details

Computes the square root of the sum of the squares of the components of the rank-1 tensor.

◆ magnitude() [4/4]

template<typename DataType , typename Index >
Scalar< DataType > magnitude ( const Tensor< DataType, Symmetry< 1 >, index_list< Index > > &  vector,
const Tensor< DataType, Symmetry< 1, 1 >, index_list< change_index_up_lo< Index >, change_index_up_lo< Index > > > &  metric 
)

Compute the magnitude of a rank-1 tensor.

Details

Returns the square root of the input tensor contracted twice with the given metric.

◆ orthonormal_oneform() [1/4]

template<typename DataType , typename Frame >
tnsr::i< DataType, 3, Frame > orthonormal_oneform ( const tnsr::i< DataType, 3, Frame > &  first_unit_form,
const tnsr::i< DataType, 3, Frame > &  second_unit_form,
const tnsr::ii< DataType, 3, Frame > &  spatial_metric,
const Scalar< DataType > &  det_spatial_metric 
)

Compute a spatial one-form orthonormal to two given unit forms.

Given a unit spatial one-form \(s_i\) and another form \(t_i\) that is orthonormal to \(s_i\), compute a new form \(u_i\) which is orthonormal to both \(s_i\) and \(t_i\), in the sense that \(\gamma^{ij}s_i u_j = \gamma^{ij}t_i u_j = 0\), for the given inverse spatial metric \(\gamma^{ij}\). The normalization of \(u_i\) is such that \(\gamma^{ij}u_iu_j = 1\).

Details

The new form is obtained by taking the covariant cross product of \(s_i\) and \( t_i\), for which the spatial metric as well as its determinant must be provided.

◆ orthonormal_oneform() [2/4]

template<typename DataType , size_t VolumeDim, typename Frame >
tnsr::i< DataType, VolumeDim, Frame > orthonormal_oneform ( const tnsr::i< DataType, VolumeDim, Frame > &  unit_form,
const tnsr::II< DataType, VolumeDim, Frame > &  inv_spatial_metric 
)

Compute a spatial one-form orthonormal to the given unit form.

Given a unit spatial one-form \(s_i\), compute a new form \(t_i\) which is orthonormal to \(s_i\), in the sense that \(\gamma^{ij}s_i t_j = 0\), for the given inverse spatial metric \(\gamma^{ij}\). The normalization of \(t_i\) is such that \(\gamma^{ij}t_it_j = 1\).

Details

The new form is obtained via Gram-Schmidt process, starting from a form whose components are \(t_i = \delta_i^I\), where \(I\) is the index of the component of \(s_i\) with the smallest absolute value.

◆ orthonormal_oneform() [3/4]

template<typename DataType , typename Frame >
void orthonormal_oneform ( gsl::not_null< tnsr::i< DataType, 3, Frame > * >  orthonormal_form,
const tnsr::i< DataType, 3, Frame > &  first_unit_form,
const tnsr::i< DataType, 3, Frame > &  second_unit_form,
const tnsr::ii< DataType, 3, Frame > &  spatial_metric,
const Scalar< DataType > &  det_spatial_metric 
)

Compute a spatial one-form orthonormal to two given unit forms.

Given a unit spatial one-form \(s_i\) and another form \(t_i\) that is orthonormal to \(s_i\), compute a new form \(u_i\) which is orthonormal to both \(s_i\) and \(t_i\), in the sense that \(\gamma^{ij}s_i u_j = \gamma^{ij}t_i u_j = 0\), for the given inverse spatial metric \(\gamma^{ij}\). The normalization of \(u_i\) is such that \(\gamma^{ij}u_iu_j = 1\).

Details

The new form is obtained by taking the covariant cross product of \(s_i\) and \( t_i\), for which the spatial metric as well as its determinant must be provided.

◆ orthonormal_oneform() [4/4]

template<typename DataType , size_t VolumeDim, typename Frame >
void orthonormal_oneform ( gsl::not_null< tnsr::i< DataType, VolumeDim, Frame > * >  orthonormal_form,
const tnsr::i< DataType, VolumeDim, Frame > &  unit_form,
const tnsr::II< DataType, VolumeDim, Frame > &  inv_spatial_metric 
)

Compute a spatial one-form orthonormal to the given unit form.

Given a unit spatial one-form \(s_i\), compute a new form \(t_i\) which is orthonormal to \(s_i\), in the sense that \(\gamma^{ij}s_i t_j = 0\), for the given inverse spatial metric \(\gamma^{ij}\). The normalization of \(t_i\) is such that \(\gamma^{ij}t_it_j = 1\).

Details

The new form is obtained via Gram-Schmidt process, starting from a form whose components are \(t_i = \delta_i^I\), where \(I\) is the index of the component of \(s_i\) with the smallest absolute value.

◆ outer_product() [1/2]

template<typename DataTypeLhs , typename SymmLhs , typename IndicesLhs , typename DataTypeRhs , typename SymmRhs , typename IndicesRhs , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
void outer_product ( const gsl::not_null< OuterProductResultTensor< DataTypeResult, SymmLhs, IndicesLhs, SymmRhs, IndicesRhs > * >  result,
const Tensor< DataTypeLhs, SymmLhs, IndicesLhs > &  lhs,
const Tensor< DataTypeRhs, SymmRhs, IndicesRhs > &  rhs 
)

The outer product (or tensor product) of two tensors.

Details

Computes \(A_{i\ldots j\ldots} = B_{i\ldots} C_{j\ldots}\) for two tensors \(B_{i\ldots}\) and \(C_{j\ldots}\). Both tensors can have arbitrary indices and symmetries.

◆ outer_product() [2/2]

template<typename DataTypeLhs , typename SymmLhs , typename IndicesLhs , typename DataTypeRhs , typename SymmRhs , typename IndicesRhs , typename DataTypeResult = decltype(blaze::evaluate(DataTypeLhs() * DataTypeRhs()))>
auto outer_product ( const Tensor< DataTypeLhs, SymmLhs, IndicesLhs > &  lhs,
const Tensor< DataTypeRhs, SymmRhs, IndicesRhs > &  rhs 
) -> OuterProductResultTensor<DataTypeResult, SymmLhs, IndicesLhs, SymmRhs, IndicesRhs>

The outer product (or tensor product) of two tensors.

Details

Computes \(A_{i\ldots j\ldots} = B_{i\ldots} C_{j\ldots}\) for two tensors \(B_{i\ldots}\) and \(C_{j\ldots}\). Both tensors can have arbitrary indices and symmetries.

◆ pointwise_l2_norm() [1/2]

template<typename DataType , typename Symm , typename IndexList >
void pointwise_l2_norm ( const gsl::not_null< Scalar< DataType > * >  norm,
const Tensor< DataType, Symm, IndexList > &  tensor 
)

Compute point-wise Euclidean \(L^2\)-norm of arbitrary Tensors.

Details

At each grid point \(p\) in the element, this function computes the point-wise Frobenius norm of a given Tensor with arbitrary rank. If the Tensor \(A\) has rank \(n\) and dimensionality \(D\), then its Frobenius norm at point \(p\) is computed as:

\begin{equation} ||A||_2(p) = \left(\sum^{D-1}_{i_1=0}\sum^{D-1}_{i_2=0}\cdots \sum^{D-1}_{i_n=0} |A_{i_1 i_2 \cdots i_n}(p)|^2 \right)^{1/2}, \end{equation}

where both contra-variant and co-variant indices are shown as lower indices.

◆ pointwise_l2_norm() [2/2]

template<typename DataType , typename Symm , typename IndexList >
Scalar< DataType > pointwise_l2_norm ( const Tensor< DataType, Symm, IndexList > &  tensor)

Compute point-wise Euclidean \(L^2\)-norm of arbitrary Tensors.

Details

At each grid point \(p\) in the element, this function computes the point-wise Frobenius norm of a given Tensor with arbitrary rank. If the Tensor \(A\) has rank \(n\) and dimensionality \(D\), then its Frobenius norm at point \(p\) is computed as:

\begin{equation} ||A||_2(p) = \left(\sum^{D-1}_{i_1=0}\sum^{D-1}_{i_2=0}\cdots \sum^{D-1}_{i_n=0} |A_{i_1 i_2 \cdots i_n}(p)|^2 \right)^{1/2}, \end{equation}

where both contra-variant and co-variant indices are shown as lower indices.

◆ prefix()

template<typename Fr >
std::string Frame::prefix ( )
inline

The frame-dependent prefix used when constructing the string returned by the name function of a tag.

For Frame::Inertial it is the empty string, otherwise, it is the name of the Frame followed by an underscore (as the name will be used in I/O).

Example

TestHelpers::db::test_simple_tag<
"Grid_SpatialVelocity");
TestHelpers::db::test_simple_tag<hydro::Tags::SpatialVelocityOneForm<
"ElementLogical_SpatialVelocityOneForm");
Stores a collection of function values.
Definition: DataVector.hpp:48
Definition: IndexType.hpp:43
The spatial velocity one-form , where is raised and lowered with the spatial metric.
Definition: Tags.hpp:282
The spatial velocity of the fluid, where . Here is the spatial part of the 4-velocity of the fluid,...
Definition: Tags.hpp:274

Variable Documentation

◆ any_index_in_frame_v

template<typename TheTensor , typename Frame >
constexpr bool TensorMetafunctions::any_index_in_frame_v
constexpr
Initial value:
=
tmpl::any< typename TheTensor::index_list, tmpl::bind< detail::frame_is_the_same, tmpl::_1, Frame > > any_index_in_frame
Return tmpl::true_type if any indices of the Tensor are in the frame Frame.
Definition: Metafunctions.hpp:148

Return true if any indices of the Tensor are in the frame Frame.

◆ is_frame_physical_v

template<typename CheckFrame >
constexpr bool Frame::is_frame_physical_v = is_frame_physical<CheckFrame>::value
constexpr

Returns true if the frame is "physical" in the sense that it is meaningful to evaluate an analytic solution in that frame.

Example

static_assert(not Frame::is_frame_physical_v<Frame::BlockLogical>,
"Failed testing Frame::is_frame_physical");
static_assert(not Frame::is_frame_physical_v<Frame::ElementLogical>,
"Failed testing Frame::is_frame_physical");
static_assert(not Frame::is_frame_physical_v<Frame::Distorted>,
"Failed testing Frame::is_frame_physical");
static_assert(not Frame::is_frame_physical_v<Frame::Grid>,
"Failed testing Frame::is_frame_physical");
static_assert(Frame::is_frame_physical_v<Frame::Inertial>,
"Failed testing Frame::is_frame_physical");