33
44
55#include " core/utilities/mpi_utils.hpp"
6+
67#include " restarts/restarts_props.hpp"
8+ #include " restarts/restarts_manager.hpp"
9+
710#include " initializer/data_provider.hpp"
11+
812#include " hdf5/detail/h5/h5_file.hpp"
913
1014namespace PHARE ::restarts::h5
1115{
12- template <typename ModelView >
16+ template <typename Hierarchy, typename ResourceManager_t >
1317class Writer
1418{
1519public:
16- using This = Writer<ModelView>;
20+ using This = Writer<Hierarchy, ResourceManager_t>;
21+
1722
18- template < typename Hierarchy, typename Model>
19- Writer (Hierarchy const & hier, Model const & model, std::string const filePath)
20- : path_{filePath }
21- , modelView_{hier, model }
23+ Writer ( Hierarchy const & hier, ResourceManager_t const & resman, std::string const filePath)
24+ : hierarchy_{hier}
25+ , resman_{resman }
26+ , path_{filePath }
2227 {
2328 }
2429
2530 ~Writer () {}
2631
2732
28- template < typename Hierarchy, typename Model>
29- static auto make_unique (Hierarchy const & hier, Model const & model ,
33+
34+ static auto make_unique (Hierarchy const & hier, ResourceManager_t const & resman ,
3035 initializer::PHAREDict const & dict)
3136 {
3237 std::string filePath = dict[" filePath" ].template to <std::string>();
33- return std::make_unique<This>(hier, model , filePath);
38+ return std::make_unique<This>(hier, resman , filePath);
3439 }
3540
3641
3742 void dump (RestartsProperties const & properties, double timestamp)
3843 {
39- auto restart_file
40- = modelView_.writeRestartFile (ModelView::restartFilePathForTime (path_, timestamp));
44+ auto restart_file = writeRestartFile (restartFilePathForTime (path_, timestamp));
4145
4246 // write model patch_data_ids to file with highfive
4347 // SAMRAI restart files are PER RANK
4448 PHARE::hdf5::h5::HighFiveFile h5File{restart_file, HighFive::File::ReadWrite,
4549 /* para=*/ false };
4650
47- auto patch_ids = modelView_. patch_data_ids ();
51+ auto const & patch_ids = patch_data_ids ();
4852 h5File.create_data_set <int >(" /phare/patch/ids" , patch_ids.size ());
4953 h5File.write_data_set (" /phare/patch/ids" , patch_ids);
5054
@@ -55,12 +59,27 @@ class Writer
5559 core::mpi::barrier ();
5660 }
5761
58- auto & modelView () { return modelView_; }
5962
6063
6164private:
65+ NO_DISCARD auto writeRestartFile (std::string const & path) const
66+ {
67+ return hierarchy_.writeRestartFile (path);
68+ }
69+
70+ NO_DISCARD auto static restartFilePathForTime (std::string path, double timestamp)
71+ {
72+ return Hierarchy::restartFilePathForTime (path, timestamp);
73+ }
74+
75+
76+ NO_DISCARD auto patch_data_ids () const { return resman_.restart_patch_data_ids (); }
77+
78+
79+
80+ Hierarchy const & hierarchy_;
81+ ResourceManager_t const & resman_;
6282 std::string const path_;
63- ModelView const modelView_;
6483};
6584
6685
0 commit comments