LCOV - code coverage report
Current view: top level - include/systems - transient_system.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 5 6 83.3 %
Date: 2025-08-19 19:27:09 Functions: 7 24 29.2 %
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_TRANSIENT_SYSTEM_H
      21             : #define LIBMESH_TRANSIENT_SYSTEM_H
      22             : 
      23             : // Local Includes
      24             : #include "libmesh/system.h"
      25             : #include "libmesh/libmesh_config.h"
      26             : 
      27             : namespace libMesh
      28             : {
      29             : 
      30             : // Forward declarations
      31             : class LinearImplicitSystem;
      32             : class NonlinearImplicitSystem;
      33             : class ExplicitSystem;
      34             : #ifdef LIBMESH_HAVE_SLEPC
      35             : class EigenSystem;
      36             : #endif
      37             : 
      38             : /**
      39             :  * \brief Manages storage and variables for transient systems.
      40             :  *
      41             :  * This class is a specialized system for solving transient systems,
      42             :  * e.g., systems with a time dependency. It provides appropriate storage,
      43             :  * manages variables and ensures consistency for these systems.
      44             :  *
      45             :  * This template class adds the functionality to manage, in addition to the
      46             :  * solution vector, an old solution and an older solution vector. These
      47             :  * vectors are useful to simulate transient systems.
      48             :  *
      49             :  * \note Additional vectors/matrices can be added via parent class
      50             :  * interfaces.
      51             :  *
      52             :  * \author Benjamin S. Kirk
      53             :  * \date 2004
      54             :  * \brief Used for solving transient systems of equations.
      55             :  */
      56             : template <class Base>
      57         240 : class TransientSystem : public Base
      58             : {
      59             : public:
      60             : 
      61             :   /**
      62             :    * Constructor.
      63             :    */
      64             :   TransientSystem (EquationSystems & es,
      65             :                    const std::string & name,
      66             :                    const unsigned int number);
      67             : 
      68             :   /**
      69             :    * Special functions.
      70             :    * - This class has the same restrictions as the union of its
      71             :    *   potential base classes (currently LinearImplicitSystem,
      72             :    *   NonlinearImplicitSystem, ExplicitSystem, and System).
      73             :    * - Destructor is defaulted out-of-line.
      74             :    */
      75             :   TransientSystem (const TransientSystem &) = delete;
      76             :   TransientSystem & operator= (const TransientSystem &) = delete;
      77             :   TransientSystem (TransientSystem &&) = default;
      78             :   TransientSystem & operator= (TransientSystem &&) = delete;
      79             :   virtual ~TransientSystem ();
      80             : 
      81             :   /**
      82             :    * The type of system.
      83             :    */
      84             :   typedef TransientSystem<Base> sys_type;
      85             : 
      86             :   /**
      87             :    * \returns A reference to *this.
      88             :    */
      89           0 :   sys_type & system () { return *this; }
      90             : 
      91             :   /**
      92             :    * Clear all the data structures associated with
      93             :    * the system.
      94             :    */
      95             :   virtual void clear () override;
      96             : 
      97             :   /**
      98             :    * \returns \p "Transient" prepended to T::system_type().
      99             :    * Helps in identifying the system type in an equation
     100             :    * system file.
     101             :    */
     102             :   virtual std::string system_type () const override;
     103             : 
     104             : 
     105             :   //-----------------------------------------------------------------
     106             :   // access to the solution data fields
     107             : 
     108             :   /**
     109             :    * \returns The old solution (at the previous timestep)
     110             :    * for the specified global DOF.
     111             :    */
     112             :   Number old_solution (const dof_id_type global_dof_number) const;
     113             : 
     114             :   /**
     115             :    * \returns The older solution (two timesteps ago)
     116             :    * for the specified global DOF.
     117             :    */
     118             :   Number older_solution (const dof_id_type global_dof_number) const;
     119             : 
     120             :   /**
     121             :    * All the values I need to compute my contribution
     122             :    * to the simulation at hand.  Think of this as the
     123             :    * current solution with any ghost values needed from
     124             :    * other processors.
     125             :    */
     126             :   NumericVector<Number> * old_local_solution;
     127             : 
     128             :   /**
     129             :    * All the values I need to compute my contribution
     130             :    * to the simulation at hand.  Think of this as the
     131             :    * current solution with any ghost values needed from
     132             :    * other processors.
     133             :    */
     134             :   NumericVector<Number> * older_local_solution;
     135             : 
     136             : protected:
     137             : 
     138             :   /**
     139             :    * Re-update the local values when the mesh has changed.
     140             :    * This method takes the data updated by \p update() and
     141             :    * makes it up-to-date on the current mesh.
     142             :    */
     143             :   virtual void re_update () override;
     144             : 
     145             : private:
     146             : 
     147             :   /**
     148             :    * Helper function for (re-)adding old and older solution vectors.
     149             :    */
     150             :   virtual void add_old_vectors ();
     151             : };
     152             : 
     153             : 
     154             : 
     155             : // -----------------------------------------------------------
     156             : // Useful typedefs
     157             : typedef TransientSystem<LinearImplicitSystem> TransientImplicitSystem;
     158             : typedef TransientSystem<LinearImplicitSystem> TransientLinearImplicitSystem;
     159             : typedef TransientSystem<NonlinearImplicitSystem> TransientNonlinearImplicitSystem;
     160             : typedef TransientSystem<ExplicitSystem> TransientExplicitSystem;
     161             : typedef TransientSystem<System> TransientBaseSystem;
     162             : #ifdef LIBMESH_HAVE_SLEPC
     163             : typedef TransientSystem<EigenSystem> TransientEigenSystem;
     164             : #endif
     165             : 
     166             : 
     167             : 
     168             : // ------------------------------------------------------------
     169             : // TransientSystem inline methods
     170             : template <class Base>
     171             : inline
     172         605 : std::string TransientSystem<Base>::system_type () const
     173             : {
     174         605 :   std::string type = "Transient";
     175          23 :   type += Base::system_type ();
     176             : 
     177         605 :   return type;
     178             : }
     179             : 
     180             : 
     181             : 
     182             : } // namespace libMesh
     183             : 
     184             : 
     185             : 
     186             : 
     187             : #endif // LIBMESH_TRANSIENT_SYSTEM_H

Generated by: LCOV version 1.14