if constexpr (MakeHorizonFinderFailOnPurpose) {
return {0.5, 0.0, 0.0};
}
return {0.0, 0.0, 0.0};
}();
for (const auto& temporal_id : temporal_ids) {
for (const auto& element_id : element_ids) {
const auto& block =
domain.blocks()[element_id.block_id()];
::Mesh<3> mesh{domain_creator->initial_extents()[element_id.block_id()],
Spectral::Basis::Legendre,
Spectral::Quadrature::GaussLobatto};
analytic_solution_coords{};
if constexpr (std::is_same_v<Frame, ::Frame::Grid> and
element_id, block.moving_mesh_logical_to_grid_map().get_clone()};
analytic_solution_coords =
element_id, block.moving_mesh_logical_to_grid_map().get_clone()};
ActionTesting::cache<target_component>(runner, 0_st);
const auto& functions_of_time =
get<domain::Tags::FunctionsOfTime>(cache);
if constexpr (std::is_same_v<Frame, ::Frame::Distorted>) {
analytic_solution_coords = block.moving_mesh_grid_to_distorted_map()(
functions_of_time);
} else {
static_assert(std::is_same_v<Frame, ::Frame::Inertial>);
analytic_solution_coords = block.moving_mesh_grid_to_inertial_map()(
functions_of_time);
}
} else {
element_id, block.stationary_map().get_clone()};
}
analytic_solution_center);
const auto solution_vars = solution.variables(
analytic_solution_coords, 0.0,
typename gr::Solutions::KerrSchild::tags<
typename ::Tags::Variables<typename metavars::interpolator_source_vars>::
type output_vars(
mesh.number_of_grid_points());
if constexpr (std::is_same_v<Frame, ::Frame::Inertial> or
const auto&
lapse = get<gr::Tags::Lapse<DataVector>>(solution_vars);
const auto& dt_lapse =
get<Tags::dt<gr::Tags::Lapse<DataVector>>>(solution_vars);
const auto& d_lapse =
get<
typename gr::Solutions::KerrSchild ::DerivLapse<
const auto&
shift = get<gr::Tags::Shift<DataVector, 3>>(solution_vars);
const auto& d_shift =
get<
typename gr::Solutions::KerrSchild ::DerivShift<
const auto& dt_shift =
get<Tags::dt<gr::Tags::Shift<DataVector, 3>>>(solution_vars);
const auto& g =
get<gr::Tags::SpatialMetric<DataVector, 3>>(solution_vars);
const auto& dt_g =
get<Tags::dt<gr::Tags::SpatialMetric<DataVector, 3>>>(
solution_vars);
const auto& d_g =
get<
typename gr::Solutions::KerrSchild ::DerivSpatialMetric<
get<::gr::Tags::SpacetimeMetric<DataVector, 3>>(output_vars) =
get<::gh::Tags::Phi<DataVector, 3>>(output_vars) =
get<::gh::Tags::Pi<DataVector, 3>>(output_vars) =
} else {
const auto&
lapse = get<gr::Tags::Lapse<DataVector>>(solution_vars);
get<gr::Tags::Shift<DataVector, 3, Frame>>(solution_vars);
const auto& g =
get<gr::Tags::SpatialMetric<DataVector, 3, Frame>>(solution_vars);
const auto& K = get<gr::Tags::ExtrinsicCurvature<DataVector, 3, Frame>>(
solution_vars);
auto&
cache = ActionTesting::cache<target_component>(runner, 0_st);
const auto& functions_of_time =
get<domain::Tags::FunctionsOfTime>(cache);
const auto coords_frame_velocity_jacobians = [&block,
&analytic_solution_coords,
&temporal_id,
&functions_of_time]() {
if constexpr (std::is_same_v<Frame, ::Frame::Grid>) {
return block.moving_mesh_grid_to_inertial_map()
.coords_frame_velocity_jacobians(
analytic_solution_coords, temporal_id, functions_of_time);
} else {
static_assert(std::is_same_v<Frame, ::Frame::Distorted>);
return block.moving_mesh_distorted_to_inertial_map()
.coords_frame_velocity_jacobians(
analytic_solution_coords, temporal_id, functions_of_time);
}
}();
const auto&
inv_jacobian = std::get<1>(coords_frame_velocity_jacobians);
const auto&
jacobian = std::get<2>(coords_frame_velocity_jacobians);
const auto& frame_velocity =
std::get<3>(coords_frame_velocity_jacobians);
using inertial_metric_vars_tags =
tmpl::list<gr::Tags::Lapse<DataVector>,
Variables<inertial_metric_vars_tags> inertial_metric_vars(
mesh.number_of_grid_points());
auto& shift_inertial =
get<::gr::Tags::Shift<DataVector, 3>>(inertial_metric_vars);
auto& lower_metric_inertial =
get<::gr::Tags::SpatialMetric<DataVector, 3>>(inertial_metric_vars);
get<gr::Tags::Lapse<DataVector>>(inertial_metric_vars) =
lapse;
for (size_t k = 0; k < 3; ++k) {
shift_inertial.get(k) = -frame_velocity.get(k);
for (size_t j = 0; j < 3; ++j) {
}
}
u_inertial,
for (size_t i = 0; i < 3; ++i) {
for (size_t j = i; j < 3; ++j) {
u_inertial->get(i, j) = 0.0;
for (size_t k = 0; k < 3; ++k) {
for (size_t p = 0; p < 3; ++p) {
u_frame.get(k, p);
}
}
}
}
};
transform(make_not_null(&lower_metric_inertial), g);
mesh.number_of_grid_points());
transform(make_not_null(&extrinsic_curvature_inertial), K);
element_id, block.moving_mesh_logical_to_grid_map().get_clone()};
const auto grid_deriv_inertial_metric_vars =
partial_derivatives<inertial_metric_vars_tags>(
inertial_metric_vars, mesh,
mesh.number_of_grid_points());
for (size_t i = 0; i < 3; ++i) {
for (size_t j = i; j < 3; ++j) {
for (size_t k = 0; k < 3; ++k) {
d_g.get(k, i, j) = 0.0;
for (size_t l = 0; l < 3; ++l) {
d_g.get(k, i, j) +=
get<Tags::deriv<gr::Tags::SpatialMetric<DataVector, 3>,
grid_deriv_inertial_metric_vars)
}
}
}
}
mesh.number_of_grid_points());
for (size_t i = 0; i < 3; ++i) {
for (size_t k = 0; k < 3; ++k) {
d_shift.get(k, i) = 0.0;
for (size_t l = 0; l < 3; ++l) {
d_shift.get(k, i) +=
get<Tags::deriv<gr::Tags::Shift<DataVector, 3>,
grid_deriv_inertial_metric_vars)
}
}
}
mesh.number_of_grid_points());
for (size_t k = 0; k < 3; ++k) {
d_lapse.get(k) = 0.0;
for (size_t l = 0; l < 3; ++l) {
d_lapse.get(k) +=
get<Tags::deriv<gr::Tags::Lapse<DataVector>, tmpl::size_t<3>,
}
}
get<::gr::Tags::SpacetimeMetric<DataVector, 3>>(output_vars) =
get<::gh::Tags::Phi<DataVector, 3>>(output_vars) =
lower_metric_inertial, d_g);
auto& Pi = get<::gh::Tags::Pi<DataVector, 3>>(output_vars);
const auto& Phi = get<::gh::Tags::Phi<DataVector, 3>>(output_vars);
for (size_t i = 0; i < 3; ++i) {
Pi.get(i + 1, 0) = 0.0;
for (size_t j = i; j < 3; ++j) {
Pi.get(i + 1, j + 1) = 2.0 * extrinsic_curvature_inertial.get(i, j);
for (size_t c = 0; c < 4; ++c) {
Pi.get(i + 1, j + 1) -=
(Phi.get(i, j + 1, c) + Phi.get(j, i + 1, c));
}
}
}
Pi.get(0, 0) = 0.0;
}
interp_component,
make_not_null(&runner), mock_core_for_each_element.at(element_id),
temporal_id, element_id,
mesh, output_vars);
}
}
typename metavars::component_list>(make_not_null(&runner));
typename metavars::component_list>(
array_indices_with_queued_simple_actions) > 0) {
typename metavars::component_list>(
make_not_null(&runner), make_not_null(&generator),
typename metavars::component_list>(make_not_null(&runner));
}
CHECK(*test_horizon_called == 3 * tmpl::size<PostHorizonFindCallbacks>{});
}
SPECTRE_TEST_CASE("Unit.NumericalAlgorithms.Interpolator.ApparentHorizonFinder",
"[Unit]") {
domain::creators::register_derived_with_charm();
domain::creators::time_dependence::register_derived_with_charm();
domain::FunctionsOfTime::register_derived_with_charm();
test_schwarzschild_horizon_called = 0;
test_kerr_horizon_called = 0;
test_apparent_horizon<tmpl::list<TestSchwarzschildHorizon<Frame::Inertial>,
TestSchwarzschildHorizon<Frame::Inertial>>,
3, 1.0, {{0.0, 0.0, 0.0}});
test_apparent_horizon<tmpl::list<TestKerrHorizon<Frame::Inertial>>,
{{0.12, 0.23, 0.45}});
test_schwarzschild_horizon_called = 0;
test_apparent_horizon<tmpl::list<TestSchwarzschildHorizon<Frame::Grid>>,
&test_schwarzschild_horizon_called, 3, 3, 1.0, {{0.0, 0.0, 0.0}});
test_schwarzschild_horizon_called = 0;
test_kerr_horizon_called = 0;
test_apparent_horizon<tmpl::list<TestSchwarzschildHorizon<Frame::Inertial>>,
4, 1.0, {{0.0, 0.0, 0.0}});
test_apparent_horizon<tmpl::list<TestKerrHorizon<Frame::Inertial>>,
{{0.12, 0.23, 0.45}});
test_schwarzschild_horizon_called = 0;
test_kerr_horizon_called = 0;
test_apparent_horizon<tmpl::list<TestSchwarzschildHorizon<Frame::Grid>>,
&test_schwarzschild_horizon_called, 3, 6, 1.0, {{0.0, 0.0, 0.0}});
test_apparent_horizon<tmpl::list<TestKerrHorizon<Frame::Grid>>,
&test_kerr_horizon_called, 3, 7, 1.1, {{0.12, 0.23, 0.45}});
tmpl::for_each<tmpl::list<std::true_type, std::false_type>>(
Stores a collection of function values.
Definition: DataVector.hpp:48
The CoordinateMap for the Element from the Logical frame to the TargetFrame
Definition: ElementMap.hpp:35
Definition: ContractFirstNIndices.hpp:16
Kerr black hole in Kerr-Schild coordinates.
Definition: KerrSchild.hpp:243
Require a pointer to not be a nullptr
Definition: Gsl.hpp:198
void logical_coordinates(gsl::not_null< tnsr::I< DataVector, VolumeDim, Frame::ElementLogical > * > logical_coords, const Mesh< VolumeDim > &mesh)
Compute the logical coordinates of a Mesh in an Element.
const auto & get(const DataBox< TagList > &box)
Retrieve the item with tag Tag from the DataBox.
Definition: DataBox.hpp:1323
void phi(gsl::not_null< tnsr::iaa< DataType, SpatialDim, Frame > * > phi, const Scalar< DataType > &lapse, const tnsr::i< DataType, SpatialDim, Frame > &deriv_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::iJ< DataType, SpatialDim, Frame > &deriv_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ijj< DataType, SpatialDim, Frame > &deriv_spatial_metric)
Computes the auxiliary variable used by the generalized harmonic formulation of Einstein's equations...
void spacetime_metric(gsl::not_null< tnsr::aa< DataType, Dim, Frame > * > spacetime_metric, const Scalar< DataType > &lapse, const tnsr::I< DataType, Dim, Frame > &shift, const tnsr::ii< DataType, Dim, Frame > &spatial_metric)
Computes the spacetime metric from the spatial metric, lapse, and shift.
void pi(gsl::not_null< tnsr::aa< DataType, SpatialDim, Frame > * > pi, const Scalar< DataType > &lapse, const Scalar< DataType > &dt_lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::I< DataType, SpatialDim, Frame > &dt_shift, const tnsr::ii< DataType, SpatialDim, Frame > &spatial_metric, const tnsr::ii< DataType, SpatialDim, Frame > &dt_spatial_metric, const tnsr::iaa< DataType, SpatialDim, Frame > &phi)
Computes the conjugate momentum of the spacetime metric .
tnsr::I< DataType, SpatialDim, Frame > shift(const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric, const tnsr::II< DataType, SpatialDim, Frame > &inverse_spatial_metric)
Compute shift from spacetime metric and inverse spatial metric.
tnsr::A< DataType, SpatialDim, Frame > spacetime_normal_vector(const Scalar< DataType > &lapse, const tnsr::I< DataType, SpatialDim, Frame > &shift)
Computes spacetime normal vector from lapse and shift.
Scalar< DataType > lapse(const tnsr::I< DataType, SpatialDim, Frame > &shift, const tnsr::aa< DataType, SpatialDim, Frame > &spacetime_metric)
Compute lapse from shift and spacetime metric.
#define MAKE_GENERATOR(...)
MAKE_GENERATOR(NAME [, SEED]) declares a variable of name NAME containing a generator of type std::mt...
Definition: TestHelpers.hpp:419
void transform(const gsl::not_null< History< DestVars > * > dest, const History< SourceVars > &source, ValueTransformer &&value_transformer, DerivativeTransformer &&derivative_transformer)
Initialize a History object based on the contents of another, applying a transformation to each value...
Definition: History.hpp:1053
constexpr T & value(T &t)
Returns t.value() if t is a std::optional otherwise returns t.
Definition: OptionalHelpers.hpp:32
auto array_indices_with_queued_simple_actions(const gsl::not_null< MockRuntimeSystem * > runner) -> detail::array_indices_for_each_component< ComponentList >
Returns a vector of array_indices for each Component. The vector is filled with only those array_indi...
Definition: MockRuntimeSystemFreeFunctions.hpp:427
size_t number_of_elements_with_queued_simple_actions(const detail::array_indices_for_each_component< ComponentList > &array_indices)
Given the output of array_indices_with_queued_simple_actions, returns the total number of array indic...
Definition: MockRuntimeSystemFreeFunctions.hpp:448
Parallel::GlobalCache< Metavariables > & cache(MockRuntimeSystem< Metavariables > &runner, const ArrayIndex &array_index)
Returns the GlobalCache of Component with index array_index.
Definition: MockRuntimeSystemFreeFunctions.hpp:379
void invoke_random_queued_simple_action(const gsl::not_null< MockRuntimeSystem * > runner, const gsl::not_null< Generator * > generator, const detail::array_indices_for_each_component< ComponentList > &array_indices)
Invokes the next queued action on a random Component on a random array_index of that component....
Definition: MockRuntimeSystemFreeFunctions.hpp:465
void simple_action(const gsl::not_null< MockRuntimeSystem< Metavariables > * > runner, const typename Component::array_index &array_index, Args &&... args)
Runs the simple action Action on the array_indexth element of the parallel component Component.
Definition: MockRuntimeSystemFreeFunctions.hpp:286
Indicates the Frame that a TensorIndexType is in.
Definition: IndexType.hpp:36
Holds entities related to the computational domain.
Definition: BoundaryCondition.hpp:14
Mesh< Dim > mesh(const Mesh< Dim > &dg_mesh)
Computes the cell-centered finite-difference mesh from the DG mesh, using grid points per dimension,...
ylm::Tags::aliases::Jacobian< Fr > jacobian(const tnsr::i< DataVector, 2, ::Frame::Spherical< Fr > > &theta_phi)
ylm::Tags::aliases::InvJacobian< Fr > inv_jacobian(const tnsr::i< DataVector, 2, ::Frame::Spherical< Fr > > &theta_phi)
Definition: IndexType.hpp:45
Definition: IndexType.hpp:46
Adds volume data from an Element.
Definition: InterpolatorReceiveVolumeData.hpp:72