Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
moxcodes committed Aug 9, 2021
1 parent 97b2b7a commit 8b66fa3
Show file tree
Hide file tree
Showing 56 changed files with 1,760 additions and 1,273 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Evolution/Systems/GeneralizedHarmonic/BoundaryConditions/RegisterDerivedWithCharm.hpp"
#include "Evolution/Systems/GeneralizedHarmonic/BoundaryCorrections/RegisterDerived.hpp"
#include "Evolution/Systems/GeneralizedHarmonic/ConstraintDamping/RegisterDerivedWithCharm.hpp"
#include "NumericalAlgorithms/Interpolation/AddTemporalIdsToInterpolationTarget.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/ErrorOnFailedApparentHorizon.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/FindApparentHorizon.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
Expand Down Expand Up @@ -59,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 @@ -50,6 +50,7 @@
#include "IO/Observer/ObserverComponent.hpp"
#include "IO/Observer/Tags.hpp"
#include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
#include "NumericalAlgorithms/Interpolation/AddTemporalIdsToInterpolationTarget.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/FindApparentHorizon.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
#include "NumericalAlgorithms/Interpolation/CleanUpInterpolator.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "Evolution/Systems/GrMhd/GhValenciaDivClean/BoundaryCorrections/RegisterDerived.hpp"
#include "Evolution/Systems/GrMhd/ValenciaDivClean/Tags.hpp"
#include "Evolution/VariableFixing/Tags.hpp"
#include "NumericalAlgorithms/Interpolation/AddTemporalIdsToInterpolationTarget.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/ErrorOnFailedApparentHorizon.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/FindApparentHorizon.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
Expand Down Expand Up @@ -61,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 @@ -75,6 +75,7 @@
#include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
#include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
#include "NumericalAlgorithms/Interpolation/Actions/ElementInitInterpPoints.hpp"
#include "NumericalAlgorithms/Interpolation/AddTemporalIdsToInterpolationTarget.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/FindApparentHorizon.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
#include "NumericalAlgorithms/Interpolation/CleanUpInterpolator.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
#include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
#include "NumericalAlgorithms/Interpolation/Actions/ElementInitInterpPoints.hpp"
#include "NumericalAlgorithms/Interpolation/AddTemporalIdsToInterpolationTarget.hpp"
#include "NumericalAlgorithms/Interpolation/Callbacks/ObserveTimeSeriesOnSurface.hpp"
#include "NumericalAlgorithms/Interpolation/CleanUpInterpolator.hpp"
#include "NumericalAlgorithms/Interpolation/InitializeInterpolationTarget.hpp"
Expand Down Expand Up @@ -400,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 @@ -10,5 +10,5 @@ spectre_target_headers(
InterpolationTargetSendPoints.hpp
InterpolationTargetVarsFromElement.hpp
SendPointsToInterpolator.hpp
VerifyTimesAndSendPoints.hpp
VerifyTemporalIdsAndSendPoints.hpp
)
Original file line number Diff line number Diff line change
Expand Up @@ -29,57 +29,62 @@ namespace Actions {
///
/// If interpolated variables for all target points have been received, then
/// - Calls `InterpolationTargetTag::post_interpolation_callback`
/// - Removes the finished time from `Tags::Times`
/// and adds it to `Tags::CompletedTimes`
/// - Removes `Tags::InterpolatedVars<InterpolationTargetTag>`,
/// - Removes the finished `temporal_id` from `Tags::TemporalIds<TemporalId>`
/// and adds it to `Tags::CompletedTemporalIds<TemporalId>`
/// - Removes `Tags::InterpolatedVars<InterpolationTargetTag,TemporalId>`,
/// `Tags::IndicesOfFilledInterpPoints`, and
/// `Tags::IndicesOfInvalidInterpPoints` for the finished time.
/// `Tags::IndicesOfInvalidInterpPoints` for the finished `temporal_id`.
///
/// Uses:
/// - DataBox:
/// - `Tags::Times`
/// - `Tags::IndicesOfFilledInterpPoints`
/// - `Tags::InterpolatedVars<InterpolationTargetTag>`
/// - `Tags::InterpolatedVars<InterpolationTargetTag>`
/// - `Tags::TemporalIds<TemporalId>`
/// - `Tags::IndicesOfFilledInterpPoints<TemporalId>`
/// - `Tags::InterpolatedVars<InterpolationTargetTag,TemporalId>`
/// - `Tags::InterpolatedVars<InterpolationTargetTag,TemporalId>`
/// - `::Tags::Variables<typename
/// InterpolationTargetTag::vars_to_interpolate_to_target>`
///
/// DataBox changes:
/// - Adds: nothing
/// - Removes: nothing
/// - Modifies:
/// - `Tags::Times`
/// - `Tags::CompletedTimes`
/// - `Tags::IndicesOfFilledInterpPoints`
/// - `Tags::InterpolatedVars<InterpolationTargetTag>`
/// - `Tags::TemporalIds<TemporalId>`
/// - `Tags::CompletedTemporalIds<TemporalId>`
/// - `Tags::IndicesOfFilledInterpPoints<TemporalId>`
/// - `Tags::InterpolatedVars<InterpolationTargetTag,TemporalId>`
/// - `::Tags::Variables<typename
/// InterpolationTargetTag::vars_to_interpolate_to_target>`
///
/// For requirements on InterpolationTargetTag, see InterpolationTarget
template <typename InterpolationTargetTag>
struct InterpolationTargetVarsFromElement {
/// For requirements on Metavariables, see InterpolationTarget
template <typename ParallelComponent, typename DbTags, typename Metavariables,
typename ArrayIndex,
Requires<tmpl::list_contains_v<DbTags, Tags::Times>> = nullptr>
template <
typename ParallelComponent, typename DbTags, typename Metavariables,
typename ArrayIndex, typename TemporalId,
Requires<tmpl::list_contains_v<DbTags, Tags::TemporalIds<TemporalId>>> =
nullptr>
static void apply(
db::DataBox<DbTags>& box, Parallel::GlobalCache<Metavariables>& cache,
db::DataBox<DbTags>& box,
Parallel::GlobalCache<Metavariables>& cache,
const ArrayIndex& /*array_index*/,
const std::vector<Variables<
typename InterpolationTargetTag::vars_to_interpolate_to_target>>&
vars_src,
const std::vector<std::vector<size_t>>& global_offsets,
const double time) noexcept {
const TemporalId& temporal_id) noexcept {
static_assert(
not InterpolationTargetTag::compute_target_points::is_sequential::value,
"Use InterpolationTargetGetVarsFromElement only with non-sequential"
" compute_target_points");
// Check if we already have completed interpolation at this time.
const auto& completed_times = db::get<Tags::CompletedTimes>(box);
// (Search from the end because time is more likely to be
// Check if we already have completed interpolation at this
// temporal_id.
const auto& completed_ids =
db::get<Tags::CompletedTemporalIds<TemporalId>>(box);
// (Search from the end because temporal_id is more likely to be
// at the end of the list then at the beginning.)
if (UNLIKELY(std::find(completed_times.rbegin(), completed_times.rend(),
time) != completed_times.rend())) {
if (UNLIKELY(std::find(completed_ids.rbegin(), completed_ids.rend(),
temporal_id) != completed_ids.rend())) {
// The code will get into this 'if' statement in the following
// scenario:
// - There is at least one interpolation point exactly on the
Expand All @@ -88,7 +93,7 @@ struct InterpolationTargetVarsFromElement {
// with data for the same interpolation point (this is ok,
// and add_received_variables handles this).
// - The only Elements that have not yet called
// InterpolationTargetVarsFromElement for this time are
// InterpolationTargetVarsFromElement for this temporal_id are
// those that have data only for duplicated interpolation
// points, and the InterpolationTarget has already received
// that data from other Elements.
Expand All @@ -97,49 +102,50 @@ struct InterpolationTargetVarsFromElement {
// one more condition needed for the scenario that gets
// us inside this 'if':
// - The InterpolationTarget has already completed its work at
// this time, and it has cleaned up its data structures
// for this time before all of the remaining calls to
// this temporal_id, and it has cleaned up its data structures
// for this temporal_id before all of the remaining calls to
// InterpolationTargetVarsFromElement have occurred at this
// time, and now we are in one of those remaining
// temporal_id, and now we are in one of those remaining
// calls.
//
// If this scenario occurs, we just return. This is because the
// InterpolationTarget is done and there is nothing left to do
// at this time. Note that if there were extra work to
// do at this time, then CompletedTimes would not
// have an entry for this time.
// at this temporal_id. Note that if there were extra work to
// do at this temporal_id, then CompletedTemporalIds would not
// have an entry for this temporal_id.
return;
}

// Call set_up_interpolation only if it has not been called for this time.
// If flag_times_for_interpolation returns an empty list, then
// flag_times_for_interpolation has already been called for the
// same time (by an invocation of InterpolationTargetVarsFromElement
// Call set_up_interpolation only if it has not been called for this
// temporal_id.
// If flag_temporal_ids_for_interpolation returns an empty list, then
// flag_temporal_ids_for_interpolation has already been called for the
// same temporal_id (by an invocation of InterpolationTargetVarsFromElement
// by a different Element) and hence set_up_interpolation has already
// been called.
if (not InterpolationTarget_detail::flag_times_for_interpolation<
if (not InterpolationTarget_detail::flag_temporal_ids_for_interpolation<
InterpolationTargetTag>(make_not_null(&box),
std::vector<double>{time})
std::vector<TemporalId>{{temporal_id}})
.empty()) {
InterpolationTarget_detail::set_up_interpolation<InterpolationTargetTag>(
make_not_null(&box), time,
make_not_null(&box), temporal_id,
InterpolationTarget_detail::block_logical_coords<
InterpolationTargetTag>(box, tmpl::type_<Metavariables>{}));
}

InterpolationTarget_detail::add_received_variables<InterpolationTargetTag>(
make_not_null(&box), vars_src, global_offsets, time);
make_not_null(&box), vars_src, global_offsets, temporal_id);

if (InterpolationTarget_detail::have_data_at_all_points<
InterpolationTargetTag>(box, time)) {
InterpolationTargetTag>(box, temporal_id)) {
// All the valid points have been interpolated.
// We throw away the return value of call_callback in this case
// (it is known to be always true; it can be false only for
// sequential interpolations, which is static-asserted against above).
InterpolationTarget_detail::call_callback<InterpolationTargetTag>(
make_not_null(&box), make_not_null(&cache), time);
make_not_null(&box), make_not_null(&cache), temporal_id);
InterpolationTarget_detail::clean_up_interpolation_target<
InterpolationTargetTag>(make_not_null(&box), time);
InterpolationTargetTag>(make_not_null(&box), temporal_id);
}
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace intrp {
namespace Actions {
/// \ingroup ActionsGroup
/// \brief Sets up points on an `InterpolationTarget` at a new time
/// \brief Sets up points on an `InterpolationTarget` at a new `temporal_id`
/// and sends these points to an `Interpolator`.
///
/// Uses:
Expand All @@ -28,26 +28,28 @@ namespace Actions {
/// - Modifies:
/// - `Tags::IndicesOfFilledInterpPoints`
/// - `Tags::IndicesOfInvalidInterpPoints`
/// - `Tags::InterpolatedVars<InterpolationTargetTag>`
/// - `Tags::InterpolatedVars<InterpolationTargetTag, TemporalId>`
///
/// For requirements on InterpolationTargetTag, see InterpolationTarget
template <typename InterpolationTargetTag>
struct SendPointsToInterpolator {
template <typename ParallelComponent, typename DbTags, typename Metavariables,
typename ArrayIndex,
Requires<tmpl::list_contains_v<DbTags, Tags::Times>> = nullptr>
template <
typename ParallelComponent, typename DbTags, typename Metavariables,
typename ArrayIndex, typename TemporalId,
Requires<tmpl::list_contains_v<DbTags, Tags::TemporalIds<TemporalId>>> =
nullptr>
static void apply(db::DataBox<DbTags>& box,
Parallel::GlobalCache<Metavariables>& cache,
const ArrayIndex& /*array_index*/,
const double time) noexcept {
const TemporalId& temporal_id) noexcept {
auto coords = InterpolationTarget_detail::block_logical_coords<
InterpolationTargetTag>(box, cache, time);
InterpolationTargetTag>(box, cache, temporal_id);
InterpolationTarget_detail::set_up_interpolation<InterpolationTargetTag>(
make_not_null(&box), time, coords);
make_not_null(&box), temporal_id, coords);
auto& receiver_proxy =
Parallel::get_parallel_component<Interpolator<Metavariables>>(cache);
Parallel::simple_action<Actions::ReceivePoints<InterpolationTargetTag>>(
receiver_proxy, time, std::move(coords));
receiver_proxy, temporal_id, std::move(coords));
}
};

Expand Down

0 comments on commit 8b66fa3

Please sign in to comment.