LCOV - code coverage report
Current view: top level - src/preconditioners - StaticCondensationFieldSplitPreconditioner.C (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 27 31 87.1 %
Date: 2026-05-29 20:35:17 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        3083 : StaticCondensationFieldSplitPreconditioner::validParams()
      28             : {
      29        3083 :   return FieldSplitPreconditionerTempl<MooseStaticCondensationPreconditioner>::validParams();
      30             : }
      31             : 
      32          11 : StaticCondensationFieldSplitPreconditioner::StaticCondensationFieldSplitPreconditioner(
      33          11 :     const InputParameters & params)
      34          11 :   : FieldSplitPreconditionerTempl<MooseStaticCondensationPreconditioner>(params)
      35             : {
      36          11 :   std::shared_ptr<Split> top_split = _nl.getSplit(_decomposition_split);
      37          11 :   top_split->setup(_nl, prefix());
      38          11 : }
      39             : 
      40             : const libMesh::DofMapBase &
      41          10 : StaticCondensationFieldSplitPreconditioner::dofMap() const
      42             : {
      43          10 :   return scDofMap();
      44             : }
      45             : 
      46             : const libMesh::System &
      47          10 : StaticCondensationFieldSplitPreconditioner::system() const
      48             : {
      49          10 :   return scDofMap().reduced_system();
      50             : }
      51             : 
      52             : std::string
      53          21 : StaticCondensationFieldSplitPreconditioner::prefix() const
      54             : {
      55          21 :   return MooseStaticCondensationPreconditioner::prefix();
      56             : }
      57             : 
      58             : void
      59          10 : StaticCondensationFieldSplitPreconditioner::setupDM()
      60             : {
      61             :   PetscBool ismoose;
      62          10 :   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          10 :   LibmeshPetscCall(DMMooseRegisterAll());
      67             :   // Create and set up the DM that will consume the split options and deal with block matrices.
      68          10 :   auto & petsc_solver = cast_ref<PetscLinearSolver<Number> &>(scSysMat().reduced_system_solver());
      69          10 :   auto ksp = petsc_solver.ksp();
      70             :   // if there exists a DMMoose object, then we do not need to recreate one
      71          10 :   LibmeshPetscCall(KSPGetDM(ksp, &dm));
      72          10 :   if (dm)
      73             :   {
      74          10 :     LibmeshPetscCall(PetscObjectTypeCompare((PetscObject)dm, DMMOOSE, &ismoose));
      75          10 :     if (ismoose)
      76           0 :       return;
      77             :   }
      78          10 :   createMooseDM(&dm);
      79          10 :   LibmeshPetscCall(KSPSetDM(ksp, dm));
      80             : // We set the operators ourselves. We do not want the DM to generate the operators
      81             : #if PETSC_VERSION_LESS_THAN(3, 25, 0)
      82             :   LibmeshPetscCall(KSPSetDMActive(ksp, PETSC_FALSE));
      83             : #else
      84          10 :   LibmeshPetscCall(KSPSetDMActive(ksp, KSP_DMACTIVE_OPERATOR, PETSC_FALSE));
      85             : #endif
      86          10 :   LibmeshPetscCall(DMDestroy(&dm));
      87             : }
      88             : 
      89             : KSP
      90           0 : StaticCondensationFieldSplitPreconditioner::getKSP()
      91             : {
      92           0 :   auto & petsc_solver = cast_ref<PetscLinearSolver<Number> &>(scSysMat().reduced_system_solver());
      93           0 :   return petsc_solver.ksp();
      94             : }

Generated by: LCOV version 1.14