Skip to content

Commit

Permalink
Use temporal_id from InterpolationTargetTags
Browse files Browse the repository at this point in the history
  • Loading branch information
moxcodes committed Aug 10, 2021
1 parent 652426b commit ae13208
Show file tree
Hide file tree
Showing 46 changed files with 468 additions and 309 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ struct EvolutionMetavars
"on a domain with a single horizon and corresponding excised region"};

struct AhA {
using temporal_id = ::Tags::Time;
using tags_to_observe =
tmpl::list<StrahlkorperGr::Tags::AreaCompute<frame>,
StrahlkorperGr::Tags::IrreducibleMassCompute<frame>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ struct EvolutionMetavars
"on a domain with a single horizon and corresponding excised region"};

struct AhA {
using temporal_id = ::Tags::Time;
using tags_to_observe =
tmpl::list<StrahlkorperGr::Tags::AreaCompute<domain_frame>>;
using compute_vars_to_interpolate = ah::ComputeHorizonVolumeQuantities;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ struct EvolutionMetavars {
};

struct KerrHorizon {
using temporal_id = ::Tags::Time;
using tags_to_observe =
tmpl::list<StrahlkorperTags::EuclideanSurfaceIntegralVectorCompute<
hydro::Tags::MassFlux<DataVector, 3>, ::Frame::Inertial>>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#pragma once

#include "DataStructures/DataBox/DataBox.hpp"
#include "NumericalAlgorithms/Interpolation/Actions/SendPointsToInterpolator.hpp"
#include "NumericalAlgorithms/Interpolation/InterpolationTargetDetail.hpp"
#include "NumericalAlgorithms/Interpolation/Tags.hpp"
#include "Parallel/GlobalCache.hpp"
Expand All @@ -21,7 +22,7 @@ template <typename InterpolationTargetTag, typename ParallelComponent,
void verify_temporal_ids_and_send_points_time_independent(
const gsl::not_null<db::DataBox<DbTags>*> box,
Parallel::GlobalCache<Metavariables>& cache) noexcept {
using TemporalId = typename Metavariables::temporal_id::type;
using TemporalId = typename InterpolationTargetTag::temporal_id::type;

// Move all PendingTemporalIds to TemporalIds, provided
// that they are not already there, and fill new_temporal_ids
Expand Down Expand Up @@ -70,7 +71,7 @@ template <typename InterpolationTargetTag, typename ParallelComponent,
void verify_temporal_ids_and_send_points_time_dependent(
const gsl::not_null<db::DataBox<DbTags>*> box,
Parallel::GlobalCache<Metavariables>& cache) noexcept {
using TemporalId = typename Metavariables::temporal_id::type;
using TemporalId = typename InterpolationTargetTag::temporal_id::type;

const auto& pending_temporal_ids =
db::get<Tags::PendingTemporalIds<TemporalId>>(*box);
Expand All @@ -97,7 +98,9 @@ void verify_temporal_ids_and_send_points_time_dependent(
})
->second->time_bounds()[1];
for (const auto& pending_id : pending_temporal_ids) {
if (pending_id.step_time().value() <= min_expiration_time) {
if (InterpolationTarget_detail::
evaluate_temporal_id_for_expiration(pending_id) <=
min_expiration_time) {
// Success: at least one pending_temporal_id is ok.
return std::unique_ptr<Parallel::Callback>{};
}
Expand Down Expand Up @@ -128,7 +131,8 @@ void verify_temporal_ids_and_send_points_time_dependent(
const gsl::not_null<std::deque<TemporalId>*> pending_ids,
const std::deque<TemporalId>& completed_ids) noexcept {
for (auto it = pending_ids->begin(); it != pending_ids->end();) {
if (it->step_time().value() <= min_expiration_time and
if (InterpolationTarget_detail::evaluate_temporal_id_for_expiration(
*it) <= min_expiration_time and
std::find(completed_ids.begin(), completed_ids.end(), *it) ==
completed_ids.end() and
std::find(ids->begin(), ids->end(), *it) == ids->end()) {
Expand Down Expand Up @@ -220,9 +224,8 @@ struct VerifyTemporalIdsAndSendPoints {
template <typename ParallelComponent, typename DbTags, typename Metavariables,
typename ArrayIndex,
Requires<tmpl::list_contains_v<
DbTags,
Tags::TemporalIds<typename Metavariables::temporal_id::type>>> =
nullptr>
DbTags, Tags::TemporalIds<typename InterpolationTargetTag::
temporal_id::type>>> = nullptr>
static void apply(db::DataBox<DbTags>& box,
Parallel::GlobalCache<Metavariables>& cache,
const ArrayIndex& /*array_index*/) noexcept {
Expand Down
1 change: 1 addition & 0 deletions src/NumericalAlgorithms/Interpolation/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ spectre_target_sources(
CubicSpanInterpolator.cpp
CubicSpline.cpp
InterpolationTargetApparentHorizon.cpp
InterpolationTargetDetail.cpp
InterpolationTargetKerrHorizon.cpp
InterpolationTargetLineSegment.cpp
InterpolationTargetSpecifiedPoints.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "DataStructures/DataBox/TagName.hpp"
#include "IO/Observer/Helpers.hpp"
#include "IO/Observer/ObservationId.hpp"
#include "NumericalAlgorithms/Interpolation/InterpolationTargetDetail.hpp"
#include "Parallel/GlobalCache.hpp"
#include "Parallel/Info.hpp"
#include "Parallel/Invoke.hpp"
Expand Down Expand Up @@ -97,10 +98,10 @@ struct ObserveTimeSeriesOnSurface {
std::numeric_limits<double>::quiet_NaN();

template <typename DbTags, typename Metavariables>
static void apply(
const db::DataBox<DbTags>& box,
Parallel::GlobalCache<Metavariables>& cache,
const typename Metavariables::temporal_id::type& temporal_id) noexcept {
static void apply(const db::DataBox<DbTags>& box,
Parallel::GlobalCache<Metavariables>& cache,
const typename InterpolationTargetTag::temporal_id::type&
temporal_id) noexcept {
auto& proxy = Parallel::get_parallel_component<
observers::ObserverWriter<Metavariables>>(cache);

Expand All @@ -111,13 +112,15 @@ struct ObserveTimeSeriesOnSurface {
auto& my_proxy = Parallel::get_parallel_component<ParallelComponent>(cache);
Parallel::threaded_action<observers::ThreadedActions::WriteReductionData>(
proxy[0],
observers::ObservationId(temporal_id.substep_time().value(),
pretty_type::get_name<ObservationType>()),
observers::ObservationId(
InterpolationTarget_detail::get_temporal_id_value(temporal_id),
pretty_type::get_name<ObservationType>()),
static_cast<size_t>(Parallel::my_node(*my_proxy.ckLocal())),
std::string{"/" + pretty_type::short_name<InterpolationTargetTag>()},
detail::make_legend(TagsToObserve{}),
detail::make_reduction_data(box, temporal_id.substep_time().value(),
TagsToObserve{}));
detail::make_reduction_data(
box, InterpolationTarget_detail::get_temporal_id_value(temporal_id),
TagsToObserve{}));
}
};
} // namespace callbacks
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,20 @@ namespace callbacks {
/// \brief post_interpolation_callback that calls Cce::ReceiveGhWorldTubeData
///
/// Uses:
/// - Metavariables
/// - `temporal_id`
/// - DataBox:
/// - `::gr::Tags::SpacetimeMetric<3,Frame::Inertial>`
/// - `::GeneralizedHarmonic::Tags::Pi<3,Frame::Inertial>`
/// - `::GeneralizedHarmonic::Tags::Phi<3,Frame::Inertial>`
///
/// This is an InterpolationTargetTag::post_interpolation_callback;
/// see InterpolationTarget for a description of InterpolationTargetTag.
template <typename CceEvolutionComponent>
template <typename CceEvolutionComponent, typename TemporalId>
struct SendGhWorldtubeData {
using observation_types = tmpl::list<>;
template <typename DbTags, typename Metavariables>
static void apply(
const db::DataBox<DbTags>& box,
Parallel::GlobalCache<Metavariables>& cache,
const typename Metavariables::temporal_id::type& temporal_id) noexcept {
static void apply(const db::DataBox<DbTags>& box,
Parallel::GlobalCache<Metavariables>& cache,
const typename TemporalId::type& temporal_id) noexcept {
auto& cce_gh_boundary_component = Parallel::get_parallel_component<
Cce::GhWorldtubeBoundary<Metavariables>>(cache);
Parallel::simple_action<
Expand Down
47 changes: 30 additions & 17 deletions src/NumericalAlgorithms/Interpolation/CleanUpInterpolator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ namespace Tags {
struct NumberOfElements;
template <typename Metavariables>
struct InterpolatedVarsHolders;
template <typename Metavariables> struct VolumeVarsInfo;
template <typename Metavariables, typename TemporalId>
struct VolumeVarsInfo;
} // namespace Tags
namespace Vars {
template <typename InterpolationTargetTag, typename Metavariables>
Expand Down Expand Up @@ -59,11 +60,11 @@ struct CleanUpInterpolator {
typename ParallelComponent, typename DbTags, typename Metavariables,
typename ArrayIndex,
Requires<tmpl::list_contains_v<DbTags, Tags::NumberOfElements>> = nullptr>
static void apply(
db::DataBox<DbTags>& box, // HorizonManager's box
const Parallel::GlobalCache<Metavariables>& /*cache*/,
const ArrayIndex& /*array_index*/,
const typename Metavariables::temporal_id::type& temporal_id) noexcept {
static void apply(db::DataBox<DbTags>& box, // HorizonManager's box
const Parallel::GlobalCache<Metavariables>& /*cache*/,
const ArrayIndex& /*array_index*/,
const typename InterpolationTargetTag::temporal_id::type&
temporal_id) noexcept {
// Signal that this InterpolationTarget is done at this time.
db::mutate<Tags::InterpolatedVarsHolders<Metavariables>>(
make_not_null(&box),
Expand All @@ -83,21 +84,29 @@ struct CleanUpInterpolator {
tmpl::for_each<typename Metavariables::interpolation_target_tags>(
[&](auto tag) noexcept {
using Tag = typename decltype(tag)::type;
const auto& found = get<Vars::HolderTag<Tag, Metavariables>>(holders)
.temporal_ids_when_data_has_been_interpolated;
if (found.count(temporal_id) == 0) {
this_temporal_id_is_done = false;
if constexpr (std::is_same_v<
typename InterpolationTargetTag::temporal_id,
typename Tag::temporal_id>) {
const auto& found =
get<Vars::HolderTag<Tag, Metavariables>>(holders)
.temporal_ids_when_data_has_been_interpolated;
if (found.count(temporal_id) == 0) {
this_temporal_id_is_done = false;
}
}
});

// We don't need any more volume data for this temporal_id,
// so remove it.
if (this_temporal_id_is_done) {
db::mutate<Tags::VolumeVarsInfo<Metavariables>>(
db::mutate<Tags::VolumeVarsInfo<
Metavariables, typename InterpolationTargetTag::temporal_id>>(
make_not_null(&box),
[&temporal_id](const gsl::not_null<
typename Tags::VolumeVarsInfo<Metavariables>::type*>
volume_vars_info) noexcept {
[&temporal_id](
const gsl::not_null<typename Tags::VolumeVarsInfo<
Metavariables,
typename InterpolationTargetTag::temporal_id>::type*>
volume_vars_info) noexcept {
volume_vars_info->erase(temporal_id);
});

Expand All @@ -111,9 +120,13 @@ struct CleanUpInterpolator {
tmpl::for_each<typename Metavariables::interpolation_target_tags>(
[&](auto tag) noexcept {
using Tag = typename decltype(tag)::type;
get<Vars::HolderTag<Tag, Metavariables>>(*holders_l)
.temporal_ids_when_data_has_been_interpolated.erase(
temporal_id);
if constexpr (std::is_same_v<typename InterpolationTargetTag::
temporal_id,
typename Tag::temporal_id>) {
get<Vars::HolderTag<Tag, Metavariables>>(*holders_l)
.temporal_ids_when_data_has_been_interpolated.erase(
temporal_id);
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,9 @@
#include "Parallel/Invoke.hpp"
#include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
#include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
#include "Time/TimeStepId.hpp"
#include "Utilities/TMPL.hpp"

/// \cond
namespace Tags {
struct TimeStepId;
} // namespace Tags
namespace domain {
namespace Tags {
template <size_t VolumeDim>
Expand Down Expand Up @@ -77,13 +73,13 @@ class InterpolateWithoutInterpComponent<VolumeDim, InterpolationTargetTag,

InterpolateWithoutInterpComponent() = default;

using argument_tags =
tmpl::list<::Tags::TimeStepId, Tags::InterpPointInfo<Metavariables>,
domain::Tags::Mesh<VolumeDim>, Tensors...>;
using argument_tags = tmpl::list<typename InterpolationTargetTag::temporal_id,
Tags::InterpPointInfo<Metavariables>,
domain::Tags::Mesh<VolumeDim>, Tensors...>;

template <typename ParallelComponent>
void operator()(
const TimeStepId& time_id,
const typename InterpolationTargetTag::temporal_id::type& time_id,
const typename Tags::InterpPointInfo<Metavariables>::type& point_infos,
const Mesh<VolumeDim>& mesh, const typename Tensors::type&... tensors,
Parallel::GlobalCache<Metavariables>& cache,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct compute_target_points_tags<
/// `Initialization` phase action list prior to this action.
template <typename Metavariables, typename InterpolationTargetTag>
struct InitializeInterpolationTarget {
using TemporalId = typename Metavariables::temporal_id::type;
using TemporalId = typename InterpolationTargetTag::temporal_id::type;
using return_tag_list_initial = tmpl::list<
Tags::IndicesOfFilledInterpPoints<TemporalId>,
Tags::IndicesOfInvalidInterpPoints<TemporalId>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Tags {
struct NumberOfElements;
template <typename Metavariables>
struct InterpolatedVarsHolders;
template <typename Metavariables>
template <typename Metavariables, typename TemporalId>
struct VolumeVarsInfo;
} // namespace Tags
} // namespace intrp
Expand All @@ -50,10 +50,11 @@ namespace Actions {
/// \note This action relies on the `SetupDataBox` aggregated initialization
/// mechanism, so `Actions::SetupDataBox` must be present in the
/// `Initialization` phase action list prior to this action.
template <typename VolumeVarsInfo, typename InterpolatedVarsHolders>
template <typename VolumeVarsInfos, typename InterpolatedVarsHolders>
struct InitializeInterpolator {
using return_tag_list = tmpl::list<Tags::NumberOfElements, VolumeVarsInfo,
InterpolatedVarsHolders>;
using return_tag_list =
tmpl::flatten<tmpl::list<Tags::NumberOfElements, VolumeVarsInfos,
InterpolatedVarsHolders>>;

using simple_tags = return_tag_list;
using compute_tags = tmpl::list<>;
Expand Down
26 changes: 13 additions & 13 deletions src/NumericalAlgorithms/Interpolation/Interpolate.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,9 @@
#include "Parallel/Invoke.hpp"
#include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
#include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
#include "Time/TimeStepId.hpp"
#include "Utilities/TMPL.hpp"

/// \cond
namespace Tags {
struct TimeStepId;
} // namespace Tags
namespace domain {
namespace Tags {
template <size_t VolumeDim>
Expand All @@ -40,6 +36,7 @@ struct InterpolationTarget;
template <typename Metavariables>
struct Interpolator;
namespace Actions {
template <typename TemporalId>
struct InterpolatorReceiveVolumeData;
} // namespace Actions
} // namespace intrp
Expand Down Expand Up @@ -72,15 +69,16 @@ class Interpolate<VolumeDim, InterpolationTargetTag, tmpl::list<Tensors...>>

Interpolate() = default;

using argument_tags =
tmpl::list<::Tags::TimeStepId, domain::Tags::Mesh<VolumeDim>, Tensors...>;
using argument_tags = tmpl::list<typename InterpolationTargetTag::temporal_id,
domain::Tags::Mesh<VolumeDim>, Tensors...>;

template <typename Metavariables, typename ParallelComponent>
void operator()(const TimeStepId& time_id, const Mesh<VolumeDim>& mesh,
const typename Tensors::type&... tensors,
Parallel::GlobalCache<Metavariables>& cache,
const ElementId<VolumeDim>& array_index,
const ParallelComponent* const /*meta*/) const noexcept {
void operator()(
const typename InterpolationTargetTag::temporal_id::type& time_id,
const Mesh<VolumeDim>& mesh, const typename Tensors::type&... tensors,
Parallel::GlobalCache<Metavariables>& cache,
const ElementId<VolumeDim>& array_index,
const ParallelComponent* const /*meta*/) const noexcept {
Variables<tmpl::list<Tensors...>> interp_vars(mesh.number_of_grid_points());
const auto copy_to_variables = [&interp_vars](const auto tensor_tag_v,
const auto& tensor) noexcept {
Expand All @@ -95,7 +93,8 @@ class Interpolate<VolumeDim, InterpolationTargetTag, tmpl::list<Tensors...>>
auto& interpolator =
*::Parallel::get_parallel_component<Interpolator<Metavariables>>(cache)
.ckLocalBranch();
Parallel::simple_action<Actions::InterpolatorReceiveVolumeData>(
Parallel::simple_action<Actions::InterpolatorReceiveVolumeData<
typename InterpolationTargetTag::temporal_id>>(
interpolator, time_id, ElementId<VolumeDim>(array_index), mesh,
interp_vars);

Expand All @@ -104,7 +103,8 @@ class Interpolate<VolumeDim, InterpolationTargetTag, tmpl::list<Tensors...>>
InterpolationTarget<Metavariables, InterpolationTargetTag>>(cache);
Parallel::simple_action<
Actions::AddTemporalIdsToInterpolationTarget<InterpolationTargetTag>>(
target, std::vector<TimeStepId>{time_id});
target, std::vector<typename InterpolationTargetTag::temporal_id::type>{
time_id});
}

using is_ready_argument_tags = tmpl::list<>;
Expand Down
5 changes: 3 additions & 2 deletions src/NumericalAlgorithms/Interpolation/InterpolatedVars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,11 @@ void operator|(PUP::er& p, Info<VolumeDim, TagList>& t) noexcept { // NOLINT
template <typename Metavariables,
typename InterpolationTargetTag, typename TagList>
struct Holder {
std::unordered_map<typename Metavariables::temporal_id::type,
using temporal_id = typename InterpolationTargetTag::temporal_id;
std::unordered_map<typename InterpolationTargetTag::temporal_id::type,
Info<Metavariables::volume_dim, TagList>>
infos;
std::unordered_set<typename Metavariables::temporal_id::type>
std::unordered_set<typename InterpolationTargetTag::temporal_id::type>
temporal_ids_when_data_has_been_interpolated;
};

Expand Down

0 comments on commit ae13208

Please sign in to comment.