SolutionDataStorage.h 3.67 KB
 Thomas Witkowski committed Sep 29, 2008 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #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:  Thomas Witkowski committed Oct 01, 2008 28 29 30  /** \brief * */  Thomas Witkowski committed Sep 29, 2008 31 32  SolutionDataStorage(std::string name);  Thomas Witkowski committed Oct 01, 2008 33 34 35  /** \brief * */  Thomas Witkowski committed Sep 29, 2008 36 37 38 39 40 41 42 43  ~SolutionDataStorage(); /** \brief * Set one fix FE Space. All solutions are defined only on the given FE Space. */ void setFixFESpace(typename SolutionHelper::type feSpace, bool cleanupFeSpace = false);  Thomas Witkowski committed Oct 01, 2008 44 45 46 47 48 49 50 51 52 53  /** \brief * */ void push(T *solution, double timestamp, bool cleanupSolution = true); /** \brief * */  Thomas Witkowski committed Sep 29, 2008 54 55  void push(T *solution, double timestamp,  Thomas Witkowski committed Oct 01, 2008 56  typename SolutionHelper::type feSpace,  Thomas Witkowski committed Sep 29, 2008 57 58 59  bool cleanupSolution = true, bool cleanupFeSpace = true);  Thomas Witkowski committed Oct 01, 2008 60 61 62 63 64 65 66  /** \brief * */ bool pop(T **solution, double *timestep); bool pop(T **solution,  Thomas Witkowski committed Sep 29, 2008 67  double *timestep,  Thomas Witkowski committed Oct 01, 2008 68 69 70 71 72 73 74 75 76 77  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]; }  Thomas Witkowski committed Sep 29, 2008 78 79  protected:  Thomas Witkowski committed Oct 01, 2008 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97  /** \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. */  Thomas Witkowski committed Sep 29, 2008 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123  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. */  Thomas Witkowski committed Oct 01, 2008 124  std::vector solutions;  Thomas Witkowski committed Sep 29, 2008 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166  /** \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 * Stores to each solution, if the data storage is allowed to delete * the solution by itself. */ std::vector cleanupSolutions; /** \brief * Stores to each fe space, if the data storage is allowed to delete * the fe space by itself. */ std::vector cleanupFeSpaces; /** \brief * Position of the latest valid solution. */ int lastPos; /** \brief * If true, the last operation on the data storage was pop. */ bool poped; }; } #include "SolutionDataStorage.hh" #endif // AMDIS_SOLUTION_DATA_STORAGE_H