SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/ScalarWave - Constraints.cpp Hit Total Coverage
Commit: b1342d46f40e2d46bbd11d0cef68fd973031a24b Lines: 2 5 40.0 %
Date: 2020-09-24 20:24:42
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/ScalarWave/Constraints.hpp"
       5             : 
       6             : #include <cstddef>
       7             : 
       8             : #include "DataStructures/Tensor/Tensor.hpp"
       9             : #include "Utilities/ConstantExpressions.hpp"
      10             : #include "Utilities/ContainerHelpers.hpp"
      11             : #include "Utilities/GenerateInstantiations.hpp"
      12             : #include "Utilities/Gsl.hpp"
      13             : #include "Utilities/MakeWithValue.hpp"
      14             : 
      15             : namespace ScalarWave {
      16             : template <size_t SpatialDim>
      17           1 : tnsr::i<DataVector, SpatialDim, Frame::Inertial> one_index_constraint(
      18             :     const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& d_psi,
      19             :     const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi) noexcept {
      20             :   tnsr::i<DataVector, SpatialDim, Frame::Inertial> constraint(
      21             :       get_size(get<0>(phi)));
      22             :   one_index_constraint(make_not_null(&constraint), d_psi, phi);
      23             :   return constraint;
      24             : }
      25             : 
      26             : template <size_t SpatialDim>
      27           0 : void one_index_constraint(
      28             :     const gsl::not_null<tnsr::i<DataVector, SpatialDim, Frame::Inertial>*>
      29             :         constraint,
      30             :     const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& d_psi,
      31             :     const tnsr::i<DataVector, SpatialDim, Frame::Inertial>& phi) noexcept {
      32             :   destructive_resize_components(constraint, get_size(get<0>(phi)));
      33             :   // Declare iterators for d_psi and phi outside the for loop,
      34             :   // because they are const but constraint is not
      35             :   auto d_psi_it = d_psi.cbegin(), phi_it = phi.cbegin();
      36             : 
      37             :   for (auto constraint_it = constraint->begin();
      38             :        constraint_it != constraint->end();
      39             :        ++constraint_it, (void)++d_psi_it, (void)++phi_it) {
      40             :     *constraint_it = *d_psi_it - *phi_it;
      41             :   }
      42             : }
      43             : 
      44             : template <size_t SpatialDim>
      45           1 : tnsr::ij<DataVector, SpatialDim, Frame::Inertial> two_index_constraint(
      46             :     const tnsr::ij<DataVector, SpatialDim, Frame::Inertial>& d_phi) noexcept {
      47             :   tnsr::ij<DataVector, SpatialDim, Frame::Inertial> constraint(
      48             :       get_size(get<0, 0>(d_phi)));
      49             :   two_index_constraint(make_not_null(&constraint), d_phi);
      50             :   return constraint;
      51             : }
      52             : 
      53             : template <size_t SpatialDim>
      54           0 : void two_index_constraint(
      55             :     const gsl::not_null<tnsr::ij<DataVector, SpatialDim, Frame::Inertial>*>
      56             :         constraint,
      57             :     const tnsr::ij<DataVector, SpatialDim, Frame::Inertial>& d_phi) noexcept {
      58             :   destructive_resize_components(constraint, get_size(get<0, 0>(d_phi)));
      59             :   for (size_t i = 0; i < SpatialDim; ++i) {
      60             :     for (size_t j = 0; j < SpatialDim; ++j) {
      61             :       constraint->get(i, j) = d_phi.get(i, j) - d_phi.get(j, i);
      62             :     }
      63             :   }
      64             : }
      65             : }  // namespace ScalarWave
      66             : 
      67             : // Explicit Instantiations
      68             : /// \cond
      69             : #define DIM(data) BOOST_PP_TUPLE_ELEM(0, data)
      70             : 
      71             : #define INSTANTIATE(_, data)                                                  \
      72             :   template tnsr::i<DataVector, DIM(data), Frame::Inertial>                    \
      73             :   ScalarWave::one_index_constraint(                                           \
      74             :       const tnsr::i<DataVector, DIM(data), Frame::Inertial>&,                 \
      75             :       const tnsr::i<DataVector, DIM(data), Frame::Inertial>&) noexcept;       \
      76             :   template void ScalarWave::one_index_constraint(                             \
      77             :       const gsl::not_null<tnsr::i<DataVector, DIM(data), Frame::Inertial>*>,  \
      78             :       const tnsr::i<DataVector, DIM(data), Frame::Inertial>&,                 \
      79             :       const tnsr::i<DataVector, DIM(data), Frame::Inertial>&) noexcept;       \
      80             :   template tnsr::ij<DataVector, DIM(data), Frame::Inertial>                   \
      81             :   ScalarWave::two_index_constraint(                                           \
      82             :       const tnsr::ij<DataVector, DIM(data), Frame::Inertial>&) noexcept;      \
      83             :   template void ScalarWave::two_index_constraint(                             \
      84             :       const gsl::not_null<tnsr::ij<DataVector, DIM(data), Frame::Inertial>*>, \
      85             :       const tnsr::ij<DataVector, DIM(data), Frame::Inertial>&) noexcept;
      86             : 
      87             : GENERATE_INSTANTIATIONS(INSTANTIATE, (1, 2, 3))
      88             : 
      89             : #undef DIM
      90             : #undef INSTANTIATE
      91             : /// \endcond

Generated by: LCOV version 1.14