SpECTRE  v2025.08.19
ah Namespace Reference

Contains utilities for working with apparent horizons. More...

Namespaces

namespace  callbacks
 Callbacks used by the apparent horizon finder.
 
namespace  Criteria
 Criteria for deciding how resolution of an apparent horizon should be adapted.
 
namespace  Tags
 Tags for the apparent horizon finder.
 

Classes

struct  Component
 The singleton parallel component responsible for finding horizons. More...
 
struct  ComputeExcisionBoundaryVolumeQuantities
 Given the generalized harmonic variables in the volume, computes the quantities that will be interpolated onto an excision boundary. More...
 
struct  ComputeHorizonVolumeQuantities
 Given the generalized harmonic variables in the volume, computes the quantities that will be interpolated onto an apparent horizon. More...
 
class  Criterion
 Base class for criteria that determine how the resolution of an apparent horizon should be changed. More...
 
struct  FindApparentHorizon
 Simple action run on the horizon finder by the Elements which receives volume data, finds the apparent horizon, and calls the callbacks after the horizon is found. More...
 
struct  HorizonOptions
 Options for finding an apparent horizon. More...
 
struct  Initialize
 Initialize items related to the horizon finder. More...
 

Typedefs

template<size_t Dim>
using source_vars = tmpl::list< gr::Tags::SpacetimeMetric< DataVector, Dim >, gh::Tags::Pi< DataVector, Dim >, gh::Tags::Phi< DataVector, Dim >, ::Tags::deriv< gh::Tags::Phi< DataVector, Dim >, tmpl::size_t< Dim >, Frame::Inertial > >
 
template<size_t Dim, typename Frame >
using vars_to_interpolate_to_target = tmpl::list< gr::Tags::SpatialMetric< DataVector, Dim, Frame >, gr::Tags::InverseSpatialMetric< DataVector, Dim, Frame >, gr::Tags::ExtrinsicCurvature< DataVector, Dim, Frame >, gr::Tags::SpatialChristoffelSecondKind< DataVector, Dim, Frame >, gr::Tags::SpatialRicci< DataVector, Dim, Frame > >
 
template<typename Frame >
using tags_for_observing = tmpl::list< gr::surfaces::Tags::Area, gr::surfaces::Tags::IrreducibleMass, ylm::Tags::MaxRicciScalar, ylm::Tags::MinRicciScalar, gr::surfaces::Tags::ChristodoulouMass, gr::surfaces::Tags::DimensionlessSpinMagnitude< Frame >, gr::surfaces::Tags::DimensionfulSpinVector< Frame > >
 
using surface_tags_for_observing = tmpl::list< ylm::Tags::RicciScalar >
 
template<size_t Dim, typename Frame >
using compute_items_on_target = tmpl::list< ylm::Tags::ThetaPhiCompute< Frame >, ylm::Tags::RadiusCompute< Frame >, ylm::Tags::RhatCompute< Frame >, ylm::Tags::CartesianCoordsCompute< Frame >, ylm::Tags::InvJacobianCompute< Frame >, ylm::Tags::InvHessianCompute< Frame >, ylm::Tags::JacobianCompute< Frame >, ylm::Tags::DxRadiusCompute< Frame >, ylm::Tags::D2xRadiusCompute< Frame >, ylm::Tags::NormalOneFormCompute< Frame >, ylm::Tags::OneOverOneFormMagnitudeCompute< DataVector, Dim, Frame >, ylm::Tags::TangentsCompute< Frame >, ylm::Tags::UnitNormalOneFormCompute< Frame >, ylm::Tags::UnitNormalVectorCompute< Frame >, ylm::Tags::GradUnitNormalOneFormCompute< Frame >, gr::surfaces::Tags::AreaElementCompute< Frame >, ylm::Tags::EuclideanAreaElementCompute< Frame >, ylm::Tags::ExtrinsicCurvatureCompute< Frame >, ylm::Tags::RicciScalarCompute< Frame >, gr::surfaces::Tags::SpinFunctionCompute< Frame >, gr::surfaces::Tags::DimensionfulSpinMagnitudeCompute< Frame >, gr::surfaces::Tags::AreaCompute< Frame >, gr::surfaces::Tags::IrreducibleMassCompute< Frame >, ylm::Tags::MaxRicciScalarCompute, ylm::Tags::MinRicciScalarCompute, gr::surfaces::Tags::ChristodoulouMassCompute< Frame >, gr::surfaces::Tags::DimensionlessSpinMagnitudeCompute< Frame >, gr::surfaces::Tags::DimensionfulSpinVectorCompute< Frame, Frame > >
 

Enumerations

enum class  Destination { Observation , ControlSystem }
 Label for what a horizon find will be used for.
 

Functions

template<typename HorizonMetavars , typename DbTags , typename Metavariables >
void invoke_callbacks (const gsl::not_null< db::DataBox< DbTags > * > box, Parallel::GlobalCache< Metavariables > &cache, const std::optional< std::string > &dependency, const FastFlow::Status status)
 Invoke the callbacks specified in the horizon_find_callbacks alias of the HorizonMetavars. More...
 
template<typename Fr >
void clean_up_horizon_finder (gsl::not_null< std::optional< LinkedMessageId< double > > * > current_time_optional, gsl::not_null< std::unordered_map< LinkedMessageId< double >, ah::Storage::SingleTimeStorage< Fr > > * > all_storage, gsl::not_null< std::set< LinkedMessageId< double > > * > completed_times, gsl::not_null< FastFlow * > fast_flow)
 Cleans up the horizon finder after a horizon find has finished. More...
 
template<typename Fr >
bool set_current_iteration_coords (gsl::not_null< ah::Storage::Iteration< Fr > * > current_iteration, gsl::not_null< std::vector< size_t > * > block_order, const LinkedMessageId< double > &time, const FastFlow &fast_flow, const ylm::Strahlkorper< Fr > &initial_guess, const ylm::Strahlkorper< Fr > &previous_iteration_surface, const std::deque< ah::Storage::PreviousSurface< Fr > > &previous_surfaces, size_t max_compute_coords_retries, const Domain< 3 > &domain, const domain::FunctionsOfTimeMap &functions_of_time, const std::optional< size_t > &current_resolution_l=std::nullopt, bool rerunning_with_higher_resolution=false)
 Compute the target points for the current iteration. More...
 
template<typename Fr >
void compute_vars_to_interpolate_to_target (gsl::not_null< Variables< ah::vars_to_interpolate_to_target< 3, Fr > > * > target_vars, const tnsr::aa< DataVector, 3 > &spacetime_metric, const tnsr::aa< DataVector, 3 > &pi, const tnsr::iaa< DataVector, 3 > &phi, const tnsr::ijaa< DataVector, 3 > &deriv_phi, const LinkedMessageId< double > &time, const Domain< 3 > &domain, const Mesh< 3 > &mesh, const ElementId< 3 > &element_id, const domain::FunctionsOfTimeMap &functions_of_time)
 Compute the ah::vars_to_interpolate_to_target for a given element_id from the ah::source_vars in that element.
 
template<typename Fr >
void set_current_time (gsl::not_null< std::optional< LinkedMessageId< double > > * > current_time, gsl::not_null< std::set< LinkedMessageId< double > > * > pending_times, const std::set< LinkedMessageId< double > > &completed_times, const std::unordered_map< LinkedMessageId< double >, ah::Storage::SingleTimeStorage< Fr > > &all_storage, const ::Verbosity &verbosity, const std::string &name)
 Determines what the current time should be. More...
 
template<typename HorizonMetavars , typename Metavariables >
bool check_if_current_time_is_ready (const LinkedMessageId< double > &current_time, Parallel::GlobalCache< Metavariables > &cache, const LinkedMessageId< double > &incoming_time, const ElementId< 3 > &incoming_element_id, const ::Mesh< 3 > &incoming_mesh, const std::optional< std::string > &dependency)
 Checks if the current time is ready. More...
 
std::ostreamoperator<< (std::ostream &os, Destination destination)
 
template<typename Fr >
bool interpolate_volume_data (gsl::not_null< ah::Storage::Iteration< Fr > * > current_iteration_storage, const ah::Storage::VolumeVariables< Fr > &volume_vars_storage, const ElementId< 3 > &element_id)
 Interpolate volume data from any new elements received by the horizon finder to the target points. More...
 
template<typename Fr >
bool operator== (const HorizonOptions< Fr > &lhs, const HorizonOptions< Fr > &rhs)
 
template<typename Fr >
bool operator!= (const HorizonOptions< Fr > &lhs, const HorizonOptions< Fr > &rhs)
 

Detailed Description

Contains utilities for working with apparent horizons.

Function Documentation

◆ check_if_current_time_is_ready()

template<typename HorizonMetavars , typename Metavariables >
bool ah::check_if_current_time_is_ready ( const LinkedMessageId< double > &  current_time,
Parallel::GlobalCache< Metavariables > &  cache,
const LinkedMessageId< double > &  incoming_time,
const ElementId< 3 > &  incoming_element_id,
const ::Mesh< 3 > &  incoming_mesh,
const std::optional< std::string > &  dependency 
)

Checks if the current time is ready.

Details

If the current time is after any expiration time, registers a callback for the ah::FindApparentHorizon action (but doesn't send the volume variables again because we already did that). Returns if the current time is ready or not.

◆ clean_up_horizon_finder()

template<typename Fr >
void ah::clean_up_horizon_finder ( gsl::not_null< std::optional< LinkedMessageId< double > > * >  current_time_optional,
gsl::not_null< std::unordered_map< LinkedMessageId< double >, ah::Storage::SingleTimeStorage< Fr > > * >  all_storage,
gsl::not_null< std::set< LinkedMessageId< double > > * >  completed_times,
gsl::not_null< FastFlow * >  fast_flow 
)

Cleans up the horizon finder after a horizon find has finished.

Details

Removes the current time from the storage map, adds the current time to the completed times, and then resets the current time. If the completed times have more than 1000 entries, this will limit the size to 1000.

◆ interpolate_volume_data()

template<typename Fr >
bool ah::interpolate_volume_data ( gsl::not_null< ah::Storage::Iteration< Fr > * >  current_iteration_storage,
const ah::Storage::VolumeVariables< Fr > &  volume_vars_storage,
const ElementId< 3 > &  element_id 
)

Interpolate volume data from any new elements received by the horizon finder to the target points.

Details

For each new element, the vars_to_interpolate_to_target in all_volume_variables are interpolated to the target points and stored in current_iteration_storage.

◆ invoke_callbacks()

template<typename HorizonMetavars , typename DbTags , typename Metavariables >
void ah::invoke_callbacks ( const gsl::not_null< db::DataBox< DbTags > * >  box,
Parallel::GlobalCache< Metavariables > &  cache,
const std::optional< std::string > &  dependency,
const FastFlow::Status  status 
)

Invoke the callbacks specified in the horizon_find_callbacks alias of the HorizonMetavars.

Details

Before invoking the callbacks, this function

  1. Restricts the final interpolated variables from the \(L_\mathrm{mesh}\) used for the FastFlow algorithm, to the actual \(L\) of the Strahlkorper.
  2. Adds the current Strahlkorper to the ah::Tags::PreviousSurfaces.
  3. Copies the Strahlkorper, its time derivative, and the dependency into the box. Also possibly computes the Inertial coordinates of the final Strahlkorper and stores them in the box if the frame of the HorizonMetavars isn't the Inertial frame.

◆ set_current_iteration_coords()

template<typename Fr >
bool ah::set_current_iteration_coords ( gsl::not_null< ah::Storage::Iteration< Fr > * >  current_iteration,
gsl::not_null< std::vector< size_t > * >  block_order,
const LinkedMessageId< double > &  time,
const FastFlow fast_flow,
const ylm::Strahlkorper< Fr > &  initial_guess,
const ylm::Strahlkorper< Fr > &  previous_iteration_surface,
const std::deque< ah::Storage::PreviousSurface< Fr > > &  previous_surfaces,
size_t  max_compute_coords_retries,
const Domain< 3 > &  domain,
const domain::FunctionsOfTimeMap functions_of_time,
const std::optional< size_t > &  current_resolution_l = std::nullopt,
bool  rerunning_with_higher_resolution = false 
)

Compute the target points for the current iteration.

Details

Returns whether the computation of the target points was successful or if there are some points outside the domain. If computation fails, one of two attempts to recover will happen:

  • For the zeroth fast flow iteration, this will increase the \(l=0,m=0\) coefficient (i.e. the size) by 50%.
  • For all other iterations, the coefficients become

    \begin{equation} S^{\mathrm{new}}_{lm} = \frac{1}{2}\left(S^{\mathrm{previous}}_{lm} + S^{\mathrm{failed}}_{lm}\right) \end{equation}

    where \(S^{\mathrm{failed}}_{lm}\) are the coefficients of the failed computation and \(S^{\mathrm{previous}}_{lm}\) are the coefficients from the previous successful iteration.

This function will try recomputing the coords using the above two rules max_compute_coords_retries times before returning false.

Parameters
current_iterationThe returned pointer to the current Iteration object
block_orderPriority order to search blocks for containing points (see block_logical_coordinates for details)
timeThe current time
fast_flowThe FastFlow object for the current horizon find
initial_guessIf the current iteration number is zero and rerunning_with_higher_resolution == false, current_iteration is set to this Strahlkorper
previous_iteration_surfaceIf empty, current_iteration is set to initial_guess; if one previous iteration, current_iteration is set to that previous iteration; if two previous iterations, current_iteration is set by linearly extrapolating in time the two pervious iterations; if three or more previous iterations, current_iteration is set by quadratic extrpolation of the three most recent iterations
previous_surfacesPreviously successful iteratios used to attempt to recover when some points are outside the domain.
max_compute_coords_retriesRetry up to this many times before returning false
domainThe spatial domain in which the horizon is being found
functions_of_timeThe functions of time for the current domain
current_resolution_lOptional; if specified, current_iteration is prolonged or restricted to this resolution
rerunning_with_higher_resolutionMust be false unless current_resolution_l is set; if true, then on iteration zero, set the initial guess to the previous iteration surface

Returns: Whether or not set_current_iteration_coords succeeded

◆ set_current_time()

template<typename Fr >
void ah::set_current_time ( gsl::not_null< std::optional< LinkedMessageId< double > > * >  current_time,
gsl::not_null< std::set< LinkedMessageId< double > > * >  pending_times,
const std::set< LinkedMessageId< double > > &  completed_times,
const std::unordered_map< LinkedMessageId< double >, ah::Storage::SingleTimeStorage< Fr > > &  all_storage,
const ::Verbosity verbosity,
const std::string name 
)

Determines what the current time should be.

Details

If there's already a current time, or there are no pending times available, then there's nothing to do. Otherwise, checks if the first pending time is the next to use. If so, sets it as the current time and removes it from pending.