@@ -103,8 +103,8 @@ class WholeMolecules:
103
103
public ActionPilot,
104
104
public ActionAtomistic
105
105
{
106
- std::vector<std::vector<std::pair<std::size_t ,std::size_t > > > p_groups;
107
- std::vector<std::vector<std::pair<std::size_t ,std::size_t > > > p_roots;
106
+ std::vector<std::vector<std::pair<std::size_t ,std::vector<std:: size_t >>> > p_groups;
107
+ std::vector<std::vector<std::pair<std::size_t ,std::vector<std:: size_t >>> > p_roots;
108
108
std::vector<Vector> refs;
109
109
bool doemst, addref;
110
110
public:
@@ -221,17 +221,35 @@ WholeMolecules::WholeMolecules(const ActionOptions&ao):
221
221
// Convert groups to p_groups
222
222
p_groups.resize ( groups.size () );
223
223
for (unsigned i=0 ; i<groups.size (); ++i) {
224
- p_groups[i].resize ( groups[i].size () );
225
- for (unsigned j=0 ; j<groups[i].size (); ++j) p_groups[i][j] = getValueIndices ( groups[i][j] );
224
+ std::size_t prev_nn=0 ;
225
+ bool first=true ;
226
+ for (unsigned j=0 ; j<groups[i].size (); ++j) {
227
+ auto a = getValueIndices ( groups[i][j] );
228
+ auto nn=a.first ;
229
+ auto kk=a.second ;
230
+ if (first || nn!=prev_nn) p_groups.back ().push_back (std::pair<std::size_t ,std::vector<std::size_t >>(nn,{}));
231
+ p_groups.back ().back ().second .push_back (kk);
232
+ first=false ;
233
+ prev_nn=nn;
234
+ }
226
235
}
236
+
227
237
// Convert roots to p_roots
228
238
p_roots.resize ( roots.size () );
229
239
for (unsigned i=0 ; i<roots.size (); ++i) {
230
- p_roots[i].resize ( roots[i].size () );
231
- for (unsigned j=0 ; j<roots[i].size (); ++j) p_roots[i][j] = getValueIndices ( roots[i][j] );
240
+ bool first=true ;
241
+ std::size_t prev_nn=0 ;
242
+ for (unsigned j=0 ; j<roots[i].size (); ++j) {
243
+ auto a = getValueIndices ( roots[i][j] );
244
+ auto nn=a.first ;
245
+ auto kk=a.second ;
246
+ if (first || nn!=prev_nn) p_roots.back ().push_back (std::pair<std::size_t ,std::vector<std::size_t >>(nn,{}));
247
+ p_roots.back ().back ().second .push_back (kk);
248
+ first=false ;
249
+ prev_nn=nn;
250
+ }
232
251
}
233
252
234
-
235
253
checkRead ();
236
254
Tools::removeDuplicates (merge);
237
255
requestAtoms (merge);
@@ -241,25 +259,38 @@ WholeMolecules::WholeMolecules(const ActionOptions&ao):
241
259
242
260
void WholeMolecules::calculate () {
243
261
for (unsigned i=0 ; i<p_groups.size (); ++i) {
244
- Vector first = getGlobalPosition (p_groups[i][0 ]);
245
- if (addref) {
246
- first = refs[i]+pbcDistance (refs[i],first);
247
- setGlobalPosition ( p_groups[i][0 ], first );
248
- }
249
- if (!doemst) {
250
- for (unsigned j=1 ; j<p_groups[i].size (); ++j) {
251
- Vector second=getGlobalPosition (p_groups[i][j]);
252
- first = first+pbcDistance (first,second);
253
- setGlobalPosition (p_groups[i][j], first );
254
- }
255
- } else {
256
- for (unsigned j=1 ; j<p_groups[i].size (); ++j) {
257
- Vector first=getGlobalPosition (p_roots[i][j-1 ]);
258
- Vector second=getGlobalPosition (p_groups[i][j]);
259
- second=first+pbcDistance (first,second);
260
- setGlobalPosition (p_groups[i][j], second );
262
+ bool start=true ;
263
+ // if(addref) {
264
+ // first = refs[i]+pbcDistance(refs[i],first);
265
+ // setGlobalPosition( p_groups[i][0], first );
266
+ // }
267
+ // if(!doemst) {
268
+
269
+ Vector first;
270
+ for (unsigned j=0 ; j<p_groups[i].size (); ++j) {
271
+ auto data = getValueData (p_groups[i][j].first );
272
+ for (const auto kk : p_groups[i][j].second ) {
273
+ Vector second{
274
+ data[0 ][kk],
275
+ data[1 ][kk],
276
+ data[2 ][kk],
277
+ };
278
+ if (start) first=second;
279
+ else first += pbcDistance (first,second);
280
+ start=false ;
281
+ data[0 ][kk]=first[0 ];
282
+ data[1 ][kk]=first[1 ];
283
+ data[2 ][kk]=first[2 ];
261
284
}
262
285
}
286
+ // } else {
287
+ // for(unsigned j=1; j<p_groups[i].size(); ++j) {
288
+ // Vector first=getGlobalPosition(p_roots[i][j-1]);
289
+ // Vector second=getGlobalPosition(p_groups[i][j]);
290
+ // second=first+pbcDistance(first,second);
291
+ // setGlobalPosition(p_groups[i][j], second );
292
+ // }
293
+ // }
263
294
}
264
295
}
265
296
0 commit comments