SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/NewtonianEuler/Sources - UniformAcceleration.cpp Hit Total Coverage
Commit: 2db722c93a8e9b106e406b439b79c8e05c2057fb Lines: 0 5 0.0 %
Date: 2021-03-03 22:01:00
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #include "Evolution/Systems/NewtonianEuler/Sources/UniformAcceleration.hpp"
       5             : 
       6             : #include <array>
       7             : #include <cstddef>
       8             : #include <pup.h>
       9             : 
      10             : #include "DataStructures/DataVector.hpp"
      11             : #include "DataStructures/Tensor/Tensor.hpp"
      12             : #include "Utilities/GenerateInstantiations.hpp"
      13             : #include "Utilities/Gsl.hpp"
      14             : 
      15             : namespace NewtonianEuler {
      16             : namespace Sources {
      17             : 
      18             : template <size_t Dim>
      19             : UniformAcceleration<Dim>::UniformAcceleration(
      20             :     const std::array<double, Dim>& acceleration_field) noexcept
      21             :     : acceleration_field_(acceleration_field) {}
      22             : 
      23             : template <size_t Dim>
      24             : void UniformAcceleration<Dim>::pup(PUP::er& p) noexcept {
      25             :   p | acceleration_field_;
      26             : }
      27             : 
      28             : template <size_t Dim>
      29             : void UniformAcceleration<Dim>::apply(
      30             :     const gsl::not_null<tnsr::I<DataVector, Dim>*> source_momentum_density,
      31             :     const gsl::not_null<Scalar<DataVector>*> source_energy_density,
      32             :     const Scalar<DataVector>& mass_density_cons,
      33             :     const tnsr::I<DataVector, Dim>& momentum_density) const noexcept {
      34             :   get(*source_energy_density) = 0.0;
      35             :   for (size_t i = 0; i < Dim; ++i) {
      36             :     source_momentum_density->get(i) =
      37             :         get(mass_density_cons) * gsl::at(acceleration_field_, i);
      38             :     get(*source_energy_density) +=
      39             :         gsl::at(acceleration_field_, i) * momentum_density.get(i);
      40             :   }
      41             : }
      42             : 
      43             : template <size_t Dim>
      44           0 : bool operator==(const UniformAcceleration<Dim>& lhs,
      45             :                 const UniformAcceleration<Dim>& rhs) noexcept {
      46             :   return lhs.acceleration_field_ == rhs.acceleration_field_;
      47             : }
      48             : 
      49             : template <size_t Dim>
      50           0 : bool operator!=(const UniformAcceleration<Dim>& lhs,
      51             :                 const UniformAcceleration<Dim>& rhs) noexcept {
      52             :   return not(lhs == rhs);
      53             : }
      54             : 
      55           0 : #define DIM(data) BOOST_PP_TUPLE_ELEM(0, data)
      56             : 
      57           0 : #define INSTANTIATE(_, data)                                                \
      58             :   template struct UniformAcceleration<DIM(data)>;                           \
      59             :   template bool operator==(const UniformAcceleration<DIM(data)>&,           \
      60             :                            const UniformAcceleration<DIM(data)>&) noexcept; \
      61             :   template bool operator!=(const UniformAcceleration<DIM(data)>&,           \
      62             :                            const UniformAcceleration<DIM(data)>&) noexcept;
      63             : 
      64             : GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3))
      65             : 
      66             : #undef INSTANTIATE
      67             : #undef DIM
      68             : }  // namespace Sources
      69             : }  // namespace NewtonianEuler

Generated by: LCOV version 1.14