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 <memory> 8 : #include <string> 9 : #include <unordered_map> 10 : #include <vector> 11 : 12 : #include "IO/H5/TensorData.hpp" 13 : #include "Options/String.hpp" 14 : #include "ParallelAlgorithms/Events/ObserveConstantsPerElement.hpp" 15 : #include "ParallelAlgorithms/EventsAndTriggers/Event.hpp" 16 : #include "Utilities/Serialization/CharmPupable.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : #include "Utilities/TypeTraits/IsA.hpp" 19 : 20 : /// \cond 21 : enum class FloatingPointType; 22 : template <size_t VolumeDim> 23 : class Domain; 24 : template <size_t VolumeDim> 25 : class ElementId; 26 : class TimeDelta; 27 : namespace domain { 28 : namespace FunctionsOfTime { 29 : class FunctionOfTime; 30 : } // namespace FunctionsOfTime 31 : namespace Tags { 32 : template <size_t VolumeDim> 33 : struct Domain; 34 : struct FunctionsOfTime; 35 : template <size_t VolumeDim, typename Frame> 36 : struct MinimumGridSpacing; 37 : } // namespace Tags 38 : } // namespace domain 39 : namespace Frame { 40 : struct Inertial; 41 : } // namespace Frame 42 : namespace Parallel { 43 : template <typename Metavariables> 44 : class GlobalCache; 45 : } // namespace Parallel 46 : namespace Tags { 47 : template <typename Tag> 48 : struct HistoryEvolvedVariables; 49 : struct Time; 50 : struct TimeStep; 51 : } // namespace Tags 52 : namespace TimeSteppers { 53 : template <typename Vars> 54 : class History; 55 : } // namespace TimeSteppers 56 : /// \endcond 57 : 58 : namespace dg::Events { 59 : /*! 60 : * \brief %Observe the time step in the volume. 61 : * 62 : * Observe the time step size in each element. Each element is output 63 : * as a single cell with two points per dimension and the observation 64 : * constant on all those points. 65 : * 66 : * Writes volume quantities: 67 : * - InertialCoordinates (only element corners) 68 : * - Time step 69 : * - Slab fraction 70 : * - Minimum grid spacing 71 : * - Integration order 72 : */ 73 : template <typename System> 74 1 : class ObserveTimeStepVolume 75 : : public ObserveConstantsPerElement<System::volume_dim> { 76 : public: 77 0 : static constexpr size_t volume_dim = System::volume_dim; 78 : static_assert(not tt::is_a_v<tmpl::list, typename System::variables_tag>, 79 : "Split variables systems not handled."); 80 : 81 : /// \cond 82 : explicit ObserveTimeStepVolume(CkMigrateMessage* m); 83 : using PUP::able::register_constructor; 84 : WRAPPED_PUPable_decl_template(ObserveTimeStepVolume); // NOLINT 85 : /// \endcond 86 : 87 0 : static constexpr Options::String help = 88 : "Observe the time step and integration order in the volume."; 89 : 90 0 : ObserveTimeStepVolume(); 91 : 92 0 : ObserveTimeStepVolume(const std::string& subfile_name, 93 : ::FloatingPointType coordinates_floating_point_type, 94 : ::FloatingPointType floating_point_type); 95 : 96 0 : using compute_tags_for_observation_box = tmpl::list<>; 97 : 98 0 : using return_tags = tmpl::list<>; 99 0 : using argument_tags = tmpl::list< 100 : ::Tags::Time, ::domain::Tags::FunctionsOfTime, 101 : ::domain::Tags::Domain<volume_dim>, ::Tags::TimeStep, 102 : domain::Tags::MinimumGridSpacing<volume_dim, Frame::Inertial>, 103 : ::Tags::HistoryEvolvedVariables<typename System::variables_tag>>; 104 : 105 : template <typename Metavariables, typename ParallelComponent> 106 0 : void operator()( 107 : const double time, 108 : const std::unordered_map< 109 : std::string, 110 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>& 111 : functions_of_time, 112 : const Domain<volume_dim>& domain, const TimeDelta& time_step, 113 : const double minimum_grid_spacing, 114 : const TimeSteppers::History<typename System::variables_tag::type>& 115 : history, 116 : Parallel::GlobalCache<Metavariables>& cache, 117 : const ElementId<volume_dim>& element_id, 118 : const ParallelComponent* const component, 119 : const Event::ObservationValue& observation_value) const { 120 : std::vector<TensorComponent> components = 121 : assemble_data(time, functions_of_time, domain, element_id, time_step, 122 : minimum_grid_spacing, history); 123 : 124 : this->observe(components, cache, element_id, component, observation_value); 125 : } 126 : 127 1 : bool needs_evolved_variables() const override; 128 : 129 : private: 130 0 : std::vector<TensorComponent> assemble_data( 131 : double time, 132 : const std::unordered_map< 133 : std::string, 134 : std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>& 135 : functions_of_time, 136 : const Domain<volume_dim>& domain, const ElementId<volume_dim>& element_id, 137 : const TimeDelta& time_step, double minimum_grid_spacing, 138 : const TimeSteppers::History<typename System::variables_tag::type>& 139 : history) const; 140 : }; 141 : } // namespace dg::Events