LCOV - code coverage report
Current view: top level - include/solvers - euler2_solver.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 1 1 100.0 %
Date: 2025-08-19 19:27:09 Functions: 2 2 100.0 %
Legend: Lines: hit not hit

          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_EULER2_SOLVER_H
      21             : #define LIBMESH_EULER2_SOLVER_H
      22             : 
      23             : // Local includes
      24             : #include "libmesh/first_order_unsteady_solver.h"
      25             : 
      26             : // C++ includes
      27             : 
      28             : namespace libMesh
      29             : {
      30             : 
      31             : /**
      32             :  * This class defines a theta-method (defaulting to Backward
      33             :  * Euler with theta = 1.0) solver to handle
      34             :  * time integration of DifferentiableSystems.
      35             :  * The "Euler2" solver differs from Euler in how it evaluates
      36             :  * residuals at intermediate theta values:
      37             :  * Euler solves m(u,u') = f(theta*u_new + (1-theta)*u_old),
      38             :  * Euler2 solves m(u') = theta*f(u_new) + (1-theta)*f(u_old)
      39             :  * i.e. the trapezoidal rule for theta = 0.5
      40             :  *
      41             :  * This class is part of the new DifferentiableSystem framework,
      42             :  * which is still experimental.  Users of this framework should
      43             :  * beware of bugs and future API changes.
      44             :  *
      45             :  * \author Roy H. Stogner
      46             :  * \date 2006
      47             :  */
      48          48 : class Euler2Solver : public FirstOrderUnsteadySolver
      49             : {
      50             : public:
      51             :   /**
      52             :    * The parent class
      53             :    */
      54             :   typedef FirstOrderUnsteadySolver Parent;
      55             : 
      56             :   /**
      57             :    * Constructor. Requires a reference to the system
      58             :    * to be solved.
      59             :    */
      60             :   explicit
      61             :   Euler2Solver (sys_type & s);
      62             : 
      63             :   /**
      64             :    * Destructor.
      65             :    */
      66             :   virtual ~Euler2Solver ();
      67             : 
      68             :   /**
      69             :    * Error convergence order: 2 for Crank-Nicolson, 1 otherwise
      70             :    */
      71             :   virtual Real error_order() const override;
      72             : 
      73             :   /**
      74             :    * A method to integrate the system::QoI functionals.
      75             :    */
      76             :   virtual void integrate_qoi_timestep() override;
      77             : 
      78             : #ifdef LIBMESH_ENABLE_AMR
      79             :   /**
      80             :    * A method to compute the adjoint refinement error estimate at the current timestep.
      81             :    * int_{tstep_start}^{tstep_end} R(u^h,z) dt.
      82             :    * The user provides an initialized ARefEE object.
      83             :    * Fills in an ErrorVector that contains the weighted sum of errors from all the QoIs and can be used to guide AMR.
      84             :    * The integration scheme used is consistent with the theta used for the unsteady solution.
      85             :    * CURRENTLY ONLY SUPPORTED for Backward Euler.
      86             :    */
      87             :   virtual void integrate_adjoint_refinement_error_estimate(AdjointRefinementEstimator & adjoint_refinement_error_estimator, ErrorVector & QoI_elementwise_error) override;
      88             : #endif // LIBMESH_ENABLE_AMR
      89             : 
      90             :   /**
      91             :    * This method uses the DifferentiablePhysics'
      92             :    * element_time_derivative() and element_constraint()
      93             :    * to build a full residual on an element.  What combination
      94             :    * it uses will depend on theta.
      95             :    */
      96             :   virtual bool element_residual (bool request_jacobian,
      97             :                                  DiffContext &) override;
      98             : 
      99             :   /**
     100             :    * This method uses the DifferentiablePhysics'
     101             :    * side_time_derivative() and side_constraint()
     102             :    * to build a full residual on an element's side.
     103             :    * What combination it uses will depend on theta.
     104             :    */
     105             :   virtual bool side_residual (bool request_jacobian,
     106             :                               DiffContext &) override;
     107             : 
     108             :   /**
     109             :    * This method uses the DifferentiablePhysics'
     110             :    * nonlocal_time_derivative() and nonlocal_constraint()
     111             :    * to build a full residual for non-local terms.
     112             :    * What combination it uses will depend on theta.
     113             :    */
     114             :   virtual bool nonlocal_residual (bool request_jacobian,
     115             :                                   DiffContext &) override;
     116             : 
     117             :   /**
     118             :    * The value for the theta method to employ: 1.0 corresponds
     119             :    * to backwards Euler, 0.0 corresponds to forwards Euler,
     120             :    * 0.5 corresponds to a Crank-Nicolson-like scheme.
     121             :    */
     122             :   Real theta;
     123             : 
     124             : protected:
     125             : 
     126             :   /**
     127             :    * This method is the underlying implementation of the public
     128             :    * residual methods.
     129             :    */
     130             :   virtual bool _general_residual (bool request_jacobian,
     131             :                                   DiffContext &,
     132             :                                   ResFuncType mass,
     133             :                                   ResFuncType damping,
     134             :                                   ResFuncType time_deriv,
     135             :                                   ResFuncType constraint,
     136             :                                   ReinitFuncType reinit,
     137             :                                   bool compute_second_order_eqns);
     138             : 
     139             : };
     140             : 
     141             : 
     142             : } // namespace libMesh
     143             : 
     144             : 
     145             : #endif // LIBMESH_EULER2_SOLVER_H

Generated by: LCOV version 1.14