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 : #include "MoosePreconditioner.h" 13 : 14 : // Forward declarations 15 : class NonlinearSystemBase; 16 : class InputParameters; 17 : namespace libMesh 18 : { 19 : class DofMapBase; 20 : } 21 : 22 : #include <vector> 23 : #include <string> 24 : 25 : /** 26 : * Base interface for field split preconditioner 27 : */ 28 : class FieldSplitPreconditionerBase 29 : { 30 : public: 31 139 : FieldSplitPreconditionerBase() = default; 32 : 33 : /** 34 : * setup the data management data structure that manages the field split 35 : */ 36 : virtual void setupDM() = 0; 37 : 38 : /** 39 : * @returns The KSP object associated with the field split preconditioner 40 : */ 41 : virtual KSP getKSP() = 0; 42 : }; 43 : 44 : /** 45 : * Implements a preconditioner designed to map onto PETSc's PCFieldSplit. 46 : */ 47 : template <typename Base> 48 : class FieldSplitPreconditionerTempl : public FieldSplitPreconditionerBase, public Base 49 : { 50 : public: 51 : /** 52 : * Constructor. Initializes SplitBasedPreconditioner data structures 53 : */ 54 : static InputParameters validParams(); 55 : 56 : FieldSplitPreconditionerTempl(const InputParameters & parameters); 57 : 58 : protected: 59 : /** 60 : * @returns The degree of freedom map to use for decomposition 61 : */ 62 : virtual const libMesh::DofMapBase & dofMap() const = 0; 63 : 64 : /** 65 : * @returns The libMesh system 66 : */ 67 : virtual const libMesh::System & system() const = 0; 68 : 69 : /** 70 : * @returns The prefix to pass to PETSc for the DM 71 : */ 72 : virtual std::string prefix() const = 0; 73 : 74 : /** 75 : * creates the MOOSE data management object 76 : */ 77 : void createMooseDM(DM * dm); 78 : 79 : /// The nonlinear system this FSP is associated with (convenience reference) 80 : NonlinearSystemBase & _nl; 81 : 82 : /** 83 : * The decomposition split 84 : */ 85 : std::string _decomposition_split; 86 : }; 87 : 88 : class FieldSplitPreconditioner : public FieldSplitPreconditionerTempl<MoosePreconditioner> 89 : { 90 : public: 91 : static InputParameters validParams(); 92 : 93 : FieldSplitPreconditioner(const InputParameters & parameters); 94 : 95 : virtual void setupDM() override; 96 : virtual KSP getKSP() override; 97 : 98 : protected: 99 : virtual const libMesh::DofMapBase & dofMap() const override; 100 : virtual const libMesh::System & system() const override; 101 : virtual std::string prefix() const override; 102 : };