Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
697e6fec
Commit
697e6fec
authored
Mar 25, 2015
by
BRAMAS Berenger
Browse files
move the computation of the particles box pos into a single class
parent
e5955c49
Changes
10
Hide whitespace changes
Inline
Side-by-side
Src/Containers/FCoordinateComputer.hpp
0 → 100644
View file @
697e6fec
#ifndef FCOORDINATECOMPUTER_HPP
#define FCOORDINATECOMPUTER_HPP
#include "../Utils/FGlobal.hpp"
#include "FTreeCoordinate.hpp"
#include "../Utils/FPoint.hpp"
#include "../Utils/FMath.hpp"
#include "../Utils/FAssert.hpp"
/**
* @brief The FCoordinateComputer struct is the main class to get the tree coordinate
* from the simulation box properties.
*/
struct
FCoordinateComputer
{
template
<
class
FReal
>
static
inline
int
GetTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidth
,
const
FReal
boxWidthAtLeafLevel
,
const
int
treeHeight
)
{
FAssertLF
(
(
inRelativePosition
>=
0
&&
inRelativePosition
<=
boxWidth
),
"inRelativePosition : "
,
inRelativePosition
,
" boxWidth "
,
boxWidth
);
if
(
inRelativePosition
==
boxWidth
){
return
FMath
::
pow2
(
treeHeight
-
1
)
-
1
;
}
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
return
static_cast
<
int
>
(
indexFReal
);
}
template
<
class
FReal
>
static
inline
FTreeCoordinate
GetCoordinateFromPosition
(
const
FPoint
<
FReal
>&
centerOfBox
,
const
FReal
boxWidth
,
const
int
treeHeight
,
const
FPoint
<
FReal
>&
pos
)
{
const
FPoint
<
FReal
>
boxCorner
(
centerOfBox
,
-
(
boxWidth
/
2
));
const
FReal
boxWidthAtLeafLevel
(
boxWidth
/
FReal
(
1
<<
(
treeHeight
-
1
)));
// box coordinate to host the particle
FTreeCoordinate
host
;
// position has to be relative to corner not center
host
.
setX
(
GetTreeCoordinate
<
FReal
>
(
pos
.
getX
()
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setY
(
GetTreeCoordinate
<
FReal
>
(
pos
.
getY
()
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setZ
(
GetTreeCoordinate
<
FReal
>
(
pos
.
getZ
()
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
return
host
;
}
template
<
class
FReal
>
static
inline
FTreeCoordinate
GetCoordinateFromPositionAndCorner
(
const
FPoint
<
FReal
>&
cornerOfBox
,
const
FReal
boxWidth
,
const
int
treeHeight
,
const
FPoint
<
FReal
>&
pos
)
{
const
FReal
boxWidthAtLeafLevel
(
boxWidth
/
FReal
(
1
<<
(
treeHeight
-
1
)));
// box coordinate to host the particle
FTreeCoordinate
host
;
// position has to be relative to corner not center
host
.
setX
(
GetTreeCoordinate
<
FReal
>
(
pos
.
getX
()
-
cornerOfBox
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setY
(
GetTreeCoordinate
<
FReal
>
(
pos
.
getY
()
-
cornerOfBox
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setZ
(
GetTreeCoordinate
<
FReal
>
(
pos
.
getZ
()
-
cornerOfBox
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
return
host
;
}
};
#endif // FCOORDINATECOMPUTER_HPP
Src/Containers/FOctree.hpp
View file @
697e6fec
...
...
@@ -29,7 +29,7 @@
#include "../Utils/FMath.hpp"
#include "../Utils/FNoCopyable.hpp"
#include "../Utils/FAssert.hpp"
#include "FCoordinateComputer.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
...
...
@@ -78,13 +78,7 @@ class FOctree : public FNoCopyable {
* @return the morton index
*/
FTreeCoordinate
getCoordinateFromPosition
(
const
FPoint
<
FReal
>&
inPosition
)
const
{
// box coordinate to host the particle
FTreeCoordinate
host
;
// position has to be relative to corner not center
host
.
setX
(
getTreeCoordinate
(
inPosition
.
getX
()
-
this
->
boxCorner
.
getX
()
));
host
.
setY
(
getTreeCoordinate
(
inPosition
.
getY
()
-
this
->
boxCorner
.
getY
()
));
host
.
setZ
(
getTreeCoordinate
(
inPosition
.
getZ
()
-
this
->
boxCorner
.
getZ
()
));
return
host
;
return
FCoordinateComputer
::
GetCoordinateFromPositionAndCorner
<
FReal
>
(
this
->
boxCorner
,
this
->
boxWidth
,
height
,
inPosition
);
}
/**
...
...
@@ -94,12 +88,7 @@ class FOctree : public FNoCopyable {
* @return the box num at the leaf level that contains inRelativePosition
*/
int
getTreeCoordinate
(
const
FReal
inRelativePosition
)
const
{
FAssertLF
(
(
inRelativePosition
>=
0
&&
inRelativePosition
<=
this
->
boxWidth
),
"inRelativePosition : "
,
inRelativePosition
);
if
(
inRelativePosition
==
this
->
boxWidth
){
return
FMath
::
pow2
(
height
-
1
)
-
1
;
}
const
FReal
indexFReal
=
inRelativePosition
/
this
->
boxWidthAtLevel
[
this
->
leafIndex
];
return
static_cast
<
int
>
(
indexFReal
);
return
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
inRelativePosition
,
this
->
boxWidth
,
this
->
boxWidthAtLevel
[
this
->
leafIndex
],
height
);
}
public:
...
...
Src/Files/FMpiTreeBuilder.hpp
View file @
697e6fec
...
...
@@ -27,6 +27,8 @@
#include "../BalanceTree/FLeafBalance.hpp"
#include "../BalanceTree/FEqualize.hpp"
#include "../Containers/FCoordinateComputer.hpp"
/**
* This class manage the loading of particles for the mpi version.
* It work in several steps.
...
...
@@ -45,19 +47,6 @@ private:
FSize
startingPoint
;
};
/**
* This method has been taken from the octree class,
* it computes a tree coordinate (x or y or z) from real cartesian position
*/
static
int
GetTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidthAtLeafLevel
,
const
FReal
boxWidth
,
const
int
height
)
{
FAssertLF
(
(
inRelativePosition
>=
0
&&
inRelativePosition
<=
boxWidth
),
"inRelativePosition : "
,
inRelativePosition
);
if
(
inRelativePosition
==
boxWidth
){
return
FMath
::
pow2
(
height
-
1
)
-
1
;
}
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
return
static_cast
<
int
>
(
indexFReal
);
}
public:
/** What sorting algorithm to use */
enum
SortingType
{
...
...
@@ -101,12 +90,12 @@ public:
// Fill the array and compute the morton index
for
(
int
idxPart
=
0
;
idxPart
<
loader
.
getNumberOfParticles
()
;
++
idxPart
){
loader
.
fillParticle
(
originalParticlesUnsorted
[
idxPart
].
particle
);
host
.
setX
(
GetTreeCoordinate
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidthAtLeafLevel
,
loader
.
getBoxWidth
(),
TreeHeight
));
host
.
setY
(
GetTreeCoordinate
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidthAtLeafLevel
,
loader
.
getBoxWidth
(),
TreeHeight
));
host
.
setZ
(
GetTreeCoordinate
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidthAtLeafLevel
,
loader
.
getBoxWidth
(),
TreeHeight
));
host
.
setX
(
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getX
()
-
boxCorner
.
getX
(),
loader
.
getBoxWidth
(),
boxWidthAtLeafLevel
,
TreeHeight
));
host
.
setY
(
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getY
()
-
boxCorner
.
getY
(),
loader
.
getBoxWidth
(),
boxWidthAtLeafLevel
,
TreeHeight
));
host
.
setZ
(
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
loader
.
getBoxWidth
(),
boxWidthAtLeafLevel
,
TreeHeight
));
originalParticlesUnsorted
[
idxPart
].
index
=
host
.
getMortonIndex
(
TreeHeight
-
1
);
}
...
...
@@ -138,12 +127,12 @@ public:
// Fill the array and compute the morton index
for
(
int
idxPart
=
0
;
idxPart
<
originalNbParticles
;
++
idxPart
){
originalParticlesUnsorted
[
idxPart
].
particle
=
inOriginalParticles
[
idxPart
];
host
.
setX
(
GetTreeCoordinate
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidthAtLeafLevel
,
boxWidth
,
TreeHeight
));
host
.
setY
(
GetTreeCoordinate
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidthAtLeafLevel
,
boxWidth
,
TreeHeight
));
host
.
setZ
(
GetTreeCoordinate
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidthAtLeafLevel
,
boxWidth
,
TreeHeight
));
host
.
setX
(
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
TreeHeight
));
host
.
setY
(
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
TreeHeight
));
host
.
setZ
(
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
originalParticlesUnsorted
[
idxPart
].
particle
.
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
TreeHeight
));
originalParticlesUnsorted
[
idxPart
].
index
=
host
.
getMortonIndex
(
TreeHeight
-
1
);
}
...
...
Src/Files/FTreeBuilder.hpp
View file @
697e6fec
...
...
@@ -23,6 +23,7 @@
#include "../Utils/FTic.hpp"
#include "../Utils/FAssert.hpp"
#include "../Containers/FOctree.hpp"
#include "../Containers/FTreeCoordinate.hpp"
#include "../Components/FBasicParticleContainer.hpp"
...
...
@@ -47,20 +48,6 @@
template
<
class
FReal
,
class
OctreeClass
,
class
LeafClass
>
class
FTreeBuilder
{
private:
/**
* This method has been taken from the octree class,
* it computes a tree coordinate (x or y or z) from real cartesian position
*/
static
int
GetTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidthAtLeafLevel
,
const
FReal
boxWidth
,
const
int
height
)
{
FAssertLF
(
(
inRelativePosition
>=
0
&&
inRelativePosition
<=
boxWidth
),
"inRelativePosition : "
,
inRelativePosition
);
if
(
inRelativePosition
==
boxWidth
){
return
FMath
::
pow2
(
height
-
1
)
-
1
;
}
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
return
static_cast
<
int
>
(
indexFReal
);
}
/** This class is the relation between particles and their morton idx */
struct
IndexedParticle
{
MortonIndex
mindex
;
...
...
@@ -112,12 +99,12 @@ public:
for
(
int
idxParts
=
0
;
idxParts
<
numberOfParticle
;
++
idxParts
){
// Get the Morton Index
const
FTreeCoordinate
host
(
GetTreeCoordinate
(
particlesContainers
.
getPositions
()[
0
][
idxParts
]
-
boxCorner
.
getX
(),
boxWidthAtLeafLevel
,
boxWidth
,
NbLevels
),
GetTreeCoordinate
(
particlesContainers
.
getPositions
()[
1
][
idxParts
]
-
boxCorner
.
getY
(),
boxWidthAtLeafLevel
,
boxWidth
,
NbLevels
),
GetTreeCoordinate
(
particlesContainers
.
getPositions
()[
2
][
idxParts
]
-
boxCorner
.
getZ
(),
boxWidthAtLeafLevel
,
boxWidth
,
NbLevels
)
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
particlesContainers
.
getPositions
()[
0
][
idxParts
]
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
),
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
particlesContainers
.
getPositions
()[
1
][
idxParts
]
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
),
FCoordinateComputer
::
GetTreeCoordinate
<
FReal
>
(
particlesContainers
.
getPositions
()[
2
][
idxParts
]
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
)
);
// Store morton index and original idx
particleIndexes
[
idxParts
].
mindex
=
host
.
getMortonIndex
(
NbLevels
-
1
);
...
...
Src/GroupTree/Core/FGroupTree.hpp
View file @
697e6fec
...
...
@@ -10,7 +10,7 @@
#include "../../Utils/FPoint.hpp"
#include "../../Utils/FQuickSort.hpp"
#include "../../Containers/FTreeCoordinate.hpp"
#include "../../Containers/FCoordinateComputer.hpp"
#include "FGroupOfCells.hpp"
#include "FGroupOfParticles.hpp"
#include "FGroupAttachedLeaf.hpp"
...
...
@@ -47,27 +47,6 @@ protected:
//< the width of a box at width level
const
FReal
boxWidthAtLeafLevel
;
int
getTreeCoordinate
(
const
FReal
inRelativePosition
)
const
{
FAssertLF
(
(
inRelativePosition
>=
0
&&
inRelativePosition
<=
this
->
boxWidth
),
"inRelativePosition : "
,
inRelativePosition
);
if
(
inRelativePosition
==
this
->
boxWidth
){
return
FMath
::
pow2
(
treeHeight
-
1
)
-
1
;
}
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
return
static_cast
<
int
>
(
indexFReal
);
}
FTreeCoordinate
getCoordinateFromPosition
(
const
FReal
xpos
,
const
FReal
ypos
,
const
FReal
zpos
)
const
{
// box coordinate to host the particle
FTreeCoordinate
host
;
// position has to be relative to corner not center
host
.
setX
(
getTreeCoordinate
(
xpos
-
this
->
boxCorner
.
getX
()
));
host
.
setY
(
getTreeCoordinate
(
ypos
-
this
->
boxCorner
.
getY
()
));
host
.
setZ
(
getTreeCoordinate
(
zpos
-
this
->
boxCorner
.
getZ
()
));
return
host
;
}
public:
typedef
typename
std
::
vector
<
CellGroupClass
*>::
iterator
CellGroupIterator
;
typedef
typename
std
::
vector
<
CellGroupClass
*>::
const_iterator
CellGroupConstIterator
;
...
...
@@ -224,7 +203,9 @@ public:
const
FReal
*
zpos
=
inParticlesContainer
->
getPositions
()[
2
];
for
(
int
idxPart
=
0
;
idxPart
<
nbParticles
;
++
idxPart
){
const
FTreeCoordinate
host
=
getCoordinateFromPosition
(
xpos
[
idxPart
],
ypos
[
idxPart
],
zpos
[
idxPart
]
);
const
FTreeCoordinate
host
=
FCoordinateComputer
::
GetCoordinateFromPositionAndCorner
<
FReal
>
(
this
->
boxCorner
,
this
->
boxWidth
,
treeHeight
,
FPoint
<
FReal
>
(
xpos
[
idxPart
],
ypos
[
idxPart
],
zpos
[
idxPart
])
);
const
MortonIndex
particleIndex
=
host
.
getMortonIndex
(
treeHeight
-
1
);
particlesToSort
[
idxPart
].
mindex
=
particleIndex
;
particlesToSort
[
idxPart
].
originalIndex
=
idxPart
;
...
...
@@ -401,7 +382,9 @@ public:
const
FReal
*
zpos
=
inParticlesContainer
->
getPositions
()[
2
];
for
(
int
idxPart
=
0
;
idxPart
<
nbParticles
;
++
idxPart
){
const
FTreeCoordinate
host
=
getCoordinateFromPosition
(
xpos
[
idxPart
],
ypos
[
idxPart
],
zpos
[
idxPart
]
);
const
FTreeCoordinate
host
=
FCoordinateComputer
::
GetCoordinateFromPosition
<
FReal
>
(
this
->
boxCorner
,
this
->
boxWidth
,
treeHeight
,
FPoint
<
FReal
>
(
xpos
[
idxPart
],
ypos
[
idxPart
],
zpos
[
idxPart
])
);
const
MortonIndex
particleIndex
=
host
.
getMortonIndex
(
treeHeight
-
1
);
particlesToSort
[
idxPart
].
mindex
=
particleIndex
;
particlesToSort
[
idxPart
].
originalIndex
=
idxPart
;
...
...
Tests/noDist/testBlockedMpiAlgorithm.cpp
View file @
697e6fec
...
...
@@ -38,37 +38,12 @@
#include "../../Src/Files/FMpiTreeBuilder.hpp"
#include "../../Src/Core/FFmmAlgorithm.hpp"
#include "../../Src/Containers/FCoordinateComputer.hpp"
#include "../../Src/GroupTree/StarPUUtils/FStarPUKernelCapacities.hpp"
#include "../../Src/GroupTree/StarPUUtils/FStarPUCpuWrapper.hpp"
template
<
class
FReal
>
int
getTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidth
,
const
FReal
boxWidthAtLeafLevel
,
const
int
treeHeight
)
{
FAssertLF
(
(
inRelativePosition
>=
0
&&
inRelativePosition
<=
boxWidth
),
"inRelativePosition : "
,
inRelativePosition
);
if
(
inRelativePosition
==
boxWidth
){
return
FMath
::
pow2
(
treeHeight
-
1
)
-
1
;
}
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
return
static_cast
<
int
>
(
indexFReal
);
}
template
<
class
FReal
>
FTreeCoordinate
getCoordinateFromPosition
(
const
FPoint
<
FReal
>&
centerOfBox
,
const
FReal
boxWidth
,
const
int
treeHeight
,
const
FPoint
<
FReal
>&
pos
)
{
const
FPoint
<
FReal
>
boxCorner
(
centerOfBox
,
-
(
boxWidth
/
2
));
const
FReal
boxWidthAtLeafLevel
(
boxWidth
/
FReal
(
1
<<
(
treeHeight
-
1
)));
// box coordinate to host the particle
FTreeCoordinate
host
;
// position has to be relative to corner not center
host
.
setX
(
getTreeCoordinate
(
pos
.
getX
()
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setY
(
getTreeCoordinate
(
pos
.
getY
()
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setZ
(
getTreeCoordinate
(
pos
.
getZ
()
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
return
host
;
}
int
main
(
int
argc
,
char
*
argv
[]){
...
...
@@ -138,7 +113,7 @@ int main(int argc, char* argv[]){
}
// Each proc need to know the righest morton index
const
FTreeCoordinate
host
=
g
etCoordinateFromPosition
(
const
FTreeCoordinate
host
=
FCoordinateComputer
::
G
etCoordinateFromPosition
<
FReal
>
(
loader
.
getCenterOfBox
(),
loader
.
getBoxWidth
(),
NbLevels
,
...
...
Tests/noDist/testBlockedMpiChebyshev.cpp
View file @
697e6fec
...
...
@@ -44,39 +44,13 @@
#include "../../Src/GroupTree/Core/FGroupTaskStarpuMpiAlgorithm.hpp"
#include "../../Src/Files/FMpiFmaGenericLoader.hpp"
#include "../../Src/Containers/FCoordinateComputer.hpp"
#include "../../Src/GroupTree/StarPUUtils/FStarPUKernelCapacities.hpp"
#include <memory>
template
<
class
FReal
>
int
getTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidth
,
const
FReal
boxWidthAtLeafLevel
,
const
int
treeHeight
)
{
FAssertLF
(
(
inRelativePosition
>=
0
&&
inRelativePosition
<=
boxWidth
),
"inRelativePosition : "
,
inRelativePosition
);
if
(
inRelativePosition
==
boxWidth
){
return
FMath
::
pow2
(
treeHeight
-
1
)
-
1
;
}
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
return
static_cast
<
int
>
(
indexFReal
);
}
template
<
class
FReal
>
FTreeCoordinate
getCoordinateFromPosition
(
const
FPoint
<
FReal
>&
centerOfBox
,
const
FReal
boxWidth
,
const
int
treeHeight
,
const
FPoint
<
FReal
>&
pos
)
{
const
FPoint
<
FReal
>
boxCorner
(
centerOfBox
,
-
(
boxWidth
/
2
));
const
FReal
boxWidthAtLeafLevel
(
boxWidth
/
FReal
(
1
<<
(
treeHeight
-
1
)));
// box coordinate to host the particle
FTreeCoordinate
host
;
// position has to be relative to corner not center
host
.
setX
(
getTreeCoordinate
(
pos
.
getX
()
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setY
(
getTreeCoordinate
(
pos
.
getY
()
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
host
.
setZ
(
getTreeCoordinate
(
pos
.
getZ
()
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
treeHeight
));
return
host
;
}
int
main
(
int
argc
,
char
*
argv
[]){
const
FParameterNames
LocalOptionBlocSize
{
{
"-bs"
},
"The size of the block of the blocked tree"
};
const
FParameterNames
LocalOptionNoValidate
{
{
"-no-validation"
},
"To avoid comparing with direct computation"
};
...
...
@@ -147,7 +121,7 @@ int main(int argc, char* argv[]){
std
::
cout
<<
"
\t
Height : "
<<
TreeHeight
<<
"
\t
sub-height : "
<<
SubTreeHeight
<<
std
::
endl
;
// Each proc need to know the righest morton index
const
FTreeCoordinate
host
=
g
etCoordinateFromPosition
(
const
FTreeCoordinate
host
=
FCoordinateComputer
::
G
etCoordinateFromPosition
<
FReal
>
(
loader
.
getCenterOfBox
(),
loader
.
getBoxWidth
(),
TreeHeight
,
...
...
Tests/noDist/testInsert.cpp
View file @
697e6fec
...
...
@@ -49,6 +49,7 @@
#include "../../Src/Utils/FParameterNames.hpp"
#include "Containers/FOctree.hpp"
#include "Containers/FCoordinateComputer.hpp"
#ifdef _OPENMP
#include "Core/FFmmAlgorithmThread.hpp"
...
...
@@ -59,22 +60,6 @@
#include "Utils/FTemplate.hpp"
/** This method has been tacken from the octree
* it computes a tree coordinate (x or y or z) from real position
*/
template
<
class
FReal
>
static
int
getTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidthAtLeafLevel
)
{
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
const
int
index
=
int
(
FMath
::
dfloor
(
indexFReal
));
if
(
index
&&
FMath
::
LookEqual
(
inRelativePosition
,
boxWidthAtLeafLevel
*
FReal
(
index
)
)
){
return
index
-
1
;
}
return
index
;
}
/**
* This program build a tree and insert the parts inside.
* Time needed for the insert is outputed
...
...
@@ -195,9 +180,9 @@ int main(int argc, char** argv){
for
(
int
idxPart
=
0
;
idxPart
<
nbOfParticles
;
++
idxPart
){
loader
.
fillParticle
(
&
arrayOfParts
[
idxPart
].
position
,
&
arrayOfParts
[
idxPart
].
physicalValue
);
//Build temporary TreeCoordinate
host
.
setX
(
g
etTreeCoordinate
(
arrayOfParts
[
idxPart
].
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidthAtLeafLevel
));
host
.
setY
(
g
etTreeCoordinate
(
arrayOfParts
[
idxPart
].
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidthAtLeafLevel
));
host
.
setZ
(
g
etTreeCoordinate
(
arrayOfParts
[
idxPart
].
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidthAtLeafLevel
));
host
.
setX
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParts
[
idxPart
].
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
));
host
.
setY
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParts
[
idxPart
].
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
));
host
.
setZ
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParts
[
idxPart
].
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
));
//Set Morton index from Tree Coordinate
arrayOfParts
[
idxPart
].
index
=
host
.
getMortonIndex
(
NbLevels
-
1
);
...
...
Tests/noDist/testTreeBuilder.cpp
View file @
697e6fec
...
...
@@ -50,6 +50,7 @@
#include "../../Src/Utils/FParameterNames.hpp"
#include "Containers/FOctree.hpp"
#include "Containers/FCoordinateComputer.hpp"
#ifdef _OPENMP
#include "Core/FFmmAlgorithmThread.hpp"
...
...
@@ -61,20 +62,6 @@
/** This method has been tacken from the octree
* it computes a tree coordinate (x or y or z) from real position
*/
template
<
class
FReal
>
static
int
getTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidthAtLeafLevel
)
{
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
const
int
index
=
int
(
FMath
::
dfloor
(
indexFReal
));
if
(
index
&&
FMath
::
LookEqual
(
inRelativePosition
,
boxWidthAtLeafLevel
*
FReal
(
index
)
)
){
return
index
-
1
;
}
return
index
;
}
/**
* This program build a tree and insert the parts inside.
...
...
@@ -189,9 +176,9 @@ int main(int argc, char** argv){
for
(
int
idxPart
=
0
;
idxPart
<
nbOfParticles
;
++
idxPart
){
loader
.
fillParticle
(
&
arrayOfParts
[
idxPart
].
position
,
&
arrayOfParts
[
idxPart
].
physicalValue
);
//Build temporary TreeCoordinate
host
.
setX
(
g
etTreeCoordinate
(
arrayOfParts
[
idxPart
].
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidthAtLeafLevel
));
host
.
setY
(
g
etTreeCoordinate
(
arrayOfParts
[
idxPart
].
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidthAtLeafLevel
));
host
.
setZ
(
g
etTreeCoordinate
(
arrayOfParts
[
idxPart
].
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidthAtLeafLevel
));
host
.
setX
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParts
[
idxPart
].
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
));
host
.
setY
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParts
[
idxPart
].
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
));
host
.
setZ
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParts
[
idxPart
].
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
NbLevels
));
//Set Morton index from Tree Coordinate
arrayOfParts
[
idxPart
].
index
=
host
.
getMortonIndex
(
NbLevels
-
1
);
...
...
UTests/utestMpiTreeBuilder.cpp
View file @
697e6fec
...
...
@@ -34,7 +34,7 @@
#include "Files/FMpiFmaGenericLoader.hpp"
#include "BalanceTree/FLeafBalance.hpp"
#include "Containers/FTreeCoordinate.hpp"
#include "Containers/FCoordinateComputer.hpp"
#include "Utils/FQuickSortMpi.hpp"
#include "Utils/FBitonicSort.hpp"
...
...
@@ -46,18 +46,6 @@
class
TestMpiTreeBuilder
:
public
FUTesterMpi
<
class
TestMpiTreeBuilder
>
{
/** This method has been tacken from the octree
* it computes a tree coordinate (x or y or z) from real position
*/
template
<
class
FReal
>
static
int
getTreeCoordinate
(
const
FReal
inRelativePosition
,
const
FReal
boxWidthAtLeafLevel
)
{
const
FReal
indexFReal
=
inRelativePosition
/
boxWidthAtLeafLevel
;
const
int
index
=
int
(
FMath
::
dfloor
(
indexFReal
));
if
(
index
&&
FMath
::
LookEqual
(
inRelativePosition
,
boxWidthAtLeafLevel
*
FReal
(
index
)
)
){
return
index
-
1
;
}
return
index
;
}
template
<
class
FReal
>
struct
TestParticle
{
...
...
@@ -136,9 +124,9 @@ class TestMpiTreeBuilder : public FUTesterMpi< class TestMpiTreeBuilder> {
arrayOfParticles
[
idxParts
].
indexInFile
=
idxParts
;
//Build temporary TreeCoordinate
host
.
setX
(
g
etTreeCoordinate
(
arrayOfParticles
[
idxParts
].
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidthAtLeafLevel
));
host
.
setY
(
g
etTreeCoordinate
(
arrayOfParticles
[
idxParts
].
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidthAtLeafLevel
));
host
.
setZ
(
g
etTreeCoordinate
(
arrayOfParticles
[
idxParts
].
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidthAtLeafLevel
));
host
.
setX
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParticles
[
idxParts
].
getPosition
().
getX
()
-
boxCorner
.
getX
(),
boxWidth
,
boxWidthAtLeafLevel
,
TreeHeight
));
host
.
setY
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParticles
[
idxParts
].
getPosition
().
getY
()
-
boxCorner
.
getY
(),
boxWidth
,
boxWidthAtLeafLevel
,
TreeHeight
));
host
.
setZ
(
FCoordinateComputer
::
G
etTreeCoordinate
<
FReal
>
(
arrayOfParticles
[
idxParts
].
getPosition
().
getZ
()
-
boxCorner
.
getZ
(),
boxWidth
,
boxWidthAtLeafLevel
,
TreeHeight
));
//Set Morton index from Tree Coordinate
arrayOfParticles
[
idxParts
].
index
=
host
.
getMortonIndex
(
TreeHeight
-
1
);
...
...
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