LCOV - code coverage report
Current view: top level - include/solvers - memory_solution_history.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 3 4 75.0 %
Date: 2025-08-19 19:27:09 Functions: 1 2 50.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_MEMORY_SOLUTION_HISTORY_H
      21             : #define LIBMESH_MEMORY_SOLUTION_HISTORY_H
      22             : 
      23             : // Local includes
      24             : #include "libmesh/numeric_vector.h"
      25             : #include "libmesh/solution_history.h"
      26             : #include "libmesh/diff_system.h"
      27             : 
      28             : // C++ includes
      29             : #include <list>
      30             : #include <memory>
      31             : 
      32             : namespace libMesh
      33             : {
      34             : 
      35             : /**
      36             :  * Subclass of Solution History that stores the solutions
      37             :  * and other important vectors in memory.
      38             :  *
      39             :  * \author Vikram Garg
      40             :  * \date 2012
      41             :  * \brief Stores past solutions in memory.
      42             :  */
      43             : class MemorySolutionHistory : public SolutionHistory
      44             : {
      45             : public:
      46             : 
      47             :   /**
      48             :    * Constructor, reference to system to be passed by user, set the
      49             :    * stored_sols iterator to some initial value
      50             :    */
      51         840 :   MemorySolutionHistory(DifferentiableSystem & system_) : SolutionHistory(), _system(system_)
      52           0 :   { libmesh_experimental(); }
      53             : 
      54             :   /**
      55             :    * Destructor
      56             :    */
      57             :   ~MemorySolutionHistory();
      58             : 
      59             :   /**
      60             :    * Virtual function store which we will be overriding to store timesteps
      61             :    */
      62             :   virtual void store(bool is_adjoint_solve, Real time) override;
      63             : 
      64             :   /**
      65             :    * Virtual function retrieve which we will be overriding to retrieve timesteps
      66             :    */
      67             :   virtual void retrieve(bool is_adjoint_solve, Real time) override;
      68             : 
      69             :   typedef std::map<std::string, std::unique_ptr<NumericVector<Number>>> map_type;
      70             : 
      71             :   /**
      72             :    * Definition of the clone function needed for the setter function
      73             :    */
      74         840 :   virtual std::unique_ptr<SolutionHistory > clone() const override
      75             :   {
      76         840 :     return std::make_unique<MemorySolutionHistory>(_system);
      77             :   }
      78             : 
      79             : private:
      80             : 
      81             :   // A system reference
      82             :   DifferentiableSystem & _system ;
      83             : };
      84             : 
      85             : } // end namespace libMesh
      86             : 
      87             : #endif // LIBMESH_MEMORY_SOLUTION_HISTORY_H

Generated by: LCOV version 1.14