SpECTRE  v2025.01.30
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge Class Referencefinal

A transition function that falls off linearly from an inner surface of a wedge to an outer surface of a wedge. Meant to be used in domain::CoordinateMaps::Wedge blocks. More...

#include <Wedge.hpp>

Public Types

enum class  Axis : int {
  PlusZ = 3 , MinusZ = -3 , PlusY = 2 , MinusY = -2 ,
  PlusX = 1 , MinusX = -1 , None = 0
}
 Class to represent the direction of the wedge relative to the outer center.
 

Public Member Functions

 Wedge (const std::array< double, 3 > &inner_center, double inner_radius, double inner_sphericity, const std::array< double, 3 > &outer_center, double outer_radius, double outer_sphericity, Axis axis, bool reverse=false)
 Construct a Wedge transition for a wedge block in a given direction. More...
 
double operator() (const std::array< double, 3 > &source_coords) const override
 
DataVector operator() (const std::array< DataVector, 3 > &source_coords) const override
 
std::optional< double > original_radius_over_radius (const std::array< double, 3 > &target_coords, double radial_distortion) const override
 The inverse of the transition function. More...
 
std::array< double, 3 > gradient (const std::array< double, 3 > &source_coords) const override
 
std::array< DataVector, 3 > gradient (const std::array< DataVector, 3 > &source_coords) const override
 
 WRAPPED_PUPable_decl_template (Wedge)
 
 Wedge (CkMigrateMessage *msg)
 
void pup (PUP::er &p) override
 
std::unique_ptr< ShapeMapTransitionFunctionget_clone () const override
 
bool operator== (const ShapeMapTransitionFunction &other) const override
 
bool operator!= (const ShapeMapTransitionFunction &other) const override
 
- Public Member Functions inherited from domain::CoordinateMaps::ShapeMapTransitionFunctions::ShapeMapTransitionFunction
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)
 

Friends

std::ostreamoperator<< (std::ostream &os, Axis axis)
 

Detailed Description

A transition function that falls off linearly from an inner surface of a wedge to an outer surface of a wedge. Meant to be used in domain::CoordinateMaps::Wedge blocks.

Details

The functional form of this transition is

(1)f(r,θ,ϕ)=Dout(r,θ,ϕ)rDout(r,θ,ϕ)Din(r,θ,ϕ),

where, in general,

(2)D(r,θ,ϕ)=R(1s3max(|sinθcosϕ|,|sinθsinϕ|,|cosθ|)+s).

Note
If reverse is true, then the functional form of the transition is actually

\begin{equation} f(r, \theta, \phi) = 1 - \frac{D_{\text{out}}(r, \theta, \phi) - r}{D_{\text{out}}(r, \theta, \phi) - D_{\text{in}}(r, \theta, \phi)} = \frac{r - \frac{D_{\text{in}}(r, \theta, \phi)} {D_{\text{out}}(r, \theta, \phi) - D_{\text{in}}(r, \theta, \phi)}. \label{eq:transition_func_reverse} \end{equation}

The function is also defined beyond Din(r,θ,ϕ) and Dout(r,θ,ϕ), but slighly differently. Within Din(r,θ,ϕ), f(r,θ,ϕ)=1 and beyond Dout(r,θ,ϕ), f(r,θ,ϕ)=0. If reverse is true, this logic is flipped.

Here, s is the sphericity of the surface which goes from 0 (flat) to 1 (spherical), R is the radius of the spherical surface, out is the outer surface, and in is the inner surface. If the sphericity is 1, then the surface is a sphere so D=R. If the sphericity is 0, then the surface is a cube. This cube is circumscribed by a sphere of radius R. See domain::CoordinateMaps::Wedge for more of an explanation of these boundary surfaces and their sphericities.

Note
Because the shape map distorts only radii and does not affect angles, D is not a function of r so we have that D(r,θ,ϕ)=D(θ,ϕ).

There are several assumptions made for this mapping:

  • The coordinates r,θ,ϕ are assumed to be from the center of the inner surface, not the center of the computational domain.
  • The wedges are concentric. (see the constructor) This is also enforced by the center of the inner surface being within the outer surface
  • If the centers of the inner and outer surface are different, then the inner sphericity must be 1 (i.e. Din=R)
  • The max in the denominator of 2 can be simplified a bit to max(|x|,|y|,|z|)/r. It was written the other way in 2 to emphasize that D has no radial dependence.

Vector formulation

Useful vectors for Wedge transition

It can be more convenient to work with vectors rather than just distances for the following equations. Therefore, we define the projection center P which points from the center of the outer surface to the center of the inner surface. If the centers of the inner and outer surface are the same, then P=0. Then, we define x as the vector from the center of the outer surface to the coordinate we are interested in. We define x0 as the vector from the center of the outer surface to the point along ray xP which intersects the inner surface. Similarly, x1 intersects the outer surface along the same ray as xP. Any cube has a side length of 2L.

In this way, we can reformulate Eq. 1 as

(3)f(x)=|x1P|r|x1P||x0P|

where

(4)r=|xP|

Computing vector to inner surface

Similar to Eq. 2 we can define x0 as

(5)x0=R0(r(1s0)3max(xiPi)+s)r^+P

with

(6)r^=xP|xP|.

and also

(7)|x0P|=R0(r(1s0)3max(xiPi)+s0)

Computing vector to outer surface

Then, we define

(8)x1=λ(xP)+P

where λ is a scalar to be determined. We can see that this is valid because xP is centered on P and lies along the ray so λ will scale this vector to be the correct length.

Computing λ is a bit complicated because the outer surface can either be a cube, a sphere, or something in between and the way to solve for λ in the cube case is different than in the sphere case. Therefore we define λc and λs as the scalar factors for the cube and sphere case, respectively. This allows us to define λ as

(9)λ=(1s1)λc+s1λs

Computing cube lambda

To compute λc for the cube case, we notice that (in the image)

(10)L=x1z^(11)=(λc+z(xP)+P)z^(12)=λc+z(xzPz)+Pz

If we generalize this to all six unit vectors and solve for λc±k we get

(13)λc±k=±LPx^k(xP)x^k

for k{x,y,z}. This quantity λc±k represents the factor needed to scale the vector xP to intersect with the infinite planes that contain the six faces of the cube.

Some λc±k will be negative as they point to the opposite planes. We can discard those. Then for the λc±k that are positive, we want the one that is smallest in magnitude. This can be written as

(14)λc=minλc±k>0(λc±k)

Computing sphere lambda

To compute λs for the sphere case, again we notice that (in the image)

(15)R12=|x1|2(16)=|λs(xP)+P|2(17)=λs2|xP|2+2λs(xP)P+|P|2

This is simply a quadratic equation for λs:

(18)0=λs2|xP|2+2λs(xP)P+|P|2R12

We explicitly don't write the typical form of the solution of a quadratic equation because that form behaviors poorly numerically if the two terms in the numerator are close to each other (bad numerical roundoff). Therefore, we just resolve to compute the solution numerically, and say that we have λs.

We have now solved for x1.

(19)x1=((1s1)λc+s1λs)(xP)+P

given the solutions for λc in Eqn. 14 and λs in Eqn. 18.

Original radius divided by mapped radius

Given an already mapped point x~ and the radial distortion Σ(θ,ϕ)=,mλmYm(θ,ϕ), we can figure out the ratio of the original radius r to the mapped r~=|x~| by solving

(20)rr~=11f(r,θ,ϕ)rΣ(θ,ϕ)

After plugging in the transition and solving, we get

(21)rr~=1+|x1P|Σ(θ,ϕ)r~(|x1P||x0P|)1+Σ(θ,ϕ)|x1P||x0P|

Note
Since x0P and x1P are not functions of the radius, we can use x~ in Eq. 5 instead of x.

Note
If reverse is true, then the value multiplying Σ in the numerator is now |x0P| and in the denomintor Σ picks up a minus sign factor.

Note
If we are inside the inner surface, then this simplifies to

(22)rr~=1+Σ(θ,ϕ)r~

because f(r,θ,ϕ)=1. If we are outside the outer surface, then r/r~=1 because f(r,θ,ϕ)=0. If reverse is true, this logic is reversed.

Gradient

The cartesian gradient of the transition function is

(23)fxi=|x1P|xixiPir|x1P||x0P|(|x1P|r)(|x1P|xi|x0P|xi)(|x1P||x0P|)2.

Note
If reverse is true, the gradient picks up an overall factor of -1.0.

Note
The gradient is not supported if points lie beyond the inner or outer surface.

Therefore, we need to compute the gradients of x0 and x1.

Gradient of vector to inner surface

If P0, then we require the inner surface to be a sphere, which means the gradient is trivially zero. Therefore the following is only for when P=0.

The gradient of |x0P| depends on the result of the max in the denominator of 7. To simplify the expression, let i{0,1,2} correspond to the max(xiPi). Then we can write the gradient of as

(24)|x0P|xi=sgn(xiPi)R(1s)(r2(xiPi)2)r(xiPi)23(25)|x0P|xi+1=R(1s)(xi+1Pi+1)r|xiPi|3(26)|x0P|xi+2=R(1s)(xi+2Pi+2)r|xiPi|3

where i+1 and i+2 are understood to be mod3. Also since we don't allow points at the center of the inner surfaces, we can be assured that for whichever i is max, that xiPi won't be zero.

Gradient of vector to outer surface

This gradient is much more complicated because of how we have to define λ. To start off with, we need to compute

(27)xi|x1P|=xi(λ|xP|)(28)=λ(xiPi)|xP|+λxi|xP|

Since we know λ and x, that just leaves

(29)λxi=λcxi(1s1)+s1λsxi

Gradient of cube lambda

Taking the gradient of Eqn. 13 we notice that L, P, and x^k are constant, so we only have to worry about x

(30)xiλc±k=(±LPx^k)(/xi(xP)x^k)((xP)x^k)2

The gradient in the numerator is simple to take so we end up with

(31)xiλc±k=(±LPx^k)(xkPk)2δik

Gradient of sphere lambda

Taking the gradient of Eqn. 18 (and using the fact that P and R are constant), we get

(32)0=λsλsxi|xP|2+λs2(xP)xi(xP)+λsxi(xP)P+λsPxi(xP)

Taking the simple gradients and moving things around, we get

(33)λsxi=λs2(xiPi)+λsPiλs|xP|2+(xP)P

where λs can be computed from Eqn. 18.

So now we can put it all together and we get

(34)λxi=(±LPx^k)(xkPk)2δik(1s1)+s1λs2(xiPi)+λsPiλs|xP|2+(xP)P

which can then be substituted into Eqn. 27 to get the gradient of |x1P|.

Constructor & Destructor Documentation

◆ Wedge()

domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::Wedge ( const std::array< double, 3 > &  inner_center,
double  inner_radius,
double  inner_sphericity,
const std::array< double, 3 > &  outer_center,
double  outer_radius,
double  outer_sphericity,
Axis  axis,
bool  reverse = false 
)

Construct a Wedge transition for a wedge block in a given direction.

Details

Many concentric wedges can be part of the same falloff from 1 at the inner boundary of the innermost wedge, to 0 at the outer boundary of the outermost wedge.

Note
If inner_center and outer_center are different, then inner_sphericity must be 1.0.
Parameters
inner_centerCenter of the inner surface
inner_radiusInner radius of innermost wedge
inner_sphericitySphericity of innermost surface of innermost wedge
outer_centerCenter of the outer surface
outer_radiusOutermost radius of outermost wedge
outer_sphericitySphericity of outermost surface of outermost wedge
axisThe direction that this wedge is in.
reverseIf true, the transition function will be 0 at the inner boundary and 1 at the outer boundary (useful for deforming star surfaces). Otherwise, it will be 1 at the inner boundary and 0 at the outer boundary (useful for deforming black hole excision surfaces).

Member Function Documentation

◆ get_clone()

std::unique_ptr< ShapeMapTransitionFunction > domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::get_clone ( ) const
inlineoverridevirtual

Evaluate the gradient of the transition function with respect to the Cartesian coordinates x, y and z at the Cartesian coordinates source_coords.

Implements domain::CoordinateMaps::ShapeMapTransitionFunctions::ShapeMapTransitionFunction.

◆ gradient() [1/2]

std::array< DataVector, 3 > domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::gradient ( const std::array< DataVector, 3 > &  source_coords) const
overridevirtual

Evaluate the gradient of the transition function with respect to the Cartesian coordinates x, y and z at the Cartesian coordinates source_coords.

Implements domain::CoordinateMaps::ShapeMapTransitionFunctions::ShapeMapTransitionFunction.

◆ gradient() [2/2]

std::array< double, 3 > domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::gradient ( const std::array< double, 3 > &  source_coords) const
overridevirtual

Evaluate the gradient of the transition function with respect to the Cartesian coordinates x, y and z at the Cartesian coordinates source_coords.

Implements domain::CoordinateMaps::ShapeMapTransitionFunctions::ShapeMapTransitionFunction.

◆ operator!=()

bool domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::operator!= ( const ShapeMapTransitionFunction other) const
overridevirtual

◆ operator()() [1/2]

DataVector domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::operator() ( const std::array< DataVector, 3 > &  source_coords) const
overridevirtual

Evaluate the transition function f(r,θ,ϕ)[0,1] at the Cartesian coordinates source_coords.

Implements domain::CoordinateMaps::ShapeMapTransitionFunctions::ShapeMapTransitionFunction.

◆ operator()() [2/2]

double domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::operator() ( const std::array< double, 3 > &  source_coords) const
overridevirtual

Evaluate the transition function f(r,θ,ϕ)[0,1] at the Cartesian coordinates source_coords.

Implements domain::CoordinateMaps::ShapeMapTransitionFunctions::ShapeMapTransitionFunction.

◆ operator==()

bool domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::operator== ( const ShapeMapTransitionFunction other) const
overridevirtual

◆ original_radius_over_radius()

std::optional< double > domain::CoordinateMaps::ShapeMapTransitionFunctions::Wedge::original_radius_over_radius ( const std::array< double, 3 > &  target_coords,
double  radial_distortion 
) const
overridevirtual

The inverse of the transition function.

This method returns r/r~ given the mapped coordinates x~i (target_coords) and the spherical harmonic expansion Σ(t,θ,ϕ)=lmλlm(t)Ylm(θ,ϕ) (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. ( ???) for r after substituting f(r,θ,ϕ).

Parameters
target_coordsThe mapped Cartesian coordinates x~i.
radial_distortionThe spherical harmonic expansion Σ(t,θ,ϕ).

Returns: The quantity r/r~.

Implements domain::CoordinateMaps::ShapeMapTransitionFunctions::ShapeMapTransitionFunction.


The documentation for this class was generated from the following file: