LCOV - code coverage report
Current view: top level - linalg - ksp.hpp (source / functions) Coverage Total Hit
Test: Palace Coverage Report Lines: 0.0 % 2 0
Test Date: 2025-10-23 22:45:05 Functions: 0.0 % 4 0
Legend: Lines: hit not hit

            Line data    Source code
       1              : // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
       2              : // SPDX-License-Identifier: Apache-2.0
       3              : 
       4              : #ifndef PALACE_LINALG_KSP_HPP
       5              : #define PALACE_LINALG_KSP_HPP
       6              : 
       7              : #include <memory>
       8              : #include <type_traits>
       9              : #include "linalg/iterative.hpp"
      10              : #include "linalg/operator.hpp"
      11              : #include "linalg/solver.hpp"
      12              : 
      13              : namespace palace
      14              : {
      15              : 
      16              : class FiniteElementSpaceHierarchy;
      17              : class IoData;
      18              : 
      19              : //
      20              : // Linear solver class composing an iterative solver and preconditioner object.
      21              : //
      22              : template <typename OperType>
      23              : class BaseKspSolver
      24              : {
      25              :   static_assert(std::is_same<OperType, Operator>::value ||
      26              :                     std::is_same<OperType, ComplexOperator>::value,
      27              :                 "Solver can only be defined for OperType = Operator or ComplexOperator!");
      28              : 
      29              :   using VecType = typename std::conditional<std::is_same<OperType, ComplexOperator>::value,
      30              :                                             ComplexVector, Vector>::type;
      31              : 
      32              : protected:
      33              :   // The actual solver and preconditioner objects.
      34              :   std::unique_ptr<IterativeSolver<OperType>> ksp;
      35              :   std::unique_ptr<Solver<OperType>> pc;
      36              : 
      37              :   // Counters for number of calls to Mult method for linear solves, and cumulative number
      38              :   // of iterations.
      39              :   mutable int ksp_mult, ksp_mult_it;
      40              : 
      41              :   // Enable timer contribution for Timer::KSP_PRECONDITIONER.
      42              :   bool use_timer;
      43              : 
      44              : public:
      45              :   BaseKspSolver(const IoData &iodata, FiniteElementSpaceHierarchy &fespaces,
      46              :                 FiniteElementSpaceHierarchy *aux_fespaces = nullptr);
      47              :   BaseKspSolver(std::unique_ptr<IterativeSolver<OperType>> &&ksp,
      48              :                 std::unique_ptr<Solver<OperType>> &&pc);
      49              : 
      50            0 :   int NumTotalMult() const { return ksp_mult; }
      51            0 :   int NumTotalMultIterations() const { return ksp_mult_it; }
      52              : 
      53              :   void SetOperators(const OperType &op, const OperType &pc_op);
      54              : 
      55              :   void Mult(const VecType &x, VecType &y) const;
      56              : };
      57              : 
      58              : using KspSolver = BaseKspSolver<Operator>;
      59              : using ComplexKspSolver = BaseKspSolver<ComplexOperator>;
      60              : 
      61              : }  // namespace palace
      62              : 
      63              : #endif  // PALACE_LINALG_KSP_HPP
        

Generated by: LCOV version 2.0-1