Free Electron
ProxMultiGrid.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __spatial_ProxMultiGrid_h__
8 #define __spatial_ProxMultiGrid_h__
9 
10 #include "signal/signal.h"
11 #include "Proximity.h"
12 #include "SpaceI.h"
13 
14 namespace fe
15 {
16 namespace ext
17 {
18 
19 /** Proximity detection.
20 
21  The method used partitions space into grids of cells. A separate
22  grid is used for each specified cell size. Cells are cubic; they are
23  the same length in each dimension.
24 
25  WARNING: this class is by design not reentrant due to the pair pooling.
26 
27  Note: this class is also a good guide on getting the most speed possible
28  out of the data system.
29 
30  @b particle attributes
31  @li AsParticle::location
32  @li AsBounded::radius
33 
34  @b pair attributes
35  @li AsProximity::left
36  @li AsProximity::right
37  */
38 class FE_DL_EXPORT ProxMultiGrid :
39  virtual public ProxI,
40  public Initialize<ProxMultiGrid>
41 {
42  typedef Vector<3, int> t_v3i;
43  public:
44  ProxMultiGrid(void);
45 virtual ~ProxMultiGrid(void);
46  void initialize(void);
47 
48  // AS ProxI
49 virtual unsigned int detect( sp<Layout> l_pair,
50  sp<RecordGroup> rg_in,
51  sp<RecordGroup> rg_out);
52 
53 
54 virtual void addGrid(Real cellSize);
55 
56  private:
57  class LocalRecord
58  {
59  public:
60  unsigned int m_index;
61  RecordArray *m_pRA;
62  SpatialVector m_location;
63  Real m_radius;
64  };
65 // apparently MS decided to stop supporting allocators properly
66 #if FE_COMPILER==FE_MICROSOFT
67  typedef std::vector<LocalRecord> t_lrecords;
68 #else
69  typedef std::vector<LocalRecord, StdAllocator<LocalRecord> > t_lrecords;
70 #endif
71  class Grid
72  {
73  public:
74  Grid(void);
75  unsigned int flatten(const t_v3i &a_idx)
76  {
77  return a_idx[0] * m_count[1] * m_count[2] +
78  a_idx[1] * m_count[2] +
79  a_idx[2];
80  }
81  unsigned int detect(void);
82  std::vector<t_lrecords> m_grid;
83  Real m_sz;
84  t_v3i m_count;
85  ProxMultiGrid *m_pMGrid;
86  };
87 
88  void add(sp<RecordArray> &ra_in, unsigned int index);
89  unsigned int detect(t_lrecords &a_a);
90  unsigned int detect(t_lrecords &a_a, t_lrecords &a_b);
91  unsigned int detect(Grid &a_ga, Grid &a_gb);
92  bool check(LocalRecord &r_a, LocalRecord &r_b);
93  void setup(sp<Scope> spScope);
94  void setup(Grid &a_grid, SpatialVector &a_extent);
95 
96  void log(void);
97 
98  private:
99  bool rangeCheck(LocalRecord &r_a);
100  sp<Scope> m_spScope;
101  AsBounded m_asBounded;
102  AsParticle m_asParticle;
103  AsProximity m_asProximity;
104 
105  Array<Grid> m_grids;
106  SpatialVector m_origin;
107  sp<SpaceI> m_spSpace;
108  SpatialVector m_boundary;
109 
110  Array<BaseAccessor> m_filters;
111 
112  sp<RecordArray> m_spPool;
113  FE_UWORD m_poolIndex;
114 
115  hp<Layout> m_hpPairLayout;
116 };
117 
118 } /* namespace ext */
119 } /* namespace fe */
120 
121 #endif /* __spatial_ProxMultiGrid_h__ */
122 
Proximity detection.
Definition: ProxMultiGrid.h:38
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
proximity detection interface
Definition: Proximity.h:21
particle in physical space
Definition: shapeAS.h:58
possible bounding area/volume attributes
Definition: shapeAS.h:148
Homogeneous collection of Records.
Definition: RecordArraySB.h:40