Testing facilities
-
constexpr const int MultiPatchTests::random_seed = 100
Seed value of the random number generation engines.
-
constexpr const CCTK_REAL MultiPatchTests::fd_delta = 1.0e-3
The “grid spacing” used in finite difference operators
-
constexpr const CCTK_REAL MultiPatchTests::fd_comp_tol = 1.0e-7
The floating point comparison tolerance when testing the equality of exact and FD computed derivatives
-
template<typename fp_type>
inline bool MultiPatchTests::isapprox(fp_type x, fp_type y, fp_type atol = 0.0) Test two floating point values for approximate equality.
This function is based on the Julia langage implementation
- Inputs:
fp_type
: A floating point type.fp_type x
: The first number to compare.fp_type y
: The second number to compare.fp_type atol
: The absolute tolerance for the comparison.fp_type rtol
: The relative tolerance of the comparison.
- Returns:
True if
x
~y
, false otherwise.
-
template<typename T>
inline bool MultiPatchTests::within(T variable, T boundary) Test if
-boundary < variable < boundary
. Fails ifvariable ~= (+/- boundary)
.- Inputs:
T
: A floating point type.T variable
: The variable to test.T boundary
: The absolute value of the region boundary
- Returns:
True if the variable is within the region, false otherwise.
-
template<typename T>
inline bool MultiPatchTests::at_boundary(T variable, T boundary) Test if
-boundary ~= variable
orvariable ~= boundary
.- Inputs
T
: A floating point type.T variable
: The variable to test.T boundary
: The absolute value of the region boundary
- Returns:
True if
variable ~= boundary
, false otherwise.
-
enum class MultiPatchTests::string_color
Tag representing possible colors to apply to diagnostic strings.
Values:
-
enumerator green
-
enumerator red
-
enumerator green
-
template<string_color color>
std::string MultiPatchTests::colored(const std::string &str) Formats a string to be colored in ANSI compatible terminals.
- Inputs:
string_color color
: The color to use.std::string &str
: The string to color.
- Returns:
The colored string.
-
const auto MultiPatchTests::PASSED = colored<string_color::green>("PASSED")
Test passed banner.
-
const auto MultiPatchTests::FAILED = colored<string_color::red>("FAILED")
Test failed banner.
-
enum class MultiPatchTests::fd_direction
Tags for the direction that a finite difference derivative will be performed
Values:
-
enumerator x
-
enumerator y
-
enumerator z
-
enumerator x
-
template<fd_direction dir, typename vector_t, typename function_t>
inline vector_t MultiPatchTests::fd_4(const function_t &function, const vector_t &point) Computes the fourth order accurate finite difference approximation to the first derivative of a function that takes a vector as input and produces another vector as output in a specified direction.
- Inputs:
fd_direction dir
: The direction of the derivativevector_t
: A vector/array type.function_t
: The type signature of the function being derived.function_t &function
: The function to be derived.const vector_t &point
: The point where the derivative is to be computed.
- Returns:
The first derivative of function in the specified direction and point.
-
template<fd_direction dir_inner, fd_direction dir_outer, typename vector_t, typename function_t>
inline vector_t MultiPatchTests::fd2_4(const function_t &function, const vector_t &point) Computes the fourth order accurate finite difference approximation to the second derivative of a function that takes a vector as input and produces another vector as output in a specified direction.
- Inputs:
fd_direction dir_inner
: The direction of the first derivativefd_direction dir_inner
: The direction of the second derivativevector_t
: A vector/array type.function_t
: The type signature of the function being derived.function_t &function
: The function to be derived.const vector_t &point
: The point where the derivative is to be computed.
- Returns:
The second derivative of function in the specified direction and point.