@@ -35,59 +35,77 @@ namespace deposit{
35
35
class owndeposit {
36
36
private:
37
37
// 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;
42
43
43
44
std::string _path;
44
45
RunningStateHost_t _data;
45
46
size_t _nparticles;
47
+ size_t _group;
46
48
double _length=1 .;
49
+ bool _isloaded;
47
50
48
51
public:
52
+
53
+ owndeposit (){}
54
+
49
55
owndeposit (std::string path, size_t nparticles, double length, size_t group=DEFAULT_GROUP){
50
56
this ->init (path, nparticles, length);
51
57
}
52
58
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 );
55
61
}
56
62
// 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
+
57
68
void init (std::string path, size_t nparticles, double length, size_t group=DEFAULT_GROUP){
58
69
if (_path==DEFAULT_PATH){
59
- if (nparticles!=_static_nparticles || length!=_static_length ){
70
+ if (nparticles!=_cached_nparticles || length!=_cached_length || group!=_cached_group ){
60
71
_data = this ->gendummy (nparticles,length);
61
72
}
62
73
else {
63
74
_data.resize (_nparticles);
64
- hydra::copy (_static_data ,_data);
75
+ hydra::copy (_cached_data ,_data);
65
76
}
66
77
_nparticles = nparticles;
67
78
_length = length;
68
79
}
69
80
else {
70
- if (path!=_static_path ){
81
+ if (path!=_cached_path ){
71
82
_data = loaddata::loadfile (path);
72
83
_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;
75
88
}
76
89
else {
77
90
_data.resize (_nparticles);
78
- hydra::copy (_static_data ,_data);
91
+ hydra::copy (_cached_data ,_data);
79
92
_nparticles = _data.size ();
80
93
}
81
94
}
95
+ _isloaded=true ;
82
96
}
97
+
98
+ // get _isloaded
99
+ bool isloaded (){return _isloaded;}
100
+
83
101
// get length
84
102
double getlength (){return _length;}
85
103
86
104
// get nparticles
87
105
double getnparticles (){return _nparticles;}
88
106
89
107
// 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){
91
109
INFO_LINE (" Generating deposit" )
92
110
hydra::Random<> Generator ( std::chrono::system_clock::now ().time_since_epoch ().count ());
93
111
size_t np=(nparticles<=0 ) ? MAXPARTICLES : nparticles;
@@ -111,21 +129,14 @@ namespace deposit{
111
129
}
112
130
hydra::copy (data_de,hydra::make_range (data_d.begin (),data_d.begin ()+halfsize));
113
131
hydra::copy (data_dh,hydra::make_range (data_d.begin ()+halfsize,data_d.end ()));
114
-
115
- return data_d;
116
132
}
117
133
118
134
// get deposit
119
- RunningStateHost_t* getdata (){return & _data;}
135
+ RunningStateHost_t getdata (){return _data;}
120
136
121
137
// 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
+
129
140
}
130
141
};
131
142
}
0 commit comments