$extrastylesheet
memory_solution_history.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_MEMORY_SOLUTION_HISTORY_H
00021 #define LIBMESH_MEMORY_SOLUTION_HISTORY_H
00022 
00023 // Local includes
00024 #include "libmesh/numeric_vector.h"
00025 #include "libmesh/solution_history.h"
00026 #include <list>
00027 
00028 namespace libMesh
00029 {
00034 class MemorySolutionHistory : public SolutionHistory
00035 {
00036 public:
00037 
00038   // Constructor, reference to system to be passed by user, set the
00039   // stored_sols iterator to some initial value
00040   MemorySolutionHistory(System & system_) : stored_sols(stored_solutions.end()), _system(system_)
00041   { libmesh_experimental(); }
00042 
00043   // Destructor
00044   ~MemorySolutionHistory();
00045 
00046   // Virtual function store which we will be overriding to store timesteps
00047   virtual void store();
00048 
00049   // Virtual function retrieve which we will be overriding to retrieve timesteps
00050   virtual void retrieve();
00051 
00052   // Typedef for Stored Solutions iterator, a list of pairs of the current
00053   // system time, map of strings and saved vectors
00054   typedef std::list<std::pair<Real, std::map<std::string, NumericVector<Number>*> > >::iterator stored_solutions_iterator;
00055 
00056   // Definition of the clone function needed for the setter function
00057   virtual UniquePtr<SolutionHistory > clone() const {
00058     return UniquePtr<SolutionHistory >
00059       (new MemorySolutionHistory(_system));}
00060 
00061 private:
00062 
00063   // This list of pairs will hold the current time and stored vectors
00064   // from each timestep
00065   std::list<std::pair<Real, std::map<std::string, NumericVector<Number>*> > > stored_solutions;
00066 
00067   // The stored solutions iterator
00068   stored_solutions_iterator stored_sols;
00069 
00070   // A helper function to locate entries at a given time
00071   void find_stored_entry();
00072 
00073   // A system reference
00074   System & _system ;
00075 
00076 };
00077 
00078 } // end namespace libMesh
00079 
00080 #endif // LIBMESH_MEMORY_SOLUTION_HISTORY_H