#ifndef AMDIS_SOLUTION_DATA_STORAGE_H #define AMDIS_SOLUTION_DATA_STORAGE_H #include #include #include "DOFVector.h" #include "SystemVector.h" #include "Parameters.h" namespace AMDiS { template struct SolutionHelper { typedef FiniteElemSpace* type; }; template <> struct SolutionHelper { typedef std::vector type; }; template class SolutionDataStorage { public: /** \brief * */ SolutionDataStorage(std::string name); /** \brief * */ ~SolutionDataStorage(); /** \brief * Set one fix FE Space. All solutions are defined only on the given FE Space. */ void setFixFESpace(typename SolutionHelper::type feSpace); /** \brief * */ void push(T *solution, double timestamp); /** \brief * */ void push(T *solution, double timestamp, typename SolutionHelper::type feSpace); /** \brief * */ bool pop(T **solution, double *timestep); bool pop(T **solution, double *timestep, typename SolutionHelper::type feSpace); /** \brief * Returns for a given solution number the corresponding fe Space. If the * the fe Space is fixed, the fe Space for all solutions is stored at * position 0. */ typename SolutionHelper::type getFeSpace(int i = 0) { return feSpaces[i]; } protected: /** \brief * Auxiliary function for deleting either a single fe space, or a * vector of fe spaces. */ void deleteFeSpace(FiniteElemSpace* feSpace) { DELETE feSpace; } void deleteFeSpace(std::vector feSpaces) { for (int i = 0; i < static_cast(feSpaces.size()); i++) DELETE feSpaces[i]; feSpaces.empty(); } /** \brief * Deletes all pointers and empties all internal vectors. */ void cleanup(); /** \brief * Number of MBytes of memory that can be used for solution storage. */ int maxMemoryUsage; /** \brief * If true, it is allowed to write solutions also to disk. */ bool useDisk; /** \brief * Directory, where solutions can be written temporarly. */ std::string writeDirectory; /** \brief * If true, all solutions are defined only on one FE Space. */ bool fixedFESpace; /** \brief * Here, all the solutions (i.e. either DOFVectors or SystemVectors) * are stored. */ std::vector solutions; /** \brief * Stores to every solution its FE Space. If \ref fixedFESpace is set * to true, only one entry exists. This is than the FE Space for all * solutions. */ std::vector< typename SolutionHelper::type > feSpaces; /** \brief * Stores to every solutions the timestamp at which the solution was * created in the adaption loop. */ std::vector timestamps; /** \brief * Position of the latest valid solution. */ int lastPos; /** \brief * If true, the last operation on the data storage was pop. */ bool poped; /** \brief * Counts the memory usage of all solutions stored in memory. */ int memoryUsage; }; } #include "SolutionDataStorage.hh" #endif // AMDIS_SOLUTION_DATA_STORAGE_H