SpECTRE
v2025.03.17
|
Holds helper functions for use with domain::CoordinateMaps::FocallyLiftedMap. More...
Functions | |
template<typename T > | |
void | scale_factor (const gsl::not_null< tt::remove_cvref_wrap_t< T > * > &result, const std::array< T, 3 > &src_point, const std::array< double, 3 > &proj_center, const std::array< double, 3 > &sphere_center, double radius, bool src_is_between_proj_and_target) |
Finds how long to extend a line segment to have it intersect a point on a 2-sphere. More... | |
std::optional< double > | try_scale_factor (const std::array< double, 3 > &src_point, const std::array< double, 3 > &proj_center, const std::array< double, 3 > &sphere_center, double radius, bool pick_larger_root, bool pick_root_greater_than_one, bool solve_for_root_minus_one=true) |
template<typename T > | |
void | d_scale_factor_d_src_point (const gsl::not_null< std::array< tt::remove_cvref_wrap_t< T >, 3 > * > &result, const std::array< T, 3 > &intersection_point, const std::array< double, 3 > &proj_center, const std::array< double, 3 > &sphere_center, const T &lambda) |
Holds helper functions for use with domain::CoordinateMaps::FocallyLiftedMap.
void domain::CoordinateMaps::FocallyLiftedMapHelpers::d_scale_factor_d_src_point | ( | const gsl::not_null< std::array< tt::remove_cvref_wrap_t< T >, 3 > * > & | result, |
const std::array< T, 3 > & | intersection_point, | ||
const std::array< double, 3 > & | proj_center, | ||
const std::array< double, 3 > & | sphere_center, | ||
const T & | lambda | ||
) |
Computes scale_factor
and x_0
is src_point
in the scale_factor
function.
The formula (see FocallyLiftedMap
) is
Note that it takes intersection_point
and not src_point
as a parameter.
In the arguments to the function below, intersection_point
is proj_center
is sphere_center
is radius
is
void domain::CoordinateMaps::FocallyLiftedMapHelpers::scale_factor | ( | const gsl::not_null< tt::remove_cvref_wrap_t< T > * > & | result, |
const std::array< T, 3 > & | src_point, | ||
const std::array< double, 3 > & | proj_center, | ||
const std::array< double, 3 > & | sphere_center, | ||
double | radius, | ||
bool | src_is_between_proj_and_target | ||
) |
Finds how long to extend a line segment to have it intersect a point on a 2-sphere.
Consider a 2-sphere with center
Consider the line passing through
where
scale_factor
computes and returns
To solve for
(where
or equivalently
This is a quadratic equation for
So how do we choose between multiple roots? Some of the maps that use scale_factor
assume that for all points, src_is_between_proj_and_target
to true. Other maps assume that for all points, src_is_between_proj_and_target
to false.
src_is_between_proj_and_target
can change from point to point, the logic of scale_factor
needs to be changed.In the arguments to the function below, src_point
is proj_center
is sphere_center
is radius
is
std::optional< double > domain::CoordinateMaps::FocallyLiftedMapHelpers::try_scale_factor | ( | const std::array< double, 3 > & | src_point, |
const std::array< double, 3 > & | proj_center, | ||
const std::array< double, 3 > & | sphere_center, | ||
double | radius, | ||
bool | pick_larger_root, | ||
bool | pick_root_greater_than_one, | ||
bool | solve_for_root_minus_one = true |
||
) |
Solves a problem of the same form as scale_factor
, but is used only by the inverse function to compute try_scale_factor
is used in two contexts:
try_scale_factor
is used to determine
try_scale_factor
is used by the lambda_tilde
functions of some of the InnerMap
classes (namely those InnerMap
classes where
In both of these contexts, the input parameter src_point
is FocallyLiftedMap
. Because the inverse function can be and is called for an arbitrary FocallyLiftedMap
, try_scale_factor
returns a std::optional, with a default-constructed std::optional if the roots it finds are not as expected (i.e. if the inverse map was called for a point not in the range of the map).
Because try_scale_factor
can be called in different situations, it has additional boolean arguments pick_larger_root
and pick_root_greater_than_one
that allow the caller to choose which root to return.
Furthermore, to reduce roundoff errors near solve_for_root_minus_one
to be false
.
try_scale_factor
is not templated on type because it is used only by the inverse function, which works only on doubles.