SpECTRE Documentation Coverage Report
Current view: top level - Domain/Creators - RotatedIntervals.hpp Hit Total Coverage
Commit: 35a1e98cd3e4fdea528eb8100f99c2f707894fda Lines: 6 63 9.5 %
Date: 2024-04-19 00:10:48
Legend: Lines: hit not hit

          Line data    Source code
       1           1 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : /// \file
       5             : /// Defines class RotatedIntervals.
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <array>
      10             : #include <cstddef>
      11             : #include <limits>
      12             : #include <memory>
      13             : #include <vector>
      14             : 
      15             : #include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp"
      16             : #include "Domain/Creators/DomainCreator.hpp"  // IWYU pragma: keep
      17             : #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
      18             : #include "Domain/Domain.hpp"
      19             : #include "Domain/Structure/DirectionMap.hpp"
      20             : #include "Options/Context.hpp"
      21             : #include "Options/String.hpp"
      22             : #include "Utilities/TMPL.hpp"
      23             : 
      24             : /// \cond
      25             : namespace domain {
      26             : namespace CoordinateMaps {
      27             : class Affine;
      28             : template <size_t VolumeDim>
      29             : class DiscreteRotation;
      30             : }  // namespace CoordinateMaps
      31             : 
      32             : template <typename SourceFrame, typename TargetFrame, typename... Maps>
      33             : class CoordinateMap;
      34             : }  // namespace domain
      35             : /// \endcond
      36             : 
      37             : namespace domain {
      38             : namespace creators {
      39             : /// Create a 1D Domain consisting of two rotated Blocks.
      40             : /// The left block has its logical \f$\xi\f$-axis aligned with the grid x-axis.
      41             : /// The right block has its logical \f$\xi\f$-axis opposite to the grid x-axis.
      42             : /// This is useful for testing code that deals with unaligned blocks.
      43           1 : class RotatedIntervals : public DomainCreator<1> {
      44             :  public:
      45           0 :   using maps_list = tmpl::list<domain::CoordinateMap<
      46             :       Frame::BlockLogical, Frame::Inertial,
      47             :       domain::CoordinateMaps::DiscreteRotation<1>, CoordinateMaps::Affine>>;
      48             : 
      49           0 :   struct LowerBound {
      50           0 :     using type = std::array<double, 1>;
      51           0 :     static constexpr Options::String help = {
      52             :         "Sequence of [x], the lower bound in the target frame."};
      53             :   };
      54             : 
      55           0 :   struct Midpoint {
      56           0 :     using type = std::array<double, 1>;
      57           0 :     static constexpr Options::String help = {
      58             :         "Sequence of [x], the midpoint in the target frame."};
      59             :   };
      60             : 
      61           0 :   struct UpperBound {
      62           0 :     using type = std::array<double, 1>;
      63           0 :     static constexpr Options::String help = {
      64             :         "Sequence of [x], the upper bound in the target frame."};
      65             :   };
      66             : 
      67           0 :   struct IsPeriodicIn {
      68           0 :     using type = std::array<bool, 1>;
      69           0 :     static constexpr Options::String help = {
      70             :         "Sequence for [x], true if periodic."};
      71             :   };
      72           0 :   struct InitialRefinement {
      73           0 :     using type = std::array<size_t, 1>;
      74           0 :     static constexpr Options::String help = {
      75             :         "Initial refinement level in [x]."};
      76             :   };
      77             : 
      78           0 :   struct InitialGridPoints {
      79           0 :     using type = std::array<std::array<size_t, 2>, 1>;
      80           0 :     static constexpr Options::String help = {
      81             :         "Initial number of grid points in [[x]]."};
      82             :   };
      83             : 
      84           0 :   struct TimeDependence {
      85           0 :     using type =
      86             :         std::unique_ptr<domain::creators::time_dependence::TimeDependence<1>>;
      87           0 :     static constexpr Options::String help = {
      88             :         "The time dependence of the moving mesh domain."};
      89             :   };
      90             : 
      91           0 :   struct BoundaryConditions {
      92           0 :     static constexpr Options::String help = "The boundary conditions to apply.";
      93             :   };
      94             :   template <typename BoundaryConditionsBase>
      95           0 :   struct UpperBoundaryCondition {
      96           0 :     static std::string name() { return "UpperBoundary"; }
      97           0 :     static constexpr Options::String help =
      98             :         "Options for the boundary condition applied at the upper boundary.";
      99           0 :     using type = std::unique_ptr<BoundaryConditionsBase>;
     100           0 :     using group = BoundaryConditions;
     101             :   };
     102             :   template <typename BoundaryConditionsBase>
     103           0 :   struct LowerBoundaryCondition {
     104           0 :     static std::string name() { return "LowerBoundary"; }
     105           0 :     static constexpr Options::String help =
     106             :         "Options for the boundary condition applied at the lower boundary.";
     107           0 :     using type = std::unique_ptr<BoundaryConditionsBase>;
     108           0 :     using group = BoundaryConditions;
     109             :   };
     110             : 
     111           0 :   using common_options = tmpl::list<LowerBound, Midpoint, UpperBound,
     112             :                                     InitialRefinement, InitialGridPoints>;
     113           0 :   using options_periodic = tmpl::list<IsPeriodicIn>;
     114             :   template <typename System>
     115           0 :   using options_boundary_conditions = tmpl::list<
     116             :       LowerBoundaryCondition<
     117             :           domain::BoundaryConditions::get_boundary_conditions_base<System>>,
     118             :       UpperBoundaryCondition<
     119             :           domain::BoundaryConditions::get_boundary_conditions_base<System>>>;
     120             : 
     121             :   template <typename Metavariables>
     122           0 :   using options = tmpl::append<
     123             :       common_options,
     124             :       tmpl::conditional_t<
     125             :           domain::BoundaryConditions::has_boundary_conditions_base_v<
     126             :               typename Metavariables::system>,
     127             :           options_boundary_conditions<typename Metavariables::system>,
     128             :           options_periodic>,
     129             :       tmpl::list<TimeDependence>>;
     130             : 
     131           0 :   static constexpr Options::String help = {
     132             :       "A DomainCreator useful for testing purposes.\n"
     133             :       "RotatedIntervals creates the interval [LowerX,UpperX] from two\n"
     134             :       "rotated Blocks. The outermost index to InitialGridPoints is the\n"
     135             :       "dimension index (of which there is only one in the case of\n"
     136             :       "RotatedIntervals), and the innermost index is the block index\n"
     137             :       "along that dimension."};
     138             : 
     139           0 :   RotatedIntervals(
     140             :       std::array<double, 1> lower_x, std::array<double, 1> midpoint_x,
     141             :       std::array<double, 1> upper_x,
     142             :       std::array<size_t, 1> initial_refinement_level_x,
     143             :       std::array<std::array<size_t, 2>, 1> initial_number_of_grid_points_in_x,
     144             :       std::array<bool, 1> is_periodic_in,
     145             :       std::unique_ptr<domain::creators::time_dependence::TimeDependence<1>>
     146             :           time_dependence);
     147             : 
     148           0 :   RotatedIntervals(
     149             :       std::array<double, 1> lower_x, std::array<double, 1> midpoint_x,
     150             :       std::array<double, 1> upper_x,
     151             :       std::array<size_t, 1> initial_refinement_level_x,
     152             :       std::array<std::array<size_t, 2>, 1> initial_number_of_grid_points_in_x,
     153             :       std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
     154             :           lower_boundary_condition,
     155             :       std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
     156             :           upper_boundary_condition,
     157             :       std::unique_ptr<domain::creators::time_dependence::TimeDependence<1>>
     158             :           time_dependence,
     159             :       const Options::Context& context = {});
     160             : 
     161           0 :   RotatedIntervals() = default;
     162           0 :   RotatedIntervals(const RotatedIntervals&) = delete;
     163           0 :   RotatedIntervals(RotatedIntervals&&) = default;
     164           0 :   RotatedIntervals& operator=(const RotatedIntervals&) = delete;
     165           0 :   RotatedIntervals& operator=(RotatedIntervals&&) = default;
     166           0 :   ~RotatedIntervals() override = default;
     167             : 
     168           0 :   Domain<1> create_domain() const override;
     169             : 
     170             :   std::vector<DirectionMap<
     171             :       1, std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>>>
     172           1 :   external_boundary_conditions() const override;
     173             : 
     174           1 :   std::vector<std::array<size_t, 1>> initial_extents() const override;
     175             : 
     176           1 :   std::vector<std::array<size_t, 1>> initial_refinement_levels() const override;
     177             : 
     178           1 :   auto functions_of_time(const std::unordered_map<std::string, double>&
     179             :                              initial_expiration_times = {}) const
     180             :       -> std::unordered_map<
     181             :           std::string,
     182             :           std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
     183             : 
     184             :  private:
     185           0 :   std::array<double, 1> lower_x_{
     186             :       {std::numeric_limits<double>::signaling_NaN()}};
     187           0 :   std::array<double, 1> midpoint_x_{
     188             :       {std::numeric_limits<double>::signaling_NaN()}};
     189           0 :   std::array<double, 1> upper_x_{
     190             :       {std::numeric_limits<double>::signaling_NaN()}};
     191           0 :   std::array<bool, 1> is_periodic_in_{{false}};
     192           0 :   std::array<size_t, 1> initial_refinement_level_x_{
     193             :       {std::numeric_limits<size_t>::max()}};
     194           0 :   std::array<std::array<size_t, 2>, 1> initial_number_of_grid_points_in_x_{
     195             :       {{{std::numeric_limits<size_t>::max()}}}};
     196             :   std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
     197           0 :       lower_boundary_condition_{nullptr};
     198             :   std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
     199           0 :       upper_boundary_condition_{nullptr};
     200             :   std::unique_ptr<domain::creators::time_dependence::TimeDependence<1>>
     201           0 :       time_dependence_{nullptr};
     202             : };
     203             : }  // namespace creators
     204             : }  // namespace domain

Generated by: LCOV version 1.14