SpECTRE  v2026.09.05
Loading...
Searching...
No Matches
evolution::initial_data Namespace Reference

Namespace for things related to initial data used for evolution systems. More...

Namespaces

namespace  OptionTags
 Option tags for initial data of evolution system.
namespace  Tags
 Tags for initial data of evolution system.

Classes

class  InitialData
 The abstract base class for initial data of evolution systems. All analytic solutions and analytic data must virtually inherit from this class. More...
class  NumericData
 Load numeric data from volume data files. More...
class  WithNoise
 Wraps any analytic InitialData and adds uniform random noise to selected evolution variables after the inner solution has initialized them. More...

Enumerations

enum class  NoiseAmplitudeType : uint8_t { Absolute , Relative }
 How the noise amplitude passed to add_noise_to_tensor is interpreted. More...

Functions

bool operator== (const NumericData &lhs, const NumericData &rhs)
bool operator!= (const NumericData &lhs, const NumericData &rhs)
std::ostream & operator<< (std::ostream &os, NoiseAmplitudeType value)
template<typename TensorType>
void add_noise_to_tensor (gsl::not_null< TensorType * > tensor, double amplitude, NoiseAmplitudeType amplitude_type, size_t element_seed, size_t component_offset)
 Add uniform random noise to all stored components of tensor.
template<size_t Dim>
size_t make_element_seed (size_t base_seed, const tnsr::I< DataVector, Dim, Frame::Inertial > &inertial_coords)
 Combine base_seed with the first grid point of inertial_coords to produce a per-element RNG seed.

Detailed Description

Namespace for things related to initial data used for evolution systems.

Enumeration Type Documentation

◆ NoiseAmplitudeType

enum class evolution::initial_data::NoiseAmplitudeType : uint8_t
strong

How the noise amplitude passed to add_noise_to_tensor is interpreted.

Enumerator
Absolute 

The noise is drawn from \([-A,\,A]\).

Relative 

The noise is drawn from \([-A M,\,A M]\), where \(M\) is the maximum absolute value over all stored components and grid points of the tensor being perturbed.

Function Documentation

◆ add_noise_to_tensor()

template<typename TensorType>
void evolution::initial_data::add_noise_to_tensor ( gsl::not_null< TensorType * > tensor,
double amplitude,
NoiseAmplitudeType amplitude_type,
size_t element_seed,
size_t component_offset )

Add uniform random noise to all stored components of tensor.

Each independent stored component receives noise drawn independently from \(\text{Uniform}[-A,\,A]\). For NoiseAmplitudeType::Absolute, \(A\) is amplitude. For NoiseAmplitudeType::Relative, \(A\) is amplitude times the maximum absolute value over all stored components and grid points of tensor, so a tensor that is identically zero receives no noise. The RNG seed for component \(i\) is hash(element_seed, component_offset + i), so calling this function with different component_offset values keeps separate tensor fields independent even when element_seed is the same.

Parameters
tensorTensor to perturb in place.
amplitudeSets \(\pm A\) of the noise interval (absolute or relative, depending on amplitude_type).
amplitude_typeWhether amplitude is absolute or relative to the maximum absolute value of tensor.
element_seedPer-element seed, typically constructed by hashing a base seed with the inertial coordinates of the element's first grid point.
component_offsetOffset added to the component index before hashing, used to keep different tensor fields independent.

◆ make_element_seed()

template<size_t Dim>
size_t evolution::initial_data::make_element_seed ( size_t base_seed,
const tnsr::I< DataVector, Dim, Frame::Inertial > & inertial_coords )

Combine base_seed with the first grid point of inertial_coords to produce a per-element RNG seed.

Because most domains have elements have distinct first grid points, this gives independent noise on almost every element even when base_seed is the same.