Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 3 : 4 : // This library is free software; you can redistribute it and/or 5 : // modify it under the terms of the GNU Lesser General Public 6 : // License as published by the Free Software Foundation; either 7 : // version 2.1 of the License, or (at your option) any later version. 8 : 9 : // This library is distributed in the hope that it will be useful, 10 : // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 : // Lesser General Public License for more details. 13 : 14 : // You should have received a copy of the GNU Lesser General Public 15 : // License along with this library; if not, write to the Free Software 16 : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 17 : 18 : 19 : 20 : #ifndef LIBMESH_TWOSTEP_TIME_SOLVER_H 21 : #define LIBMESH_TWOSTEP_TIME_SOLVER_H 22 : 23 : // Local includes 24 : #include "libmesh/adaptive_time_solver.h" 25 : 26 : // C++ includes 27 : 28 : namespace libMesh 29 : { 30 : 31 : // Forward declarations 32 : class System; 33 : 34 : // UPDATE THIS DESCRIPTION 35 : 36 : /** 37 : * This class wraps another UnsteadySolver derived class, and compares 38 : * the results of timestepping with deltat and timestepping with 39 : * 2*deltat to adjust future timestep lengths. 40 : * 41 : * Currently this class only works on fully coupled Systems 42 : * 43 : * This class is part of the new DifferentiableSystem framework, 44 : * which is still experimental. Users of this framework should 45 : * beware of bugs and future API changes. 46 : * 47 : * \author Roy H. Stogner 48 : * \date 2007 49 : */ 50 48 : class TwostepTimeSolver : public AdaptiveTimeSolver 51 : { 52 : public: 53 : /** 54 : * The parent class 55 : */ 56 : typedef AdaptiveTimeSolver Parent; 57 : 58 : /** 59 : * Constructor. Requires a reference to the system 60 : * to be solved. 61 : */ 62 : explicit 63 : TwostepTimeSolver (sys_type & s); 64 : 65 : /** 66 : * Destructor. 67 : */ 68 : ~TwostepTimeSolver (); 69 : 70 : virtual void solve() override; 71 : 72 : virtual std::pair<unsigned int, Real> adjoint_solve (const QoISet & qoi_indices) override; 73 : 74 : /** 75 : * A method to integrate the system::QoI functionals. 76 : */ 77 : virtual void integrate_qoi_timestep() override; 78 : 79 : /** 80 : * A method to integrate the adjoint sensitivity w.r.t a given parameter 81 : * vector. int_{tstep_start}^{tstep_end} dQ/dp dt = int_{tstep_start}^{tstep_end} (\partialQ / \partial p) - ( \partial R (u,z) / \partial p ) dt 82 : * The midpoint rule is used to integrate each substep 83 : */ 84 : virtual void integrate_adjoint_sensitivity(const QoISet & qois, const ParameterVector & parameter_vector, SensitivityData & sensitivities) override; 85 : 86 : #ifdef LIBMESH_ENABLE_AMR 87 : /** 88 : * A method to compute the adjoint refinement error estimate at the current timestep. 89 : * int_{tstep_start}^{tstep_end} R(u^h,z) dt 90 : * The user provides an initialized ARefEE object. 91 : * Fills in an ErrorVector that contains the weighted sum of errors from all the QoIs and can be used to guide AMR. 92 : * CURRENTLY ONLY SUPPORTED for Backward Euler. 93 : */ 94 : virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator & adjoint_refinement_error_estimator, ErrorVector & QoI_elementwise_error) override; 95 : #endif // LIBMESH_ENABLE_AMR 96 : 97 : }; 98 : 99 : 100 : } // namespace libMesh 101 : 102 : 103 : #endif // LIBMESH_TWOSTEP_TIME_SOLVER_H