SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/NewtonianEuler/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/NewtonianEuler/BoundaryConditions/BoundaryCondition.hpp"
      18             : #include "Evolution/Systems/NewtonianEuler/ConservativeFromPrimitive.hpp"
      19             : #include "Evolution/Systems/NewtonianEuler/Fluxes.hpp"
      20             : #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
      21             : #include "Options/Options.hpp"
      22             : #include "Parallel/CharmPupable.hpp"
      23             : #include "PointwiseFunctions/AnalyticData/Tags.hpp"
      24             : #include "PointwiseFunctions/AnalyticSolutions/AnalyticSolution.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 NewtonianEuler::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 using either analytic solution or "
      47             :       "analytic data."};
      48           0 :   static std::string name() noexcept { return "DirichletAnalytic"; }
      49             : 
      50           0 :   DirichletAnalytic() = default;
      51           0 :   DirichletAnalytic(DirichletAnalytic&&) noexcept = default;
      52           0 :   DirichletAnalytic& operator=(DirichletAnalytic&&) noexcept = default;
      53           0 :   DirichletAnalytic(const DirichletAnalytic&) = default;
      54           0 :   DirichletAnalytic& operator=(const DirichletAnalytic&) = default;
      55           0 :   ~DirichletAnalytic() override = default;
      56             : 
      57           0 :   explicit DirichletAnalytic(CkMigrateMessage* msg) noexcept;
      58             : 
      59           0 :   WRAPPED_PUPable_decl_base_template(
      60             :       domain::BoundaryConditions::BoundaryCondition, DirichletAnalytic);
      61             : 
      62           0 :   auto get_clone() const noexcept -> std::unique_ptr<
      63             :       domain::BoundaryConditions::BoundaryCondition> override;
      64             : 
      65           0 :   static constexpr evolution::BoundaryConditions::Type bc_type =
      66             :       evolution::BoundaryConditions::Type::Ghost;
      67             : 
      68           0 :   void pup(PUP::er& p) override;
      69             : 
      70           0 :   using dg_interior_evolved_variables_tags = tmpl::list<>;
      71           0 :   using dg_interior_temporary_tags =
      72             :       tmpl::list<domain::Tags::Coordinates<Dim, Frame::Inertial>>;
      73           0 :   using dg_interior_primitive_variables_tags = tmpl::list<>;
      74           0 :   using dg_gridless_tags =
      75             :       tmpl::list<::Tags::Time, ::Tags::AnalyticSolutionOrData>;
      76             : 
      77             :   template <typename AnalyticSolutionOrData>
      78           0 :   std::optional<std::string> dg_ghost(
      79             :       const gsl::not_null<Scalar<DataVector>*> mass_density,
      80             :       const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
      81             :           momentum_density,
      82             :       const gsl::not_null<Scalar<DataVector>*> energy_density,
      83             : 
      84             :       const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
      85             :           flux_mass_density,
      86             :       const gsl::not_null<tnsr::IJ<DataVector, Dim, Frame::Inertial>*>
      87             :           flux_momentum_density,
      88             :       const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*>
      89             :           flux_energy_density,
      90             : 
      91             :       const gsl::not_null<tnsr::I<DataVector, Dim, Frame::Inertial>*> velocity,
      92             :       const gsl::not_null<Scalar<DataVector>*> specific_internal_energy,
      93             : 
      94             :       const std::optional<
      95             :           tnsr::I<DataVector, Dim, Frame::Inertial>>& /*face_mesh_velocity*/,
      96             :       const tnsr::i<DataVector, Dim, Frame::Inertial>& /*normal_covector*/,
      97             :       const tnsr::I<DataVector, Dim, Frame::Inertial>& coords,
      98             :       const double time,
      99             :       const AnalyticSolutionOrData& analytic_solution_or_data) const noexcept {
     100             :     auto boundary_values = [&analytic_solution_or_data, &coords,
     101             :                             &time]() noexcept {
     102             :       if constexpr (std::is_base_of_v<MarkAsAnalyticSolution,
     103             :                                       AnalyticSolutionOrData>) {
     104             :         return analytic_solution_or_data.variables(
     105             :             coords, time,
     106             :             tmpl::list<Tags::MassDensity<DataVector>,
     107             :                        Tags::Velocity<DataVector, Dim>,
     108             :                        Tags::Pressure<DataVector>,
     109             :                        Tags::SpecificInternalEnergy<DataVector>>{});
     110             : 
     111             :       } else {
     112             :         (void)time;
     113             :         return analytic_solution_or_data.variables(
     114             :             coords, tmpl::list<Tags::MassDensity<DataVector>,
     115             :                                Tags::Velocity<DataVector, Dim>,
     116             :                                Tags::Pressure<DataVector>,
     117             :                                Tags::SpecificInternalEnergy<DataVector>>{});
     118             :       }
     119             :     }();
     120             : 
     121             :     *mass_density = get<Tags::MassDensity<DataVector>>(boundary_values);
     122             :     *velocity = get<Tags::Velocity<DataVector, Dim>>(boundary_values);
     123             :     *specific_internal_energy =
     124             :         get<Tags::SpecificInternalEnergy<DataVector>>(boundary_values);
     125             : 
     126             :     ConservativeFromPrimitive<Dim>::apply(mass_density, momentum_density,
     127             :                                           energy_density, *mass_density,
     128             :                                           *velocity, *specific_internal_energy);
     129             :     ComputeFluxes<Dim>::apply(flux_mass_density, flux_momentum_density,
     130             :                               flux_energy_density, *momentum_density,
     131             :                               *energy_density, *velocity,
     132             :                               get<Tags::Pressure<DataVector>>(boundary_values));
     133             : 
     134             :     return {};
     135             :   }
     136             : };
     137             : }  // namespace NewtonianEuler::BoundaryConditions

Generated by: LCOV version 1.14