Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
O
openfpm_pdata
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
1
Issues
1
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
openfpm
openfpm_pdata
Commits
b958b201
Commit
b958b201
authored
Jun 18, 2018
by
incardon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Latest version
parent
e90b6e45
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
208 deletions
+36
-208
src/Amr/grid_dist_amr.hpp
src/Amr/grid_dist_amr.hpp
+1
-0
src/Grid/Iterators/grid_dist_id_iterator.hpp
src/Grid/Iterators/grid_dist_id_iterator.hpp
+17
-204
src/Grid/grid_dist_id.hpp
src/Grid/grid_dist_id.hpp
+12
-1
src/Grid/grid_dist_id_comm.hpp
src/Grid/grid_dist_id_comm.hpp
+2
-2
src/Grid/tests/sgrid_dist_id_unit_tests.cpp
src/Grid/tests/sgrid_dist_id_unit_tests.cpp
+4
-1
No files found.
src/Amr/grid_dist_amr.hpp
View file @
b958b201
...
...
@@ -235,6 +235,7 @@ public:
// Add the coarse level
gd_array
.
add
(
grid_dist_id
<
dim
,
St
,
T
,
Decomposition
,
Memory
,
device_grid
>
(
dec
,
g_sz
,
g_int
));
gd_array
.
last
().
setBackgroundValue
(
bck
);
initialize_other
(
n_lvl
,
g_sz_lvl
);
}
...
...
src/Grid/Iterators/grid_dist_id_iterator.hpp
View file @
b958b201
...
...
@@ -10,29 +10,12 @@
#define FREE 1
#define FIXED 2
#define ITERATION_ISOLATION 4
#include "Grid/grid_dist_key.hpp"
#include "VCluster/VCluster.hpp"
#include "util/GBoxes.hpp"
/*! \brief Distributed grid iterator
*
* Iterator across the local elements of the distributed grid
*
* \tparam dim dimensionality of the grid
* \tparam device_grid type of basic grid
* \tparam device_sub_it device grid sib-iterator type
* \tparam impl implementation
*
*/
template
<
unsigned
int
dim
,
typename
device_grid
,
typename
device_sub_it
,
int
impl
,
typename
stencil
=
no_stencil
>
class
grid_dist_iterator
{
};
/*! \brief Distributed grid iterator
*
* Iterator across the local elements of the distributed grid
...
...
@@ -43,8 +26,8 @@ class grid_dist_iterator
* \tparam sub_iterator it indicate the sub-iterator type of the device_grid
*
*/
template
<
unsigned
int
dim
,
typename
device_grid
,
typename
device_sub_it
,
typename
stencil
>
class
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FREE
,
stencil
>
template
<
unsigned
int
dim
,
typename
device_grid
,
typename
device_sub_it
,
int
impl
,
typename
stencil
=
no_stencil
>
class
grid_dist_iterator
{
//! grid list counter
size_t
g_c
;
...
...
@@ -68,8 +51,16 @@ class grid_dist_iterator<dim,device_grid,device_sub_it,FREE,stencil>
{
do
{
// When the grid has size 0 potentially all the other informations are garbage
while
(
g_c
<
gList
.
size
()
&&
(
gList
.
get
(
g_c
).
size
()
==
0
||
gdb_ext
.
get
(
g_c
).
Dbox
.
isValid
()
==
false
)
)
g_c
++
;
if
(
impl
==
FREE
)
{
// When the grid has size 0 potentially all the other informations are garbage
while
(
g_c
<
gList
.
size
()
&&
(
gList
.
get
(
g_c
).
size
()
==
0
||
gdb_ext
.
get
(
g_c
).
Dbox
.
isValid
()
==
false
)
)
g_c
++
;
}
else
{
// When the grid has size 0 potentially all the other informations are garbage
while
(
g_c
<
gList
.
size
()
&&
(
gList
.
get
(
g_c
).
size
()
==
0
||
gdb_ext
.
get
(
g_c
).
GDbox
.
isValid
()
==
false
)
)
g_c
++
;
}
// get the next grid iterator
if
(
g_c
<
gList
.
size
())
...
...
@@ -100,6 +91,7 @@ class grid_dist_iterator<dim,device_grid,device_sub_it,FREE,stencil>
selectValidGrid
();
}
/*! \brief Constructor of the distributed grid iterator with
* stencil support
*
...
...
@@ -121,12 +113,12 @@ class grid_dist_iterator<dim,device_grid,device_sub_it,FREE,stencil>
}
//! Copy constructor
grid_dist_iterator
(
const
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FREE
,
stencil
>
&
g
)
grid_dist_iterator
(
const
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
impl
,
stencil
>
&
g
)
:
g_c
(
g
.
g_c
),
gList
(
g
.
gList
),
gdb_ext
(
g
.
gdb_ext
),
a_it
(
g
.
a_it
),
stop
(
g
.
stop
)
{}
//! Copy constructor
grid_dist_iterator
(
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FREE
,
stencil
>
&&
g
)
grid_dist_iterator
(
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
impl
,
stencil
>
&&
g
)
:
g_c
(
g
.
g_c
),
gList
(
g
.
gList
),
gdb_ext
(
g
.
gdb_ext
),
a_it
(
g
.
a_it
),
stop
(
g
.
stop
)
{}
...
...
@@ -140,7 +132,7 @@ class grid_dist_iterator<dim,device_grid,device_sub_it,FREE,stencil>
* \return the next grid_key
*
*/
inline
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FREE
,
stencil
>
&
operator
++
()
inline
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
impl
,
stencil
>
&
operator
++
()
{
++
a_it
;
...
...
@@ -261,184 +253,5 @@ class grid_dist_iterator<dim,device_grid,device_sub_it,FREE,stencil>
};
/*! \brief Distributed grid iterator
*
* Iterator across the local elements of the distributed grid
*
* \tparam dim dimensionality of the grid
* \tparam device_grid type of basic grid
* \tparam impl implementation
*
*/
template
<
unsigned
int
dim
,
typename
device_grid
,
typename
device_sub_it
,
typename
stencil
>
class
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FIXED
,
stencil
>
{
//! grid list counter
size_t
g_c
;
//! List of the grids we are going to iterate
const
openfpm
::
vector
<
device_grid
>
&
gList
;
//! Extension of each grid: domain and ghost + domain
const
openfpm
::
vector
<
GBoxes
<
device_grid
::
dims
>>
&
gdb_ext
;
//! Actual iterator
device_sub_it
a_it
;
/*! \brief from g_c increment g_c until you find a valid grid
*
*/
void
selectValidGrid
()
{
do
{
// When the grid has size 0 potentially all the other informations are garbage
while
(
g_c
<
gList
.
size
()
&&
(
gList
.
get
(
g_c
).
size
()
==
0
||
gdb_ext
.
get
(
g_c
).
GDbox
.
isValid
()
==
false
)
)
g_c
++
;
// get the next grid iterator
if
(
g_c
<
gList
.
size
())
{
a_it
.
reinitialize
(
gList
.
get
(
g_c
).
getIterator
(
gdb_ext
.
get
(
g_c
).
Dbox
.
getKP1
(),
gdb_ext
.
get
(
g_c
).
Dbox
.
getKP2
()));
if
(
a_it
.
isNext
()
==
false
)
{
g_c
++
;}
}
}
while
(
g_c
<
gList
.
size
()
&&
a_it
.
isNext
()
==
false
);
}
public:
/*! \brief Copy operator=
*
* \param tmp iterator to copy
*
* \return itself
*
*/
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FIXED
>
&
operator
=
(
const
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FIXED
>
&
tmp
)
{
g_c
=
tmp
.
g_c
;
gList
=
tmp
.
gList
;
gdb_ext
=
tmp
.
gdb_ext
;
a_it
.
reinitialize
(
tmp
.
a_it
);
return
*
this
;
}
/*! \brief Constructor of the distributed grid iterator
*
* \param gk std::vector of the local grid
* \param gdb_ext information about the local grids
*
*/
grid_dist_iterator
(
const
openfpm
::
vector
<
device_grid
>
&
gk
,
const
openfpm
::
vector
<
GBoxes
<
device_grid
::
dims
>>
&
gdb_ext
)
:
g_c
(
0
),
gList
(
gk
),
gdb_ext
(
gdb_ext
)
{
// Initialize the current iterator
// with the first grid
selectValidGrid
();
}
// Destructor
~
grid_dist_iterator
()
{
}
/*! \brief Get the next element
*
* \return the next grid_key
*
*/
grid_dist_iterator
<
dim
,
device_grid
,
device_sub_it
,
FIXED
>
&
operator
++
()
{
++
a_it
;
// check if a_it is at the end
if
(
a_it
.
isNext
()
==
true
)
return
*
this
;
else
{
// switch to the new grid
g_c
++
;
selectValidGrid
();
}
return
*
this
;
}
/*! \brief Check if there is the next element
*
* \return true if there is the next, false otherwise
*
*/
bool
isNext
()
{
// If there are no other grid stop
if
(
g_c
>=
gList
.
size
())
return
false
;
return
true
;
}
/*! \brief Get the actual key
*
* \return the actual key
*
*/
grid_dist_key_dx
<
dim
>
get
()
{
return
grid_dist_key_dx
<
dim
>
(
g_c
,
a_it
.
get
());
}
/*! \brief Get the boxes
*
* Get the boxes that define the local grids
*
* \return Vector of local boxes
*
*/
inline
const
openfpm
::
vector
<
GBoxes
<
device_grid
::
dims
>>
&
getGBoxes
()
{
return
gdb_ext
;
}
/*! \brief Convert a g_dist_key_dx into a global key
*
* \see grid_dist_key_dx
* \see grid_dist_iterator
*
* \param k local coordinates to convert into global
*
* \return the global position in the grid
*
*/
inline
grid_key_dx
<
dim
>
getGKey
(
const
grid_dist_key_dx
<
dim
,
typename
device_grid
::
base_key
>
&
k
)
{
// Get the sub-domain id
size_t
sub_id
=
k
.
getSub
();
grid_key_dx
<
dim
>
k_glob
=
k
.
getKey
();
// shift
k_glob
=
k_glob
+
gdb_ext
.
get
(
sub_id
).
origin
;
return
k_glob
;
}
/*! \brief Return the stencil point offset
*
* \tparam id
*
* \return linearized distributed key
*
*/
template
<
unsigned
int
id
>
inline
grid_dist_lin_dx
getStencil
()
{
return
grid_dist_lin_dx
(
g_c
,
a_it
.
template
getStencil
<
id
>());
}
};
#endif
/* GRID_DIST_ID_ITERATOR_SUB_HPP_ */
src/Grid/grid_dist_id.hpp
View file @
b958b201
...
...
@@ -1798,9 +1798,13 @@ public:
#ifdef SE_CLASS2
check_valid
(
this
,
8
);
#endif
grid_key_dx
<
dim
>
stop
;
for
(
size_t
i
=
0
;
i
<
dim
;
i
++
)
{
stop
.
set_d
(
i
,
0
);}
grid_dist_iterator
<
dim
,
device_grid
,
decltype
(
device_grid
::
type_of_iterator
()),
FIXED
>
it
(
loc_grid
,
gdb_ext
);
FIXED
>
it
(
loc_grid
,
gdb_ext
,
stop
);
return
it
;
}
...
...
@@ -2399,6 +2403,10 @@ public:
*/
void
map
(
size_t
opt
=
0
)
{
// Save the background values
T
bv
;
meta_copy
<
T
>::
meta_copy_
(
bv
,
loc_grid
.
get
(
0
).
getBackgroundValue
());
if
(
!
(
opt
&
NO_GDB_EXT_SWITCH
))
{
gdb_ext_old
=
gdb_ext
;
...
...
@@ -2417,6 +2425,9 @@ public:
// reset ghost structure to recalculate
reset_ghost_structures
();
// Reset the background values
setBackgroundValue
(
bv
);
}
/*! \brief Save the grid state on HDF5
...
...
src/Grid/grid_dist_id_comm.hpp
View file @
b958b201
...
...
@@ -171,7 +171,7 @@ class grid_dist_id_comm
//! Memory for the ghost sending buffer
Memory
g_send_prp_mem
;
//! Memory for the ghost
send
ing buffer
//! Memory for the ghost
receiv
ing buffer
Memory
g_recv_prp_mem
;
/*! \brief Sync the local ghost part
...
...
@@ -1014,7 +1014,7 @@ public:
std
::
vector
<
size_t
>
prp_recv
;
// Create an object of preallocated memory for properties
ExtPreAlloc
<
Memory
>
&
prRecv_prp
=
*
(
new
ExtPreAlloc
<
Memory
>
(
tot_recv
,
g_recv_prp_mem
));
ExtPreAlloc
<
Memory
>
&
prRecv_prp
=
*
(
new
ExtPreAlloc
<
Memory
>
(
g_recv_prp_mem
.
size
()
,
g_recv_prp_mem
));
prRecv_prp
.
incRef
();
// Before wait for the communication to complete we sync the local ghost
...
...
src/Grid/tests/sgrid_dist_id_unit_tests.cpp
View file @
b958b201
...
...
@@ -11,6 +11,9 @@
#include "Grid/grid_dist_id.hpp"
#include "Point_test.hpp"
////////////////////////////////////// THEESE TEST ARE BROKEN TO REMPOVE OR FIX ////
const
int
x
=
0
;
const
int
y
=
1
;
const
int
z
=
2
;
...
...
@@ -34,7 +37,7 @@ BOOST_AUTO_TEST_CASE( sgrid_dist_id_basic_test_2D)
sgrid_dist_id
<
2
,
double
,
Point_test
<
float
>>
sg
(
sz
,
domain
,
g
,
bc
);
// create a grid iterator
over a bilion point
// create a grid iterator
auto
it
=
sg
.
getGridIterator
();
...
...
Write
Preview
Markdown
is supported
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