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
23
29
37
43
44const libMesh::System &
49
50std::string
55
56void
58{
59 PetscBool ismoose;
60 DM dm = LIBMESH_PETSC_NULLPTR;
61
62 // Initialize the part of the DM package that's packaged with Moose; in the PETSc source tree this
63 // call would be in DMInitializePackage()
64 LibmeshPetscCall(DMMooseRegisterAll());
65 // Create and set up the DM that will consume the split options and deal with block matrices.
66 auto & petsc_solver =
67 cast_ref<libMesh::PetscLinearSolver<Number> &>(scSysMat().reduced_system_solver());
68 auto ksp = petsc_solver.ksp();
69 // if there exists a DMMoose object, then we do not need to recreate one
70 LibmeshPetscCall(KSPGetDM(ksp, &dm));
71 if (dm)
72 {
73 LibmeshPetscCall(PetscObjectTypeCompare((PetscObject)dm, DMMOOSE, &ismoose));
74 if (ismoose)
75 return;
76 }
78 LibmeshPetscCall(KSPSetDM(ksp, dm));
79// We set the operators ourselves. We do not want the DM to generate the operators
80#if PETSC_VERSION_LESS_THAN(3, 25, 0)
81 LibmeshPetscCall(KSPSetDMActive(ksp, PETSC_FALSE));
82#else
83 LibmeshPetscCall(KSPSetDMActive(ksp, KSP_DMACTIVE_OPERATOR, PETSC_FALSE));
84#endif
85 LibmeshPetscCall(DMDestroy(&dm));
86}
87
88KSP
90{
91 auto & petsc_solver =
92 cast_ref<libMesh::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()