SpECTRE  v2026.04.01
Loading...
Searching...
No Matches
domain::CoordinateMap< SourceFrame, TargetFrame, Maps > Class Template Reference

A coordinate map or composition of coordinate maps. More...

#include <CoordinateMap.hpp>

Public Types

using source_frame = SourceFrame
using target_frame = TargetFrame
using maps_list = tmpl::list<Maps...>
Public Types inherited from domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >
using source_frame
using target_frame

Public Member Functions

 CoordinateMap ()=default
 Used for Charm++ serialization.
 CoordinateMap (const CoordinateMap &)=default
CoordinateMapoperator= (const CoordinateMap &)=default
 CoordinateMap (CoordinateMap &&)=default
CoordinateMapoperator= (CoordinateMap &&)=default
 CoordinateMap (Maps... maps)
std::unique_ptr< CoordinateMapBase< SourceFrame, TargetFrame, dim > > get_clone () const override
std::unique_ptr< CoordinateMapBase< SourceFrame, Frame::Grid, dim > > get_to_grid_frame () const override
 Retrieve the same map but going from SourceFrame to Frame::Grid.
bool is_identity () const override
 Returns true if the map is the identity.
bool inv_jacobian_is_time_dependent () const override
 Returns true if the inverse Jacobian depends on time.
bool jacobian_is_time_dependent () const override
 Returns true if the Jacobian depends on time.
const std::unordered_set< std::string > & function_of_time_names () const override
 Get a set of all FunctionOfTime names from Maps
bool supports_hessian () const override
 Returns true if this coordinate map supports hessian.
 WRAPPED_PUPable_decl_base_template (SINGLE_ARG(CoordinateMapBase< SourceFrame, TargetFrame, dim >), CoordinateMap)
 CoordinateMap (CkMigrateMessage *)
void pup (PUP::er &p) override
tnsr::I< double, dim, TargetFrame > operator() (tnsr::I< double, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Apply the Maps... to the point(s) source_point
tnsr::I< DataVector, dim, TargetFrame > operator() (tnsr::I< DataVector, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Apply the Maps... to the point(s) source_point
tnsr::I< autodiff::HigherOrderDual< 2, double >, dim, TargetFrame > operator() (tnsr::I< autodiff::HigherOrderDual< 2, double >, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Apply the Maps... to the point(s) source_point
tnsr::I< autodiff::HigherOrderDual< 2, simd::batch< double > >, dim, TargetFrame > operator() (tnsr::I< autodiff::HigherOrderDual< 2, simd::batch< double > >, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Apply the Maps... to the point(s) source_point
std::optional< tnsr::I< double, dim, SourceFrame > > inverse (tnsr::I< double, dim, TargetFrame > target_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Apply the inverse Maps... to the point(s) target_point
InverseJacobian< double, dim, SourceFrame, TargetFrame > inv_jacobian (tnsr::I< double, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Compute the inverse Jacobian of the Maps... at the point(s) source_point
InverseJacobian< DataVector, dim, SourceFrame, TargetFrame > inv_jacobian (tnsr::I< DataVector, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Compute the inverse Jacobian of the Maps... at the point(s) source_point
InverseJacobian< autodiff::HigherOrderDual< 2, double >, dim, SourceFrame, TargetFrame > inv_jacobian (tnsr::I< autodiff::HigherOrderDual< 2, double >, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Compute the inverse Jacobian of the Maps... at the point(s) source_point
InverseHessian< double, dim, SourceFrame, TargetFrame > inv_hessian (tnsr::I< double, dim, SourceFrame > source_point, const ::InverseJacobian< double, dim, SourceFrame, TargetFrame > &inverse_jac, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
InverseHessian< DataVector, dim, SourceFrame, TargetFrame > inv_hessian (tnsr::I< DataVector, dim, SourceFrame > source_point, const ::InverseJacobian< DataVector, dim, SourceFrame, TargetFrame > &inverse_jac, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
Jacobian< double, dim, SourceFrame, TargetFrame > jacobian (tnsr::I< double, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Compute the Jacobian of the Maps... at the point(s) source_point
Jacobian< DataVector, dim, SourceFrame, TargetFrame > jacobian (tnsr::I< DataVector, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const override
 Compute the Jacobian of the Maps... at the point(s) source_point
auto coords_frame_velocity_jacobians (tnsr::I< double, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const -> std::tuple< tnsr::I< double, dim, TargetFrame >, InverseJacobian< double, dim, SourceFrame, TargetFrame >, Jacobian< double, dim, SourceFrame, TargetFrame >, tnsr::I< double, dim, TargetFrame > > override
 Compute the mapped coordinates, frame velocity, Jacobian, and inverse Jacobian. The inverse Jacobian is computed by numerically inverting the Jacobian as this was measured to be quicker than computing it directly for more complex map concatenations.
auto coords_frame_velocity_jacobians (tnsr::I< DataVector, dim, SourceFrame > source_point, const double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const -> std::tuple< tnsr::I< DataVector, dim, TargetFrame >, InverseJacobian< DataVector, dim, SourceFrame, TargetFrame >, Jacobian< DataVector, dim, SourceFrame, TargetFrame >, tnsr::I< DataVector, dim, TargetFrame > > override
 Compute the mapped coordinates, frame velocity, Jacobian, and inverse Jacobian. The inverse Jacobian is computed by numerically inverting the Jacobian as this was measured to be quicker than computing it directly for more complex map concatenations.
Public Member Functions inherited from domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >
 WRAPPED_PUPable_abstract (CoordinateMapBase)
CoordinateMapBaseoperator= (const CoordinateMapBase &)=default
virtual tnsr::I< double, Dim, TargetFrame > operator() (tnsr::I< double, Dim, SourceFrame > source_point, double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const=0
 Apply the Maps to the point(s) source_point
virtual std::optional< tnsr::I< double, Dim, SourceFrame > > inverse (tnsr::I< double, Dim, TargetFrame > target_point, double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const=0
 Apply the inverse Maps to the point(s) target_point. The returned std::optional is invalid if the map is not invertible at target_point, or if target_point can be easily determined to not make sense for the map. An example of the latter is passing a point with a negative value of z into a positive-z Wedge<3> inverse map. The inverse function is only callable with doubles because the inverse might fail if called for a point out of range, and it is unclear what should happen if the inverse were to succeed for some points in a DataVector but fail for other points.
virtual InverseJacobian< double, Dim, SourceFrame, TargetFrame > inv_jacobian (tnsr::I< double, Dim, SourceFrame > source_point, double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const=0
 Compute the inverse Jacobian of the Maps at the point(s) source_point
virtual InverseHessian< double, Dim, SourceFrame, TargetFrame > inv_hessian (tnsr::I< double, Dim, SourceFrame > source_point, const InverseJacobian< double, Dim, SourceFrame, TargetFrame > &inverse_jac, double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const=0
 Compute the inverse Hessian of the Maps at the point(s) source_point
virtual Jacobian< double, Dim, SourceFrame, TargetFrame > jacobian (tnsr::I< double, Dim, SourceFrame > source_point, double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const=0
 Compute the Jacobian of the Maps at the point(s) source_point
virtual auto coords_frame_velocity_jacobians (tnsr::I< double, Dim, SourceFrame > source_point, double time=std::numeric_limits< double >::signaling_NaN(), const FunctionsOfTimeMap &functions_of_time={}) const -> std::tuple< tnsr::I< double, Dim, TargetFrame >, InverseJacobian< double, Dim, SourceFrame, TargetFrame >, Jacobian< double, Dim, SourceFrame, TargetFrame >, tnsr::I< double, Dim, TargetFrame > >=0
 Compute the mapped coordinates, frame velocity, Jacobian, and inverse Jacobian.

Static Public Attributes

static constexpr size_t dim = CoordinateMaps::map_dim<Maps...>
Static Public Attributes inherited from domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >
static constexpr size_t dim

Friends

bool operator== (const CoordinateMap &lhs, const CoordinateMap &rhs)
template<typename NewMap, typename LocalSourceFrame, typename LocalTargetFrame, typename... LocalMaps, size_t... Is>
CoordinateMap< LocalSourceFrame, LocalTargetFrame, LocalMaps..., NewMap > push_back_impl (CoordinateMap< LocalSourceFrame, LocalTargetFrame, LocalMaps... > &&old_map, NewMap new_map, std::index_sequence< Is... >)
template<typename... NewMaps, typename LocalSourceFrame, typename LocalTargetFrame, typename... LocalMaps, size_t... Is, size_t... Js>
CoordinateMap< LocalSourceFrame, LocalTargetFrame, LocalMaps..., NewMaps... > push_back_impl (CoordinateMap< LocalSourceFrame, LocalTargetFrame, LocalMaps... > &&old_map, CoordinateMap< LocalSourceFrame, LocalTargetFrame, NewMaps... > new_map, std::index_sequence< Is... >, std::index_sequence< Js... >)
template<typename NewMap, typename LocalSourceFrame, typename LocalTargetFrame, typename... LocalMaps, size_t... Is>
CoordinateMap< LocalSourceFrame, LocalTargetFrame, NewMap, LocalMaps... > push_front_impl (CoordinateMap< LocalSourceFrame, LocalTargetFrame, LocalMaps... > &&old_map, NewMap new_map, std::index_sequence< Is... >)

Detailed Description

template<typename SourceFrame, typename TargetFrame, typename... Maps>
class domain::CoordinateMap< SourceFrame, TargetFrame, Maps >

A coordinate map or composition of coordinate maps.

Maps coordinates from the SourceFrame to the TargetFrame using the coordinate maps Maps.... The individual maps are applied left to right from the source to the target Frame. The inverse map, as well as Jacobian and inverse Jacobian are also provided. The CoordinateMap class must be used even if just wrapping a single coordinate map. It is designed to be an extremely minimal interface to the underlying coordinate maps. For a list of all coordinate maps see the CoordinateMaps group or namespace.

Each coordinate map must contain a static constexpr size_t dim variable that is equal to the dimensionality of the map. The Coordinatemap class contains a member static constexpr size_t dim, a type alias source_frame, a type alias target_frame and typelist of the Maps...`.

Member Function Documentation

◆ function_of_time_names()

template<typename SourceFrame, typename TargetFrame, typename... Maps>
const std::unordered_set< std::string > & domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::function_of_time_names ( ) const
inlineoverridevirtual

Get a set of all FunctionOfTime names from Maps

Implements domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >.

◆ get_clone()

template<typename SourceFrame, typename TargetFrame, typename... Maps>
std::unique_ptr< CoordinateMapBase< SourceFrame, TargetFrame, dim > > domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::get_clone ( ) const
inlineoverridevirtual

◆ get_to_grid_frame()

template<typename SourceFrame, typename TargetFrame, typename... Maps>
std::unique_ptr< CoordinateMapBase< SourceFrame, Frame::Grid, dim > > domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::get_to_grid_frame ( ) const
inlineoverridevirtual

Retrieve the same map but going from SourceFrame to Frame::Grid.

This functionality is needed when composing time-dependent maps with time-independent maps, where the target frame of the time-independent map is Frame::Grid.

Implements domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >.

◆ inv_hessian() [1/2]

template<typename SourceFrame, typename TargetFrame, typename... Maps>
InverseHessian< DataVector, dim, SourceFrame, TargetFrame > domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::inv_hessian ( tnsr::I< DataVector, dim, SourceFrame > source_point,
const ::InverseJacobian< DataVector, dim, SourceFrame, TargetFrame > & inverse_jac,
const double time = std::numeric_limits<double>::signaling_NaN(),
const FunctionsOfTimeMap & functions_of_time = {} ) const
inlineoverride

Compute the inverse Hessian of the Maps... at the point(s) source_point by computing the Hessian of the Maps... and compose it with inverse Jacobians of the Maps....

This function propagates autodiff dual types through the call_impl function to automatically get the Hessian \( \frac{\partial^2 x^i}{\partial\xi^j \partial\xi^k} \) where \( x^i \) are the target coordinates and \( \xi^i \) are the source coordinates. Then the inverse Hessian is computed by the identity

\[\frac{\partial^2 \xi^i}{\partial x^m \partial x^n} = -\frac{\partial \xi^i}{\partial x^j} \frac{\partial \xi^k}{\partial x^m} \frac{\partial \xi^l}{\partial x^n} \frac{\partial^2 x^j}{\partial \xi^k \partial \xi^l}, \]

where the inverse Jacobian is passed in as a function argument.

See Test_CoordinateMap.cpp for a different implementation. The current implementation is chosen in production as it is faster when we have the inverse Jacobian already, and in most cases we do.

We use forward mode autodiff here as it is simpler to implement and has better optimization than the reverse mode. Reverse mode in the Autodiff library has higher cost per propagation and does not support taping. Also see this github issue.

Note
Require SPECTRE_AUTODIFF=ON.

◆ inv_hessian() [2/2]

template<typename SourceFrame, typename TargetFrame, typename... Maps>
InverseHessian< double, dim, SourceFrame, TargetFrame > domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::inv_hessian ( tnsr::I< double, dim, SourceFrame > source_point,
const ::InverseJacobian< double, dim, SourceFrame, TargetFrame > & inverse_jac,
const double time = std::numeric_limits<double>::signaling_NaN(),
const FunctionsOfTimeMap & functions_of_time = {} ) const
inlineoverride

Compute the inverse Hessian of the Maps... at the point(s) source_point by computing the Hessian of the Maps... and compose it with inverse Jacobians of the Maps....

This function propagates autodiff dual types through the call_impl function to automatically get the Hessian \( \frac{\partial^2 x^i}{\partial\xi^j \partial\xi^k} \) where \( x^i \) are the target coordinates and \( \xi^i \) are the source coordinates. Then the inverse Hessian is computed by the identity

\[\frac{\partial^2 \xi^i}{\partial x^m \partial x^n} = -\frac{\partial \xi^i}{\partial x^j} \frac{\partial \xi^k}{\partial x^m} \frac{\partial \xi^l}{\partial x^n} \frac{\partial^2 x^j}{\partial \xi^k \partial \xi^l}, \]

where the inverse Jacobian is passed in as a function argument.

See Test_CoordinateMap.cpp for a different implementation. The current implementation is chosen in production as it is faster when we have the inverse Jacobian already, and in most cases we do.

We use forward mode autodiff here as it is simpler to implement and has better optimization than the reverse mode. Reverse mode in the Autodiff library has higher cost per propagation and does not support taping. Also see this github issue.

Note
Require SPECTRE_AUTODIFF=ON.

◆ inv_jacobian_is_time_dependent()

template<typename SourceFrame, typename TargetFrame, typename... Maps>
bool domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::inv_jacobian_is_time_dependent ( ) const
overridevirtual

Returns true if the inverse Jacobian depends on time.

Implements domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >.

◆ is_identity()

template<typename SourceFrame, typename TargetFrame, typename... Maps>
bool domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::is_identity ( ) const
overridevirtual

◆ jacobian_is_time_dependent()

template<typename SourceFrame, typename TargetFrame, typename... Maps>
bool domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::jacobian_is_time_dependent ( ) const
overridevirtual

Returns true if the Jacobian depends on time.

Implements domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >.

◆ operator()() [1/2]

template<typename SourceFrame, typename TargetFrame, typename... Maps>
tnsr::I< autodiff::HigherOrderDual< 2, double >, dim, TargetFrame > domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::operator() ( tnsr::I< autodiff::HigherOrderDual< 2, double >, dim, SourceFrame > source_point,
const double time = std::numeric_limits<double>::signaling_NaN(),
const FunctionsOfTimeMap & functions_of_time = {} ) const
inlineoverride

Apply the Maps... to the point(s) source_point

Note
Require SPECTRE_AUTODIFF=ON.

◆ operator()() [2/2]

template<typename SourceFrame, typename TargetFrame, typename... Maps>
tnsr::I< autodiff::HigherOrderDual< 2, simd::batch< double > >, dim, TargetFrame > domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::operator() ( tnsr::I< autodiff::HigherOrderDual< 2, simd::batch< double > >, dim, SourceFrame > source_point,
const double time = std::numeric_limits<double>::signaling_NaN(),
const FunctionsOfTimeMap & functions_of_time = {} ) const
inlineoverride

Apply the Maps... to the point(s) source_point

Note
Require SPECTRE_AUTODIFF=ON.

◆ supports_hessian()

template<typename SourceFrame, typename TargetFrame, typename... Maps>
bool domain::CoordinateMap< SourceFrame, TargetFrame, Maps >::supports_hessian ( ) const
inlineoverridevirtual

Returns true if this coordinate map supports hessian.

Implements domain::CoordinateMapBase< SourceFrame, TargetFrame, CoordinateMaps::map_dim< Maps... > >.


The documentation for this class was generated from the following file:
  • src/Domain/CoordinateMaps/CoordinateMap.hpp