Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
solverstack
ScalFMM
Commits
25204605
Commit
25204605
authored
Jan 30, 2015
by
BRAMAS Berenger
Browse files
Prepare the algorithm in order to work in specific level of the tree
parent
914b3dc1
Changes
10
Hide whitespace changes
Inline
Side-by-side
Src/Core/FCoreCommon.hpp
View file @
25204605
...
...
@@ -41,17 +41,55 @@ enum FFmmOperations {
*/
class
FAbstractAlgorithm
{
protected:
//< Where to start the work
int
upperWorkingLevel
;
//< Where to end the work (exclusif)
int
lowerWorkingLevel
;
//< Height of the tree
int
nbLevelsInTree
;
void
setNbLevelsInTree
(
const
int
inNbLevelsInTree
){
nbLevelsInTree
=
inNbLevelsInTree
;
lowerWorkingLevel
=
nbLevelsInTree
;
}
virtual
void
executeCore
(
const
unsigned
operationsToProceed
)
=
0
;
public:
FAbstractAlgorithm
()
:
upperWorkingLevel
(
2
),
lowerWorkingLevel
(
0
),
nbLevelsInTree
(
-
1
){
}
virtual
~
FAbstractAlgorithm
(){
}
/** Execute all the fmm but for given levels*/
virtual
void
execute
(
const
int
inUpperWorkingLevel
,
const
int
inLowerWorkingLevel
)
final
{
upperWorkingLevel
=
inUpperWorkingLevel
;
lowerWorkingLevel
=
inLowerWorkingLevel
;
executeCore
(
FFmmNearAndFarFields
);
}
/** Execute all the fmm */
void
execute
(){
execute
(
FFmmNearAndFarFields
);
virtual
void
execute
()
final
{
upperWorkingLevel
=
2
;
lowerWorkingLevel
=
nbLevelsInTree
;
executeCore
(
FFmmNearAndFarFields
);
}
/** Execute only some FMM operation for given levels */
virtual
void
execute
(
const
unsigned
operationsToProceed
,
const
int
inUpperWorkingLevel
,
const
int
inLowerWorkingLevel
)
final
{
upperWorkingLevel
=
inUpperWorkingLevel
;
lowerWorkingLevel
=
inLowerWorkingLevel
;
executeCore
(
operationsToProceed
);
}
/** Execute only some steps */
virtual
void
execute
(
const
unsigned
operationsToProceed
)
=
0
;
virtual
void
execute
(
const
unsigned
operationsToProceed
)
final
{
upperWorkingLevel
=
2
;
lowerWorkingLevel
=
nbLevelsInTree
;
executeCore
(
operationsToProceed
);
}
};
...
...
Src/Core/FFmmAlgorithm.hpp
View file @
25204605
...
...
@@ -60,6 +60,8 @@ public:
FAssertLF
(
tree
,
"tree cannot be null"
);
FAssertLF
(
kernels
,
"kernels cannot be null"
);
FAbstractAlgorithm
::
setNbLevelsInTree
(
tree
->
getHeight
());
FLOG
(
FLog
::
Controller
<<
"FFmmAlgorithm
\n
"
);
}
...
...
@@ -67,11 +69,12 @@ public:
virtual
~
FFmmAlgorithm
(){
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
Timers
[
P2MTimer
].
tic
();
if
(
operationsToProceed
&
FFmmP2M
)
bottomPass
();
...
...
@@ -94,7 +97,6 @@ public:
Timers
[
NearTimer
].
tac
();
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
...
...
Src/Core/FFmmAlgorithmPeriodic.hpp
View file @
25204605
...
...
@@ -78,11 +78,77 @@ public:
kernels
=
inKernel
;
}
long
long
int
theoricalRepetition
()
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// we know it is 3 (-1;+1)
return
3
;
}
// Else we find the repetition in one dir and double it
const
long
long
int
oneDirectionRepetition
=
(
1
<<
(
nbLevelsAboveRoot
+
2
));
// 2^nbLevelsAboveRoot in each dim
const
long
long
int
fullRepetition
=
2
*
oneDirectionRepetition
;
return
fullRepetition
;
}
void
repetitionsIntervals
(
FTreeCoordinate
*
const
min
,
FTreeCoordinate
*
const
max
)
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// We know it is (-1;1)
min
->
setPosition
(
-
1
,
-
1
,
-
1
);
max
->
setPosition
(
1
,
1
,
1
);
}
else
{
const
int
halfRepeated
=
int
(
theoricalRepetition
()
/
2
);
min
->
setPosition
(
-
halfRepeated
,
-
halfRepeated
,
-
halfRepeated
);
// if we repeat the box 8 times, we go from [-4 to 3]
max
->
setPosition
(
halfRepeated
-
1
,
halfRepeated
-
1
,
halfRepeated
-
1
);
}
}
FReal
extendedBoxWidth
()
const
{
// The simulation box is repeated is repeated 4 times if nbLevelsAboveRoot==-1
// And then it doubles by two
return
tree
->
getBoxWidth
()
*
FReal
(
1
<<
(
nbLevelsAboveRoot
+
3
));
}
/** This function has to be used to init the kernel with correct args
* it return the box cneter seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalBoxWidth and originalBoxCenter given in parameter
* @param originalBoxCenter the real system center
* @param originalBoxWidth the real system size
* @return the center the kernel should use
*/
FPoint
extendedBoxCenter
()
const
{
const
FReal
originalBoxWidth
=
tree
->
getBoxWidth
();
const
FReal
originalBoxWidthDiv2
=
originalBoxWidth
/
2.0
;
const
FPoint
originalBoxCenter
=
tree
->
getBoxCenter
();
const
FReal
offset
=
extendedBoxWidth
()
/
FReal
(
2.0
);
return
FPoint
(
originalBoxCenter
.
getX
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getY
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getZ
()
-
originalBoxWidthDiv2
+
offset
);
}
/** This function has to be used to init the kernel with correct args
* it return the tree heigh seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalTreeHeight given in parameter
* @param originalTreeHeight the real tree heigh
* @return the heigh the kernel should use
*/
int
extendedTreeHeight
()
const
{
// The real height
return
OctreeHeight
+
offsetRealTree
;
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
FAssertLF
(
kernels
,
"kernels cannot be null"
);
if
(
operationsToProceed
&
FFmmP2M
)
bottomPass
();
...
...
@@ -346,69 +412,6 @@ public:
return
(((
x
+
3
)
*
7
)
+
(
y
+
3
))
*
7
+
(
z
+
3
);
}
long
long
int
theoricalRepetition
()
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// we know it is 3 (-1;+1)
return
3
;
}
// Else we find the repetition in one dir and double it
const
long
long
int
oneDirectionRepetition
=
(
1
<<
(
nbLevelsAboveRoot
+
2
));
// 2^nbLevelsAboveRoot in each dim
const
long
long
int
fullRepetition
=
2
*
oneDirectionRepetition
;
return
fullRepetition
;
}
void
repetitionsIntervals
(
FTreeCoordinate
*
const
min
,
FTreeCoordinate
*
const
max
)
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// We know it is (-1;1)
min
->
setPosition
(
-
1
,
-
1
,
-
1
);
max
->
setPosition
(
1
,
1
,
1
);
}
else
{
const
int
halfRepeated
=
int
(
theoricalRepetition
()
/
2
);
min
->
setPosition
(
-
halfRepeated
,
-
halfRepeated
,
-
halfRepeated
);
// if we repeat the box 8 times, we go from [-4 to 3]
max
->
setPosition
(
halfRepeated
-
1
,
halfRepeated
-
1
,
halfRepeated
-
1
);
}
}
FReal
extendedBoxWidth
()
const
{
// The simulation box is repeated is repeated 4 times if nbLevelsAboveRoot==-1
// And then it doubles by two
return
tree
->
getBoxWidth
()
*
FReal
(
1
<<
(
nbLevelsAboveRoot
+
3
));
}
/** This function has to be used to init the kernel with correct args
* it return the box cneter seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalBoxWidth and originalBoxCenter given in parameter
* @param originalBoxCenter the real system center
* @param originalBoxWidth the real system size
* @return the center the kernel should use
*/
FPoint
extendedBoxCenter
()
const
{
const
FReal
originalBoxWidth
=
tree
->
getBoxWidth
();
const
FReal
originalBoxWidthDiv2
=
originalBoxWidth
/
2.0
;
const
FPoint
originalBoxCenter
=
tree
->
getBoxCenter
();
const
FReal
offset
=
extendedBoxWidth
()
/
FReal
(
2.0
);
return
FPoint
(
originalBoxCenter
.
getX
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getY
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getZ
()
-
originalBoxWidthDiv2
+
offset
);
}
/** This function has to be used to init the kernel with correct args
* it return the tree heigh seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalTreeHeight given in parameter
* @param originalTreeHeight the real tree heigh
* @return the heigh the kernel should use
*/
int
extendedTreeHeight
()
const
{
// The real height
return
OctreeHeight
+
offsetRealTree
;
}
/** Periodicity Core
* This function is split in several part:
* 1 - special case managment
...
...
Src/Core/FFmmAlgorithmSectionTask.hpp
View file @
25204605
...
...
@@ -83,11 +83,12 @@ public:
delete
[]
this
->
kernels
;
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
#pragma omp parallel
{
...
...
@@ -115,7 +116,6 @@ public:
}
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
...
...
Src/Core/FFmmAlgorithmTask.hpp
View file @
25204605
...
...
@@ -83,11 +83,12 @@ public:
delete
[]
this
->
kernels
;
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
if
(
operationsToProceed
&
FFmmP2M
)
bottomPass
();
...
...
@@ -100,7 +101,6 @@ public:
if
((
operationsToProceed
&
FFmmP2P
)
||
(
operationsToProceed
&
FFmmL2P
))
directPass
((
operationsToProceed
&
FFmmP2P
),(
operationsToProceed
&
FFmmL2P
));
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
...
...
Src/Core/FFmmAlgorithmThread.hpp
View file @
25204605
...
...
@@ -92,11 +92,12 @@ public:
delete
[]
this
->
kernels
;
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
for
(
int
idxShape
=
0
;
idxShape
<
SizeShape
;
++
idxShape
){
this
->
shapeLeaf
[
idxShape
]
=
0
;
...
...
@@ -139,7 +140,6 @@ public:
iterArray
=
nullptr
;
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
...
...
Src/Core/FFmmAlgorithmThreadProc.hpp
View file @
25204605
...
...
@@ -164,11 +164,12 @@ public:
delete
[]
workingIntervalsPerLevel
;
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
// Count leaf
this
->
numberOfLeafs
=
0
;
{
...
...
@@ -279,8 +280,6 @@ public:
iterArrayComm
=
nullptr
;
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
...
...
Src/Core/FFmmAlgorithmThreadProcPeriodic.hpp
View file @
25204605
...
...
@@ -162,11 +162,78 @@ public:
delete
[]
workingIntervalsPerLevel
;
}
long
long
int
theoricalRepetition
()
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// we know it is 3 (-1;+1)
return
3
;
}
// Else we find the repetition in one dir and double it
const
long
long
int
oneDirectionRepetition
=
(
1
<<
(
nbLevelsAboveRoot
+
2
));
// 2^nbLevelsAboveRoot in each dim
const
long
long
int
fullRepetition
=
2
*
oneDirectionRepetition
;
return
fullRepetition
;
}
void
repetitionsIntervals
(
FTreeCoordinate
*
const
min
,
FTreeCoordinate
*
const
max
)
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// We know it is (-1;1)
min
->
setPosition
(
-
1
,
-
1
,
-
1
);
max
->
setPosition
(
1
,
1
,
1
);
}
else
{
const
int
halfRepeated
=
int
(
theoricalRepetition
()
/
2
);
min
->
setPosition
(
-
halfRepeated
,
-
halfRepeated
,
-
halfRepeated
);
// if we repeat the box 8 times, we go from [-4 to 3]
max
->
setPosition
(
halfRepeated
-
1
,
halfRepeated
-
1
,
halfRepeated
-
1
);
}
}
FReal
extendedBoxWidth
()
const
{
// The simulation box is repeated is repeated 4 times if nbLevelsAboveRoot==-1
// And then it doubles by two
return
tree
->
getBoxWidth
()
*
FReal
(
1
<<
(
nbLevelsAboveRoot
+
3
));
}
/** This function has to be used to init the kernel with correct args
* it return the box cneter seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalBoxWidth and originalBoxCenter given in parameter
* @param originalBoxCenter the real system center
* @param originalBoxWidth the real system size
* @return the center the kernel should use
*/
FPoint
extendedBoxCenter
()
const
{
const
FReal
originalBoxWidth
=
tree
->
getBoxWidth
();
const
FReal
originalBoxWidthDiv2
=
originalBoxWidth
/
2.0
;
const
FPoint
originalBoxCenter
=
tree
->
getBoxCenter
();
const
FReal
offset
=
extendedBoxWidth
()
/
FReal
(
2.0
);
return
FPoint
(
originalBoxCenter
.
getX
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getY
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getZ
()
-
originalBoxWidthDiv2
+
offset
);
}
/** This function has to be used to init the kernel with correct args
* it return the tree heigh seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalTreeHeight given in parameter
* @param originalTreeHeight the real tree heigh
* @return the heigh the kernel should use
*/
int
extendedTreeHeight
()
const
{
// The real height
return
OctreeHeight
+
offsetRealTree
;
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
// Count leaf
this
->
numberOfLeafs
=
0
;
{
...
...
@@ -259,8 +326,6 @@ public:
iterArrayComm
=
nullptr
;
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
...
...
@@ -1783,7 +1848,6 @@ private:
/////////////////////////////////////////////////////////////////////////////
// Periodic levels = levels <= 0
/////////////////////////////////////////////////////////////////////////////
public:
/** Get the index of a interaction neighbors (for M2L)
...
...
@@ -1796,69 +1860,6 @@ public:
return
(((
x
+
3
)
*
7
)
+
(
y
+
3
))
*
7
+
(
z
+
3
);
}
long
long
int
theoricalRepetition
()
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// we know it is 3 (-1;+1)
return
3
;
}
// Else we find the repetition in one dir and double it
const
long
long
int
oneDirectionRepetition
=
(
1
<<
(
nbLevelsAboveRoot
+
2
));
// 2^nbLevelsAboveRoot in each dim
const
long
long
int
fullRepetition
=
2
*
oneDirectionRepetition
;
return
fullRepetition
;
}
void
repetitionsIntervals
(
FTreeCoordinate
*
const
min
,
FTreeCoordinate
*
const
max
)
const
{
if
(
nbLevelsAboveRoot
==
-
1
){
// We know it is (-1;1)
min
->
setPosition
(
-
1
,
-
1
,
-
1
);
max
->
setPosition
(
1
,
1
,
1
);
}
else
{
const
int
halfRepeated
=
int
(
theoricalRepetition
()
/
2
);
min
->
setPosition
(
-
halfRepeated
,
-
halfRepeated
,
-
halfRepeated
);
// if we repeat the box 8 times, we go from [-4 to 3]
max
->
setPosition
(
halfRepeated
-
1
,
halfRepeated
-
1
,
halfRepeated
-
1
);
}
}
FReal
extendedBoxWidth
()
const
{
// The simulation box is repeated is repeated 4 times if nbLevelsAboveRoot==-1
// And then it doubles by two
return
tree
->
getBoxWidth
()
*
FReal
(
1
<<
(
nbLevelsAboveRoot
+
3
));
}
/** This function has to be used to init the kernel with correct args
* it return the box cneter seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalBoxWidth and originalBoxCenter given in parameter
* @param originalBoxCenter the real system center
* @param originalBoxWidth the real system size
* @return the center the kernel should use
*/
FPoint
extendedBoxCenter
()
const
{
const
FReal
originalBoxWidth
=
tree
->
getBoxWidth
();
const
FReal
originalBoxWidthDiv2
=
originalBoxWidth
/
2.0
;
const
FPoint
originalBoxCenter
=
tree
->
getBoxCenter
();
const
FReal
offset
=
extendedBoxWidth
()
/
FReal
(
2.0
);
return
FPoint
(
originalBoxCenter
.
getX
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getY
()
-
originalBoxWidthDiv2
+
offset
,
originalBoxCenter
.
getZ
()
-
originalBoxWidthDiv2
+
offset
);
}
/** This function has to be used to init the kernel with correct args
* it return the tree heigh seen from a kernel point of view from the periodicity the user ask for
* this is computed using the originalTreeHeight given in parameter
* @param originalTreeHeight the real tree heigh
* @return the heigh the kernel should use
*/
int
extendedTreeHeight
()
const
{
// The real height
return
OctreeHeight
+
offsetRealTree
;
}
/** Periodicity Core
* This function is split in several part:
* 1 - special case managment
...
...
Src/Core/FFmmAlgorithmThreadTsm.hpp
View file @
25204605
...
...
@@ -87,11 +87,12 @@ public:
delete
[]
this
->
kernels
;
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
// Count leaf
int
numberOfLeafs
=
0
;
typename
OctreeClass
::
Iterator
octreeIterator
(
tree
);
...
...
Src/Core/FFmmAlgorithmTsm.hpp
View file @
25204605
...
...
@@ -68,11 +68,12 @@ public:
virtual
~
FFmmAlgorithmTsm
(){
}
protected:
/**
* To execute the fmm algorithm
* Call this function to run the complete algorithm
*/
void
execute
(
const
unsigned
operationsToProceed
=
FFmmNearAndFarFields
)
{
void
execute
Core
(
const
unsigned
operationsToProceed
)
override
{
if
(
operationsToProceed
&
FFmmP2M
)
bottomPass
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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