Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
TurTLE
TurTLE
Commits
eb1b7d36
Commit
eb1b7d36
authored
Sep 20, 2017
by
Berenger Bramas
Browse files
Add first version of particle particle interactions
parent
0ce7d47f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
bfps/cpp/particles/.tocompile
0 → 100644
View file @
eb1b7d36
mpicxx -g main_tocompile.cpp -o /tmp/main_test_part.exe -I/home/bbramas/Projects/bfps/bfps/cpp/ -I/home/bbramas/Downloads/hdf5install/include -L/home/bbramas/Downloads/hdf5install/lib -lhdf5 -lsz -lz
mpicxx -fPIC -rdynamic -g NSVE-v2.0.1-single.cpp -o /tmp/NSVE-v2.0.1-single.exe -I/home/bbramas/Projects/bfps/bfps/cpp/ -I/home/bbramas/Downloads/hdf5install/include -I/home/bbramas/Downloads/fftw-3.3.4/install/include/ -L/home/bbramas/Downloads/hdf5install/lib -lhdf5 -lsz -lz -L/home/bbramas/.local/lib/python2.7/site-packages/bfps-2.0.1.post31+g12693ea-py2.7.egg/bfps/ -lbfps -fopenmp -lgomp -L/home/bbramas/Downloads/fftw-3.3.4/install/lib/ -lfftw3_mpi -lfftw3f_mpi -lfftw3_omp -lfftw3f_omp -lfftw3 -lfftw3f
bfps/cpp/particles/p2p_computer.hpp
0 → 100644
View file @
eb1b7d36
#ifndef P2P_COMPUTER_HPP
#define P2P_COMPUTER_HPP
#include
<cstring>
template
<
class
real_number
,
class
partsize_t
>
class
p2p_computer
{
public:
template
<
int
size_particle_rhs
>
void
init_result_array
(
real_number
rhs
[],
const
partsize_t
nbParticles
)
const
{
memset
(
rhs
,
0
,
sizeof
(
real_number
)
*
nbParticles
);
}
template
<
int
size_particle_rhs
>
void
reduce_particles_rhs
(
real_number
rhs_dst
[],
const
real_number
rhs_src
[],
const
partsize_t
nbParticles
)
const
{
for
(
int
idx_part
=
0
;
idx_part
<
nbParticles
;
++
idx_part
){
for
(
int
idx_rhs
=
0
;
idx_rhs
<
size_particle_rhs
;
++
idx_rhs
){
rhs_dst
[
idx_part
*
size_particle_rhs
+
idx_rhs
]
+=
rhs_src
[
idx_part
*
size_particle_rhs
+
idx_rhs
];
}
}
}
template
<
int
size_particle_positions
,
int
size_particle_rhs
>
void
compute_interaction
(
const
real_number
pos_part1
[],
real_number
rhs_part1
[],
const
real_number
pos_part2
[],
real_number
rhs_part2
[],
const
real_number
dist_pow2
)
const
{
rhs_part1
[
0
]
+=
1
;
rhs_part2
[
0
]
+=
1
;
}
};
#endif
bfps/cpp/particles/p2p_distr_mpi.hpp
0 → 100644
View file @
eb1b7d36
This diff is collapsed.
Click to expand it.
bfps/cpp/particles/p2p_tree.hpp
0 → 100644
View file @
eb1b7d36
#ifndef P2P_TREE_HPP
#define P2P_TREE_HPP
#include
<unordered_map>
#include
<vector>
template
<
class
CellClass
>
class
p2p_tree
{
std
::
unordered_map
<
long
int
,
CellClass
>
data
;
CellClass
emptyCell
;
std
::
array
<
long
int
,
3
>
nb_cell_levels
;
long
int
get_cell_coord_x_from_index
(
const
long
int
index
)
const
{
return
index
%
nb_cell_levels
[
IDX_X
];
}
long
int
get_cell_coord_y_from_index
(
const
long
int
index
)
const
{
return
(
index
-
get_cell_coord_z_from_index
(
index
)
*
(
nb_cell_levels
[
IDX_X
]
*
nb_cell_levels
[
IDX_Y
]))
/
nb_cell_levels
[
IDX_X
];
}
long
int
get_cell_coord_z_from_index
(
const
long
int
index
)
const
{
return
index
/
(
nb_cell_levels
[
IDX_X
]
*
nb_cell_levels
[
IDX_Y
]);
}
long
int
get_cell_idx
(
const
long
int
idx_x
,
const
long
int
idx_y
,
const
long
int
idx_z
)
const
{
return
(((
idx_z
*
nb_cell_levels
[
IDX_Y
])
+
idx_y
)
*
nb_cell_levels
[
IDX_X
])
+
idx_x
;
}
public:
explicit
p2p_tree
(
std
::
array
<
long
int
,
3
>
in_nb_cell_levels
)
:
nb_cell_levels
(
in_nb_cell_levels
){
}
CellClass
&
getCell
(
const
long
int
idx
){
return
data
[
idx
];
}
const
CellClass
&
getCell
(
const
long
int
idx
)
const
{
const
auto
&
iter
=
data
.
find
(
idx
);
if
(
iter
!=
data
.
end
()){
return
iter
->
second
;
}
return
emptyCell
;
}
int
getNeighbors
(
const
long
int
idx
,
const
CellClass
*
output
[
27
])
const
{
int
nbNeighbors
=
0
;
const
long
int
idx_x
=
get_cell_coord_x_from_index
(
idx
);
const
long
int
idx_y
=
get_cell_coord_y_from_index
(
idx
);
const
long
int
idx_z
=
get_cell_coord_z_from_index
(
idx
);
for
(
long
int
neigh_x
=
-
1
;
neigh_x
<=
1
;
++
neigh_x
){
long
int
neigh_x_pbc
=
neigh_x
+
idx_x
;
if
(
neigh_x_pbc
<
0
){
neigh_x_pbc
+=
nb_cell_levels
[
IDX_X
];
}
else
if
(
nb_cell_levels
[
IDX_X
]
<=
neigh_x_pbc
){
neigh_x_pbc
-=
nb_cell_levels
[
IDX_X
];
}
for
(
long
int
neigh_y
=
-
1
;
neigh_y
<=
1
;
++
neigh_y
){
long
int
neigh_y_pbc
=
neigh_y
+
idx_y
;
if
(
neigh_y_pbc
<
0
){
neigh_y_pbc
+=
nb_cell_levels
[
IDX_Y
];
}
else
if
(
nb_cell_levels
[
IDX_Y
]
<=
neigh_y_pbc
){
neigh_y_pbc
-=
nb_cell_levels
[
IDX_Y
];
}
for
(
long
int
neigh_z
=
-
1
;
neigh_z
<=
1
;
++
neigh_z
){
long
int
neigh_z_pbc
=
neigh_z
+
idx_z
;
if
(
neigh_z_pbc
<
0
){
neigh_z_pbc
+=
nb_cell_levels
[
IDX_Z
];
}
else
if
(
nb_cell_levels
[
IDX_Z
]
<=
neigh_z_pbc
){
neigh_z_pbc
-=
nb_cell_levels
[
IDX_Z
];
}
// Not the current cell
if
(
neigh_x_pbc
!=
idx_x
||
neigh_y_pbc
!=
idx_y
||
neigh_z_pbc
!=
idx_z
){
const
long
int
idx_neigh
=
get_cell_idx
(
neigh_x_pbc
,
neigh_y_pbc
,
neigh_z_pbc
);
const
auto
&
iter
=
data
.
find
(
idx_neigh
);
if
(
iter
!=
data
.
end
()){
output
[
nbNeighbors
]
=
&
(
iter
->
second
);
}
}
}
}
}
return
nbNeighbors
;
}
typename
std
::
unordered_map
<
long
int
,
CellClass
>::
iterator
begin
(){
return
data
.
begin
();
}
typename
std
::
unordered_map
<
long
int
,
CellClass
>::
iterator
end
(){
return
data
.
end
();
}
};
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment