SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GeneralizedHarmonic/BoundaryConditions - DirichletAnalytic.hpp Hit Total Coverage
Commit: 990bc653376fc4a4068db06123ec02659d814816 Lines: 1 21 4.8 %
Date: 2021-05-16 17:17:32
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 <optional>
       8             : #include <pup.h>
       9             : #include <string>
      10             : #include <type_traits>
      11             : 
      12             : #include "DataStructures/DataBox/Prefixes.hpp"
      13             : #include "DataStructures/DataVector.hpp"
      14             : #include "DataStructures/Tensor/Tensor.hpp"
      15             : #include "DataStructures/Variables.hpp"
      16             : #include "Evolution/BoundaryConditions/Type.hpp"
      17             : #include "Evolution/Systems/GeneralizedHarmonic/BoundaryConditions/BoundaryCondition.hpp"
      18             : #include "Evolution/Systems/GeneralizedHarmonic/ConstraintDamping/Tags.hpp"
      19             : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
      20             : #include "Options/Options.hpp"
      21             : #include "Parallel/CharmPupable.hpp"
      22             : #include "PointwiseFunctions/AnalyticData/Tags.hpp"
      23             : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.hpp"
      24             : #include "PointwiseFunctions/GeneralRelativity/Tags.hpp"
      25             : #include "Time/Tags.hpp"
      26             : #include "Utilities/Gsl.hpp"
      27             : #include "Utilities/TMPL.hpp"
      28             : 
      29             : /// \cond
      30             : namespace domain::Tags {
      31             : template <size_t Dim, typename Frame>
      32             : struct Coordinates;
      33             : }  // namespace domain::Tags
      34             : /// \endcond
      35             : 
      36             : namespace GeneralizedHarmonic::BoundaryConditions {
      37             : /*!
      38             :  * \brief Sets Dirichlet boundary conditions using the analytic solution or
      39             :  * analytic data.
      40             :  */
      41             : template <size_t Dim>
      42           1 : class DirichletAnalytic final : public BoundaryCondition<Dim> {
      43             :  public:
      44           0 :   using options = tmpl::list<>;
      45           0 :   static constexpr Options::String help{
      46             :       "DirichletAnalytic boundary conditions setting the value of the "
      47             :       "spacetime metric and its derivatives Phi and Pi to the analytic "
      48             :       "solution or analytic data."};
      49           0 :   static std::string name() noexcept { return "DirichletAnalytic"; }
      50             : 
      51           0 :   DirichletAnalytic() = default;
      52           0 :   DirichletAnalytic(DirichletAnalytic&&) noexcept = default;
      53           0 :   DirichletAnalytic& operator=(DirichletAnalytic&&) noexcept = default;
      54           0 :   DirichletAnalytic(const DirichletAnalytic&) = default;
      55           0 :   DirichletAnalytic& operator=(const DirichletAnalytic&) = default;
      56           0 :   ~DirichletAnalytic() override = default;
      57             : 
      58           0 :   explicit DirichletAnalytic(CkMigrateMessage* msg) noexcept;
      59             : 
      60           0 :   WRAPPED_PUPable_decl_base_template(
      61             :       domain::BoundaryConditions::BoundaryCondition, DirichletAnalytic);
      62             : 
      63           0 :   auto get_clone() const noexcept -> std::unique_ptr<
      64             :       domain::BoundaryConditions::BoundaryCondition> override;
      65             : 
      66           0 :   static constexpr evolution::BoundaryConditions::Type bc_type =
      67             :       evolution::BoundaryConditions::Type::Ghost;
      68             : 
      69           0 :   void pup(PUP::er& p) override;
      70             : 
      71           0 :   using dg_interior_evolved_variables_tags = tmpl::list<>;
      72           0 :   using dg_interior_temporary_tags = tmpl::list<
      73             :       domain::Tags::Coordinates<Dim, Frame::Inertial>,
      74             :       ::GeneralizedHarmonic::ConstraintDamping::Tags::ConstraintGamma1,
      75             :       ::GeneralizedHarmonic::ConstraintDamping::Tags::ConstraintGamma2>;
      76           0 :   using dg_gridless_tags =
      77             :       tmpl::list<::Tags::Time, ::Tags::AnalyticSolutionOrData>;
      78             : 
      79             :   template <typename AnalyticSolutionOrData>
      80           0 :   std::optional<std::string> dg_ghost(
      81             :       const gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*>
      82             :           spacetime_metric,
      83             :       const gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*> pi,
      84             :       const gsl::not_null<tnsr::iaa<DataVector, Dim, Frame::Inertial>*> phi,
      85             :       const gsl::not_null<Scalar<DataVector>*> gamma1,
      86             :       const gsl::not_null<Scalar<DataVector>*> gamma2,
      87             :       const gsl::not_null<Scalar<DataVector>*> lapse,
      88             :       const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
      89             :       const gsl::not_null<tnsr::II<DataVector, Dim, Frame::Inertial>*>
      90             :           inv_spatial_metric,
      91             :       const std::optional<
      92             :           tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
      93             :       const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
      94             :       const tnsr::I<DataVector, Dim, Frame::Inertial>& /*normal_vector*/,
      95             :       const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
      96             :       const Scalar<DataVector>& interior_gamma1,
      97             :       const Scalar<DataVector>& interior_gamma2, const double time,
      98             :       const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
      99             :     *gamma1 = interior_gamma1;
     100             :     *gamma2 = interior_gamma2;
     101             :     auto boundary_values = [&analytic_solution_or_data, &coords,
     102             :                             &time]() noexcept {
     103             :       if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
     104             :                                       AnalyticSolutionOrData>) {
     105             :         return analytic_solution_or_data.variables(
     106             :             coords, time,
     107             :             tmpl::list<
     108             :                 GeneralizedHarmonic::Tags::Pi<Dim, Frame::Inertial>,
     109             :                 GeneralizedHarmonic::Tags::Phi<Dim, Frame::Inertial>,
     110             :                 gr::Tags::SpacetimeMetric<Dim, Frame::Inertial, DataVector>>{});
     111             : 
     112             :       } else {
     113             :         (void)time;
     114             :         return analytic_solution_or_data.variables(
     115             :             coords,
     116             :             tmpl::list<
     117             :                 GeneralizedHarmonic::Tags::Pi<Dim, Frame::Inertial>,
     118             :                 GeneralizedHarmonic::Tags::Phi<Dim, Frame::Inertial>,
     119             :                 gr::Tags::SpacetimeMetric<Dim, Frame::Inertial, DataVector>>{});
     120             :       }
     121             :     }();
     122             : 
     123             :     *spacetime_metric =
     124             :         get<gr::Tags::SpacetimeMetric<Dim, Frame::Inertial, DataVector>>(
     125             :             boundary_values);
     126             :     *pi = get<GeneralizedHarmonic::Tags::Pi<Dim, Frame::Inertial>>(
     127             :         boundary_values);
     128             :     *phi = get<GeneralizedHarmonic::Tags::Phi<Dim, Frame::Inertial>>(
     129             :         boundary_values);
     130             : 
     131             :     // Now compute lapse and shift...
     132             :     lapse_shift_and_inv_spatial_metric(lapse, shift, inv_spatial_metric,
     133             :                                        *spacetime_metric);
     134             :     return {};
     135             :   }
     136             : 
     137             :  private:
     138           0 :   void lapse_shift_and_inv_spatial_metric(
     139             :       gsl::not_null<Scalar<DataVector>*> lapse,
     140             :       gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> shift,
     141             :       gsl::not_null<tnsr::II<DataVector, Dim, Frame::Inertial>*>
     142             :           inv_spatial_metric,
     143             :       const tnsr::aa<DataVector, Dim, Frame::Inertial>& spacetime_metric)
     144             :       const noexcept;
     145             : };
     146             : }  // namespace GeneralizedHarmonic::BoundaryConditions

Generated by: LCOV version 1.14