SpECTRE Documentation Coverage Report
Current view: top level - NumericalAlgorithms/Integration - GslQuadAdaptive.cpp Hit Total Coverage
Commit: 2db722c93a8e9b106e406b439b79c8e05c2057fb Lines: 1 2 50.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 "NumericalAlgorithms/Integration/GslQuadAdaptive.hpp"
       5             : 
       6             : #include <cstddef>
       7             : #include <gsl/gsl_errno.h>
       8             : #include <gsl/gsl_integration.h>
       9             : #include <memory>
      10             : #include <pup.h>
      11             : 
      12             : #include "Utilities/ErrorHandling/Exceptions.hpp"
      13             : #include "Utilities/MakeString.hpp"
      14             : 
      15           1 : namespace integration::detail {
      16             : 
      17             : GslQuadAdaptiveImpl::GslQuadAdaptiveImpl(const size_t max_intervals) noexcept
      18             :     : max_intervals_(max_intervals), gsl_integrand_(gsl_function{}) {
      19             :   initialize();
      20             : }
      21             : 
      22             : void GslQuadAdaptiveImpl::pup(PUP::er& p) noexcept {
      23             :   p | max_intervals_;
      24             :   if (p.isUnpacking()) {
      25             :     initialize();
      26             :   }
      27             : }
      28             : 
      29             : void GslQuadAdaptiveImpl::GslIntegrationWorkspaceDeleter::operator()(
      30             :     gsl_integration_workspace* workspace) const noexcept {
      31             :   gsl_integration_workspace_free(workspace);
      32             : }
      33             : 
      34             : void GslQuadAdaptiveImpl::initialize() noexcept {
      35             :   workspace_ = std::unique_ptr<gsl_integration_workspace,
      36             :                                GslIntegrationWorkspaceDeleter>{
      37             :       gsl_integration_workspace_alloc(max_intervals_)};
      38             : }
      39             : 
      40             : void check_status_code(const int status_code) {
      41             :   if (status_code != 0) {
      42             :     throw convergence_error(MakeString{}
      43             :                             << "Integration failed with GSL error: "
      44             :                             << gsl_strerror(status_code));
      45             :   }
      46             : }
      47             : 
      48             : void disable_gsl_error_handling() noexcept { gsl_set_error_handler_off(); }
      49             : 
      50             : }  // namespace integration::detail

Generated by: LCOV version 1.14