SpECTRE
v2024.09.29
|
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 Tensor s. 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 Tensor s. 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::NoFrame > | identity (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... | |
Tensor use documentation.
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.
Index | the TensorIndexType to change |
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
Index | the TensorIndexType to change |
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.
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> >> |
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> >> |
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
TheTensor | the tensor type whose first index is removed |
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.
SpatialDim | the spatial dimensionality of the TensorIndexType |
Ul | either UpLo::Up or UpLo::Lo for contra or covariant |
Fr | the Frame the TensorIndexType is in |
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.
SpatialDim | the spatial dimensionality of the TensorIndexType |
Ul | either UpLo::Up or UpLo::Lo for contra or covariant |
Fr | the Frame the TensorIndexType is in |
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.
NewType | the new data type |
TheTensor | the tensor from which to keep symmetry and index information |
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
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.
T | the integers denoting the symmetry of the Tensor |
|
strong |
Indicates whether the TensorIndexType is Spatial or Spacetime.
Enumerator | |
---|---|
Spatial | The TensorIndexType is purely spatial. |
Spacetime | The TensorIndexType is a spacetime index. |
|
strong |
Whether a TensorIndexType is covariant or contravariant.
Enumerator | |
---|---|
Up | Contravariant, or Upper index. |
Lo | Covariant, or Lower index. |
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.
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 \).
SpatialDim | the number of spatial dimensions in the input and output tensors |
Ul | whether the new index is covariant or contravariant (must match that of the spatial index of the input spatial tensor) |
Frame | the frame of the new spacetime index (must match that of the spatial index of the input spatial tensor) |
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 Tensor
s.
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.
NumIndicesToContract | the number of indices to contract |
auto contract_first_n_indices | ( | const T1 & | tensor1, |
const T2 & | tensor2 | ||
) |
Contract the first N indices of two Tensor
s.
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.
NumIndicesToContract | the number of indices to contract |
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.
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.
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.
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.
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.
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\).
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.
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})\).
void determinant | ( | const gsl::not_null< Scalar< T > * > | det_tensor, |
const Tensor< T, Symm, index_list< Index0, Index1 > > & | tensor | ||
) |
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.
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\).
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.
DetTag | the Tag for the determinant of input Tensor. |
InvTag | the Tag for the inverse of input Tensor. |
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.
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\).
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.
DetTag | the Tag for the determinant of input Tensor. |
InvTag | the Tag for the inverse of input Tensor. |
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.
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\).
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.
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\).
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.
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}\).
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.
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\).
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.
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\).
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.
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}\).
|
constexpr |
Get dimensionality of i'th tensor index.
double l2_norm | ( | const Tensor< DataType, Symm, IndexList > & | tensor | ) |
Compute Euclidean \(L^2\)-norm of arbitrary Tensors reduced over an element.
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.
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.
Computes the square root of the sum of the squares of the components of the rank-1 tensor.
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.
Returns the square root of the input tensor contracted twice with the given metric.
Scalar< DataType > magnitude | ( | const Tensor< DataType, Symmetry< 1 >, index_list< Index > > & | vector | ) |
Compute the Euclidean magnitude of a rank-1 tensor.
Computes the square root of the sum of the squares of the components of the rank-1 tensor.
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.
Returns the square root of the input tensor contracted twice with the given metric.
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\).
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.
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\).
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.
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\).
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.
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\).
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.
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.
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.
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.
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.
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.
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.
Scalar< DataType > pointwise_l2_norm | ( | const Tensor< DataType, Symm, IndexList > & | tensor | ) |
Compute point-wise Euclidean \(L^2\)-norm of arbitrary Tensors.
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.
|
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).
|
constexpr |
Return true if any indices of the Tensor are in the frame Frame.
|
constexpr |
Returns true if the frame is "physical" in the sense that it is meaningful to evaluate an analytic solution in that frame.