SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/NewtonianEuler/Sources - VortexPerturbation.cpp Hit Total Coverage
Commit: 2db722c93a8e9b106e406b439b79c8e05c2057fb Lines: 0 1 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/VortexPerturbation.hpp"
       5             : 
       6             : #include <cstddef>
       7             : #include <pup.h>
       8             : 
       9             : #include "DataStructures/DataVector.hpp"
      10             : #include "DataStructures/Tags/TempTensor.hpp"
      11             : #include "DataStructures/Tensor/Tensor.hpp"
      12             : #include "DataStructures/Variables.hpp"
      13             : #include "Evolution/Systems/NewtonianEuler/ConservativeFromPrimitive.hpp"
      14             : #include "Evolution/Systems/NewtonianEuler/Tags.hpp"
      15             : #include "PointwiseFunctions/AnalyticSolutions/NewtonianEuler/IsentropicVortex.hpp"
      16             : #include "Utilities/GenerateInstantiations.hpp"
      17             : #include "Utilities/Gsl.hpp"
      18             : #include "Utilities/TMPL.hpp"
      19             : 
      20             : // IWYU pragma: no_include <array>
      21             : 
      22             : // IWYU pragma: no_forward_declare Tensor
      23             : 
      24             : /// \cond
      25             : namespace NewtonianEuler::Sources {
      26             : template <>
      27             : void VortexPerturbation<2>::apply() const noexcept {}
      28             : 
      29             : template <>
      30             : void VortexPerturbation<3>::apply(
      31             :     const gsl::not_null<Scalar<DataVector>*> source_mass_density_cons,
      32             :     const gsl::not_null<tnsr::I<DataVector, 3>*> source_momentum_density,
      33             :     const gsl::not_null<Scalar<DataVector>*> source_energy_density,
      34             :     const NewtonianEuler::Solutions::IsentropicVortex<3>& vortex,
      35             :     const tnsr::I<DataVector, 3>& x, const double time) const noexcept {
      36             :   const size_t number_of_grid_points = get<0>(x).size();
      37             :   const auto vortex_primitives = vortex.variables(
      38             :       x, time,
      39             :       tmpl::list<Tags::MassDensity<DataVector>, Tags::Velocity<DataVector, 3>,
      40             :                  Tags::SpecificInternalEnergy<DataVector>,
      41             :                  Tags::Pressure<DataVector>>{});
      42             :   Variables<
      43             :       tmpl::list<::Tags::TempScalar<0>, ::Tags::TempI<1, 3, Frame::Inertial>,
      44             :                  ::Tags::TempScalar<2>>>
      45             :       temp_buffer(number_of_grid_points);
      46             :   auto& vortex_mass_density_cons = get<::Tags::TempScalar<0>>(temp_buffer);
      47             :   auto& vortex_momentum_density =
      48             :       get<::Tags::TempI<1, 3, Frame::Inertial>>(temp_buffer);
      49             :   auto& vortex_energy_density = get<::Tags::TempScalar<2>>(temp_buffer);
      50             : 
      51             :   NewtonianEuler::ConservativeFromPrimitive<3>::apply(
      52             :       make_not_null(&vortex_mass_density_cons),
      53             :       make_not_null(&vortex_momentum_density),
      54             :       make_not_null(&vortex_energy_density),
      55             :       get<Tags::MassDensity<DataVector>>(vortex_primitives),
      56             :       get<Tags::Velocity<DataVector, 3>>(vortex_primitives),
      57             :       get<Tags::SpecificInternalEnergy<DataVector>>(vortex_primitives));
      58             : 
      59             :   // We save the precomputed value of dv_z/dz in source_mass_density_cons
      60             :   // in order to save an allocation
      61             :   get(*source_mass_density_cons) =
      62             :       vortex.perturbation_amplitude() *
      63             :       vortex.deriv_of_perturbation_profile(get<2>(x));
      64             : 
      65             :   for (size_t i = 0; i < 3; ++i) {
      66             :     source_momentum_density->get(i) =
      67             :         vortex_momentum_density.get(i) * get(*source_mass_density_cons);
      68             :   }
      69             :   source_momentum_density->get(2) *= 2.0;
      70             : 
      71             :   get(*source_energy_density) =
      72             :       (get(vortex_energy_density) +
      73             :        get(get<Tags::Pressure<DataVector>>(vortex_primitives)) +
      74             :        vortex_momentum_density.get(2) *
      75             :            get<2>(get<Tags::Velocity<DataVector, 3>>(
      76             :                vortex_primitives))) *
      77             :       get(*source_mass_density_cons);
      78             : 
      79             :   get(*source_mass_density_cons) *= get(vortex_mass_density_cons);
      80             : }
      81             : 
      82             : #define DIM(data) BOOST_PP_TUPLE_ELEM(0, data)
      83             : 
      84             : #define INSTANTIATE(_, data) template struct VortexPerturbation<DIM(data)>;
      85             : 
      86             : GENERATE_INSTANTIATIONS(INSTANTIATE, (2, 3))
      87             : 
      88             : #undef INSTANTIATE
      89             : #undef DIM
      90             : }  // namespace NewtonianEuler::Sources
      91             : /// \endcond

Generated by: LCOV version 1.14