Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute a worldtube constraint for Klein-Gordon Cce #5931

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ struct EvolutionMetavars : CharacteristicExtractDefaults<false> {
using klein_gordon_scri_tags =
tmpl::list<Cce::Tags::ScriPlus<Cce::Tags::KleinGordonPi>>;

using klein_gordon_constraint_tags =
tmpl::list<Cce::Tags::KleinGordonWorldtubeConstraint>;

using cce_step_choosers =
tmpl::list<StepChoosers::Constant<StepChooserUse::LtsStep>,
StepChoosers::Increase<StepChooserUse::LtsStep>,
Expand Down Expand Up @@ -110,7 +113,8 @@ struct EvolutionMetavars : CharacteristicExtractDefaults<false> {

using scri_values_to_observe =
tmpl::append<cce_base::scri_values_to_observe,
tmpl::list<Cce::Tags::ScriPlus<Cce::Tags::KleinGordonPsi>>>;
tmpl::list<Cce::Tags::KleinGordonWorldtubeConstraint,
Cce::Tags::ScriPlus<Cce::Tags::KleinGordonPsi>>>;

using cce_scri_tags =
tmpl::append<cce_base::cce_scri_tags,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ struct InitializeKleinGordonVariables {
::Tags::Variables<typename Metavariables::klein_gordon_source_tags>;
using klein_gordon_integrand_variables_tag = ::Tags::Variables<
typename Metavariables::klein_gordon_cce_integrand_tags>;
using klein_gordon_constraint_variables_tag =
::Tags::Variables<typename Metavariables::klein_gordon_constraint_tags>;

using simple_tags =
tmpl::list<klein_gordon_boundary_communication_tags,
Expand All @@ -60,7 +62,8 @@ struct InitializeKleinGordonVariables {
klein_gordon_swsh_derivatives_variables_tag,
klein_gordon_transform_buffer_variables_tag,
klein_gordon_source_variables_tag,
klein_gordon_integrand_variables_tag>;
klein_gordon_integrand_variables_tag,
klein_gordon_constraint_variables_tag>;

template <typename DbTags, typename... InboxTags, typename ArrayIndex,
typename ActionList, typename ParallelComponent>
Expand Down Expand Up @@ -91,7 +94,8 @@ struct InitializeKleinGordonVariables {
typename klein_gordon_transform_buffer_variables_tag::type{
transform_buffer_size},
typename klein_gordon_source_variables_tag::type{volume_size},
typename klein_gordon_integrand_variables_tag::type{volume_size});
typename klein_gordon_integrand_variables_tag::type{volume_size},
typename klein_gordon_constraint_variables_tag::type{boundary_size});
return {Parallel::AlgorithmExecution::Continue, std::nullopt};
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/Evolution/Systems/Cce/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ spectre_target_sources(
ScriPlusValues.cpp
SpecBoundaryData.cpp
WorldtubeBufferUpdater.cpp
WorldtubeConstraint.cpp
WorldtubeDataManager.cpp
)

Expand Down Expand Up @@ -52,6 +53,7 @@ spectre_target_headers(
KleinGordonSystem.hpp
Tags.hpp
WorldtubeBufferUpdater.hpp
WorldtubeConstraint.hpp
WorldtubeDataManager.hpp
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Evolution/Systems/Cce/Components/CharacteristicEvolution.hpp"
#include "Evolution/Systems/Cce/KleinGordonSource.hpp"
#include "Evolution/Systems/Cce/KleinGordonSystem.hpp"
#include "Evolution/Systems/Cce/WorldtubeConstraint.hpp"
#include "Parallel/GlobalCache.hpp"
#include "Parallel/Local.hpp"
#include "Parallel/Phase.hpp"
Expand Down Expand Up @@ -63,6 +64,7 @@ struct KleinGordonCharacteristicEvolution

using klein_gordon_hypersurface_computation = tmpl::list<
::Actions::MutateApply<GaugeAdjustedBoundaryValue<Tags::KleinGordonPi>>,
::Actions::MutateApply<ComputeKGWorldtubeConstraint>,
Actions::CalculateIntegrandInputsForTag<Tags::KleinGordonPi>,
tmpl::transform<
integrand_terms_to_compute_for_bondi_variable<Tags::KleinGordonPi>,
Expand Down
6 changes: 6 additions & 0 deletions src/Evolution/Systems/Cce/Tags.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,5 +456,11 @@ struct SelfStartGhInterfaceManager : db::SimpleTag {
return Cce::InterfaceManagers::GhLockstep();
}
};

/// A worldtube constraint of Klein-Gordon Cce monitored during evolution
struct KleinGordonWorldtubeConstraint : db::SimpleTag {
using type = Scalar<SpinWeighted<ComplexDataVector, 0>>;
static std::string name() { return "KGConstraint"; }
};
} // namespace Tags
} // namespace Cce
22 changes: 22 additions & 0 deletions src/Evolution/Systems/Cce/WorldtubeConstraint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#include "Evolution/Systems/Cce/WorldtubeConstraint.hpp"

namespace Cce {
void ComputeKGWorldtubeConstraint::apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 0>>*>
evolution_kg_constraint,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& cauchy_kg_psi,
const Spectral::Swsh::SwshInterpolator& interpolator, const size_t l_max,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& volume_psi) {
SpinWeighted<ComplexDataVector, 0> evolution_kg_psi;
interpolator.interpolate(make_not_null(&evolution_kg_psi),
get(cauchy_kg_psi));

const SpinWeighted<ComplexDataVector, 0> surface_psi;
make_const_view(make_not_null(&surface_psi), get(volume_psi), 0,
Spectral::Swsh::number_of_swsh_collocation_points(l_max));
get(*evolution_kg_constraint) = evolution_kg_psi - surface_psi;
}
} // namespace Cce
36 changes: 36 additions & 0 deletions src/Evolution/Systems/Cce/WorldtubeConstraint.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Distributed under the MIT License.
// See LICENSE.txt for details.

#pragma once

#include "Evolution/Systems/Cce/OptionTags.hpp"
#include "Evolution/Systems/Cce/Tags.hpp"
#include "Utilities/Gsl.hpp"
#include "Utilities/TMPL.hpp"

namespace Cce {
/*!
* \brief Compute a worldtube constraint for Klein-Gordon Cce
*
* \details Both Cauchy and characteristic systems evolve the scalar field
* independently. The results have to be consistent at the worldtube. The
* difference (`Tags::KleinGordonWorldtubeConstraint`) between the Cauchy
* worldtube data `Tags::BoundaryValue<Tags::KleinGordonPsi>` and the evolved
* volume data `Tags::KleinGordonPsi` (at the worldtube)
* indicates the accuracy of the simulation.
*/
struct ComputeKGWorldtubeConstraint {
using return_tags = tmpl::list<Tags::KleinGordonWorldtubeConstraint>;
using argument_tags = tmpl::list<
Tags::BoundaryValue<Tags::KleinGordonPsi>,
Spectral::Swsh::Tags::SwshInterpolator<Tags::CauchyAngularCoords>,
Tags::LMax, Tags::KleinGordonPsi>;

static void apply(
gsl::not_null<Scalar<SpinWeighted<ComplexDataVector, 0>>*>
evolution_kg_constraint,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& cauchy_kg_psi,
const Spectral::Swsh::SwshInterpolator& interpolator, size_t l_max,
const Scalar<SpinWeighted<ComplexDataVector, 0>>& volume_psi);
};
} // namespace Cce
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ struct metavariables : CharacteristicExtractDefaults<false> {
tmpl::list<Cce::Tags::PoleOfIntegrand<Cce::Tags::KleinGordonPi>,
Cce::Tags::RegularIntegrand<Cce::Tags::KleinGordonPi>>;

using klein_gordon_constraint_tags =
tmpl::list<Cce::Tags::KleinGordonWorldtubeConstraint>;

using const_global_cache_tags = tmpl::list<Tags::SpecifiedStartTime>;
struct factory_creation
: tt::ConformsTo<Options::protocols::FactoryCreation> {
Expand Down Expand Up @@ -263,6 +266,13 @@ void test_klein_gordon_cce_initialization(const gsl::not_null<Generator*> gen) {
Spectral::Swsh::number_of_swsh_collocation_points(l_max) *
number_of_radial_points);

const auto& kg_constraint_tags = ActionTesting::get_databox_tag<
component,
::Tags::Variables<typename metavariables::klein_gordon_constraint_tags>>(
runner, 0);
CHECK(kg_constraint_tags.number_of_grid_points() ==
Spectral::Swsh::number_of_swsh_collocation_points(l_max));

if (file_system::check_if_file_exists(filename)) {
file_system::rm(filename, true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "Evolution/Systems/Cce/Actions/InitializeKleinGordonFirstHypersurface.hpp"
#include "Evolution/Systems/Cce/KleinGordonSource.hpp"
#include "Evolution/Systems/Cce/PrecomputeCceDependencies.hpp"
#include "Evolution/Systems/Cce/WorldtubeConstraint.hpp"
#include "Framework/ActionTesting.hpp"
#include "Framework/TestHelpers.hpp"
#include "Helpers/DataStructures/MakeWithRandomValues.hpp"
Expand Down Expand Up @@ -38,7 +39,8 @@ using swsh_volume_tags_to_generate =
Spectral::Swsh::Tags::Eth>>;

using swsh_boundary_tags_to_generate =
tmpl::list<Tags::BoundaryValue<Tags::KleinGordonPi>, Tags::BondiUAtScri>;
tmpl::list<Tags::BoundaryValue<Tags::KleinGordonPsi>,
Tags::BoundaryValue<Tags::KleinGordonPi>, Tags::BondiUAtScri>;

using swsh_volume_tags_to_compute =
tmpl::list<Tags::KleinGordonSource<Tags::BondiBeta>,
Expand All @@ -62,7 +64,8 @@ using swsh_volume_tags_to_compute =
Tags::RegularIntegrand<Tags::KleinGordonPi>>;

using swsh_boundary_tags_to_compute =
tmpl::list<Tags::EvolutionGaugeBoundaryValue<Tags::KleinGordonPi>>;
tmpl::list<Tags::EvolutionGaugeBoundaryValue<Tags::KleinGordonPi>,
Tags::KleinGordonWorldtubeConstraint>;

using swsh_transform_tags_to_compute = tmpl::list<
Spectral::Swsh::Tags::SwshTransform<Spectral::Swsh::Tags::Derivative<
Expand Down Expand Up @@ -113,7 +116,8 @@ struct mock_kg_characteristic_evolution {
integrand_terms_to_compute_for_bondi_variable<
Tags::KleinGordonPi>,
tmpl::bind<::Actions::MutateApply,
tmpl::bind<ComputeBondiIntegrand, tmpl::_1>>>>>>;
tmpl::bind<ComputeBondiIntegrand, tmpl::_1>>>,
::Actions::MutateApply<ComputeKGWorldtubeConstraint>>>>;

using const_global_cache_tags =
tmpl::list<Tags::LMax, Tags::NumberOfRadialPoints>;
Expand All @@ -129,9 +133,9 @@ struct metavariables {
// `CalculateIntegrandInputsForTag<Tags::KleinGordonPi>`, the mutators
// `ComputeKleinGordonSource`,
// `GaugeAdjustedBoundaryValue<Tags::KleinGordonPi>`,
// `ComputeBondiIntegrand<Tags::RegularIntegrand<Tags::KleinGordonPi>>`, and
// `ComputeBondiIntegrand<Tags::PoleOfIntegrand<Tags::KleinGordonPi>>`. The test
// involves
// `ComputeBondiIntegrand<Tags::RegularIntegrand<Tags::KleinGordonPi>>`,
// `ComputeBondiIntegrand<Tags::PoleOfIntegrand<Tags::KleinGordonPi>>`, and
// `ComputeKGWorldtubeConstraint`. The test involves
// (a) Fills a bunch of variables with random numbers (filtered so that there is
// no aliasing in highest modes).
// (b) Puts those variables in two places: the MockRuntimeSystem runner and a
Expand Down Expand Up @@ -239,7 +243,7 @@ void test_klein_gordon_cce_source(const gsl::not_null<Generator*> gen) {

runner.set_phase(Parallel::Phase::Evolve);

for (int i = 0; i < 9; i++) {
for (int i = 0; i < 10; i++) {
ActionTesting::next_action<component>(make_not_null(&runner), 0);
}

Expand Down Expand Up @@ -349,6 +353,20 @@ void test_klein_gordon_cce_source(const gsl::not_null<Generator*> gen) {
auto expected_result = db::get<tag>(expected_box);
CHECK(computed_result == expected_result);
});

// tests for `ComputeKGWorldtubeConstraint`
{
db::mutate_apply<ComputeKGWorldtubeConstraint>(
make_not_null(&expected_box));
auto computed_result =
ActionTesting::get_databox_tag<component,
Tags::KleinGordonWorldtubeConstraint>(
runner, 0);

auto expected_result =
db::get<Tags::KleinGordonWorldtubeConstraint>(expected_box);
CHECK(computed_result == expected_result);
}
}
} // namespace

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ struct test_metavariables : CharacteristicExtractDefaults<false> {
using klein_gordon_transform_buffer_tags = tmpl::list<>;
using klein_gordon_source_tags = tmpl::list<>;
using klein_gordon_cce_integrand_tags = tmpl::list<>;
using klein_gordon_constraint_tags = tmpl::list<>;

struct factory_creation
: tt::ConformsTo<Options::protocols::FactoryCreation> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ struct test_metavariables : CharacteristicExtractDefaults<false> {
using klein_gordon_transform_buffer_tags = tmpl::list<>;
using klein_gordon_source_tags = tmpl::list<>;
using klein_gordon_cce_integrand_tags = tmpl::list<>;
using klein_gordon_constraint_tags = tmpl::list<>;

struct factory_creation
: tt::ConformsTo<Options::protocols::FactoryCreation> {
Expand Down
2 changes: 2 additions & 0 deletions tests/Unit/Evolution/Systems/Cce/Test_Tags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ SPECTRE_TEST_CASE("Unit.Evolution.Systems.Cce.Tags", "[Unit][Cce]") {
"InterpolationManager(SomeTag)");
TestHelpers::db::test_simple_tag<Cce::Tags::KleinGordonPsi>("KGPsi");
TestHelpers::db::test_simple_tag<Cce::Tags::KleinGordonPi>("KGPi");
TestHelpers::db::test_simple_tag<Cce::Tags::KleinGordonWorldtubeConstraint>(
"KGConstraint");

TestHelpers::db::test_prefix_tag<::Tags::dt<Cce::Tags::BondiJ>>("H");
TestHelpers::db::test_prefix_tag<Cce::Tags::Dy<SomeTag>>("Dy(SomeTag)");
Expand Down
Loading