SpECTRE Documentation Coverage Report
Current view: top level - Domain/BoundaryConditions - Periodic.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 3 23 13.0 %
Date: 2024-04-23 20:50:18
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 <memory>
       7             : #include <pup.h>
       8             : 
       9             : #include "Domain/BoundaryConditions/BoundaryCondition.hpp"
      10             : #include "Options/String.hpp"
      11             : #include "Utilities/Serialization/CharmPupable.hpp"
      12             : #include "Utilities/TMPL.hpp"
      13             : 
      14             : namespace domain::BoundaryConditions {
      15             : /// Mark a boundary condition as being periodic.
      16             : ///
      17             : /// Periodic boundary conditions shouldn't require any implementation outside of
      18             : /// a check in the domain creator using the `is_periodic()` function to
      19             : /// determine what boundaries are periodic. Across each matching pair of
      20             : /// periodic boundary conditions, the domain creator should specify that the DG
      21             : /// elements are neighbors of each other.
      22           1 : class MarkAsPeriodic {
      23             :  public:
      24           0 :   MarkAsPeriodic() = default;
      25           0 :   MarkAsPeriodic(MarkAsPeriodic&&) = default;
      26           0 :   MarkAsPeriodic& operator=(MarkAsPeriodic&&) = default;
      27           0 :   MarkAsPeriodic(const MarkAsPeriodic&) = default;
      28           0 :   MarkAsPeriodic& operator=(const MarkAsPeriodic&) = default;
      29           0 :   virtual ~MarkAsPeriodic() = 0;
      30             : };
      31             : 
      32             : /*!
      33             :  * \brief Periodic boundary conditions.
      34             :  *
      35             :  * To use with a specific system add:
      36             :  *
      37             :  * \code
      38             :  *  domain::BoundaryConditions::Periodic<your::system::BoundaryConditionBase>
      39             :  * \endcode
      40             :  *
      41             :  * to the list of creatable classes.
      42             :  *
      43             :  * \note Not all domain creators will allow you to specify periodic boundary
      44             :  * conditions since they may not make sense.
      45             :  */
      46             : template <typename SystemBoundaryConditionBaseClass>
      47           1 : struct Periodic final : public SystemBoundaryConditionBaseClass,
      48             :                         public MarkAsPeriodic {
      49             :  public:
      50           0 :   using options = tmpl::list<>;
      51           0 :   static constexpr Options::String help{
      52             :       "Periodic boundary conditions.\n\nNote: Not all domain creators will "
      53             :       "allow you to specify periodic boundary conditions since they may not "
      54             :       "make sense."};
      55           0 :   static std::string name() { return "Periodic"; }
      56             : 
      57           0 :   Periodic() = default;
      58           0 :   Periodic(Periodic&&) = default;
      59           0 :   Periodic& operator=(Periodic&&) = default;
      60           0 :   Periodic(const Periodic&) = default;
      61           0 :   Periodic& operator=(const Periodic&) = default;
      62           0 :   ~Periodic() override = default;
      63             : 
      64           0 :   explicit Periodic(CkMigrateMessage* msg);
      65             : 
      66           0 :   WRAPPED_PUPable_decl_base_template(
      67             :       domain::BoundaryConditions::BoundaryCondition, Periodic);
      68             : 
      69           0 :   auto get_clone() const -> std::unique_ptr<
      70             :       domain::BoundaryConditions::BoundaryCondition> override;
      71             : 
      72           0 :   void pup(PUP::er& p) override;
      73             : };
      74             : 
      75             : template <typename SystemBoundaryConditionBaseClass>
      76             : Periodic<SystemBoundaryConditionBaseClass>::Periodic(
      77             :     CkMigrateMessage* const msg)
      78             :     : SystemBoundaryConditionBaseClass(msg) {}
      79             : 
      80             : template <typename SystemBoundaryConditionBaseClass>
      81             : std::unique_ptr<domain::BoundaryConditions::BoundaryCondition>
      82             : Periodic<SystemBoundaryConditionBaseClass>::get_clone() const {
      83             :   return std::make_unique<Periodic>(*this);
      84             : }
      85             : 
      86             : template <typename SystemBoundaryConditionBaseClass>
      87             : void Periodic<SystemBoundaryConditionBaseClass>::pup(PUP::er& p) {
      88             :   BoundaryCondition::pup(p);
      89             : }
      90             : 
      91             : /// \cond
      92             : template <typename SystemBoundaryConditionBaseClass>
      93             : // NOLINTNEXTLINE
      94             : PUP::able::PUP_ID Periodic<SystemBoundaryConditionBaseClass>::my_PUP_ID = 0;
      95             : /// \endcond
      96             : 
      97             : /// Check if a boundary condition inherits from `MarkAsPeriodic`, which
      98             : /// constitutes as it being marked as a periodic boundary condition.
      99           1 : bool is_periodic(const std::unique_ptr<BoundaryCondition>& boundary_condition);
     100             : }  // namespace domain::BoundaryConditions

Generated by: LCOV version 1.14