SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Executables/ScalarWave - EvolveScalarWave.hpp Hit Total Coverage
Commit: 2ae2b99409ac582030d56a4560a92a3e066a7e54 Lines: 0 25 0.0 %
Date: 2022-01-15 08:40:38
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <cstddef>
       7             : #include <cstdint>
       8             : #include <vector>
       9             : 
      10             : #include "DataStructures/Tensor/IndexType.hpp"
      11             : #include "Domain/Creators/Factory1D.hpp"
      12             : #include "Domain/Creators/Factory2D.hpp"
      13             : #include "Domain/Creators/Factory3D.hpp"
      14             : #include "Domain/Creators/RegisterDerivedWithCharm.hpp"
      15             : #include "Domain/Creators/TimeDependence/RegisterDerivedWithCharm.hpp"
      16             : #include "Domain/FunctionsOfTime/RegisterDerivedWithCharm.hpp"
      17             : #include "Domain/Tags.hpp"
      18             : #include "Evolution/Actions/RunEventsAndDenseTriggers.hpp"
      19             : #include "Evolution/ComputeTags.hpp"
      20             : #include "Evolution/DiscontinuousGalerkin/Actions/ApplyBoundaryCorrections.hpp"
      21             : #include "Evolution/DiscontinuousGalerkin/Actions/ComputeTimeDerivative.hpp"
      22             : #include "Evolution/DiscontinuousGalerkin/DgElementArray.hpp"  // IWYU pragma: keep
      23             : #include "Evolution/DiscontinuousGalerkin/Initialization/Mortars.hpp"
      24             : #include "Evolution/DiscontinuousGalerkin/Initialization/QuadratureTag.hpp"
      25             : #include "Evolution/EventsAndDenseTriggers/DenseTrigger.hpp"
      26             : #include "Evolution/EventsAndDenseTriggers/DenseTriggers/Factory.hpp"
      27             : #include "Evolution/Initialization/DgDomain.hpp"
      28             : #include "Evolution/Initialization/Evolution.hpp"
      29             : #include "Evolution/Initialization/NonconservativeSystem.hpp"
      30             : #include "Evolution/Initialization/SetVariables.hpp"
      31             : #include "Evolution/Systems/ScalarWave/BoundaryConditions/Factory.hpp"
      32             : #include "Evolution/Systems/ScalarWave/BoundaryCorrections/Factory.hpp"
      33             : #include "Evolution/Systems/ScalarWave/BoundaryCorrections/RegisterDerived.hpp"
      34             : #include "Evolution/Systems/ScalarWave/EnergyDensity.hpp"
      35             : #include "Evolution/Systems/ScalarWave/Equations.hpp"
      36             : #include "Evolution/Systems/ScalarWave/Initialize.hpp"
      37             : #include "Evolution/Systems/ScalarWave/System.hpp"
      38             : #include "Evolution/TypeTraits.hpp"
      39             : #include "IO/Observer/Actions/RegisterEvents.hpp"
      40             : #include "IO/Observer/Helpers.hpp"            // IWYU pragma: keep
      41             : #include "IO/Observer/ObserverComponent.hpp"  // IWYU pragma: keep
      42             : #include "NumericalAlgorithms/DiscontinuousGalerkin/Formulation.hpp"
      43             : #include "NumericalAlgorithms/DiscontinuousGalerkin/Tags.hpp"
      44             : #include "NumericalAlgorithms/LinearOperators/ExponentialFilter.hpp"
      45             : #include "NumericalAlgorithms/LinearOperators/FilterAction.hpp"  // IWYU pragma: keep
      46             : #include "Options/Options.hpp"
      47             : #include "Options/Protocols/FactoryCreation.hpp"
      48             : #include "Parallel/Actions/SetupDataBox.hpp"
      49             : #include "Parallel/Actions/TerminatePhase.hpp"
      50             : #include "Parallel/InitializationFunctions.hpp"
      51             : #include "Parallel/PhaseControl/CheckpointAndExitAfterWallclock.hpp"
      52             : #include "Parallel/PhaseControl/ExecutePhaseChange.hpp"
      53             : #include "Parallel/PhaseControl/PhaseControlTags.hpp"
      54             : #include "Parallel/PhaseControl/VisitAndReturn.hpp"
      55             : #include "Parallel/PhaseDependentActionList.hpp"
      56             : #include "Parallel/Reduction.hpp"
      57             : #include "Parallel/RegisterDerivedClassesWithCharm.hpp"
      58             : #include "ParallelAlgorithms/Actions/MutateApply.hpp"
      59             : #include "ParallelAlgorithms/Events/Factory.hpp"  // IWYU pragma: keep
      60             : #include "ParallelAlgorithms/Events/ObserveVolumeIntegrals.hpp"
      61             : #include "ParallelAlgorithms/EventsAndTriggers/Actions/RunEventsAndTriggers.hpp"  // IWYU pragma: keep
      62             : #include "ParallelAlgorithms/EventsAndTriggers/Completion.hpp"
      63             : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp"
      64             : #include "ParallelAlgorithms/EventsAndTriggers/EventsAndTriggers.hpp"  // IWYU pragma: keep
      65             : #include "ParallelAlgorithms/EventsAndTriggers/LogicalTriggers.hpp"
      66             : #include "ParallelAlgorithms/EventsAndTriggers/Tags.hpp"
      67             : #include "ParallelAlgorithms/EventsAndTriggers/Trigger.hpp"
      68             : #include "ParallelAlgorithms/Initialization/Actions/AddComputeTags.hpp"
      69             : #include "ParallelAlgorithms/Initialization/Actions/RemoveOptionsAndTerminatePhase.hpp"
      70             : #include "PointwiseFunctions/AnalyticSolutions/Tags.hpp"
      71             : #include "PointwiseFunctions/AnalyticSolutions/WaveEquation/PlaneWave.hpp"  // IWYU pragma: keep
      72             : #include "PointwiseFunctions/AnalyticSolutions/WaveEquation/RegularSphericalWave.hpp"  // IWYU pragma: keep
      73             : #include "PointwiseFunctions/MathFunctions/Factory.hpp"
      74             : #include "PointwiseFunctions/MathFunctions/MathFunction.hpp"
      75             : #include "Time/Actions/AdvanceTime.hpp"            // IWYU pragma: keep
      76             : #include "Time/Actions/ChangeSlabSize.hpp"         // IWYU pragma: keep
      77             : #include "Time/Actions/ChangeStepSize.hpp"         // IWYU pragma: keep
      78             : #include "Time/Actions/RecordTimeStepperData.hpp"  // IWYU pragma: keep
      79             : #include "Time/Actions/SelfStartActions.hpp"       // IWYU pragma: keep
      80             : #include "Time/Actions/UpdateU.hpp"                // IWYU pragma: keep
      81             : #include "Time/StepChoosers/ByBlock.hpp"
      82             : #include "Time/StepChoosers/Factory.hpp"
      83             : #include "Time/StepChoosers/StepChooser.hpp"
      84             : #include "Time/StepControllers/Factory.hpp"
      85             : #include "Time/StepControllers/StepController.hpp"
      86             : #include "Time/Tags.hpp"
      87             : #include "Time/TimeSequence.hpp"
      88             : #include "Time/TimeSteppers/TimeStepper.hpp"
      89             : #include "Time/Triggers/TimeTriggers.hpp"
      90             : #include "Utilities/Blas.hpp"
      91             : #include "Utilities/ErrorHandling/Error.hpp"
      92             : #include "Utilities/ErrorHandling/FloatingPointExceptions.hpp"
      93             : #include "Utilities/Functional.hpp"
      94             : #include "Utilities/MemoryHelpers.hpp"
      95             : #include "Utilities/ProtocolHelpers.hpp"
      96             : #include "Utilities/TMPL.hpp"
      97             : 
      98             : /// \cond
      99             : namespace Frame {
     100             : // IWYU pragma: no_forward_declare MathFunction
     101             : struct Inertial;
     102             : }  // namespace Frame
     103             : namespace Parallel {
     104             : template <typename Metavariables>
     105             : class CProxy_GlobalCache;
     106             : }  // namespace Parallel
     107             : namespace PUP {
     108             : class er;
     109             : }  // namespace PUP
     110             : /// \endcond
     111             : 
     112             : template <size_t Dim, typename InitialData>
     113             : struct EvolutionMetavars {
     114             :   static constexpr size_t volume_dim = Dim;
     115             :   // Customization/"input options" to simulation
     116           0 :   using initial_data_tag = Tags::AnalyticSolution<InitialData>;
     117             :   static_assert(
     118             :       evolution::is_analytic_data_v<InitialData> xor
     119             :           evolution::is_analytic_solution_v<InitialData>,
     120             :       "initial_data must be either an analytic_data or an analytic_solution");
     121             : 
     122           0 :   using system = ScalarWave::System<Dim>;
     123             :   static constexpr dg::Formulation dg_formulation =
     124             :       dg::Formulation::StrongInertial;
     125           0 :   using temporal_id = Tags::TimeStepId;
     126             :   static constexpr bool local_time_stepping = true;
     127           0 :   using time_stepper_tag = Tags::TimeStepper<
     128             :       tmpl::conditional_t<local_time_stepping, LtsTimeStepper, TimeStepper>>;
     129             : 
     130           0 :   using analytic_solution_fields = typename system::variables_tag::tags_list;
     131           0 :   using deriv_compute = ::Tags::DerivCompute<
     132             :       typename system::variables_tag,
     133             :       domain::Tags::InverseJacobian<volume_dim, Frame::ElementLogical,
     134             :                                     Frame::Inertial>,
     135             :       typename system::gradient_variables>;
     136           0 :   using analytic_compute =
     137             :       evolution::Tags::AnalyticCompute<Dim, initial_data_tag,
     138             :                                        analytic_solution_fields>;
     139             : 
     140           0 :   using observe_fields =
     141             :       tmpl::push_back<tmpl::append<typename system::variables_tag::tags_list,
     142             :                                    typename deriv_compute::type::tags_list>,
     143             :                       ScalarWave::Tags::EnergyDensityCompute<volume_dim>,
     144             :                       ScalarWave::Tags::OneIndexConstraintCompute<volume_dim>,
     145             :                       ScalarWave::Tags::TwoIndexConstraintCompute<volume_dim>,
     146             :                       ::Tags::PointwiseL2NormCompute<
     147             :                           ScalarWave::Tags::OneIndexConstraint<volume_dim>>,
     148             :                       ::Tags::PointwiseL2NormCompute<
     149             :                           ScalarWave::Tags::TwoIndexConstraint<volume_dim>>>;
     150             : 
     151             :   struct factory_creation
     152             :       : tt::ConformsTo<Options::protocols::FactoryCreation> {
     153           0 :     using factory_classes = tmpl::map<
     154             :         tmpl::pair<DenseTrigger, DenseTriggers::standard_dense_triggers>,
     155             :         tmpl::pair<DomainCreator<volume_dim>, domain_creators<volume_dim>>,
     156             :         tmpl::pair<Event,
     157             :                    tmpl::flatten<tmpl::list<
     158             :                        Events::Completion,
     159             :                        dg::Events::field_observations<
     160             :                            volume_dim, Tags::Time, observe_fields,
     161             :                            analytic_solution_fields,
     162             :                            tmpl::list<deriv_compute, analytic_compute>>,
     163             :                        dg::Events::ObserveVolumeIntegrals<
     164             :                            volume_dim, Tags::Time,
     165             :                            tmpl::list<ScalarWave::Tags::EnergyDensityCompute<
     166             :                                volume_dim>>>,
     167             :                        Events::time_events<system>>>>,
     168             :         tmpl::pair<MathFunction<1, Frame::Inertial>,
     169             :                    MathFunctions::all_math_functions<1, Frame::Inertial>>,
     170             :         tmpl::pair<
     171             :             ScalarWave::BoundaryConditions::BoundaryCondition<volume_dim>,
     172             :             ScalarWave::BoundaryConditions::standard_boundary_conditions<
     173             :                 volume_dim>>,
     174             :         tmpl::pair<StepChooser<StepChooserUse::LtsStep>,
     175             :                    tmpl::push_back<StepChoosers::standard_step_choosers<system>,
     176             :                                    StepChoosers::ByBlock<
     177             :                                        StepChooserUse::LtsStep, volume_dim>>>,
     178             :         tmpl::pair<StepChooser<StepChooserUse::Slab>,
     179             :                    tmpl::push_back<StepChoosers::standard_slab_choosers<
     180             :                                        system, local_time_stepping>,
     181             :                                    StepChoosers::ByBlock<StepChooserUse::Slab,
     182             :                                                          volume_dim>>>,
     183             :         tmpl::pair<StepController, StepControllers::standard_step_controllers>,
     184             :         tmpl::pair<TimeSequence<double>,
     185             :                    TimeSequences::all_time_sequences<double>>,
     186             :         tmpl::pair<TimeSequence<std::uint64_t>,
     187             :                    TimeSequences::all_time_sequences<std::uint64_t>>,
     188             :         tmpl::pair<Trigger, tmpl::append<Triggers::logical_triggers,
     189             :                                          Triggers::time_triggers>>>;
     190             :   };
     191             : 
     192           0 :   using observed_reduction_data_tags =
     193             :       observers::collect_reduction_data_tags<tmpl::flatten<tmpl::list<
     194             :           tmpl::at<typename factory_creation::factory_classes, Event>>>>;
     195             : 
     196             :   // The scalar wave system generally does not require filtering, except
     197             :   // possibly on certain deformed domains.  Here a filter is added in 2D for
     198             :   // testing purposes.  When performing numerical experiments with the scalar
     199             :   // wave system, the user should determine whether this filter can be removed.
     200             :   static constexpr bool use_filtering = (2 == volume_dim);
     201             : 
     202           0 :   using step_actions = tmpl::flatten<tmpl::list<
     203             :       evolution::dg::Actions::ComputeTimeDerivative<EvolutionMetavars>,
     204             :       tmpl::conditional_t<
     205             :           local_time_stepping,
     206             :           tmpl::list<evolution::Actions::RunEventsAndDenseTriggers<>,
     207             :                      evolution::dg::Actions::ApplyBoundaryCorrections<
     208             :                          EvolutionMetavars>>,
     209             :           tmpl::list<evolution::dg::Actions::ApplyBoundaryCorrections<
     210             :                          EvolutionMetavars>,
     211             :                      Actions::RecordTimeStepperData<>,
     212             :                      evolution::Actions::RunEventsAndDenseTriggers<>,
     213             :                      Actions::UpdateU<>>>,
     214             :       tmpl::conditional_t<
     215             :           use_filtering,
     216             :           dg::Actions::Filter<
     217             :               Filters::Exponential<0>,
     218             :               tmpl::list<ScalarWave::Tags::Psi, ScalarWave::Tags::Pi,
     219             :                          ScalarWave::Tags::Phi<Dim>>>,
     220             :           tmpl::list<>>>>;
     221             : 
     222           0 :   enum class Phase {
     223             :     Initialization,
     224             :     RegisterWithObserver,
     225             :     InitializeTimeStepperHistory,
     226             :     LoadBalancing,
     227             :     WriteCheckpoint,
     228             :     Evolve,
     229             :     Exit
     230             :   };
     231             : 
     232           0 :   static std::string phase_name(Phase phase) {
     233             :     if (phase == Phase::LoadBalancing) {
     234             :       return "LoadBalancing";
     235             :     }
     236             :     ERROR(
     237             :         "Passed phase that should not be used in input file. Integer "
     238             :         "corresponding to phase is: "
     239             :         << static_cast<int>(phase));
     240             :   }
     241             : 
     242           0 :   using phase_changes =
     243             :       tmpl::list<PhaseControl::Registrars::VisitAndReturn<EvolutionMetavars,
     244             :                                                           Phase::LoadBalancing>,
     245             :                  PhaseControl::Registrars::CheckpointAndExitAfterWallclock<
     246             :                      EvolutionMetavars>>;
     247             : 
     248           0 :   using initialize_phase_change_decision_data =
     249             :       PhaseControl::InitializePhaseChangeDecisionData<phase_changes>;
     250             : 
     251           0 :   using phase_change_tags_and_combines_list =
     252             :       PhaseControl::get_phase_change_tags<phase_changes>;
     253             : 
     254           0 :   using const_global_cache_tags =
     255             :       tmpl::list<initial_data_tag, Tags::EventsAndTriggers,
     256             :                  PhaseControl::Tags::PhaseChangeAndTriggers<phase_changes>>;
     257             : 
     258           0 :   using dg_registration_list =
     259             :       tmpl::list<observers::Actions::RegisterEventsWithObservers>;
     260             : 
     261           0 :   using initialization_actions = tmpl::list<
     262             :       Actions::SetupDataBox,
     263             :       Initialization::Actions::TimeAndTimeStep<EvolutionMetavars>,
     264             :       evolution::dg::Initialization::Domain<volume_dim>,
     265             :       Initialization::Actions::NonconservativeSystem<system>,
     266             :       evolution::Initialization::Actions::SetVariables<
     267             :           domain::Tags::Coordinates<Dim, Frame::ElementLogical>>,
     268             :       Initialization::Actions::TimeStepperHistory<EvolutionMetavars>,
     269             :       ScalarWave::Actions::InitializeConstraints<volume_dim>,
     270             :       Initialization::Actions::AddComputeTags<
     271             :           StepChoosers::step_chooser_compute_tags<EvolutionMetavars>>,
     272             :       ::evolution::dg::Initialization::Mortars<volume_dim, system>,
     273             :       evolution::Actions::InitializeRunEventsAndDenseTriggers,
     274             :       Initialization::Actions::RemoveOptionsAndTerminatePhase>;
     275             : 
     276           0 :   using dg_element_array = DgElementArray<
     277             :       EvolutionMetavars,
     278             :       tmpl::list<
     279             :           Parallel::PhaseActions<Phase, Phase::Initialization,
     280             :                                  initialization_actions>,
     281             : 
     282             :           Parallel::PhaseActions<
     283             :               Phase, Phase::InitializeTimeStepperHistory,
     284             :               SelfStart::self_start_procedure<step_actions, system>>,
     285             : 
     286             :           Parallel::PhaseActions<Phase, Phase::RegisterWithObserver,
     287             :                                  tmpl::list<dg_registration_list,
     288             :                                             Parallel::Actions::TerminatePhase>>,
     289             : 
     290             :           Parallel::PhaseActions<
     291             :               Phase, Phase::Evolve,
     292             :               tmpl::list<
     293             :                   Actions::RunEventsAndTriggers, Actions::ChangeSlabSize,
     294             :                   step_actions, Actions::AdvanceTime,
     295             :                   PhaseControl::Actions::ExecutePhaseChange<phase_changes>>>>>;
     296             : 
     297             :   template <typename ParallelComponent>
     298             :   struct registration_list {
     299           0 :     using type =
     300             :         std::conditional_t<std::is_same_v<ParallelComponent, dg_element_array>,
     301             :                            dg_registration_list, tmpl::list<>>;
     302             :   };
     303             : 
     304           0 :   using component_list =
     305             :       tmpl::list<observers::Observer<EvolutionMetavars>,
     306             :                  observers::ObserverWriter<EvolutionMetavars>,
     307             :                  dg_element_array>;
     308             : 
     309             :   static constexpr Options::String help{
     310             :       "Evolve a Scalar Wave in Dim spatial dimension.\n\n"
     311             :       "The numerical flux is:    UpwindFlux\n"};
     312             : 
     313             :   template <typename... Tags>
     314           0 :   static Phase determine_next_phase(
     315             :       const gsl::not_null<tuples::TaggedTuple<Tags...>*>
     316             :           phase_change_decision_data,
     317             :       const Phase& current_phase,
     318             :       const Parallel::CProxy_GlobalCache<EvolutionMetavars>& cache_proxy) {
     319             :     const auto next_phase = PhaseControl::arbitrate_phase_change<phase_changes>(
     320             :         phase_change_decision_data, current_phase,
     321             :         *(cache_proxy.ckLocalBranch()));
     322             :     if (next_phase.has_value()) {
     323             :       return next_phase.value();
     324             :     }
     325             :     switch (current_phase) {
     326             :       case Phase::Initialization:
     327             :         return Phase::InitializeTimeStepperHistory;
     328             :       case Phase::InitializeTimeStepperHistory:
     329             :         return Phase::RegisterWithObserver;
     330             :       case Phase::RegisterWithObserver:
     331             :         return Phase::Evolve;
     332             :       case Phase::Evolve:
     333             :         return Phase::Exit;
     334             :       case Phase::Exit:
     335             :         ERROR(
     336             :             "Should never call determine_next_phase with the current phase "
     337             :             "being 'Exit'");
     338             :       default:
     339             :         ERROR(
     340             :             "Unknown type of phase. Did you static_cast<Phase> an integral "
     341             :             "value?");
     342             :     }
     343             :   }
     344             : 
     345             :   // NOLINTNEXTLINE(google-runtime-references)
     346           0 :   void pup(PUP::er& /*p*/) {}
     347             : };
     348             : 
     349             : static const std::vector<void (*)()> charm_init_node_funcs{
     350             :     &setup_error_handling,
     351             :     &setup_memory_allocation_failure_reporting,
     352             :     &disable_openblas_multithreading,
     353             :     &domain::creators::register_derived_with_charm,
     354             :     &domain::creators::time_dependence::register_derived_with_charm,
     355             :     &domain::FunctionsOfTime::register_derived_with_charm,
     356             :     &ScalarWave::BoundaryCorrections::register_derived_with_charm,
     357             :     &Parallel::register_derived_classes_with_charm<TimeStepper>,
     358             :     &Parallel::register_derived_classes_with_charm<
     359             :         PhaseChange<metavariables::phase_changes>>,
     360             :     &Parallel::register_factory_classes_with_charm<metavariables>};
     361             : 
     362             : static const std::vector<void (*)()> charm_init_proc_funcs{
     363             :     &enable_floating_point_exceptions};

Generated by: LCOV version 1.14