Namespaces | Classes | Macros | Functions
Data Structures

Various useful data structures used in SpECTRE. More...

Namespaces

 MakeWithValueImpls
 Implementations of make_with_value.
 

Classes

class  ComplexDataVector
 Stores a collection of complex function values. More...
 
class  ComplexDiagonalModalOperator
 A class for an element-wise complex multiplier of modal coefficients. More...
 
class  ComplexModalVector
 A class for storing complex spectral coefficients on a spectral grid. More...
 
class  DataVector
 Stores a collection of function values. More...
 
class  DenseMatrix< T, SO >
 A dynamically sized matrix of arbitrary type. More...
 
class  DenseVector< T, TF >
 A dynamically sized vector of arbitrary type. More...
 
class  DiagonalModalOperator
 A class for an element-wise multiplier of modal coefficients. More...
 
class  FixedHashMap< MaxSize, Key, ValueType, Hash, KeyEqual >
 A hash table with a compile-time specified maximum size and ability to efficiently handle perfect hashes. More...
 
struct  IdPair< IdType, DataType >
 A data structure that contains an ID and data associated with that ID. More...
 
class  Index< Dim >
 An integer multi-index. More...
 
class  IndexIterator< Dim >
 IndexIterator iterates over a unique set of Index. More...
 
class  LeviCivitaIterator< Dim >
 Iterate over all nonzero index permutations for a Levi-Civita symbol. More...
 
class  Matrix
 A dynamically sized matrix of doubles with column-major storage. More...
 
class  ModalVector
 A class for storing spectral coefficients on a spectral grid. More...
 
class  SliceIterator
 Iterate over a (dim-1)-dimensional slice. More...
 
struct  SpinWeighted< T, Spin, is_vector >
 Make a spin-weighted type T with spin-weight Spin. Mathematical operators are restricted to addition, subtraction, multiplication and division, with spin-weights checked for validity. More...
 
struct  is_any_spin_weighted< T >
 This is a std::true_type if the provided type is a SpinWeighted of any type and spin, otherwise is a std::false_type. More...
 
struct  is_spin_weighted_of< InternalType, T >
 This is a std::true_type if the provided type T is a SpinWeighted of InternalType and any spin, otherwise is a std::false_type. More...
 
struct  is_spin_weighted_of_same_type< T1, T2 >
 This is a std::true_type if the provided type T1 is a SpinWeighted and T2 is a SpinWeighted, and both have the same internal type, but any combination of spin weights. More...
 
class  StripeIterator
 Iterates over the 1-dimensional stripes with info on how to iterate over the current stripe. More...
 
struct  TempBuffer< TagList, is_fundamental >
 A TempBuffer holds a set of Tensor<DataType>s, where DataType is either a DataVector (or similar type) or a fundamental type, in a way that minimizes allocations. More...
 
struct  Tags::Magnitude< Tag >
 The magnitude of a (co)vector. More...
 
struct  Tags::EuclideanMagnitude< Tag >
 The Euclidean magnitude of a (co)vector. More...
 
struct  Tags::NonEuclideanMagnitude< Tag, MetricTag >
 The magnitude of a (co)vector with respect to a specific metric. More...
 
struct  Tags::Normalized< Tag >
 The normalized (co)vector represented by Tag. More...
 
struct  TensorComponent
 An untyped tensor component with a name for observation. More...
 
struct  ExtentsAndTensorVolumeData
 Holds the extents of the mesh and the tensor components on the mesh. More...
 
class  Variables< tmpl::list< Tags... > >
 A Variables holds a contiguous memory block with Tensors pointing into it. More...
 
class  VectorImpl< T, VectorType >
 Base class template for various DataVector and related types. More...
 
struct  get_vector_element_type< T, bool >
 Helper struct to determine the element type of a VectorImpl or container of VectorImpl. More...
 
class  DirectionMap< Dim, T >
 An optimized map with Direction keys. More...
 
class  Mesh< Dim >
 Holds the number of grid points, basis, and quadrature in each direction of the computational grid. More...
 

Macros

#define BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT(VECTOR_TYPE, BLAZE_MATH_TRAIT)
 Instructs Blaze to provide the appropriate vector result type after math operations. This is accomplished by specializing Blaze's type traits that are used for handling return type deduction and specifying the using Type = nested type alias in the traits. More...
 
#define BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT(VECTOR_TYPE, COMPATIBLE, BLAZE_MATH_TRAIT)
 Instructs Blaze to provide the appropriate vector result type of an operator between VECTOR_TYPE and COMPATIBLE, where the operation is represented by BLAZE_MATH_TRAIT More...
 
#define VECTOR_BLAZE_TRAIT_SPECIALIZE_ARITHMETIC_TRAITS(VECTOR_TYPE)
 Instructs Blaze to provide the appropriate vector result type of arithmetic operations for VECTOR_TYPE. This is accomplished by specializing Blaze's type traits that are used for handling return type deduction. More...
 
#define VECTOR_BLAZE_TRAIT_SPECIALIZE_ALL_MAP_TRAITS(VECTOR_TYPE)
 Instructs Blaze to provide the appropriate vector result type of Map operations (unary and binary) acting on VECTOR_TYPE. This is accomplished by specializing Blaze's type traits that are used for handling return type deduction. More...
 
#define MAKE_STD_ARRAY_VECTOR_BINOPS(VECTOR_TYPE)
 Defines the set of binary operations often supported for std::array<VECTOR_TYPE, size>, for arbitrary size. More...
 
#define MAKE_MATH_ASSIGN_EXPRESSION_ARITHMETIC(VECTOR_TYPE)
 Defines MAKE_MATH_ASSIGN_EXPRESSION_POINTERVECTOR with all assignment arithmetic operations. More...
 
#define MAKE_WITH_VALUE_IMPL_DEFINITION_FOR(VECTOR_TYPE)
 Defines the MakeWithValueImpl apply specialization. More...
 

Functions

template<size_t N>
size_t collapsed_index (const Index< N > &index, const Index< N > &extents) noexcept
 Get the collapsed index into a 1D array of the data corresponding to this Index. Note that the first dimension of the Index varies fastest when computing the collapsed index.
 
template<size_t VolumeDim>
auto volume_and_slice_indices (const Index< VolumeDim > &extents) noexcept -> std::pair< std::unique_ptr< std::pair< size_t, size_t >[], decltype(&free)>, std::array< std::pair< gsl::span< std::pair< size_t, size_t >>, gsl::span< std::pair< size_t, size_t >>>, VolumeDim >>
 Get the mapping between volume and boundary slice indices. More...
 
template<typename Tag , typename TagList >
constexpr Tag::type & get (Variables< TagList > &v) noexcept
 Return Tag::type pointing into the contiguous array. More...
 
template<std::size_t VolumeDim, typename TagsList >
void add_slice_to_data (const gsl::not_null< Variables< TagsList > *> volume_vars, const Variables< TagsList > &vars_on_slice, const Index< VolumeDim > &extents, const size_t sliced_dim, const size_t fixed_index) noexcept
 Adds data on a codimension 1 slice to a volume quantity. The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to add to the lower boundary of sliced_dim, pass 0 for fixed_index; to add to the upper boundary, pass extents[sliced_dim] - 1. More...
 
template<typename R , typename T , typename ValueType >
std::remove_const_t< R > make_with_value (const T &input, const ValueType &value) noexcept
 Given an object of type T, create an object of type R whose elements are initialized to value. More...
 
template<std::size_t VolumeDim, typename TagsList >
void data_on_slice (const gsl::not_null< Variables< TagsList > *> interface_vars, const Variables< TagsList > &vars, const Index< VolumeDim > &element_extents, const size_t sliced_dim, const size_t fixed_index) noexcept
 Slices the data within vars to a codimension 1 slice. The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to get the lower boundary of sliced_dim, pass 0 for fixed_index; to get the upper boundary, pass extents[sliced_dim] - 1. More...
 
template<std::size_t VolumeDim, typename TagsList >
Variables< TagsList > data_on_slice (const Variables< TagsList > &vars, const Index< VolumeDim > &element_extents, const size_t sliced_dim, const size_t fixed_index) noexcept
 Slices the data within vars to a codimension 1 slice. The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to get the lower boundary of sliced_dim, pass 0 for fixed_index; to get the upper boundary, pass extents[sliced_dim] - 1. More...
 
template<typename... TagsToSlice, size_t VolumeDim>
void data_on_slice (const gsl::not_null< Variables< tmpl::list< TagsToSlice... >> *> interface_vars, const Index< VolumeDim > &element_extents, const size_t sliced_dim, const size_t fixed_index, const typename TagsToSlice::type &... tensors) noexcept
 Slices volume Tensors into a Variables More...
 
template<typename... TagsToSlice, size_t VolumeDim>
Variables< tmpl::list< TagsToSlice... > > data_on_slice (const Index< VolumeDim > &element_extents, const size_t sliced_dim, const size_t fixed_index, const typename TagsToSlice::type &... tensors) noexcept
 Slices volume Tensors into a Variables More...
 
template<size_t VolumeDim, typename TagsList >
Variables< TagsList > orient_variables (const Variables< TagsList > &variables, const Index< VolumeDim > &extents, const OrientationMap< VolumeDim > &orientation_of_neighbor) noexcept
 Orient variables to the data-storage order of a neighbor element with the given orientation.
 
template<size_t VolumeDim, typename TagsList >
Variables< TagsList > orient_variables_on_slice (const Variables< TagsList > &variables_on_slice, const Index< VolumeDim - 1 > &slice_extents, const size_t sliced_dim, const OrientationMap< VolumeDim > &orientation_of_neighbor) noexcept
 Orient variables to the data-storage order of a neighbor element with the given orientation.
 

Detailed Description

Various useful data structures used in SpECTRE.

Macro Definition Documentation

◆ BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT

#define BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT (   VECTOR_TYPE,
  BLAZE_MATH_TRAIT 
)
Value:
template <> \
struct BLAZE_MATH_TRAIT<VECTOR_TYPE, VECTOR_TYPE> { \
using Type = VECTOR_TYPE; \
}; \
template <> \
struct BLAZE_MATH_TRAIT<VECTOR_TYPE, VECTOR_TYPE::value_type> { \
using Type = VECTOR_TYPE; \
}; \
template <> \
struct BLAZE_MATH_TRAIT<VECTOR_TYPE::value_type, VECTOR_TYPE> { \
using Type = VECTOR_TYPE; \
}

Instructs Blaze to provide the appropriate vector result type after math operations. This is accomplished by specializing Blaze's type traits that are used for handling return type deduction and specifying the using Type = nested type alias in the traits.

Parameters
VECTOR_TYPEThe vector type, which matches the type of the operation result (e.g. DataVector)
BLAZE_MATH_TRAITThe blaze trait/expression for which you want to specify the return type (e.g. AddTrait).

◆ BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT

#define BLAZE_TRAIT_SPECIALIZE_COMPATIBLE_BINARY_TRAIT (   VECTOR_TYPE,
  COMPATIBLE,
  BLAZE_MATH_TRAIT 
)
Value:
template <> \
struct BLAZE_MATH_TRAIT<VECTOR_TYPE, COMPATIBLE> { \
using Type = VECTOR_TYPE; \
}; \
template <> \
struct BLAZE_MATH_TRAIT<COMPATIBLE, VECTOR_TYPE> { \
using Type = VECTOR_TYPE; \
}

Instructs Blaze to provide the appropriate vector result type of an operator between VECTOR_TYPE and COMPATIBLE, where the operation is represented by BLAZE_MATH_TRAIT

Parameters
VECTOR_TYPEThe vector type, which matches the type of the operation result (e.g. ComplexDataVector)
COMPATIBLEthe type for which you want math operations to work with VECTOR_TYPE smoothly (e.g. DataVector)
BLAZE_MATH_TRAITThe blaze trait for which you want declare the Type field (e.g. AddTrait)

◆ MAKE_MATH_ASSIGN_EXPRESSION_ARITHMETIC

#define MAKE_MATH_ASSIGN_EXPRESSION_ARITHMETIC (   VECTOR_TYPE)
Value:
MAKE_MATH_ASSIGN_EXPRESSION_POINTERVECTOR(-=, VECTOR_TYPE) \
MAKE_MATH_ASSIGN_EXPRESSION_POINTERVECTOR(*=, VECTOR_TYPE) \
MAKE_MATH_ASSIGN_EXPRESSION_POINTERVECTOR(/=, VECTOR_TYPE)
#define MAKE_MATH_ASSIGN_EXPRESSION_POINTERVECTOR(OP, TYPE)
Generates the OP assignment operator for the type TYPE
Definition: PointerVector.hpp:1430

Defines MAKE_MATH_ASSIGN_EXPRESSION_POINTERVECTOR with all assignment arithmetic operations.

Parameters
VECTOR_TYPEThe vector type (e.g. DataVector)

◆ MAKE_STD_ARRAY_VECTOR_BINOPS

#define MAKE_STD_ARRAY_VECTOR_BINOPS (   VECTOR_TYPE)
Value:
DEFINE_STD_ARRAY_BINOP(VECTOR_TYPE, VECTOR_TYPE::value_type, \
VECTOR_TYPE, operator+, std::plus<>()) \
DEFINE_STD_ARRAY_BINOP(VECTOR_TYPE, VECTOR_TYPE, \
VECTOR_TYPE::value_type, operator+, std::plus<>()) \
DEFINE_STD_ARRAY_BINOP(VECTOR_TYPE, VECTOR_TYPE, VECTOR_TYPE, operator+, \
DEFINE_STD_ARRAY_BINOP(VECTOR_TYPE, VECTOR_TYPE::value_type, \
VECTOR_TYPE, operator-, std::minus<>()) \
DEFINE_STD_ARRAY_BINOP(VECTOR_TYPE, VECTOR_TYPE, \
VECTOR_TYPE::value_type, operator-, std::minus<>()) \
DEFINE_STD_ARRAY_BINOP(VECTOR_TYPE, VECTOR_TYPE, VECTOR_TYPE, operator-, \
DEFINE_STD_ARRAY_INPLACE_BINOP(VECTOR_TYPE, VECTOR_TYPE, operator-=, \
DEFINE_STD_ARRAY_INPLACE_BINOP( \
VECTOR_TYPE, VECTOR_TYPE::value_type, operator-=, std::minus<>()) \
DEFINE_STD_ARRAY_INPLACE_BINOP(VECTOR_TYPE, VECTOR_TYPE, operator+=, \
DEFINE_STD_ARRAY_INPLACE_BINOP( \
VECTOR_TYPE, VECTOR_TYPE::value_type, operator+=, std::plus<>())
#define DEFINE_STD_ARRAY_INPLACE_BINOP(LTYPE, RTYPE, OP_FUNCTION_NAME, BINARY_OP)
Declares an in-place binary function on an array, intended for operations such as += ...
Definition: StdArrayHelpers.hpp:242
#define DEFINE_STD_ARRAY_BINOP(RESULT_TYPE, LTYPE, RTYPE, OP_FUNCTION_NAME, BINARY_OP)
Declares a binary function on an array, intended for binary operators such as +
Definition: StdArrayHelpers.hpp:213

Defines the set of binary operations often supported for std::array<VECTOR_TYPE, size>, for arbitrary size.

Parameters
VECTOR_TYPEThe vector type (e.g. DataVector)

◆ MAKE_WITH_VALUE_IMPL_DEFINITION_FOR

#define MAKE_WITH_VALUE_IMPL_DEFINITION_FOR (   VECTOR_TYPE)
Value:
namespace MakeWithValueImpls { \
template <> \
struct MakeWithValueImpl<VECTOR_TYPE, VECTOR_TYPE> { \
apply(const VECTOR_TYPE& input, \
const VECTOR_TYPE::value_type value) noexcept { \
return VECTOR_TYPE(input.size(), value); \
} \
}; \
template <> \
struct MakeWithValueImpl<VECTOR_TYPE, size_t> { \
apply(const size_t& size, const VECTOR_TYPE::value_type value) noexcept { \
return VECTOR_TYPE(size, value); \
} \
}; \
}
Implementations of make_with_value.
Definition: DenseVector.hpp:61
constexpr auto apply(F &&f, const DataBox< BoxTags > &box, Args &&... args)
Apply the function f with argument Tags TagsList from DataBox box
Definition: DataBox.hpp:1595
#define SPECTRE_ALWAYS_INLINE
Always inline a function. Only use this if you benchmarked the code.
Definition: ForceInline.hpp:20

Defines the MakeWithValueImpl apply specialization.

Details

The MakeWithValueImpl<VECTOR_TYPE, VECTOR_TYPE> member apply(VECTOR_TYPE, VECTOR_TYPE::value_type) specialization defined by this macro produces an object with the same size as the input argument, initialized with the value argument in every entry.

Parameters
VECTOR_TYPEThe vector type (e.g. DataVector)

◆ VECTOR_BLAZE_TRAIT_SPECIALIZE_ALL_MAP_TRAITS

#define VECTOR_BLAZE_TRAIT_SPECIALIZE_ALL_MAP_TRAITS (   VECTOR_TYPE)
Value:
template <typename Operator> \
struct MapTrait<VECTOR_TYPE, Operator> { \
using Type = VECTOR_TYPE; \
}; \
template <typename Operator> \
struct MapTrait<VECTOR_TYPE, VECTOR_TYPE, Operator> { \
using Type = VECTOR_TYPE; \
}

Instructs Blaze to provide the appropriate vector result type of Map operations (unary and binary) acting on VECTOR_TYPE. This is accomplished by specializing Blaze's type traits that are used for handling return type deduction.

Details

Type declarations here are suitable for contiguous data (e.g. DataVector), but this macro might need to be tweaked for other types of data, for instance Fourier coefficients.

Parameters
VECTOR_TYPEThe vector type, which for the Map operations is the type of the operation result (e.g. DataVector)

◆ VECTOR_BLAZE_TRAIT_SPECIALIZE_ARITHMETIC_TRAITS

#define VECTOR_BLAZE_TRAIT_SPECIALIZE_ARITHMETIC_TRAITS (   VECTOR_TYPE)
Value:
template <> \
struct IsVector<VECTOR_TYPE> : std::true_type {}; \
template <> \
struct TransposeFlag<VECTOR_TYPE> \
: BoolConstant<VECTOR_TYPE::transpose_flag> {}; \
BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT(VECTOR_TYPE, AddTrait); \
BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT(VECTOR_TYPE, SubTrait); \
BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT(VECTOR_TYPE, MultTrait); \
BLAZE_TRAIT_SPECIALIZE_BINARY_TRAIT(VECTOR_TYPE, DivTrait)

Instructs Blaze to provide the appropriate vector result type of arithmetic operations for VECTOR_TYPE. This is accomplished by specializing Blaze's type traits that are used for handling return type deduction.

Details

Type definitions here are suitable for contiguous data (e.g. DataVector), but this macro might need to be tweaked for other types of data, for instance Fourier coefficients.

Parameters
VECTOR_TYPEThe vector type, which for the arithmetic operations is the type of the operation result (e.g. DataVector)

Function Documentation

◆ add_slice_to_data()

template<std::size_t VolumeDim, typename TagsList >
void add_slice_to_data ( const gsl::not_null< Variables< TagsList > *>  volume_vars,
const Variables< TagsList > &  vars_on_slice,
const Index< VolumeDim > &  extents,
const size_t  sliced_dim,
const size_t  fixed_index 
)
noexcept

Adds data on a codimension 1 slice to a volume quantity. The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to add to the lower boundary of sliced_dim, pass 0 for fixed_index; to add to the upper boundary, pass extents[sliced_dim] - 1.

See also
data_on_slice

◆ data_on_slice() [1/4]

template<std::size_t VolumeDim, typename TagsList >
void data_on_slice ( const gsl::not_null< Variables< TagsList > *>  interface_vars,
const Variables< TagsList > &  vars,
const Index< VolumeDim > &  element_extents,
const size_t  sliced_dim,
const size_t  fixed_index 
)
noexcept

Slices the data within vars to a codimension 1 slice. The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to get the lower boundary of sliced_dim, pass 0 for fixed_index; to get the upper boundary, pass extents[sliced_dim] - 1.

See also
add_slice_to_data

returns Variables class sliced to a hypersurface.

◆ data_on_slice() [2/4]

template<std::size_t VolumeDim, typename TagsList >
Variables<TagsList> data_on_slice ( const Variables< TagsList > &  vars,
const Index< VolumeDim > &  element_extents,
const size_t  sliced_dim,
const size_t  fixed_index 
)
noexcept

Slices the data within vars to a codimension 1 slice. The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to get the lower boundary of sliced_dim, pass 0 for fixed_index; to get the upper boundary, pass extents[sliced_dim] - 1.

See also
add_slice_to_data

returns Variables class sliced to a hypersurface.

◆ data_on_slice() [3/4]

template<typename... TagsToSlice, size_t VolumeDim>
void data_on_slice ( const gsl::not_null< Variables< tmpl::list< TagsToSlice... >> *>  interface_vars,
const Index< VolumeDim > &  element_extents,
const size_t  sliced_dim,
const size_t  fixed_index,
const typename TagsToSlice::type &...  tensors 
)
noexcept

Slices volume Tensors into a Variables

The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to get the lower boundary of sliced_dim, pass 0 for fixed_index; to get the upper boundary, pass extents[sliced_dim] - 1.

◆ data_on_slice() [4/4]

template<typename... TagsToSlice, size_t VolumeDim>
Variables<tmpl::list<TagsToSlice...> > data_on_slice ( const Index< VolumeDim > &  element_extents,
const size_t  sliced_dim,
const size_t  fixed_index,
const typename TagsToSlice::type &...  tensors 
)
noexcept

Slices volume Tensors into a Variables

The slice has a constant logical coordinate in direction sliced_dim, slicing the volume at fixed_index in that dimension. For example, to get the lower boundary of sliced_dim, pass 0 for fixed_index; to get the upper boundary, pass extents[sliced_dim] - 1.

◆ get()

template<typename Tag , typename TagList >
constexpr Tag::type& get ( Variables< TagList > &  v)
noexcept

Return Tag::type pointing into the contiguous array.

Template Parameters
Tagthe variable to return

◆ make_with_value()

template<typename R , typename T , typename ValueType >
std::remove_const_t<R> make_with_value ( const T &  input,
const ValueType &  value 
)
noexcept

Given an object of type T, create an object of type R whose elements are initialized to value.

Details

This function is useful in function templates in order to initialize the return type of a function template with value for functions that can be called either at a single grid-point or to fill a data structure at the same set of grid-points as the input

Template Parameters
ValueTypeThe type of value. For many containers, this will be double, but when making a ComplexDataVector with value, std::complex<double> is appropriate.
See also
MakeWithValueImpls

◆ volume_and_slice_indices()

template<size_t VolumeDim>
auto volume_and_slice_indices ( const Index< VolumeDim > &  extents) -> std::pair< std::unique_ptr< std::pair< size_t, size_t >[], decltype(&free)>, std::array< std::pair< gsl::span< std::pair< size_t, size_t >>, gsl::span< std::pair< size_t, size_t >>>, VolumeDim >>
noexcept

Get the mapping between volume and boundary slice indices.

SliceIterator is used to map between the index of a point on a slice in the volume data and the index in the corresponding sliced data. Repeatedly applying the SliceIterator on various components of a tensor becomes very expensive and so precomputing the index map is sometimes advantageous. This function computes the index map onto all boundary slices of volume mesh with extents extents.

The unique_ptr is where the volume and slice indices are stored in memory, the array holds views into the memory buffer. The index of the array is the fixed dimension, the outer pair holds the indices for the lower and upper side, respectively, while the pairs in the spans hold the volume and slice indices, respectively.