SpECTRE Documentation Coverage Report
Current view: top level - Domain/Creators - Rectangle.hpp Hit Total Coverage
Commit: 664546099c4dbf27a1b708fac45e39c82dd743d2 Lines: 7 51 13.7 %
Date: 2024-04-19 16:28:01
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 Rectangle.
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <array>
      10             : #include <cstddef>
      11             : #include <memory>
      12             : #include <string>
      13             : #include <unordered_map>
      14             : #include <unordered_set>
      15             : #include <vector>
      16             : 
      17             : #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
      18             : #include "Domain/BoundaryConditions/GetBoundaryConditionsBase.hpp"
      19             : #include "Domain/Creators/DomainCreator.hpp"  // IWYU pragma: keep
      20             : #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
      21             : #include "Domain/Domain.hpp"
      22             : #include "Domain/Structure/DirectionMap.hpp"
      23             : #include "Options/Context.hpp"
      24             : #include "Options/String.hpp"
      25             : #include "Utilities/MakeArray.hpp"
      26             : #include "Utilities/TMPL.hpp"
      27             : 
      28             : /// \cond
      29             : namespace domain {
      30             : namespace CoordinateMaps {
      31             : class Affine;
      32             : template <typename Map1, typename Map2>
      33             : class ProductOf2Maps;
      34             : }  // namespace CoordinateMaps
      35             : 
      36             : template <typename SourceFrame, typename TargetFrame, typename... Maps>
      37             : class CoordinateMap;
      38             : }  // namespace domain
      39             : /// \endcond
      40             : 
      41             : namespace domain {
      42             : namespace creators {
      43             : /// Create a 2D Domain consisting of a single Block.
      44           1 : class Rectangle : public DomainCreator<2> {
      45             :  public:
      46           0 :   using maps_list = tmpl::list<domain::CoordinateMap<
      47             :       Frame::BlockLogical, Frame::Inertial,
      48             :       CoordinateMaps::ProductOf2Maps<CoordinateMaps::Affine,
      49             :                                      CoordinateMaps::Affine>>>;
      50             : 
      51           0 :   struct LowerBound {
      52           0 :     using type = std::array<double, 2>;
      53           0 :     static constexpr Options::String help = {
      54             :         "Sequence of [x,y] for lower bounds."};
      55             :   };
      56             : 
      57           0 :   struct UpperBound {
      58           0 :     using type = std::array<double, 2>;
      59           0 :     static constexpr Options::String help = {
      60             :         "Sequence of [x,y] for upper bounds."};
      61             :   };
      62           0 :   struct IsPeriodicIn {
      63           0 :     using type = std::array<bool, 2>;
      64           0 :     static constexpr Options::String help = {
      65             :         "Sequence for [x,y], true if periodic."};
      66             :   };
      67             : 
      68           0 :   struct InitialRefinement {
      69           0 :     using type = std::array<size_t, 2>;
      70           0 :     static constexpr Options::String help = {
      71             :         "Initial refinement level in [x,y]."};
      72             :   };
      73             : 
      74           0 :   struct InitialGridPoints {
      75           0 :     using type = std::array<size_t, 2>;
      76           0 :     static constexpr Options::String help = {
      77             :         "Initial number of grid points in [x,y]."};
      78             :   };
      79           0 :   struct TimeDependence {
      80           0 :     using type =
      81             :         std::unique_ptr<domain::creators::time_dependence::TimeDependence<2>>;
      82           0 :     static constexpr Options::String help = {
      83             :         "The time dependence of the moving mesh domain."};
      84             :   };
      85             :   template <typename BoundaryConditionsBase>
      86           0 :   struct BoundaryCondition {
      87           0 :     static std::string name() { return "BoundaryCondition"; }
      88           0 :     static constexpr Options::String help =
      89             :         "The boundary condition to impose on all sides.";
      90           0 :     using type = std::unique_ptr<BoundaryConditionsBase>;
      91             :   };
      92             : 
      93           0 :   using common_options =
      94             :       tmpl::list<LowerBound, UpperBound, InitialRefinement, InitialGridPoints>;
      95             : 
      96           0 :   using options_periodic = tmpl::list<IsPeriodicIn>;
      97             : 
      98             :   template <typename Metavariables>
      99           0 :   using options = tmpl::append<
     100             :       common_options,
     101             :       tmpl::conditional_t<
     102             :           domain::BoundaryConditions::has_boundary_conditions_base_v<
     103             :               typename Metavariables::system>,
     104             :           tmpl::list<BoundaryCondition<
     105             :               domain::BoundaryConditions::get_boundary_conditions_base<
     106             :                   typename Metavariables::system>>>,
     107             :           options_periodic>,
     108             :       tmpl::list<TimeDependence>>;
     109             : 
     110           0 :   static constexpr Options::String help{"Creates a 2D rectangle."};
     111             : 
     112           0 :   Rectangle(
     113             :       std::array<double, 2> lower_xy, std::array<double, 2> upper_xy,
     114             :       std::array<size_t, 2> initial_refinement_level_xy,
     115             :       std::array<size_t, 2> initial_number_of_grid_points_in_xy,
     116             :       std::array<bool, 2> is_periodic_in_xy,
     117             :       std::unique_ptr<domain::creators::time_dependence::TimeDependence<2>>
     118             :           time_dependence = nullptr);
     119             : 
     120           0 :   Rectangle(
     121             :       std::array<double, 2> lower_xy, std::array<double, 2> upper_xy,
     122             :       std::array<size_t, 2> initial_refinement_level_xy,
     123             :       std::array<size_t, 2> initial_number_of_grid_points_in_xy,
     124             :       std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
     125             :           boundary_condition,
     126             :       std::unique_ptr<domain::creators::time_dependence::TimeDependence<2>>
     127             :           time_dependence,
     128             :       const Options::Context& context = {});
     129             : 
     130           0 :   Rectangle() = default;
     131           0 :   Rectangle(const Rectangle&) = delete;
     132           0 :   Rectangle(Rectangle&&) = default;
     133           0 :   Rectangle& operator=(const Rectangle&) = delete;
     134           0 :   Rectangle& operator=(Rectangle&&) = default;
     135           0 :   ~Rectangle() override = default;
     136             : 
     137           0 :   Domain<2> create_domain() const override;
     138             : 
     139             :   std::vector<DirectionMap<
     140             :       2, std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>>>
     141           1 :   external_boundary_conditions() const override;
     142             : 
     143           1 :   std::vector<std::array<size_t, 2>> initial_extents() const override;
     144             : 
     145           1 :   std::vector<std::array<size_t, 2>> initial_refinement_levels() const override;
     146             : 
     147           1 :   auto functions_of_time(const std::unordered_map<std::string, double>&
     148             :                              initial_expiration_times = {}) const
     149             :       -> std::unordered_map<
     150             :           std::string,
     151             :           std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
     152             : 
     153           1 :   std::vector<std::string> block_names() const override { return block_names_; }
     154             : 
     155             :  private:
     156           0 :   typename LowerBound::type lower_xy_{};
     157           0 :   typename UpperBound::type upper_xy_{};
     158           0 :   typename IsPeriodicIn::type is_periodic_in_xy_{};
     159           0 :   typename InitialRefinement::type initial_refinement_level_xy_{};
     160           0 :   typename InitialGridPoints::type initial_number_of_grid_points_in_xy_{};
     161             :   std::unique_ptr<domain::creators::time_dependence::TimeDependence<2>>
     162           0 :       time_dependence_{nullptr};
     163             :   std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
     164           0 :       boundary_condition_{nullptr};
     165           0 :   inline static const std::vector<std::string> block_names_{"Rectangle"};
     166             : };
     167             : }  // namespace creators
     168             : }  // namespace domain

Generated by: LCOV version 1.14