The test suite is extensive. Note that LLMs were used to aid in the development of the test suite. All LLM generated code was manually reviewed.
37 lines
1.5 KiB
C++
37 lines
1.5 KiB
C++
#include <cmath>
|
|
#include <print>
|
|
|
|
#include "serif/mapping/mapping.hpp"
|
|
#include "serif/types.hpp"
|
|
|
|
/** @brief Map an exterior reference point toward physical infinity using the selected native vector storage. */
|
|
int main() {
|
|
namespace mapping = serif::mapping;
|
|
namespace compactification = mapping::compactification;
|
|
|
|
const compactification::KelvinCompactification exterior({.r_star_ref = 1.0, .r_inf_ref = 4.0});
|
|
serif::Vector position(3), coordinate_gradient(3);
|
|
position = 0.0;
|
|
position[0] = 2.0;
|
|
coordinate_gradient = 0.0;
|
|
coordinate_gradient[0] = 1.0 / 3.0;
|
|
serif::DenseMatrix displacement_jacobian(3);
|
|
displacement_jacobian = 0.0;
|
|
for (int dimension = 0; dimension < 3; ++dimension) {
|
|
displacement_jacobian(dimension, dimension) = 1.0;
|
|
}
|
|
const compactification::ExteriorMapInput input{
|
|
.reference_position = position, .displaced_position = position,
|
|
.displacement_jacobian = displacement_jacobian,
|
|
.compactification_coordinate_gradient = coordinate_gradient,
|
|
.compactification_coordinate = 1.0 / 3.0};
|
|
compactification::ExteriorMapResult result;
|
|
const auto status = exterior.evaluate(input, result);
|
|
if (status != mapping::MappingStatus::VALID) {
|
|
std::println(stderr, "Exterior mapping failed.");
|
|
return 1;
|
|
}
|
|
std::println("Reference radius {} maps to physical radius {}", position[0], result.physical_position[0]);
|
|
return std::isfinite(result.physical_position[0]) ? 0 : 1;
|
|
}
|