libMesh
solution_history.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 #ifndef LIBMESH_SOLUTION_HISTORY_H
19 #define LIBMESH_SOLUTION_HISTORY_H
20 
21 // Local Includes
22 #include "libmesh/system.h"
23 #include "libmesh/history_data.h"
24 
25 namespace libMesh
26 {
27 
41 {
42 public:
43 
48  stored_datum(stored_data.end()) {}
49 
53  virtual ~SolutionHistory () {}
54 
58  virtual void store(bool is_adjoint_solve, Real time) = 0;
59 
63  virtual void retrieve(bool is_adjoint_solve, Real time) = 0;
64 
68  void erase(Real time);
69 
74  virtual std::unique_ptr<SolutionHistory > clone() const = 0;
75 
82 
83 protected:
84 
85  // Flag to specify whether we want to overwrite previously stored
86  // vectors at a given time or not
88 
89  // The abstract data structure that indexes and stores history data
90  // Any type of history, solution, mesh or any future type will use
91  // a realization of this map to store history information. This way,
92  // we avoid multiple histories scatterred across the code.
93  typedef std::map<Real, std::unique_ptr<HistoryData>> map_type;
95  typedef map_type::iterator stored_data_iterator;
97 
98  // Function to locate entries at a given time
99  // Behaviour depends on whether we are calling this function
100  // while storing or retrieving/erasing entries.
101  // While storing, if no entry in our map matches our time key,
102  // we will create a new entry in the map. If we are not storing,
103  // not matching a given time key implies an error.
104  void find_stored_entry(Real time, bool storing = false);
105 
106 };
107 
108 } // end namespace libMesh
109 
110 #endif // LIBMESH_SOLUTION_HISTORY_H
void set_overwrite_previously_stored(bool val)
Turn on overwrite_previously_stored to overwrite any already-saved data encountered during subsequent...
SolutionHistory()
Constructor.
virtual void retrieve(bool is_adjoint_solve, Real time)=0
Function to retrieve a solution, pure virtual.
virtual ~SolutionHistory()
Destructor.
The libMesh namespace provides an interface to certain functionality in the library.
virtual std::unique_ptr< SolutionHistory > clone() const =0
Cloning function for a std::unique_ptr, pure virtual, used in the setter function in time_solver...
A SolutionHistory class that enables the storage and retrieval of timesteps and (in the future) adapt...
void erase(Real time)
Erase stored_data entry at time.
map_type::iterator stored_data_iterator
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
stored_data_iterator stored_datum
std::map< Real, std::unique_ptr< HistoryData > > map_type
virtual void store(bool is_adjoint_solve, Real time)=0
Function to store a solution, pure virtual.
void find_stored_entry(Real time, bool storing=false)