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

Wraps any analytic InitialData and adds uniform random noise to selected evolution variables after the inner solution has initialized them. More...

#include <WithNoise.hpp>

Classes

struct  Amplitude
 Amplitude \(A\) of the noise interval \([-A,\,A]\). More...
struct  AmplitudeType
 Whether Amplitude is absolute or relative to the maximum absolute value of each variable on each element. More...
struct  Seed
 Seed for the random number generator. More...
struct  Solution
 The analytic initial data to wrap. More...
struct  Variables
 Names of evolution variables to perturb, or [All] for all. More...

Public Types

using options

Public Member Functions

 WithNoise (const WithNoise &rhs)
WithNoise & operator= (const WithNoise &rhs)
 WithNoise (WithNoise &&)=default
WithNoise & operator= (WithNoise &&)=default
 WithNoise (std::unique_ptr< evolution::initial_data::InitialData > solution, double amplitude, NoiseAmplitudeType amplitude_type, std::optional< size_t > seed, std::vector< std::string > variables)
std::unique_ptr< evolution::initial_data::InitialData > get_clone () const override
void pup (PUP::er &p) override
const evolution::initial_data::InitialData & solution () const
const evolution::initial_data::InitialData & unwrap () const override
 Unwrap to the inner analytic solution, recursively resolving nested WithNoise wrappers.
double amplitude () const
NoiseAmplitudeType amplitude_type () const
size_t seed () const
const std::vector< std::string > & variables () const

Static Public Attributes

static constexpr Options::String help

Friends

bool operator== (const WithNoise &lhs, const WithNoise &rhs)
bool operator!= (const WithNoise &lhs, const WithNoise &rhs)

Detailed Description

Wraps any analytic InitialData and adds uniform random noise to selected evolution variables after the inner solution has initialized them.

Details

The inner solution first sets all evolution variables in the normal way. Then each variable whose db::tag_name appears in Variables (or every variable if All is listed) has independent noise from \(\text{Uniform}[-A,\,A]\) added to every grid point and every independent tensor component. If AmplitudeType is Absolute, \(A\) is Amplitude. If AmplitudeType is Relative, \(A\) is Amplitude times the maximum absolute value of the variable on the element, taken over all of its independent components and grid points. Relative noise is therefore suited to systems whose variables differ greatly in magnitude. Because the maximum is computed element by element, \(A\) can differ slightly between elements, and a variable that is identically zero on an element (e.g. Pi for Minkowski) receives no noise there; use Absolute to perturb such variables.

Valid variable names are the db::tag_names of the system's evolution variables. Examples:

  • ScalarWave: Psi, Pi, Phi
  • GeneralizedHarmonic: SpacetimeMetric, Pi, Phi

Different elements receive independent noise because the RNG seed is mixed with the inertial coordinates of each element's first grid point. Set Seed to a fixed integer for reproducible results.

Note
Only analytic initial data (analytic solutions or analytic data) are supported as the inner Solution.
Nesting WithNoise inside WithNoise is not supported.
Systems with primitive and conservative variables (e.g. ValenciaDivClean, NewtonianEuler) are not yet supported and trigger a static_assert in evolution::Initialization::Actions::SetVariables.
GeneralizedHarmonic systems: the initialization phase InitializeInitialDataDependentQuantities runs gh::gauges::SetPiAndPhiFromConstraints after WithNoise applies noise. That action unconditionally overwrites Phi with the numerical spatial derivative of SpacetimeMetric and recomputes Pi from the gauge source function and the current geometry. As a result, noise added to Pi or Phi is effectively erased. Only noise added to SpacetimeMetric persists and propagates into the other variables: it appears in Phi amplified by roughly one over the grid spacing (due to differentiation), and in Pi through the geometric quantities (lapse, shift) extracted from the metric.

Example input-file snippet for ScalarWave:

InitialData:
WithNoise:
Amplitude: 1.0e-6
AmplitudeType: Absolute
Seed: 42
Variables: [Psi, Pi]
Solution:
PlaneWave:
...

Member Typedef Documentation

◆ options

using evolution::initial_data::WithNoise::options
Initial value:
tmpl::list<Solution, Amplitude, AmplitudeType, Seed, Variables>

Member Function Documentation

◆ get_clone()

std::unique_ptr< evolution::initial_data::InitialData > evolution::initial_data::WithNoise::get_clone ( ) const
overridevirtual

◆ unwrap()

const evolution::initial_data::InitialData & evolution::initial_data::WithNoise::unwrap ( ) const
inlineoverridevirtual

Unwrap to the inner analytic solution, recursively resolving nested WithNoise wrappers.

Reimplemented from evolution::initial_data::InitialData.

Member Data Documentation

◆ help

Options::String evolution::initial_data::WithNoise::help
staticconstexpr
Initial value:
=
"Wraps any analytic initial data and adds uniform random noise to "
"selected evolution variables after the inner solution sets them."

The documentation for this class was generated from the following file:
  • src/PointwiseFunctions/InitialDataUtilities/WithNoise.hpp