@@ -35,59 +35,77 @@ namespace deposit{
3535 class owndeposit {
3636 private:
3737 // static are useful not to reload deposits if not needed
38- static std::string _static_path;
39- static RunningStateHost_t _static_data;
40- static size_t _static_nparticles;
41- static double _static_length;
38+ std::string _cached_path;
39+ RunningStateHost_t _cached_data;
40+ size_t _cached_nparticles;
41+ size_t cached_group;
42+ double _cached_length;
4243
4344 std::string _path;
4445 RunningStateHost_t _data;
4546 size_t _nparticles;
47+ size_t _group;
4648 double _length=1 .;
49+ bool _isloaded;
4750
4851 public:
52+
53+ owndeposit (){}
54+
4955 owndeposit (std::string path, size_t nparticles, double length, size_t group=DEFAULT_GROUP){
5056 this ->init (path, nparticles, length);
5157 }
5258
53- owndeposit (singleconf cf){
54- this ->init (std::get<std::string>(cf. get ( " path " )), std::get< size_t >(cf. get ( " nparticles " )),std::get< double >(cf. get ( " length " )) );
59+ owndeposit (singleconf& cf){
60+ this ->init (cf );
5561 }
5662 // initialise
63+
64+ void init (singleconf& cf){
65+ this ->init (std::get<std::string>(cf.get (" path" )), std::get<size_t >(cf.get (" nparticles" )),std::get<double >(cf.get (" length" ),,std::get<size_t >(cf.get (" group" )));
66+ }
67+
5768 void init (std::string path, size_t nparticles, double length, size_t group=DEFAULT_GROUP){
5869 if (_path==DEFAULT_PATH){
59- if (nparticles!=_static_nparticles || length!=_static_length ){
70+ if (nparticles!=_cached_nparticles || length!=_cached_length || group!=_cached_group ){
6071 _data = this ->gendummy (nparticles,length);
6172 }
6273 else {
6374 _data.resize (_nparticles);
64- hydra::copy (_static_data ,_data);
75+ hydra::copy (_cached_data ,_data);
6576 }
6677 _nparticles = nparticles;
6778 _length = length;
6879 }
6980 else {
70- if (path!=_static_path ){
81+ if (path!=_cached_path ){
7182 _data = loaddata::loadfile (path);
7283 _nparticles = _data.size ();
73- _static_data.resize (_nparticles);
74- hydra::copy (_data,_static_data);
84+ _cached_data.resize (_nparticles);
85+ hydra::copy (_data,_cached_data);
86+ _cached_nparticles = _nparticles;
87+ _cached_length = length;
7588 }
7689 else {
7790 _data.resize (_nparticles);
78- hydra::copy (_static_data ,_data);
91+ hydra::copy (_cached_data ,_data);
7992 _nparticles = _data.size ();
8093 }
8194 }
95+ _isloaded=true ;
8296 }
97+
98+ // get _isloaded
99+ bool isloaded (){return _isloaded;}
100+
83101 // get length
84102 double getlength (){return _length;}
85103
86104 // get nparticles
87105 double getnparticles (){return _nparticles;}
88106
89107 // generate dummy deposit
90- RunningStateHost_t gendummy (size_t nparticles, double length, size_t group=DEFAULT_GROUP){
108+ void gendummy (size_t nparticles, double length, size_t group=DEFAULT_GROUP){
91109 INFO_LINE (" Generating deposit" )
92110 hydra::Random<> Generator ( std::chrono::system_clock::now ().time_since_epoch ().count ());
93111 size_t np=(nparticles<=0 ) ? MAXPARTICLES : nparticles;
@@ -111,21 +129,14 @@ namespace deposit{
111129 }
112130 hydra::copy (data_de,hydra::make_range (data_d.begin (),data_d.begin ()+halfsize));
113131 hydra::copy (data_dh,hydra::make_range (data_d.begin ()+halfsize,data_d.end ()));
114-
115- return data_d;
116132 }
117133
118134 // get deposit
119- RunningStateHost_t* getdata (){return & _data;}
135+ RunningStateHost_t getdata (){return _data;}
120136
121137 // get deposit and change if different
122- RunningStateHost_t* getdata (std::string newfile, size_t nparticles, double length=1 ., size_t group=DEFAULT_GROUP){
123- if (_path!=newfile){
124- _path=newfile;
125- if (newfile==DEFAULT_PATH) _data = loaddata::getDummy (nparticles,length);
126- else _data=loaddata::loadfile (newfile);
127- }
128- return &_data;
138+ void SendToDevice (RunningStateDev_t& todev, singleconf)
139+
129140 }
130141 };
131142}
0 commit comments