LCOV - code coverage report
Current view: top level - include/solvers - petsc_diff_solver.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 1 1 100.0 %
Date: 2025-08-19 19:27:09 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 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_DIFF_SOLVER_H
      21             : #define LIBMESH_PETSC_DIFF_SOLVER_H
      22             : 
      23             : #include "libmesh/libmesh_common.h"
      24             : 
      25             : #ifdef LIBMESH_HAVE_PETSC
      26             : 
      27             : // Local includes
      28             : #include "libmesh/diff_solver.h"
      29             : #include "libmesh/petsc_macro.h"
      30             : #include "libmesh/petsc_dm_wrapper.h"
      31             : #include "libmesh/wrapped_petsc.h"
      32             : 
      33             : // PETSc includes
      34             : #ifdef I
      35             : # define LIBMESH_SAW_I
      36             : #endif
      37             : #include <petscsnes.h>
      38             : #ifndef LIBMESH_SAW_I
      39             : # undef I // Avoid complex.h contamination
      40             : #endif
      41             : 
      42             : namespace libMesh
      43             : {
      44             : 
      45             : /**
      46             :  * This class defines a solver which uses a PETSc SNES
      47             :  * context to handle a DifferentiableSystem
      48             :  *
      49             :  * This class is part of the new DifferentiableSystem framework,
      50             :  * which is still experimental.  Users of this framework should
      51             :  * beware of bugs and future API changes.
      52             :  *
      53             :  * \author Roy H. Stogner
      54             :  * \date 2008
      55             :  */
      56          48 : class PetscDiffSolver : public DiffSolver
      57             : {
      58             : public:
      59             :   /**
      60             :    * Constructor. Requires a reference to the system
      61             :    * to be solved.
      62             :    */
      63             :   explicit
      64             :   PetscDiffSolver (sys_type & system);
      65             : 
      66             :   /**
      67             :    * Destructor.
      68             :    */
      69             :   virtual ~PetscDiffSolver ();
      70             : 
      71             :   typedef DiffSolver Parent;
      72             : 
      73             :   /**
      74             :    * The reinitialization function.  This method is used after
      75             :    * changes in the mesh.
      76             :    */
      77             :   virtual void reinit () override;
      78             : 
      79             :   /**
      80             :    * The initialization function.
      81             :    */
      82             :   virtual void init () override;
      83             : 
      84             :   /**
      85             :    * The clear function. Called if we reinit or when we destroy this object.
      86             :    */
      87             :   void clear ();
      88             : 
      89             :   /**
      90             :    * This method performs a solve.  What occurs in
      91             :    * this method will depend on the PETSc SNES settings.
      92             :    * See the PETSc documentation for more details.
      93             :    */
      94             :   virtual unsigned int solve () override;
      95             : 
      96             : protected:
      97             : 
      98             :   /**
      99             :    * Nonlinear solver context
     100             :    */
     101             :   WrappedPetsc<SNES> _snes;
     102             : 
     103             :   /**
     104             :    * Wrapper object for interacting with PetscDM
     105             :    */
     106             : #if !PETSC_VERSION_LESS_THAN(3,7,3)
     107             : #if defined(LIBMESH_ENABLE_AMR) && defined(LIBMESH_HAVE_METAPHYSICL)
     108             :   PetscDMWrapper _dm_wrapper;
     109             : #endif
     110             : #endif
     111             : 
     112             : private:
     113             : 
     114             :   /**
     115             :    * Common helper function to setup PETSc data structures
     116             :    */
     117             :   void setup_petsc_data();
     118             : };
     119             : 
     120             : } // namespace libMesh
     121             : 
     122             : #endif // #ifdef LIBMESH_HAVE_PETSC
     123             : 
     124             : #endif // LIBMESH_PETSC_DIFF_SOLVER_H

Generated by: LCOV version 1.14