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 : #pragma once 11 : 12 : // MOOSE includes 13 : #include "MooseObject.h" 14 : #include "Restartable.h" 15 : #include "PerfGraphInterface.h" 16 : 17 : // Libmesh include 18 : #include "libmesh/preconditioner.h" 19 : #include "libmesh/linear_solver.h" 20 : #include "libmesh/coupling_matrix.h" 21 : 22 : // Forward declarations 23 : class FEProblemBase; 24 : class NonlinearSystemBase; 25 : namespace libMesh 26 : { 27 : class MeshBase; 28 : template <typename T> 29 : class NumericVector; 30 : } 31 : 32 : /** 33 : * Base class for MOOSE preconditioners. 34 : */ 35 : class MoosePreconditioner : public MooseObject, public Restartable, public PerfGraphInterface 36 : { 37 : public: 38 : static InputParameters validParams(); 39 : 40 : MoosePreconditioner(const InputParameters & params); 41 12517 : virtual ~MoosePreconditioner() = default; 42 : 43 : /** 44 : * Helper function for copying values associated with variables in 45 : * vectors from two different systems. 46 : */ 47 : static void copyVarValues(MeshBase & mesh, 48 : const unsigned int from_system, 49 : const unsigned int from_var, 50 : const NumericVector<Number> & from_vector, 51 : const unsigned int to_system, 52 : const unsigned int to_var, 53 : NumericVector<Number> & to_vector); 54 : 55 : /** 56 : * Perform some setup tasks such as storing the PETSc options 57 : */ 58 : virtual void initialSetup(); 59 : 60 : protected: 61 : /// Setup the coupling matrix on the finite element problem 62 : void setCouplingMatrix(std::unique_ptr<libMesh::CouplingMatrix> cm); 63 : 64 : /// Subproblem this preconditioner is part of 65 : FEProblemBase & _fe_problem; 66 : 67 : /// The nonlinear system number whose linearization this preconditioner should be applied to 68 : const unsigned int _nl_sys_num; 69 : 70 : /// The nonlinear system whose linearization this preconditioner should be applied to 71 : NonlinearSystemBase & _nl; 72 : 73 : friend class SetupPreconditionerAction; 74 : };