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_STEADY_SOLVER_H 21 : #define LIBMESH_STEADY_SOLVER_H 22 : 23 : // Local includes 24 : #include "libmesh/time_solver.h" 25 : 26 : // C++ includes 27 : 28 : namespace libMesh 29 : { 30 : 31 : // Forward Declarations 32 : class DiffContext; 33 : class DifferentiableSystem; 34 : class TimeSolver; 35 : 36 : /** 37 : * This class implements a TimeSolver which does a single 38 : * solve of the steady state problem. 39 : * 40 : * This class is part of the new DifferentiableSystem framework, 41 : * which is still experimental. Users of this framework should 42 : * beware of bugs and future API changes. 43 : * 44 : * \author Roy H. Stogner 45 : * \date 2006 46 : */ 47 344 : class SteadySolver : public TimeSolver 48 : { 49 : public: 50 : /** 51 : * The type of system 52 : */ 53 : typedef DifferentiableSystem sys_type; 54 : 55 : /** 56 : * The parent class 57 : */ 58 : typedef TimeSolver Parent; 59 : 60 : /** 61 : * Constructor. Requires a reference to the system 62 : * to be solved. 63 : */ 64 : explicit 65 852 : SteadySolver (sys_type & s) : Parent(s) {} 66 : 67 : /** 68 : * Destructor. 69 : */ 70 : virtual ~SteadySolver (); 71 : 72 : /** 73 : * error convergence order against deltat is 74 : * not applicable to a steady problem. 75 : */ 76 0 : virtual Real error_order() const { return 0.; } 77 : 78 : /** 79 : * This method uses the DifferentiablePhysics' 80 : * element_time_derivative() and element_constraint() 81 : * to build a full residual/jacobian on an element. 82 : */ 83 : virtual bool element_residual (bool request_jacobian, 84 : DiffContext &) override; 85 : 86 : /** 87 : * This method uses the DifferentiablePhysics' 88 : * side_time_derivative() and side_constraint() 89 : * to build a full residual/jacobian on an element's side. 90 : */ 91 : virtual bool side_residual (bool request_jacobian, 92 : DiffContext &) override; 93 : 94 : /** 95 : * This method uses the DifferentiablePhysics' 96 : * nonlocal_time_derivative() and nonlocal_constraint() 97 : * to build a full residual/jacobian for non-local terms. 98 : */ 99 : virtual bool nonlocal_residual (bool request_jacobian, 100 : DiffContext &) override; 101 : 102 : /** 103 : * \returns 0, but derived classes should override this function to 104 : * compute the size of the difference between successive solution 105 : * iterates ||u^{n+1} - u^{n}|| in some norm. 106 : */ 107 0 : virtual Real du(const SystemNorm &) const override { return 0; } 108 : 109 : /** 110 : * This is a steady-state solver. 111 : */ 112 9704035 : virtual bool is_steady() const override { return true; } 113 : 114 : /** 115 : * A method to integrate the system::QoI functionals. 116 : */ 117 : virtual void integrate_qoi_timestep() override; 118 : 119 : /** 120 : * A method to integrate the adjoint sensitivity w.r.t a given parameter 121 : * vector. int_{tstep_start}^{tstep_end} dQ/dp dt = int_{tstep_start}^{tstep_end} (\partialQ / \partial p) - ( \partial R (u,z) / \partial p ) dt 122 : */ 123 : virtual void integrate_adjoint_sensitivity(const QoISet & qois, const ParameterVector & parameter_vector, SensitivityData & sensitivities) override; 124 : 125 : #ifdef LIBMESH_ENABLE_AMR 126 : /** 127 : * A method to compute the adjoint refinement error estimate at the current timestep. 128 : * int_{tstep_start}^{tstep_end} R(u^h,z) dt 129 : * The user provides an initialized ARefEE object. 130 : * Fills in an ErrorVector that contains the weighted sum of errors from all the QoIs and can be used to guide AMR. 131 : * CURRENTLY ONLY SUPPORTED for Backward Euler. 132 : */ 133 : virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator & adjoint_refinement_error_estimator, ErrorVector & QoI_elementwise_error) override; 134 : #endif // LIBMESH_ENABLE_AMR 135 : 136 : protected: 137 : 138 : /** 139 : * This method is the underlying implementation of the public 140 : * residual methods. 141 : */ 142 : virtual bool _general_residual (bool request_jacobian, 143 : DiffContext &, 144 : ResFuncType time_deriv, 145 : ResFuncType constraint); 146 : }; 147 : 148 : 149 : } // namespace libMesh 150 : 151 : 152 : #endif // LIBMESH_STEADY_SOLVER_H