DataTransfer.hpp 1.78 KB
 Praetorius, Simon committed Nov 15, 2018 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 #pragma once #include #include namespace AMDiS { typedef enum { NO_OPERATION = 0, INTERPOLATE = 1 } DataTransferOperation; template class DataTransferInterface { public: /// Virtual destructor virtual ~DataTransferInterface() = default; /// Collect data that is needed before grid adaption virtual void preAdapt(Container const& container, bool mightCoarsen) = 0; /// Interpolate data to new grid after grid adaption  Müller, Felix committed Feb 26, 2019 26  virtual void postAdapt(Container& container, bool refined) = 0;  Praetorius, Simon committed Nov 15, 2018 27 28 29 30 31 32 33 34 35 36  }; /// Implementation of \ref DataTransferInterface that does not interpolation, but /// just resizes the containers to the dimension of the basis template class NoDataTransfer : public DataTransferInterface { public:  Müller, Felix committed Feb 26, 2019 37  void preAdapt(Container const& container, bool) override {}  Praetorius, Simon committed Nov 15, 2018 38   Müller, Felix committed Feb 26, 2019 39  void postAdapt(Container& container, bool) override  Praetorius, Simon committed Nov 15, 2018 40 41 42 43 44 45 46  { container.compress(); } }; template  Müller, Felix committed Feb 26, 2019 47  class DataTransfer;  Praetorius, Simon committed Nov 15, 2018 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63  /// Factory to create DataTransfer objects based on the \ref DataTransferOperation template class DataTransferFactory { using Interface = DataTransferInterface; public: template static std::unique_ptr create(DataTransferOperation op, Basis const& basis) { switch (op) { case NO_OPERATION: return std::make_unique>(); case INTERPOLATE:  Müller, Felix committed Feb 26, 2019 64  return std::make_unique< DataTransfer >(basis);  Praetorius, Simon committed Nov 15, 2018 65 66 67 68 69 70 71 72  default: error_exit("Invalid data transfer\n"); return nullptr; // avoid warnings } } }; } // end namespace AMDiS  Müller, Felix committed Feb 26, 2019 73 74  #include "DataTransfer.inc.hpp"