faunus
spheres_container.h
1 #ifndef VORONOTALT_SPHERES_CONTAINER_H_
2 #define VORONOTALT_SPHERES_CONTAINER_H_
3 
4 #include "spheres_searcher.h"
5 #include "periodic_box.h"
6 #include "time_recorder.h"
7 
8 namespace voronotalt
9 {
10 
12 {
13 public:
15  {
16  std::vector< std::pair<UnsignedInt, UnsignedInt> > relevant_collision_ids;
17 
19  {
20  }
21  };
22 
23  SpheresContainer() noexcept : total_collisions_(0)
24  {
25  }
26 
27  void init(const std::vector<SimpleSphere>& input_spheres, TimeRecorder& time_recorder) noexcept
28  {
29  init(input_spheres, PeriodicBox(), time_recorder);
30  }
31 
32  void init(const std::vector<SimpleSphere>& input_spheres, const PeriodicBox& periodic_box, TimeRecorder& time_recorder) noexcept
33  {
34  time_recorder.reset();
35 
36  periodic_box_=periodic_box;
37  input_spheres_=input_spheres;
38 
39  if(periodic_box_.enabled())
40  {
41  populated_spheres_.resize(input_spheres_.size()*27);
42  std::vector<UnsignedInt> collected_indices;
43  for(UnsignedInt i=0;i<input_spheres_.size();i++)
44  {
45  set_sphere_periodic_instances(i, false, collected_indices);
46  }
47  }
48  else
49  {
50  populated_spheres_=input_spheres_;
51  }
52 
53  all_exclusion_statuses_.resize(populated_spheres_.size(), 0);
54 
55  time_recorder.record_elapsed_miliseconds_and_reset("populate spheres");
56 
57  spheres_searcher_.init(populated_spheres_);
58 
59  time_recorder.record_elapsed_miliseconds_and_reset("init spheres searcher");
60 
61  all_colliding_ids_.resize(input_spheres_.size());
62 
63  {
64 #ifdef VORONOTALT_OPENMP
65 #pragma omp parallel for
66 #endif
67  for(UnsignedInt i=0;i<input_spheres_.size();i++)
68  {
69  all_colliding_ids_[i].reserve(100);
70  spheres_searcher_.find_colliding_ids(i, all_colliding_ids_[i], true, all_exclusion_statuses_[i]);
71  }
72  }
73 
74  if(periodic_box_.enabled())
75  {
76  for(UnsignedInt i=0;i<input_spheres_.size();i++)
77  {
78  set_exclusion_status_periodic_instances(i);
79  }
80  }
81 
82  time_recorder.record_elapsed_miliseconds_and_reset("detect all collisions");
83 
84  total_collisions_=0;
85 
86  for(UnsignedInt i=0;i<all_colliding_ids_.size();i++)
87  {
88  total_collisions_+=all_colliding_ids_[i].size();
89  }
90 
91  total_collisions_=total_collisions_/2;
92 
93  time_recorder.record_elapsed_miliseconds_and_reset("count all collisions");
94  }
95 
96  bool update(
97  const std::vector<SimpleSphere>& new_input_spheres,
98  const std::vector<UnsignedInt>& provided_ids_of_changed_input_spheres,
99  const bool trust_provided_ids_of_changed_input_spheres,
100  std::vector<UnsignedInt>& ids_of_changed_input_spheres,
101  std::vector<UnsignedInt>& ids_of_affected_input_spheres,
102  TimeRecorder& time_recorder) noexcept
103  {
104  time_recorder.reset();
105 
106  ids_of_changed_input_spheres.clear();
107  ids_of_affected_input_spheres.clear();
108 
109  if(new_input_spheres.size()!=input_spheres_.size())
110  {
111  reinit(new_input_spheres, ids_of_changed_input_spheres, ids_of_affected_input_spheres, time_recorder);
112  return true;
113  }
114 
115  if(trust_provided_ids_of_changed_input_spheres)
116  {
117  ids_of_changed_input_spheres=provided_ids_of_changed_input_spheres;
118  }
119  else
120  {
121  for(UnsignedInt i=0;i<new_input_spheres.size();i++)
122  {
123  if(!sphere_equals_sphere(new_input_spheres[i], input_spheres_[i]))
124  {
125  if(ids_of_changed_input_spheres.size()<size_threshold_for_full_reinit())
126  {
127  ids_of_changed_input_spheres.push_back(i);
128  }
129  else
130  {
131  reinit(new_input_spheres, ids_of_changed_input_spheres, ids_of_affected_input_spheres, time_recorder);
132  return true;
133  }
134  }
135  }
136 
137  time_recorder.record_elapsed_miliseconds_and_reset("identify changed spheres ids for update");
138  }
139 
140  if(ids_of_changed_input_spheres.empty())
141  {
142  return false;
143  }
144 
145  if(ids_of_changed_input_spheres.size()>size_threshold_for_full_reinit())
146  {
147  reinit(new_input_spheres, ids_of_changed_input_spheres, ids_of_affected_input_spheres, time_recorder);
148  return true;
149  }
150 
151  for(UnsignedInt i=0;i<ids_of_changed_input_spheres.size();i++)
152  {
153  if(ids_of_changed_input_spheres[i]>=input_spheres_.size())
154  {
155  reinit(new_input_spheres, ids_of_changed_input_spheres, ids_of_affected_input_spheres, time_recorder);
156  return true;
157  }
158  }
159 
160  {
161  bool update_needed=false;
162  for(UnsignedInt i=0;!update_needed && i<ids_of_changed_input_spheres.size();i++)
163  {
164  const UnsignedInt sphere_id=ids_of_changed_input_spheres[i];
165  if(!sphere_equals_sphere(new_input_spheres[sphere_id], input_spheres_[sphere_id]))
166  {
167  update_needed=true;
168  }
169  }
170  if(!update_needed)
171  {
172  return false;
173  }
174  }
175 
176  {
177  ids_of_affected_input_spheres=ids_of_changed_input_spheres;
178  std::sort(ids_of_affected_input_spheres.begin(), ids_of_affected_input_spheres.end());
179 
180  for(UnsignedInt i=0;i<ids_of_changed_input_spheres.size();i++)
181  {
182  const UnsignedInt sphere_id=ids_of_changed_input_spheres[i];
183  for(UnsignedInt j=0;j<all_colliding_ids_[sphere_id].size();j++)
184  {
185  if(ids_of_affected_input_spheres.size()<size_threshold_for_full_reinit())
186  {
187  const UnsignedInt affected_sphere_id=all_colliding_ids_[sphere_id][j].index%input_spheres_.size();
188  std::vector<UnsignedInt>::iterator it=std::lower_bound(ids_of_affected_input_spheres.begin(), ids_of_affected_input_spheres.end(), affected_sphere_id);
189  if(it==ids_of_affected_input_spheres.end() || (*it)!=affected_sphere_id)
190  {
191  ids_of_affected_input_spheres.insert(it, affected_sphere_id);
192  }
193  }
194  else
195  {
196  reinit(new_input_spheres, ids_of_changed_input_spheres, ids_of_affected_input_spheres, time_recorder);
197  return true;
198  }
199  }
200  }
201  }
202 
203  time_recorder.record_elapsed_miliseconds_and_reset("gather affected spheres ids for update");
204 
205  {
206  if(periodic_box_.enabled())
207  {
208  std::vector<UnsignedInt> ids_of_changed_populated_spheres;
209  ids_of_changed_populated_spheres.reserve(ids_of_changed_input_spheres.size()*27);
210  for(UnsignedInt i=0;i<ids_of_changed_input_spheres.size();i++)
211  {
212  const UnsignedInt sphere_id=ids_of_changed_input_spheres[i];
213  input_spheres_[sphere_id]=new_input_spheres[sphere_id];
214  if(periodic_box_.enabled())
215  {
216  set_sphere_periodic_instances(sphere_id, true, ids_of_changed_populated_spheres);
217  }
218  }
219  spheres_searcher_.update(populated_spheres_, ids_of_changed_populated_spheres);
220  }
221  else
222  {
223  for(UnsignedInt i=0;i<ids_of_changed_input_spheres.size();i++)
224  {
225  const UnsignedInt sphere_id=ids_of_changed_input_spheres[i];
226  input_spheres_[sphere_id]=new_input_spheres[sphere_id];
227  populated_spheres_[sphere_id]=input_spheres_[sphere_id];
228  }
229  spheres_searcher_.update(input_spheres_, ids_of_changed_input_spheres);
230  }
231 
232  time_recorder.record_elapsed_miliseconds_and_reset("update spheres searcher");
233 
234  {
235 #ifdef VORONOTALT_OPENMP
236 #pragma omp parallel for
237 #endif
238  for(UnsignedInt i=0;i<ids_of_affected_input_spheres.size();i++)
239  {
240  const UnsignedInt sphere_id=ids_of_affected_input_spheres[i];
241  all_colliding_ids_[sphere_id].clear();
242  spheres_searcher_.find_colliding_ids(sphere_id, all_colliding_ids_[sphere_id], true, all_exclusion_statuses_[sphere_id]);
243  }
244  }
245 
246  if(periodic_box_.enabled())
247  {
248  for(UnsignedInt i=0;i<ids_of_affected_input_spheres.size();i++)
249  {
250  const UnsignedInt sphere_id=ids_of_affected_input_spheres[i];
251  set_exclusion_status_periodic_instances(sphere_id);
252  }
253  }
254 
255  buffered_temporary_storage_.clear();
256 
257  for(UnsignedInt i=0;i<ids_of_changed_input_spheres.size();i++)
258  {
259  const UnsignedInt sphere_id=ids_of_changed_input_spheres[i];
260  for(UnsignedInt j=0;j<all_colliding_ids_[sphere_id].size();j++)
261  {
262  const UnsignedInt affected_sphere_id=all_colliding_ids_[sphere_id][j].index%input_spheres_.size();
263  std::vector<UnsignedInt>::iterator it=std::lower_bound(buffered_temporary_storage_.more_ids_of_affected_input_spheres.begin(), buffered_temporary_storage_.more_ids_of_affected_input_spheres.end(), affected_sphere_id);
264  if(it==buffered_temporary_storage_.more_ids_of_affected_input_spheres.end() || (*it)!=affected_sphere_id)
265  {
266  if(!std::binary_search(ids_of_affected_input_spheres.begin(), ids_of_affected_input_spheres.end(), affected_sphere_id))
267  {
268  buffered_temporary_storage_.more_ids_of_affected_input_spheres.insert(it, affected_sphere_id);
269  }
270  }
271  }
272  }
273 
274  if(!buffered_temporary_storage_.more_ids_of_affected_input_spheres.empty())
275  {
276  {
277 #ifdef VORONOTALT_OPENMP
278 #pragma omp parallel for
279 #endif
280  for(UnsignedInt i=0;i<buffered_temporary_storage_.more_ids_of_affected_input_spheres.size();i++)
281  {
282  const UnsignedInt sphere_id=buffered_temporary_storage_.more_ids_of_affected_input_spheres[i];
283  all_colliding_ids_[sphere_id].clear();
284  spheres_searcher_.find_colliding_ids(sphere_id, all_colliding_ids_[sphere_id], true, all_exclusion_statuses_[sphere_id]);
285  }
286  }
287 
288  if(periodic_box_.enabled())
289  {
290  for(UnsignedInt i=0;i<ids_of_affected_input_spheres.size();i++)
291  {
292  const UnsignedInt sphere_id=ids_of_affected_input_spheres[i];
293  set_exclusion_status_periodic_instances(sphere_id);
294  }
295  }
296 
297  buffered_temporary_storage_.merged_ids_of_affected_input_spheres.resize(ids_of_affected_input_spheres.size()+buffered_temporary_storage_.more_ids_of_affected_input_spheres.size());
298 
299  std::merge(ids_of_affected_input_spheres.begin(), ids_of_affected_input_spheres.end(),
300  buffered_temporary_storage_.more_ids_of_affected_input_spheres.begin(), buffered_temporary_storage_.more_ids_of_affected_input_spheres.end(),
301  buffered_temporary_storage_.merged_ids_of_affected_input_spheres.begin());
302 
303  ids_of_affected_input_spheres.swap(buffered_temporary_storage_.merged_ids_of_affected_input_spheres);
304  }
305 
306  time_recorder.record_elapsed_miliseconds_and_reset("update relevant collisions");
307 
308  total_collisions_=0;
309 
310  for(UnsignedInt i=0;i<all_colliding_ids_.size();i++)
311  {
312  total_collisions_+=all_colliding_ids_[i].size();
313  }
314 
315  total_collisions_=total_collisions_/2;
316 
317  time_recorder.record_elapsed_miliseconds_and_reset("recount all collisions");
318  }
319 
320  return true;
321  }
322 
323  bool update_by_setting_exclusion_status(const UnsignedInt id_of_masked_input_sphere, const bool new_exclusion_status) noexcept
324  {
325  if(id_of_masked_input_sphere>=input_spheres_.size() || id_of_masked_input_sphere>=all_exclusion_statuses_.size() || (new_exclusion_status ? all_exclusion_statuses_[id_of_masked_input_sphere]>0 : all_exclusion_statuses_[id_of_masked_input_sphere]<1))
326  {
327  return false;
328  }
329 
330  all_exclusion_statuses_[id_of_masked_input_sphere]=(new_exclusion_status ? 1 : 0);
331 
332  if(periodic_box_.enabled())
333  {
334  set_exclusion_status_periodic_instances(id_of_masked_input_sphere);
335  }
336 
337  return true;
338  }
339 
340  bool update_by_setting_exclusion_status(const UnsignedInt id_of_masked_input_sphere, const bool new_exclusion_status, std::vector<UnsignedInt>& ids_of_changed_input_spheres, std::vector<UnsignedInt>& ids_of_affected_input_spheres) noexcept
341  {
342  ids_of_changed_input_spheres.clear();
343  ids_of_affected_input_spheres.clear();
344 
345  if(id_of_masked_input_sphere>=input_spheres_.size() || id_of_masked_input_sphere>=all_exclusion_statuses_.size() || (new_exclusion_status ? all_exclusion_statuses_[id_of_masked_input_sphere]>0 : all_exclusion_statuses_[id_of_masked_input_sphere]<1))
346  {
347  return false;
348  }
349 
350  ids_of_changed_input_spheres.push_back(id_of_masked_input_sphere);
351  ids_of_affected_input_spheres.push_back(id_of_masked_input_sphere);
352 
353  for(std::size_t j=0;j<all_colliding_ids_[id_of_masked_input_sphere].size();j++)
354  {
355  const UnsignedInt affected_sphere_id=all_colliding_ids_[id_of_masked_input_sphere][j].index%input_spheres_.size();
356  std::vector<UnsignedInt>::iterator it=std::lower_bound(ids_of_affected_input_spheres.begin(), ids_of_affected_input_spheres.end(), affected_sphere_id);
357  if(it==ids_of_affected_input_spheres.end() || (*it)!=affected_sphere_id)
358  {
359  ids_of_affected_input_spheres.insert(it, affected_sphere_id);
360  }
361  }
362 
363  all_exclusion_statuses_[id_of_masked_input_sphere]=(new_exclusion_status ? 1 : 0);
364 
365  if(periodic_box_.enabled())
366  {
367  set_exclusion_status_periodic_instances(id_of_masked_input_sphere);
368  }
369 
370  return true;
371  }
372 
373  void assign(const SpheresContainer& obj) noexcept
374  {
375  periodic_box_=obj.periodic_box_;
376  total_collisions_=obj.total_collisions_;
377 
378  spheres_searcher_.assign(obj.spheres_searcher_);
379 
380  input_spheres_.resize(obj.input_spheres_.size());
381  populated_spheres_.resize(obj.populated_spheres_.size());
382  all_exclusion_statuses_.resize(obj.all_exclusion_statuses_.size());
383  all_colliding_ids_.resize(obj.all_colliding_ids_.size());
384 
385  {
386 #ifdef VORONOTALT_OPENMP
387 #pragma omp parallel for
388 #endif
389  for(UnsignedInt i=0;i<obj.input_spheres_.size();i++)
390  {
391  input_spheres_[i]=obj.input_spheres_[i];
392  }
393  }
394 
395  {
396 #ifdef VORONOTALT_OPENMP
397 #pragma omp parallel for
398 #endif
399  for(UnsignedInt i=0;i<obj.populated_spheres_.size();i++)
400  {
401  populated_spheres_[i]=obj.populated_spheres_[i];
402  }
403  }
404 
405  {
406 #ifdef VORONOTALT_OPENMP
407 #pragma omp parallel for
408 #endif
409  for(UnsignedInt i=0;i<obj.all_exclusion_statuses_.size();i++)
410  {
411  all_exclusion_statuses_[i]=obj.all_exclusion_statuses_[i];
412  }
413  }
414 
415  {
416 #ifdef VORONOTALT_OPENMP
417 #pragma omp parallel for
418 #endif
419  for(UnsignedInt i=0;i<obj.all_colliding_ids_.size();i++)
420  {
421  all_colliding_ids_[i]=obj.all_colliding_ids_[i];
422  }
423  }
424  }
425 
426  void assign(const SpheresContainer& obj, const std::vector<UnsignedInt>& subset_of_ids) noexcept
427  {
428  if(subset_of_ids.empty()
429  || obj.input_spheres_.empty()
430  || !periodic_box_.equals(obj.periodic_box_)
431  || input_spheres_.size()!=obj.input_spheres_.size()
432  || populated_spheres_.size()!=obj.populated_spheres_.size()
433  || all_exclusion_statuses_.size()!=obj.all_exclusion_statuses_.size()
434  || all_colliding_ids_.size()!=obj.all_colliding_ids_.size()
435  || subset_of_ids.size()>=size_threshold_for_full_reinit())
436  {
437  assign(obj);
438  }
439  else
440  {
441  for(UnsignedInt i=0;i<subset_of_ids.size();i++)
442  {
443  const UnsignedInt sphere_id=subset_of_ids[i];
444  if(sphere_id>=input_spheres_.size())
445  {
446  assign(obj);
447  return;
448  }
449  }
450 
451  periodic_box_=obj.periodic_box_;
452  total_collisions_=obj.total_collisions_;
453 
454  spheres_searcher_.assign(obj.spheres_searcher_);
455 
456  {
457 #ifdef VORONOTALT_OPENMP
458 #pragma omp parallel for
459 #endif
460  for(UnsignedInt i=0;i<subset_of_ids.size();i++)
461  {
462  const UnsignedInt sphere_id=subset_of_ids[i];
463  input_spheres_[sphere_id]=obj.input_spheres_[sphere_id];
464  populated_spheres_[sphere_id]=obj.populated_spheres_[sphere_id];
465  all_exclusion_statuses_[sphere_id]=obj.all_exclusion_statuses_[sphere_id];
466  all_colliding_ids_[sphere_id]=obj.all_colliding_ids_[sphere_id];
467  }
468  }
469 
470  if(periodic_box_.enabled() && populated_spheres_.size()==input_spheres_.size()*27 && all_exclusion_statuses_.size()==all_exclusion_statuses_.size()*27)
471  {
472 #ifdef VORONOTALT_OPENMP
473 #pragma omp parallel for
474 #endif
475  for(UnsignedInt i=0;i<subset_of_ids.size();i++)
476  {
477  const UnsignedInt sphere_id=subset_of_ids[i];
478  for(UnsignedInt m=1;m<27;m++)
479  {
480  const UnsignedInt shifted_sphere_id=(m*input_spheres_.size()+sphere_id);
481  populated_spheres_[shifted_sphere_id]=obj.populated_spheres_[sphere_id];
482  all_exclusion_statuses_[shifted_sphere_id]=all_exclusion_statuses_[sphere_id];
483  }
484  }
485  }
486  }
487  }
488 
489  const PeriodicBox& periodic_box() const noexcept
490  {
491  return periodic_box_;
492  }
493 
494  const std::vector<SimpleSphere>& input_spheres() const noexcept
495  {
496  return input_spheres_;
497  }
498 
499  const std::vector<SimpleSphere>& populated_spheres() const noexcept
500  {
501  return populated_spheres_;
502  }
503 
504  const std::vector<int>& all_exclusion_statuses() const noexcept
505  {
506  return all_exclusion_statuses_;
507  }
508 
509  const std::vector< std::vector<ValuedID> >& all_colliding_ids() const noexcept
510  {
511  return all_colliding_ids_;
512  }
513 
514  UnsignedInt total_collisions() const noexcept
515  {
516  return total_collisions_;
517  }
518 
519  bool prepare_for_tessellation(const std::vector<int>& grouping_of_spheres, ResultOfPreparationForTessellation& result, TimeRecorder& time_recorder) const noexcept
520  {
521  return prepare_for_tessellation(std::vector<int>(), grouping_of_spheres, result, time_recorder);
522  }
523 
524  bool prepare_for_tessellation(const std::vector<int>& involvement_of_spheres, const std::vector<int>& grouping_of_spheres, ResultOfPreparationForTessellation& result, TimeRecorder& time_recorder) const noexcept
525  {
526  time_recorder.reset();
527 
528  result.relevant_collision_ids.clear();
529 
530  if(populated_spheres_.empty())
531  {
532  return false;
533  }
534 
535  result.relevant_collision_ids.reserve(total_collisions_);
536 
537  for(UnsignedInt id_a=0;id_a<input_spheres_.size();id_a++)
538  {
539  if((involvement_of_spheres.empty() || id_a>=involvement_of_spheres.size() || involvement_of_spheres[id_a]>0) && all_exclusion_statuses_[id_a]==0)
540  {
541  for(UnsignedInt j=0;j<all_colliding_ids_[id_a].size();j++)
542  {
543  const UnsignedInt id_b=all_colliding_ids_[id_a][j].index;
544  const UnsignedInt id_b_canonical=(id_b%input_spheres_.size());
545  if((involvement_of_spheres.empty() || id_b_canonical>=involvement_of_spheres.size() || involvement_of_spheres[id_b_canonical]>0) && all_exclusion_statuses_[id_b_canonical]==0)
546  {
547  if(id_b>=input_spheres_.size() || (all_colliding_ids_[id_a].size()<all_colliding_ids_[id_b_canonical].size()) || (id_a<id_b && all_colliding_ids_[id_a].size()==all_colliding_ids_[id_b_canonical].size()))
548  {
549  if(grouping_of_spheres.empty() || id_a>=grouping_of_spheres.size() || id_b_canonical>=grouping_of_spheres.size() || grouping_of_spheres[id_a]!=grouping_of_spheres[id_b_canonical])
550  {
551  result.relevant_collision_ids.push_back(std::pair<UnsignedInt, UnsignedInt>(id_a, id_b));
552  }
553  }
554  }
555  }
556  }
557  }
558 
559  time_recorder.record_elapsed_miliseconds_and_reset("collect relevant collision indices");
560 
561  return true;
562  }
563 
564 private:
565  struct BufferedTemporaryStorage
566  {
567  std::vector<UnsignedInt> more_ids_of_affected_input_spheres;
568  std::vector<UnsignedInt> merged_ids_of_affected_input_spheres;
569 
570  void clear() noexcept
571  {
572  more_ids_of_affected_input_spheres.clear();
573  merged_ids_of_affected_input_spheres.clear();
574  }
575  };
576 
577  UnsignedInt size_threshold_for_full_reinit() const noexcept
578  {
579  return static_cast<UnsignedInt>(input_spheres_.size()/2);
580  }
581 
582  void reinit(const std::vector<SimpleSphere>& new_input_spheres, std::vector<UnsignedInt>& ids_of_changed_input_spheres, std::vector<UnsignedInt>& ids_of_affected_input_spheres, TimeRecorder& time_recorder) noexcept
583  {
584  init(new_input_spheres, periodic_box_, time_recorder);
585  ids_of_changed_input_spheres.clear();
586  ids_of_affected_input_spheres.clear();
587  }
588 
589  void set_sphere_periodic_instances(const UnsignedInt i, const bool collect_indices, std::vector<UnsignedInt>& collected_indices) noexcept
590  {
591  if(i<input_spheres_.size())
592  {
593  const SimpleSphere& o=input_spheres_[i];
594  if(!periodic_box_.enabled())
595  {
596  if(populated_spheres_.size()!=input_spheres_.size())
597  {
598  populated_spheres_.resize(input_spheres_.size());
599  }
600  populated_spheres_[i]=o;
601  if(collect_indices)
602  {
603  collected_indices.push_back(i);
604  }
605  }
606  else
607  {
608  if(populated_spheres_.size()!=(input_spheres_.size()*27))
609  {
610  populated_spheres_.resize(input_spheres_.size()*27);
611  }
612  populated_spheres_[i]=o;
613  if(collect_indices)
614  {
615  collected_indices.push_back(i);
616  }
617  UnsignedInt g=1;
618  for(int sx=-1;sx<=1;sx++)
619  {
620  for(int sy=-1;sy<=1;sy++)
621  {
622  for(int sz=-1;sz<=1;sz++)
623  {
624  if(sx!=0 || sy!=0 || sz!=0)
625  {
626  const UnsignedInt mi=(g*input_spheres_.size()+i);
627  populated_spheres_[mi]=periodic_box_.shift_by_weighted_directions(o, static_cast<Float>(sx), static_cast<Float>(sy), static_cast<Float>(sz));
628  if(collect_indices)
629  {
630  collected_indices.push_back(mi);
631  }
632  g++;
633  }
634  }
635  }
636  }
637  }
638  }
639  }
640 
641  void set_exclusion_status_periodic_instances(const UnsignedInt i) noexcept
642  {
643  if(i<input_spheres_.size() && all_exclusion_statuses_.size()==input_spheres_.size()*27)
644  {
645  for(UnsignedInt m=1;m<27;m++)
646  {
647  all_exclusion_statuses_[m*input_spheres_.size()+i]=all_exclusion_statuses_[i];
648  }
649  }
650  }
651 
652  PeriodicBox periodic_box_;
653  std::vector<SimpleSphere> input_spheres_;
654  std::vector<SimpleSphere> populated_spheres_;
655  std::vector<int> all_exclusion_statuses_;
656  SpheresSearcher spheres_searcher_;
657  std::vector< std::vector<ValuedID> > all_colliding_ids_;
658  UnsignedInt total_collisions_;
659  BufferedTemporaryStorage buffered_temporary_storage_;
660 };
661 
662 }
663 
664 #endif /* VORONOTALT_SPHERES_CONTAINER_H_ */
Definition: time_recorder.h:7
Definition: spheres_searcher.h:12
Definition: spheres_container.h:11
Definition: periodic_box.h:11
Definition: basic_types_and_functions.h:19
Definition: basic_types_and_functions.h:49