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 : 14 : /** 15 : * Implicit Euler's method 16 : */ 17 : class ImplicitEuler : public TimeIntegrator 18 : { 19 : public: 20 : static InputParameters validParams(); 21 : 22 : ImplicitEuler(const InputParameters & parameters); 23 : virtual ~ImplicitEuler(); 24 : 25 0 : virtual int order() override { return 1; } 26 : virtual void computeTimeDerivatives() override; 27 : void computeADTimeDerivatives(ADReal & ad_u_dot, 28 : const dof_id_type & dof, 29 : ADReal & ad_u_dotdot) const override; 30 : virtual void postResidual(NumericVector<Number> & residual) override; 31 463764 : virtual bool overridesSolve() const override { return false; } 32 : 33 : virtual Real timeDerivativeRHSContribution(const dof_id_type dof_id, 34 : const std::vector<Real> & factors) const override; 35 : virtual Real timeDerivativeMatrixContribution(const Real factor) const override; 36 : 37 : protected: 38 : /** 39 : * Helper function that actually does the math for computing the time derivative 40 : */ 41 : template <typename T, typename T2> 42 : void computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const; 43 : }; 44 : 45 : template <typename T, typename T2> 46 : void 47 29011419 : ImplicitEuler::computeTimeDerivativeHelper(T & u_dot, const T2 & u_old) const 48 : { 49 29011419 : u_dot -= u_old; 50 29011419 : u_dot *= 1. / _dt; 51 29011419 : }