https://mooseframework.inl.gov
Loading...
Searching...
No Matches
StaticCondensationFieldSplitPreconditioner.C
Go to the documentation of this file.
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
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
22using namespace libMesh;
23
25
31
39
45
46const libMesh::System &
51
52std::string
57
58void
60{
61 PetscBool ismoose;
62 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 LibmeshPetscCall(DMMooseRegisterAll());
67 // Create and set up the DM that will consume the split options and deal with block matrices.
68 auto & petsc_solver = cast_ref<PetscLinearSolver<Number> &>(scSysMat().reduced_system_solver());
69 auto ksp = petsc_solver.ksp();
70 // if there exists a DMMoose object, then we do not need to recreate one
71 LibmeshPetscCall(KSPGetDM(ksp, &dm));
72 if (dm)
73 {
74 LibmeshPetscCall(PetscObjectTypeCompare((PetscObject)dm, DMMOOSE, &ismoose));
75 if (ismoose)
76 return;
77 }
79 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 LibmeshPetscCall(KSPSetDMActive(ksp, KSP_DMACTIVE_OPERATOR, PETSC_FALSE));
85#endif
86 LibmeshPetscCall(DMDestroy(&dm));
87}
88
89KSP
91{
92 auto & petsc_solver = cast_ref<PetscLinearSolver<Number> &>(scSysMat().reduced_system_solver());
93 return petsc_solver.ksp();
94}
PetscErrorCode PetscOptionItems *PetscErrorCode DM dm
PetscErrorCode DMMooseRegisterAll()
registerMooseObjectAliased("MooseApp", StaticCondensationFieldSplitPreconditioner, "SCFSP")
Implements a preconditioner designed to map onto PETSc's PCFieldSplit.
static InputParameters validParams()
Constructor.
NonlinearSystemBase & _nl
The nonlinear system this FSP is associated with (convenience reference)
void createMooseDM(DM *dm)
creates the MOOSE data management object
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
std::shared_ptr< Split > getSplit(const std::string &name)
Retrieves a split by name.
Implements a field split preconditioner for a statically condensed system.
virtual void setupDM() override
setup the data management data structure that manages the field split
virtual const libMesh::System & system() const override
virtual const libMesh::DofMapBase & dofMap() const override
const System & reduced_system() const
LinearSolver< Number > & reduced_system_solver()
The following methods are specializations for using the libMesh::Parallel::packed_range_* routines fo...