LCOV - code coverage report
Current view: top level - include/numerics - petsc_preconditioner.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4476 (4beb67) with base a68cc6 Lines: 0 1 0.0 %
Date: 2026-06-03 20:22:46 Functions: 0 2 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : 
      19             : 
      20             : #ifndef LIBMESH_PETSC_PRECONDITIONER_H
      21             : #define LIBMESH_PETSC_PRECONDITIONER_H
      22             : 
      23             : #include "libmesh/libmesh_config.h"
      24             : 
      25             : #ifdef LIBMESH_HAVE_PETSC
      26             : 
      27             : // libMesh includes
      28             : #include "libmesh/preconditioner.h"
      29             : #include "libmesh/libmesh_common.h"
      30             : #include "libmesh/reference_counted_object.h"
      31             : #include "libmesh/libmesh.h"
      32             : #include "libmesh/petsc_macro.h"
      33             : #include "libmesh/wrapped_petsc.h"
      34             : #include "libmesh/system.h"
      35             : 
      36             : // Petsc includes
      37             : #include "petscpc.h"
      38             : 
      39             : namespace libMesh
      40             : {
      41             : 
      42             : // forward declarations
      43             : template <typename T> class SparseMatrix;
      44             : template <typename T> class NumericVector;
      45             : template <typename T> class ShellMatrix;
      46             : enum PreconditionerType : int;
      47             : 
      48             : /**
      49             :  * This class provides an interface to the suite of preconditioners
      50             :  * available from PETSc. All overridden virtual functions are
      51             :  * documented in preconditioner.h.
      52             :  *
      53             :  * \author Derek Gaston
      54             :  * \date 2009
      55             :  */
      56             : template <typename T>
      57             : class PetscPreconditioner : public Preconditioner<T>
      58             : {
      59             : public:
      60             : 
      61             :   /**
      62             :    *  Constructor. Initializes PetscPreconditioner data structures
      63             :    */
      64             :   PetscPreconditioner (const libMesh::Parallel::Communicator & comm_in);
      65             : 
      66           0 :   virtual ~PetscPreconditioner () = default;
      67             : 
      68             :   virtual void apply(const NumericVector<T> & x, NumericVector<T> & y) override;
      69             : 
      70             :   virtual void clear () override;
      71             : 
      72             :   virtual void init () override;
      73             : 
      74             :   /**
      75             :    * \returns The PETSc PC object.  Can be useful for implementing
      76             :    * more advanced algorithms.
      77             :    */
      78             :   PC pc();
      79             : 
      80             :   /**
      81             :    * Tells PETSc to use the user-specified preconditioner.
      82             :    */
      83             :   static void set_petsc_preconditioner_type (const PreconditionerType & preconditioner_type, PC & pc);
      84             : 
      85             :   /**
      86             :    * Builds PETSc auxiliary data needed by preconditioners such as hypre ams/ads.
      87             :    */
      88             : #ifdef LIBMESH_HAVE_PETSC_HYPRE
      89             :   static void set_petsc_aux_data (PC & pc, System & sys, const unsigned v = 0);
      90             :   static void set_hypre_ams_data (PC & pc, System & sys, const unsigned v);
      91             :   static void set_hypre_ads_data (PC & pc, System & sys, const unsigned v);
      92             : #else
      93             :   static void set_petsc_aux_data (PC &, System &, const unsigned = 0) {}
      94             : #endif
      95             : 
      96             : protected:
      97             : 
      98             :   /**
      99             :    * Preconditioner context
     100             :    */
     101             :   WrappedPetsc<PC> _pc;
     102             : 
     103             :   /**
     104             :    * PETSc Mat pulled out of the _matrix object during init(). We
     105             :    * aren't responsible for cleaning up this one.
     106             :    */
     107             :   Mat _mat;
     108             : };
     109             : 
     110             : } // namespace libMesh
     111             : 
     112             : #endif // #ifdef LIBMESH_HAVE_PETSC
     113             : #endif // LIBMESH_PETSC_PRECONDITIONER_H

Generated by: LCOV version 1.14