SpECTRE  v2026.11.11
Loading...
Searching...
No Matches
TestHelpers Namespace Reference

Collection of classes and functions useful for testing. More...

Namespaces

namespace  AnalyticData
 Functions for testing analytic data.
namespace  AnalyticSolutions
 Functions for testing analytic solutions.
namespace  elliptic
 Helper functions to test elliptic first-order systems.
namespace  gr
 Make random GR variables which correct physical behavior, e.g. spatial metric will be positive definite.
namespace  hydro
 Make random hydro variables which correct physical behavior, e.g. Lorentz factor will be greater or equal than one.
namespace  serialization
 Collection of classes and functions for testing serialization.
namespace  tenex
 Functions for testing TensorExpressions.
namespace  VerifyGrSolution
 Functions for testing GR analytic solutions.

Functions

template<typename T, typename Metavariables = NoSuchType>
T test_creation (const std::string &construction_string)
 Creates an instance of a given option-creatable type.
template<typename OptionTag, typename Metavariables = NoSuchType>
TestCreation_detail::option_return_t< OptionTag > test_option_tag (const std::string &construction_string)
 Runs the option parser on a given tag.
template<typename BaseClass, typename DerivedClass>
std::unique_ptr< BaseClass > test_factory_creation (const std::string &construction_string)
 Creates a class of a known derived type using a factory.
template<typename OptionTag, typename DerivedClass>
OptionTag::type test_option_tag_factory_creation (const std::string &construction_string)
 A wrapper that allows testing an option tag without having to write a Metavariables class. Combines TestHelpers::test_factory_creation() and TestHelpers::test_option_tag().
void do_something (gsl::not_null< SomeType * >)
template<typename Function>
void check_on_device (const Function &function, const Approx &custom_approx=approx)
 Checks that function gives the same results in a Kokkos kernel as on the host.

Detailed Description

Collection of classes and functions useful for testing.

Function Documentation

◆ check_on_device()

template<typename Function>
void TestHelpers::check_on_device ( const Function & function,
const Approx & custom_approx = approx )

Checks that function gives the same results in a Kokkos kernel as on the host.

function must be callable on the host and the device without arguments (e.g. a KOKKOS_LAMBDA that captures its inputs) and return a std::array of the values to compare. Floating-point values are compared with custom_approx (approx by default) rather than exactly, because device code may be compiled differently (e.g. with fused multiply-adds).

Note
You must run, not just compile, the tests. nvcc can compile code that will give wrong results (e.g. host standard library algorithms).