Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
solverstack
ScalFMM
Commits
c9c0457e
Commit
c9c0457e
authored
May 31, 2017
by
DUFOYER Benjamin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding information in BlockedLinearInformation
parent
b562c0b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
24 deletions
+62
-24
Src/GroupTree/Core/FBlockedLinearTree.hpp
Src/GroupTree/Core/FBlockedLinearTree.hpp
+62
-24
No files found.
Src/GroupTree/Core/FBlockedLinearTree.hpp
View file @
c9c0457e
...
...
@@ -5,13 +5,18 @@
#include "../../Utils/FLog.hpp"
#include "FDistributedGroupTreeBuilder.hpp"
using
FReal
=
double
;
template
<
class
node_t
>
class
FBlockedLinearTree
{
protected:
const
int
block_size
;
int
nb_leaf
;
const
FPoint
<
FReal
>
box_center
;
const
FReal
box_width
;
int
nb_block
;
std
::
vector
<
node_t
>*
linear_tree
;
...
...
@@ -30,18 +35,33 @@ public:
* @param in_linear_tree current linear_tree
* @param in_block_size block_size needed
*/
FBlockedLinearTree
(
const
int
in_block_size
,
std
::
vector
<
node_t
>*
in_linear_tree
)
:
FBlockedLinearTree
(
const
int
in_block_size
,
std
::
vector
<
node_t
>*
in_linear_tree
,
FPoint
<
FReal
>
in_box_center
,
FReal
in_box_width
)
:
block_size
(
in_block_size
),
nb_leaf
((
int
)
in_linear_tree
->
size
())
nb_leaf
((
int
)
in_linear_tree
->
size
()),
box_center
(
in_box_center
),
box_width
(
in_box_width
)
{
if
(
nb_leaf
%
block_size
==
0
)
this
->
nb_block
=
nb_leaf
/
block_size
;
else
this
->
nb_block
=
nb_leaf
/
block_size
+
1
;
init_blocked_linear_tree
(
in_linear_tree
);
}
std
::
swap
(
in_linear_tree
,
linear_tree
);
template
<
class
Box
>
FBlockedLinearTree
(
const
int
in_block_size
,
std
::
vector
<
node_t
>*
in_linear_tree
,
const
Box
box
,
int
dim
=
3
)
:
block_size
(
in_block_size
),
nb_leaf
((
int
)
in_linear_tree
->
size
()),
box_center
(
box
.
center
()),
box_width
(
box
.
width
(
dim
))
{
init_blocked_linear_tree
(
in_linear_tree
);
}
void
init_blocked_linear_tree
(
std
::
vector
<
node_t
>*
in_linear_tree
){
if
(
this
->
nb_leaf
%
this
->
block_size
==
0
)
this
->
nb_block
=
this
->
nb_leaf
/
this
->
block_size
;
else
this
->
nb_block
=
this
->
nb_leaf
/
this
->
block_size
+
1
;
std
::
swap
(
in_linear_tree
,
this
->
linear_tree
);
}
////////////////////////////////////////////////
// destructor
////////////////////////////////////////////////
...
...
@@ -97,21 +117,33 @@ public:
* @param num_block number of the block
* @return size of the block
*/
int
get_block_size_at
(
int
num_block
)
{
int
get_block_size_at
(
int
num_block
)
const
{
FAssertLF
(
num_block
<
this
->
nb_block
);
int
size
;
if
(
num_block
<
this
->
nb_block
){
if
(
num_block
==
this
->
nb_block
-
1
){
size
=
this
->
nb_leaf
-
((
this
->
nb_block
-
1
)
*
this
->
block_size
);
}
else
{
size
=
this
->
block_size
;
}
if
(
num_block
==
this
->
nb_block
-
1
){
size
=
this
->
nb_leaf
-
((
this
->
nb_block
-
1
)
*
this
->
block_size
);
}
else
{
FLOG
(
FLog
::
Controller
<<
"[ERROR][FBlockedLinearTree] Trying to access to undefined block, returning block_size "
<<
"
\n
"
);
size
=
this
->
block_size
;
}
return
size
;
}
int
get_idx_first_cell_for_block
(
int
num_block
){
FAssertLF
(
num_block
<
this
->
nb_block
);
return
this
->
block_size
*
num_block
;
}
int
get_idx_last_cell_for_block
(
int
num_block
){
FAssertLF
(
num_block
<
this
->
nb_block
);
int
last
;
//if it's the last block
if
(
num_block
==
(
this
->
nb_block
-
1
))
last
=
nb_leaf
-
1
;
else
last
=
(
this
->
block_size
*
(
num_block
+
1
))
-
1
;
return
last
;
}
/**
* get_leaf_at return the leaf at the position placed in parameter
* @author benjamin.dufoyer@inria.fr
...
...
@@ -119,20 +151,18 @@ public:
* @return the leaf
*/
node_t
get_leaf_at
(
int
position
){
node_t
leaf
;
if
(
position
<
this
->
nb_leaf
&&
position
>=
0
)
{
leaf
=
this
->
linear_tree
->
at
(
position
);
}
else
{
FLOG
(
FLog
::
Controller
<<
"[ERROR][FBlockedLinearTree] Trying to access to undefined leaf "
<<
"
\n
"
);
leaf
=
this
->
linear_tree
->
front
();
}
return
leaf
;
FAssertLF
(
position
<
this
->
nb_leaf
&&
position
>=
0
);
return
this
->
linear_tree
->
at
(
position
);
}
size_t
get_leaf_level
(){
size_t
get_leaf_level
()
const
{
return
this
->
linear_tree
->
front
().
level
;
}
size_t
get_tree_height
()
const
{
return
this
->
get_leaf_level
();
}
size_t
get_first_morton_index
(){
return
this
->
linear_tree
->
front
().
morton_index
;
}
...
...
@@ -150,6 +180,14 @@ public:
}
}
FPoint
<
FReal
>
get_box_center
()
const
{
return
this
->
box_center
;
}
FReal
get_box_width
()
const
{
return
this
->
box_width
;
}
};
#endif //_FBLOCKED_LINEAR_TREE_HPP_
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