LCOV - code coverage report
Current view: top level - src/preconditioners - StaticCondensationFieldSplitPreconditioner.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: 909fe5 Lines: 27 31 87.1 %
Date: 2025-08-29 20:01:24 Functions: 6 7 85.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://mooseframework.inl.gov
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #include "StaticCondensationFieldSplitPreconditioner.h"
      11             : 
      12             : // MOOSE includes
      13             : #include "PetscSupport.h"
      14             : #include "NonlinearSystemBase.h"
      15             : #include "PetscDMMoose.h"
      16             : #include "Split.h"
      17             : 
      18             : #include "libmesh/static_condensation.h"
      19             : #include "libmesh/static_condensation_dof_map.h"
      20             : #include "libmesh/petsc_linear_solver.h"
      21             : 
      22             : using namespace libMesh;
      23             : 
      24             : registerMooseObjectAliased("MooseApp", StaticCondensationFieldSplitPreconditioner, "SCFSP");
      25             : 
      26             : InputParameters
      27       14291 : StaticCondensationFieldSplitPreconditioner::validParams()
      28             : {
      29       14291 :   return FieldSplitPreconditionerTempl<MooseStaticCondensationPreconditioner>::validParams();
      30             : }
      31             : 
      32          13 : StaticCondensationFieldSplitPreconditioner::StaticCondensationFieldSplitPreconditioner(
      33          13 :     const InputParameters & params)
      34          13 :   : FieldSplitPreconditionerTempl<MooseStaticCondensationPreconditioner>(params)
      35             : {
      36          13 :   std::shared_ptr<Split> top_split = _nl.getSplit(_decomposition_split);
      37          13 :   top_split->setup(_nl, prefix());
      38          13 : }
      39             : 
      40             : const libMesh::DofMapBase &
      41          12 : StaticCondensationFieldSplitPreconditioner::dofMap() const
      42             : {
      43          12 :   return scDofMap();
      44             : }
      45             : 
      46             : const libMesh::System &
      47          12 : StaticCondensationFieldSplitPreconditioner::system() const
      48             : {
      49          12 :   return scDofMap().reduced_system();
      50             : }
      51             : 
      52             : std::string
      53          25 : StaticCondensationFieldSplitPreconditioner::prefix() const
      54             : {
      55          25 :   return MooseStaticCondensationPreconditioner::prefix();
      56             : }
      57             : 
      58             : void
      59          12 : StaticCondensationFieldSplitPreconditioner::setupDM()
      60             : {
      61             :   PetscBool ismoose;
      62          12 :   DM dm = LIBMESH_PETSC_NULLPTR;
      63             : 
      64             :   // Initialize the part of the DM package that's packaged with Moose; in the PETSc source tree this
      65             :   // call would be in DMInitializePackage()
      66          12 :   LibmeshPetscCall(DMMooseRegisterAll());
      67             :   // Create and set up the DM that will consume the split options and deal with block matrices.
      68          12 :   auto & petsc_solver = cast_ref<PetscLinearSolver<Number> &>(scSysMat().reduced_system_solver());
      69          12 :   auto ksp = petsc_solver.ksp();
      70             :   // if there exists a DMMoose object, not to recreate a new one
      71          12 :   LibmeshPetscCall(KSPGetDM(ksp, &dm));
      72          12 :   if (dm)
      73             :   {
      74          12 :     LibmeshPetscCall(PetscObjectTypeCompare((PetscObject)dm, DMMOOSE, &ismoose));
      75          12 :     if (ismoose)
      76           0 :       return;
      77             :   }
      78          12 :   createMooseDM(&dm);
      79          12 :   LibmeshPetscCall(KSPSetDM(ksp, dm));
      80             :   // We set the operators ourselves. We do not want the DM to generate the operators
      81          12 :   LibmeshPetscCall(KSPSetDMActive(ksp, PETSC_FALSE));
      82          12 :   LibmeshPetscCall(DMDestroy(&dm));
      83             : }
      84             : 
      85             : KSP
      86           0 : StaticCondensationFieldSplitPreconditioner::getKSP()
      87             : {
      88           0 :   auto & petsc_solver = cast_ref<PetscLinearSolver<Number> &>(scSysMat().reduced_system_solver());
      89           0 :   return petsc_solver.ksp();
      90             : }

Generated by: LCOV version 1.14