Skip to content

Commit

Permalink
general AnalyticSolution and AnalyticData changes to M1Grey system
Browse files Browse the repository at this point in the history
  • Loading branch information
pajkosmi committed Jan 29, 2025
1 parent d4338e0 commit 3ba9bdd
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,15 @@
#include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp"
#include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
#include "PointwiseFunctions/AnalyticData/AnalyticData.hpp"
#include "PointwiseFunctions/AnalyticData/RadiationTransport/M1Grey/AnalyticData.hpp"
#include "PointwiseFunctions/AnalyticData/RadiationTransport/M1Grey/Factory.hpp"
#include "PointwiseFunctions/AnalyticData/Tags.hpp"
#include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
#include "PointwiseFunctions/AnalyticSolutions/RadiationTransport/M1Grey/ConstantM1.hpp"
#include "PointwiseFunctions/AnalyticSolutions/RadiationTransport/M1Grey/Factory.hpp"
#include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
#include "PointwiseFunctions/Hydro/Tags.hpp"
#include "PointwiseFunctions/InitialDataUtilities/Tags/InitialData.hpp"
#include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
#include "Time/Actions/AdvanceTime.hpp"
#include "Time/Actions/CleanHistory.hpp"
#include "Time/Actions/RecordTimeStepperData.hpp"
Expand Down Expand Up @@ -110,9 +113,6 @@ class CProxy_GlobalCache;
struct EvolutionMetavars {
static constexpr size_t volume_dim = 3;

using initial_data_list =
RadiationTransport::M1Grey::Solutions::all_solutions;

// Set list of neutrino species to be used by M1 code
using neutrino_species = tmpl::list<neutrinos::ElectronNeutrinos<1>>;

Expand All @@ -124,6 +124,10 @@ struct EvolutionMetavars {
TimeStepperBase::local_time_stepping;
static constexpr bool use_dg_element_collection = false;

using initial_data_list =
tmpl::append<RadiationTransport::M1Grey::AnalyticData::all_data,
RadiationTransport::M1Grey::Solutions::all_solutions>;

using analytic_variables_tags = typename system::variables_tag::tags_list;
using limiter = Tags::Limiter<
Limiters::Minmod<3, typename system::variables_tag::tags_list>>;
Expand Down Expand Up @@ -156,7 +160,6 @@ struct EvolutionMetavars {
volume_dim, observe_fields, non_tensor_compute_tags>,
Events::time_events<system>>>>,
tmpl::pair<ImexTimeStepper, TimeSteppers::imex_time_steppers>,
tmpl::pair<evolution::initial_data::InitialData, initial_data_list>,
tmpl::pair<PhaseChange, PhaseControl::factory_creatable_classes>,
tmpl::pair<RadiationTransport::M1Grey::BoundaryConditions::
BoundaryCondition<neutrino_species>,
Expand All @@ -173,7 +176,8 @@ struct EvolutionMetavars {
TimeSequences::all_time_sequences<std::uint64_t>>,
tmpl::pair<TimeStepper, TimeSteppers::time_steppers>,
tmpl::pair<Trigger, tmpl::append<Triggers::logical_triggers,
Triggers::time_triggers>>>;
Triggers::time_triggers>>,
tmpl::pair<evolution::initial_data::InitialData, initial_data_list>>;
};

using observed_reduction_data_tags =
Expand Down Expand Up @@ -269,8 +273,7 @@ struct EvolutionMetavars {
using const_global_cache_tags =
tmpl::list<evolution::initial_data::Tags::InitialData>;

static constexpr Options::String help{
"Evolve the M1Grey system (without coupling to hydro).\n\n"};
static constexpr Options::String help{"Evolve the M1Grey system. \n\n"};

static constexpr std::array<Parallel::Phase, 5> default_phase_order{
{Parallel::Phase::Initialization,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ target_link_libraries(
GeneralRelativity
Hydro
LinearOperators
M1GreyAnalyticData
M1GreySolutions
Serialization
Utilities
INTERFACE
Expand Down
94 changes: 57 additions & 37 deletions src/Evolution/Systems/RadiationTransport/M1Grey/Initialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@
#include "Parallel/AlgorithmExecution.hpp"
#include "Parallel/GlobalCache.hpp"
#include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
#include "PointwiseFunctions/AnalyticData/RadiationTransport/M1Grey/Factory.hpp"
#include "PointwiseFunctions/AnalyticSolutions/RadiationTransport/M1Grey/Factory.hpp"
#include "PointwiseFunctions/InitialDataUtilities/InitialData.hpp"
#include "PointwiseFunctions/InitialDataUtilities/Tags/InitialData.hpp"
#include "Utilities/CallWithDynamicType.hpp"
#include "Utilities/Gsl.hpp"
#include "Utilities/TMPL.hpp"
#include "Utilities/TaggedTuple.hpp"
Expand All @@ -22,10 +26,8 @@
namespace Frame {
struct Inertial;
} // namespace Frame
namespace evolution::initial_data::Tags {
struct InitialData;
} // namespace evolution::initial_data::Tags
namespace Tags {
struct AnalyticSolutionOrData;
struct Time;
} // namespace Tags
namespace domain {
Expand Down Expand Up @@ -60,46 +62,64 @@ struct InitializeM1Tags {
static Parallel::iterable_action_return_t apply(
db::DataBox<DbTagsList>& box,
const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
const Parallel::GlobalCache<Metavariables>& /*cache*/,
const Parallel::GlobalCache<Metavariables>& cache,
const ArrayIndex& /*array_index*/, ActionList /*meta*/,
const ParallelComponent* const /*meta*/) {
using EvolvedVars = typename evolved_variables_tag::type;
using HydroVars = typename hydro_variables_tag::type;
using M1Vars = typename m1_variables_tag::type;
using derived_classes =
tmpl::at<typename Metavariables::factory_creation::factory_classes,
evolution::initial_data::InitialData>;
call_with_dynamic_type<void, derived_classes>(
&db::get<evolution::initial_data::Tags::InitialData>(box),
[&box](const auto* const data_or_solution) {
static constexpr size_t dim = System::volume_dim;
const double initial_time = db::get<::Tags::Time>(box);
const size_t num_grid_points =
db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points();
const auto& inertial_coords =
db::get<domain::Tags::Coordinates<dim, Frame::Inertial>>(box);

db::mutate<evolved_variables_tag>(
[initial_time, &inertial_coords, &data_or_solution](
const gsl::not_null<EvolvedVars*> evolved_vars) {
evolved_vars->assign_subset(
evolution::Initialization::initial_data(
*data_or_solution, inertial_coords, initial_time,
typename evolved_variables_tag::tags_list{}));
},
make_not_null(&box));

// Get hydro variables
HydroVars hydro_variables{num_grid_points};
hydro_variables.assign_subset(evolution::Initialization::initial_data(
*data_or_solution, inertial_coords, initial_time,
typename hydro_variables_tag::tags_list{}));

M1Vars m1_variables{num_grid_points, -1.};
Initialization::mutate_assign<simple_tags>(make_not_null(&box),
std::move(hydro_variables),
std::move(m1_variables));

static constexpr size_t dim = System::volume_dim;
const double initial_time = db::get<::Tags::Time>(box);
const size_t num_grid_points =
db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points();
const auto& inertial_coords =
db::get<domain::Tags::Coordinates<dim, Frame::Inertial>>(box);

using initial_data_evo_tags = typename evolved_variables_tag::tags_list;
using initial_data_hydro_tags = typename hydro_variables_tag::tags_list;

using initial_data_list =
tmpl::append<RadiationTransport::M1Grey::AnalyticData::all_data,
RadiationTransport::M1Grey::Solutions::all_solutions>;

const auto initial_data_evo_vars = call_with_dynamic_type<
tuples::tagged_tuple_from_typelist<initial_data_evo_tags>,
initial_data_list>(
&Parallel::get<evolution::initial_data::Tags::InitialData>(cache),
[&inertial_coords, &initial_time](const auto* const initial_data) {
return evolution::Initialization::initial_data(
*initial_data, inertial_coords, initial_time,
initial_data_evo_tags{});
});

const auto initial_data_hydro_vars = call_with_dynamic_type<
tuples::tagged_tuple_from_typelist<initial_data_hydro_tags>,
initial_data_list>(
&Parallel::get<evolution::initial_data::Tags::InitialData>(cache),
[&inertial_coords, &initial_time](const auto* const initial_data) {
return evolution::Initialization::initial_data(
*initial_data, inertial_coords, initial_time,
initial_data_hydro_tags{});
});

db::mutate<evolved_variables_tag>(
[&initial_data_evo_vars](
const gsl::not_null<EvolvedVars*> evolved_vars) {
evolved_vars->assign_subset(initial_data_evo_vars);
},
make_not_null(&box));

// Get hydro variables
HydroVars hydro_variables{num_grid_points};

hydro_variables.assign_subset(initial_data_hydro_vars);

M1Vars m1_variables{num_grid_points, -1.};
Initialization::mutate_assign<simple_tags>(make_not_null(&box),
std::move(hydro_variables),
std::move(m1_variables));

return {Parallel::AlgorithmExecution::Continue, std::nullopt};
}
};
Expand Down

0 comments on commit 3ba9bdd

Please sign in to comment.