SpECTRE Documentation Coverage Report
Current view: top level - NumericalAlgorithms/Interpolation - IrregularInterpolant.hpp Hit Total Coverage
Commit: 2ae2b99409ac582030d56a4560a92a3e066a7e54 Lines: 4 11 36.4 %
Date: 2022-01-15 08:40:38
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 <cstddef>
       7             : 
       8             : #include "DataStructures/DataVector.hpp"
       9             : #include "DataStructures/Matrix.hpp"
      10             : #include "DataStructures/Tensor/TypeAliases.hpp"
      11             : #include "DataStructures/Variables.hpp"
      12             : #include "Utilities/Blas.hpp"
      13             : #include "Utilities/ErrorHandling/Assert.hpp"
      14             : #include "Utilities/Gsl.hpp"
      15             : 
      16             : /// \cond
      17             : template <size_t Dim>
      18             : class Mesh;
      19             : namespace PUP {
      20             : class er;
      21             : }  // namespace PUP
      22             : // IWYU pragma: no_forward_declare Variables
      23             : /// \endcond
      24             : 
      25             : namespace intrp {
      26             : 
      27             : /// \ingroup NumericalAlgorithmsGroup
      28             : /// \brief Interpolates a `Variables` onto an arbitrary set of points.
      29             : ///
      30             : /// \details If the `source_mesh` uses Spectral::Basis::FiniteDifference,
      31             : /// linear interpolation is done in each dimension; otherwise it uses the
      32             : /// barycentric interpolation provided by Spectral::interpolation_matrix in each
      33             : /// dimension.
      34             : template <size_t Dim>
      35           1 : class Irregular {
      36             :  public:
      37           0 :   Irregular(
      38             :       const Mesh<Dim>& source_mesh,
      39             :       const tnsr::I<DataVector, Dim, Frame::ElementLogical>& target_points);
      40           0 :   Irregular();
      41             : 
      42             :   /// Serialization for Charm++
      43             :   // NOLINTNEXTLINE(google-runtime-references)
      44           1 :   void pup(PUP::er& p);
      45             : 
      46             :   /// @{
      47             :   /// Performs the interpolation on a `Variables` with grid points corresponding
      48             :   /// to the `Mesh<Dim>` specified in the constructor.
      49             :   /// The result is a `Variables` whose internal `DataVector` goes over the
      50             :   /// list of target_points that were specified in the constructor.
      51             :   /// \note for the void function, `result` will be resized to the proper size.
      52             :   template <typename TagsList>
      53           1 :   void interpolate(gsl::not_null<Variables<TagsList>*> result,
      54             :                    const Variables<TagsList>& vars) const;
      55             :   template <typename TagsList>
      56           1 :   Variables<TagsList> interpolate(const Variables<TagsList>& vars) const;
      57             :   /// @}
      58             : 
      59             :  private:
      60           0 :   friend bool operator==(const Irregular& lhs, const Irregular& rhs) {
      61             :     return lhs.interpolation_matrix_ == rhs.interpolation_matrix_;
      62             :   }
      63           0 :   Matrix interpolation_matrix_;
      64             : };
      65             : 
      66             : template <size_t Dim>
      67             : template <typename TagsList>
      68           0 : void Irregular<Dim>::interpolate(
      69             :     const gsl::not_null<Variables<TagsList>*> result,
      70             :     const Variables<TagsList>& vars) const {
      71             :   // For matrix multiplication of Interp . Source = Result:
      72             :   //   matrix Interp is m rows by k columns
      73             :   //   matrix Source is k rows by n columns
      74             :   //   matrix Result is m rows by n columns
      75             :   const size_t m = interpolation_matrix_.rows();
      76             :   const size_t k = interpolation_matrix_.columns();
      77             :   const size_t n = vars.number_of_independent_components;
      78             :   ASSERT(k == vars.number_of_grid_points(),
      79             :          "Number of grid points in source 'vars', "
      80             :              << vars.number_of_grid_points()
      81             :              << ",\n disagrees with the size of the source_mesh, " << k
      82             :              << ", that was passed into the constructor");
      83             :   if (result->number_of_grid_points() != m) {
      84             :     *result = Variables<TagsList>(m, 0.);
      85             :   }
      86             :   dgemm_('n', 'n', m, n, k, 1.0, interpolation_matrix_.data(),
      87             :          interpolation_matrix_.spacing(), vars.data(), k, 0.0, result->data(),
      88             :          m);
      89             : }
      90             : 
      91             : template <size_t Dim>
      92             : template <typename TagsList>
      93             : Variables<TagsList> Irregular<Dim>::interpolate(
      94             :     const Variables<TagsList>& vars) const {
      95             :   Variables<TagsList> result;
      96             :   interpolate(make_not_null(&result), vars);
      97             :   return result;
      98             : }
      99             : 
     100             : template <size_t Dim>
     101           0 : bool operator!=(const Irregular<Dim>& lhs, const Irregular<Dim>& rhs);
     102             : 
     103             : }  // namespace intrp
     104             : 

Generated by: LCOV version 1.14