Skip to content

Commit f8f4e8c

Browse files
authored
Update README.md
1 parent 479d280 commit f8f4e8c

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

README.md

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,31 +27,35 @@ CompactNSearch::NeighborhoodSearch nsearch(r);
2727
```
2828
An arbitrary number of point clouds can then be added to the data structure using the method ```add_point_set```. The library expects the point positions to be contiguously stored in an array-like structure. The method will return a unique id associated with the initialized point set.
2929
```c++
30-
std::vector<std::array<Real, 3>> positions;
3130
// ... Fill array with 3 * n real numbers representing three-dimensional point positions.
32-
unsigned int point_set_id = nsearch.add_point_set(positions.front().data(), positions.size());
33-
nsearch.find_neighbors();
31+
std::vector<std::array<Real, 3>> point_set_1;
32+
std::vector<std::array<Real, 3>> point_set_2;
33+
34+
unsigned int point_set_1_id = nsearch.add_point_set(positions.front().data(), positions.size());
35+
unsigned int point_set_2_id = nsearch.add_point_set(positions.front().data(), positions.size());
3436
```
3537
In order to generate the neighborhood information simply execute the following command
3638
```c++
3739
nsearch.find_neighbors();
3840
```
3941
Finally, the neighborhood information can be accessed as follows
4042
```c++
41-
PointSet const& ps = nsearch.point_set(point_set_id);
42-
for (int i = 0; i < ps.n_points(); ++i)
43+
CompactNSearch::PointSet const& ps_1 = nsearch.point_set(point_set_1_id);
44+
for (int i = 0; i < ps_1.n_points(); ++i)
4345
{
44-
for (size_t j = 0; j < ps.n_neighbors(neighbor_point_set_id, i); ++j)
45-
{
46-
// Return the point id of the jth neighbor of the ith particle in the 0th point set.
47-
const unsigned int pid = ps.neighbor(0, i, j);
48-
// ...
49-
// Do whatever you want with the point id. The id contains two indices.
50-
// The first field pid.point_set_id represents the unique point set id returnd by add_point_set.
51-
// The second field pid.point_id stands for the index of the neighboring particle within
52-
// the containing point set.
53-
// ...
54-
}
46+
// Get point set 1 neighbors of point set 1.
47+
for (size_t j = 0; j < ps_1.n_neighbors(point_set_1_id, i); ++j)
48+
{
49+
// Return the point id of the jth neighbor of the ith particle in the point_set_1.
50+
const unsigned int pid = ps_1.neighbor(point_set_1_id, i, j);
51+
}
52+
53+
// Get point set 2 neighbors of point set 1.
54+
for (size_t j = 0; j < ps_1.n_neighbors(point_set_2_id, i); ++j)
55+
{
56+
// Return the point id of the jth neighbor of the ith particle in the point_set_1.
57+
const unsigned int pid = ps_1.neighbor(point_set_2_id, i, j);
58+
}
5559
}
5660
```
5761

@@ -61,7 +65,7 @@ nsearch.z_sort();
6165
```
6266
Please note that the actual reordering must be invoked by the user by
6367
```c++
64-
ps.sort_field(positions.data());
68+
ps_1.sort_field(positions.data());
6569
```
6670
Assuming that there is additional information stored per-point (e.g. velocity, color, mass etc.) the information **must** also be reorded using the same method to maintain consistency. Subsequently, the ```find_neighbors``` function has to be invoked again to update the neighborhood information.
6771

@@ -71,7 +75,8 @@ Another self-explaining (benchmark) [demo](demo/main.cpp) is contained in the pr
7175

7276
When maintaining multiple it is sometimes desired that only certain point sets can find points from other point sets. Therefore an activation table is implemented where the user can specify whether a point set i searches points in another point set j. When nothing else is specified all point sets will search points in all other point sets. The activation table can be modified with e.g.
7377
```c++
74-
nsearch.set_active(i, j, false)
78+
// Point set 2 will not look for neighbors within its own points
79+
nsearch.set_active(point_set_2_id, point_set_2_id, false)
7580
```
7681

7782
## References

0 commit comments

Comments
 (0)