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 "TimeIntegrator.h" 13 : #include "MeshChangedInterface.h" 14 : 15 : #include "libmesh/linear_solver.h" 16 : #include "libmesh/preconditioner.h" 17 : #include "libmesh/numeric_vector.h" 18 : 19 : #include "LumpedPreconditioner.h" 20 : 21 : /** 22 : * Base class for explicit time integrators that are implemented without using 23 : * a nonlinear solver. 24 : */ 25 : class ExplicitTimeIntegrator : public TimeIntegrator, public MeshChangedInterface 26 : { 27 : public: 28 : static InputParameters validParams(); 29 : 30 : ExplicitTimeIntegrator(const InputParameters & parameters); 31 : 32 : virtual void initialSetup() override; 33 : virtual void init() override; 34 : virtual void preSolve() override; 35 : virtual void meshChanged() override; 36 0 : virtual bool isExplicit() const override { return true; } 37 : 38 : protected: 39 : void setupSolver(); 40 : 41 : enum SolveType 42 : { 43 : CONSISTENT, 44 : LUMPED, 45 : LUMP_PRECONDITIONED 46 : }; 47 : 48 : /** 49 : * Solves a linear system using the chosen solve type 50 : * 51 : * @param[in] mass_matrix Mass matrix 52 : */ 53 : virtual bool performExplicitSolve(SparseMatrix<Number> & mass_matrix); 54 : 55 : /** 56 : * Solves a linear system 57 : * 58 : * @param[in] mass_matrix Mass matrix 59 : */ 60 : bool solveLinearSystem(SparseMatrix<Number> & mass_matrix); 61 : 62 : /** 63 : * Check for the linear solver convergence 64 : */ 65 : bool checkLinearConvergence(); 66 : 67 : /** 68 : * @returns the mass matrix tag ID 69 : */ 70 326 : virtual TagID massMatrixTagID() const { return _Ke_time_tag; } 71 : 72 : /// Solve type for how mass matrix is handled 73 : MooseEnum _solve_type; 74 : 75 : /// Residual used for the RHS 76 : NumericVector<Real> * _explicit_residual; 77 : 78 : /// Solution vector for the linear solve 79 : NumericVector<Real> * _solution_update; 80 : 81 : /// Diagonal of the lumped mass matrix (and its inversion) 82 : NumericVector<Real> * _mass_matrix_diag_inverted; 83 : 84 : /// Vector of 1's to help with creating the lumped mass matrix 85 : NumericVector<Real> * _ones; 86 : 87 : /// For computing the mass matrix 88 : TagID _Ke_time_tag; 89 : 90 : /// For solving with the consistent matrix 91 : std::unique_ptr<libMesh::LinearSolver<Number>> _linear_solver; 92 : 93 : /// For solving with lumped preconditioning 94 : std::unique_ptr<LumpedPreconditioner> _preconditioner; 95 : 96 : /// Save off current time to reset it back and forth 97 : Real _current_time; 98 : };