Commit 25204605 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Prepare the algorithm in order to work in specific level of the tree

parent 914b3dc1
......@@ -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);
}
};
......
......@@ -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 executeCore(const unsigned operationsToProceed) override {
Timers[P2MTimer].tic();
if(operationsToProceed & FFmmP2M) bottomPass();
......@@ -94,7 +97,6 @@ public:
Timers[NearTimer].tac();
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
......
......@@ -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 executeCore(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
......
......@@ -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 executeCore(const unsigned operationsToProceed) override {
#pragma omp parallel
{
......@@ -115,7 +116,6 @@ public:
}
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
......
......@@ -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 executeCore(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
/////////////////////////////////////////////////////////////////////////////
......
......@@ -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 executeCore(const unsigned operationsToProceed) override {
for(int idxShape = 0 ; idxShape < SizeShape ; ++idxShape){
this->shapeLeaf[idxShape] = 0;
......@@ -139,7 +140,6 @@ public:
iterArray = nullptr;
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
......
......@@ -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 executeCore(const unsigned operationsToProceed) override {
// Count leaf
this->numberOfLeafs = 0;
{
......@@ -279,8 +280,6 @@ public:
iterArrayComm = nullptr;
}
private:
/////////////////////////////////////////////////////////////////////////////
// P2M
/////////////////////////////////////////////////////////////////////////////
......
......@@ -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 executeCore(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
......
......@@ -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 executeCore(const unsigned operationsToProceed) override {
// Count leaf
int numberOfLeafs = 0;
typename OctreeClass::Iterator octreeIterator(tree);
......
......@@ -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 executeCore(const unsigned operationsToProceed) override {
if(operationsToProceed & FFmmP2M) bottomPass();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment