SpECTRE
v2024.12.16
|
Abstract base class for the transition functions used by the domain::CoordinateMaps::TimeDependent::Shape map. More...
#include <ShapeMapTransitionFunction.hpp>
Public Member Functions | |
virtual std::optional< double > | original_radius_over_radius (const std::array< double, 3 > &target_coords, double radial_distortion) const =0 |
The inverse of the transition function. More... | |
virtual bool | operator== (const ShapeMapTransitionFunction &other) const =0 |
virtual bool | operator!= (const ShapeMapTransitionFunction &other) const =0 |
WRAPPED_PUPable_abstract (ShapeMapTransitionFunction) | |
ShapeMapTransitionFunction (CkMigrateMessage *m) | |
virtual double | operator() (const std::array< double, 3 > &source_coords) const =0 |
virtual DataVector | operator() (const std::array< DataVector, 3 > &source_coords) const =0 |
virtual std::array< double, 3 > | gradient (const std::array< double, 3 > &source_coords) const =0 |
virtual std::array< DataVector, 3 > | gradient (const std::array< DataVector, 3 > &source_coords) const =0 |
virtual std::unique_ptr< ShapeMapTransitionFunction > | get_clone () const =0 |
Abstract base class for the transition functions used by the domain::CoordinateMaps::TimeDependent::Shape map.
This base class defines the required methods of a transition function used by the shape map. Different domains require the shape map to fall off towards the boundary in different ways. This behavior is controlled by the transition function. It is also needed to find the inverse of the shape map. Since the shape map preserves angles, the problem of finding its inverse reduces to the 1-dimensional problem of finding the original radius from the mapped radius. The mapped radius \(\tilde{r}\) is related to the original \(r\) radius by:
\begin{equation}\label{eq:shape_map_radius} \tilde{r} = r (1 - \frac{f(r,\theta,\phi)}{r} \sum_{lm} \lambda_{lm}(t)Y_{lm}(\theta,\phi)), \end{equation}
where \(f(r,\theta,\phi) \in [0, 1]\) is the transition function (see docs of domain::CoordinateMaps::TimeDependent::Shape map). Depending on the format of the transition function, it should be possible to analytically derive this map's inverse because it preserves angles and shifts only the radius of each point. Otherwise the inverse has to be computed numerically.
The transition function must also be able to compute the gradient and the value of the function divided by the radius. Care must be taken that this does not divide by zero.
All member functions with the exception of original_radius_over_radius
exist as overloads for types double
and DataVector
so that they work with the templated shape map methods calling them. To avoid code duplication these can be forwarded to templated implementation methods held by the derived classes only.
For an example, see SphereTransition.
It was decided to make the ShapeMapTransitionFunction an abstract base class with overloads for types double
and DataVector
corresponding to the template parameter T
of the shape map's methods. The shape map holds a unique_ptr
to this abstract class using a common dynamic dispatch design pattern. This approach avoids templating the shape map all together.
An alternative approach would be to directly template the transition functions onto the shape map so that no abstract base class is necessary. These approaches can also be combined by making the transition function an abstract base class but also templating it onto the shape map. In this way the shape map does not need to hold a unique_ptr
but can hold the transition function directly as a member.
|
pure virtual |
Evaluate the gradient of the transition function with respect to the Cartesian coordinates x, y and z at the Cartesian coordinates source_coords
.
Implemented in domain::CoordinateMaps::ShapeMapTransitionFunctions::SphereTransition, and domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge.
|
pure virtual |
Evaluate the gradient of the transition function with respect to the Cartesian coordinates x, y and z at the Cartesian coordinates source_coords
.
Implemented in domain::CoordinateMaps::ShapeMapTransitionFunctions::SphereTransition, and domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge.
|
pure virtual |
Evaluate the gradient of the transition function with respect to the Cartesian coordinates x, y and z at the Cartesian coordinates source_coords
.
Implemented in domain::CoordinateMaps::ShapeMapTransitionFunctions::SphereTransition, and domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge.
|
pure virtual |
Evaluate the transition function \(f(r,\theta,\phi) \in [0, 1]\) at the Cartesian coordinates source_coords
.
Implemented in domain::CoordinateMaps::ShapeMapTransitionFunctions::SphereTransition, and domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge.
|
pure virtual |
Evaluate the transition function \(f(r,\theta,\phi) \in [0, 1]\) at the Cartesian coordinates source_coords
.
Implemented in domain::CoordinateMaps::ShapeMapTransitionFunctions::SphereTransition, and domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge.
|
pure virtual |
The inverse of the transition function.
This method returns \(r/\tilde{r}\) given the mapped coordinates \(\tilde{x}^i\) (target_coords
) and the spherical harmonic expansion \(\Sigma(t, \theta, \phi) = \sum_{lm} \lambda_{lm}(t)Y_{lm}(\theta, \phi)\) (radial_distortion
). See domain::CoordinateMaps::TimeDependent::Shape for details on how this quantity is used to compute the inverse of the Shape map.
To derive the expression for this inverse, solve Eq. ( \(\ref{eq:shape_map_radius}\)) for \(r\) after substituting \(f(r,\theta,\phi)\).
target_coords | The mapped Cartesian coordinates \(\tilde{x}^i\). |
radial_distortion | The spherical harmonic expansion \(\Sigma(t, \theta, \phi)\). |
Returns: The quantity \(r/\tilde{r}\).
Implemented in domain::CoordinateMaps::ShapeMapTransitionFunctions::SphereTransition, and domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge.