Commit 95626445 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Remove old fashion periodic system from spherical kernel

parent 6f55fa9a
......@@ -47,13 +47,13 @@ protected:
// M2L transfer, there is a maximum of 3 neighbors in each direction,
// so 6 in each dimension
FReal treeWidthAtLevel = Parent::boxWidth * FReal( 1 << Parent::periodicLevels);
preM2LTransitions = new FComplexe**[Parent::treeHeight + Parent::periodicLevels];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe**) * (Parent::treeHeight + Parent::periodicLevels));
FReal treeWidthAtLevel = Parent::boxWidth;
preM2LTransitions = new FComplexe**[Parent::treeHeight];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe**) * (Parent::treeHeight));
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
preM2LTransitions[idxLevel + Parent::periodicLevels] = new FComplexe*[(7 * 7 * 7)];
memset(preM2LTransitions[idxLevel + Parent::periodicLevels], 0, sizeof(FComplexe*) * (7*7*7));
for(int idxLevel = 0 ; idxLevel < Parent::treeHeight ; ++idxLevel ){
preM2LTransitions[idxLevel] = new FComplexe*[(7 * 7 * 7)];
memset(preM2LTransitions[idxLevel], 0, sizeof(FComplexe*) * (7*7*7));
for(int idxX = -3 ; idxX <= 3 ; ++idxX ){
for(int idxY = -3 ; idxY <= 3 ; ++idxY ){
......@@ -93,7 +93,7 @@ protected:
matrix[idxCol * FF_MATRIX_ROW_DIM + idxRow] = workMatrix[idxCol + idxRow * FF_MATRIX_COLUMN_DIM];
}
}
preM2LTransitions[idxLevel + Parent::periodicLevels][indexM2LTransition(idxX,idxY,idxZ)] = matrix;
preM2LTransitions[idxLevel][indexM2LTransition(idxX,idxY,idxZ)] = matrix;
}
}
}
......@@ -113,8 +113,8 @@ public:
* @param inBoxWidth the size of the simulation box
* @param inPeriodicLevel the number of level upper to 0 that will be requiried
*/
FSphericalBlasKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const int inPeriodicLevel = 0)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter, inPeriodicLevel),
FSphericalBlasKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter),
FF_MATRIX_ROW_DIM(Parent::harmonic.getExpSize()), FF_MATRIX_COLUMN_DIM(Parent::harmonic.getNExpSize()),
FF_MATRIX_SIZE(FF_MATRIX_ROW_DIM * FF_MATRIX_COLUMN_DIM),
temporaryMultiSource(new FComplexe[FF_MATRIX_COLUMN_DIM]),
......@@ -136,16 +136,16 @@ public:
~FSphericalBlasKernel(){
delete[] temporaryMultiSource;
if(preM2LTransitions.isLast()){
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
for(int idxLevel = 0 ; idxLevel < Parent::treeHeight ; ++idxLevel ){
for(int idxX = -3 ; idxX <= 3 ; ++idxX ){
for(int idxY = -3 ; idxY <= 3 ; ++idxY ){
for(int idxZ = -3 ; idxZ <= 3 ; ++idxZ ){
delete[] preM2LTransitions[idxLevel + Parent::periodicLevels][indexM2LTransition(idxX,idxY,idxZ)];
delete[] preM2LTransitions[idxLevel][indexM2LTransition(idxX,idxY,idxZ)];
}
}
}
}
FMemUtils::DeleteAll(preM2LTransitions.getPtr(), Parent::treeHeight + Parent::periodicLevels);
FMemUtils::DeleteAll(preM2LTransitions.getPtr(), Parent::treeHeight);
}
}
......@@ -155,7 +155,7 @@ public:
// For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){
if( distantNeighbors[idxNeigh] ){
const FComplexe* const transitionVector = preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh];
const FComplexe* const transitionVector = preM2LTransitions[inLevel][idxNeigh];
multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
}
}
......
......@@ -62,13 +62,13 @@ protected:
// M2L transfer, there is a maximum of 3 neighbors in each direction,
// so 6 in each dimension
FReal treeWidthAtLevel = Parent::boxWidth * FReal( 1 << Parent::periodicLevels);
preM2LTransitions = new FComplexe**[Parent::treeHeight + Parent::periodicLevels];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe**) * (Parent::treeHeight + Parent::periodicLevels));
FReal treeWidthAtLevel = Parent::boxWidth;
preM2LTransitions = new FComplexe**[Parent::treeHeight];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe**) * (Parent::treeHeight));
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
preM2LTransitions[idxLevel + Parent::periodicLevels] = new FComplexe*[(7 * 7 * 7)];
memset(preM2LTransitions[idxLevel + Parent::periodicLevels], 0, sizeof(FComplexe*) * (7*7*7));
for(int idxLevel = 0 ; idxLevel < Parent::treeHeight ; ++idxLevel ){
preM2LTransitions[idxLevel] = new FComplexe*[(7 * 7 * 7)];
memset(preM2LTransitions[idxLevel], 0, sizeof(FComplexe*) * (7*7*7));
for(int idxX = -3 ; idxX <= 3 ; ++idxX ){
for(int idxY = -3 ; idxY <= 3 ; ++idxY ){
......@@ -108,7 +108,7 @@ protected:
matrix[idxCol * FF_MATRIX_ROW_DIM + idxRow] = workMatrix[idxCol + idxRow * FF_MATRIX_COLUMN_DIM];
}
}
preM2LTransitions[idxLevel + Parent::periodicLevels][indexM2LTransition(idxX,idxY,idxZ)] = matrix;
preM2LTransitions[idxLevel][indexM2LTransition(idxX,idxY,idxZ)] = matrix;
}
}
}
......@@ -128,8 +128,8 @@ public:
* @param inBoxWidth the size of the simulation box
* @param inPeriodicLevel the number of level upper to 0 that will be requiried
*/
FSphericalBlockBlasKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const int inBlockSize = 512, const int inPeriodicLevel = 0)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter, inPeriodicLevel),
FSphericalBlockBlasKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const int inBlockSize = 512)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter),
FF_MATRIX_ROW_DIM(Parent::harmonic.getExpSize()), FF_MATRIX_COLUMN_DIM(Parent::harmonic.getNExpSize()),
FF_MATRIX_SIZE(FF_MATRIX_ROW_DIM * FF_MATRIX_COLUMN_DIM),
BlockSize(inBlockSize),
......@@ -156,16 +156,16 @@ public:
delete[] multipoleMatrix;
delete[] localMatrix;
if(preM2LTransitions.isLast()){
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
for(int idxLevel = 0 ; idxLevel < Parent::treeHeight ; ++idxLevel ){
for(int idxX = -3 ; idxX <= 3 ; ++idxX ){
for(int idxY = -3 ; idxY <= 3 ; ++idxY ){
for(int idxZ = -3 ; idxZ <= 3 ; ++idxZ ){
delete[] preM2LTransitions[idxLevel + Parent::periodicLevels][indexM2LTransition(idxX,idxY,idxZ)];
delete[] preM2LTransitions[idxLevel][indexM2LTransition(idxX,idxY,idxZ)];
}
}
}
}
FMemUtils::DeleteAll(preM2LTransitions.getPtr(), Parent::treeHeight + Parent::periodicLevels);
FMemUtils::DeleteAll(preM2LTransitions.getPtr(), Parent::treeHeight);
}
}
......@@ -235,7 +235,7 @@ public:
*
*Remark: here we have always j+n >= |-k-l|
*
* const FComplexe*const M2LTransfer = preM2LTransitions[inLevel + Parent::periodicLevels][interactionIndex];
* const FComplexe*const M2LTransfer = preM2LTransitions[inLevel][interactionIndex];
* for(int idxK = 0 ; idxK < interactions[interactionIndex].getSize() ; ++idxK){
* for(int idxRow = 0 ; idxRow < FF_MATRIX_ROW_DIM ; ++idxRow){
* FComplexe compute;
......@@ -263,7 +263,7 @@ public:
FF_MATRIX_COLUMN_DIM,
interactions[interactionIndex].getSize(),
one,
FComplexe::ToFReal(preM2LTransitions[inLevel + Parent::periodicLevels][interactionIndex]),
FComplexe::ToFReal(preM2LTransitions[inLevel][interactionIndex]),
FF_MATRIX_ROW_DIM,
FComplexe::ToFReal(multipoleMatrix),
FF_MATRIX_COLUMN_DIM,
......
......@@ -36,13 +36,13 @@ protected:
void allocAndInit(){
// M2L transfer, there is a maximum of 3 neighbors in each direction,
// so 6 in each dimension
preM2LTransitions = new FComplexe*[Parent::treeHeight + Parent::periodicLevels];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe*) * (Parent::treeHeight + Parent::periodicLevels));
preM2LTransitions = new FComplexe*[Parent::treeHeight];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe*) * (Parent::treeHeight));
// We start from the higher level
FReal treeWidthAtLevel = Parent::boxWidth * FReal(1 << Parent::periodicLevels);
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
FReal treeWidthAtLevel = Parent::boxWidth;
for(int idxLevel = 0 ; idxLevel < Parent::treeHeight ; ++idxLevel ){
// Allocate data for this level
preM2LTransitions[idxLevel + Parent::periodicLevels] = new FComplexe[(7 * 7 * 7) * devM2lP];
preM2LTransitions[idxLevel] = new FComplexe[(7 * 7 * 7) * devM2lP];
// Precompute transfer vector
for(int idxX = -3 ; idxX <= 3 ; ++idxX ){
for(int idxY = -3 ; idxY <= 3 ; ++idxY ){
......@@ -50,7 +50,7 @@ protected:
if(FMath::Abs(idxX) > 1 || FMath::Abs(idxY) > 1 || FMath::Abs(idxZ) > 1){
const FPoint relativePos( FReal(-idxX) * treeWidthAtLevel , FReal(-idxY) * treeWidthAtLevel , FReal(-idxZ) * treeWidthAtLevel );
Parent::harmonic.computeOuter(FSpherical(relativePos));
FMemUtils::copyall<FComplexe>(&preM2LTransitions[idxLevel + Parent::periodicLevels][indexM2LTransition(idxX,idxY,idxZ)], Parent::harmonic.result(), Parent::harmonic.getExpSize());
FMemUtils::copyall<FComplexe>(&preM2LTransitions[idxLevel][indexM2LTransition(idxX,idxY,idxZ)], Parent::harmonic.result(), Parent::harmonic.getExpSize());
}
}
}
......@@ -68,8 +68,8 @@ public:
* @param inBoxWidth the size of the simulation box
* @param inPeriodicLevel the number of level upper to 0 that will be requiried
*/
FSphericalKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const int inPeriodicLevel = 0)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter, inPeriodicLevel),
FSphericalKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter),
devM2lP(int(((inDevP*2)+1) * ((inDevP*2)+2) * 0.5)),
preM2LTransitions(0) {
allocAndInit();
......@@ -85,7 +85,7 @@ public:
/** Destructor */
~FSphericalKernel(){
if( preM2LTransitions.isLast() ){
FMemUtils::DeleteAll(preM2LTransitions.getPtr(), Parent::treeHeight + Parent::periodicLevels);
FMemUtils::DeleteAll(preM2LTransitions.getPtr(), Parent::treeHeight);
}
}
......@@ -95,7 +95,7 @@ public:
// For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){
if( distantNeighbors[idxNeigh] ){
const FComplexe* const transitionVector = &preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh * devM2lP];
const FComplexe* const transitionVector = &preM2LTransitions[inLevel][idxNeigh * devM2lP];
multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
}
}
......
......@@ -352,22 +352,22 @@ protected:
void allocAndInit(){
// M2L transfer, there is a maximum of 3 neighbors in each direction,
// so 6 in each dimension
preM2LTransitions = new RotationM2LTransfer*[Parent::treeHeight + Parent::periodicLevels];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe*) * (Parent::treeHeight + Parent::periodicLevels));
preM2LTransitions = new RotationM2LTransfer*[Parent::treeHeight];
memset(preM2LTransitions.getPtr(), 0, sizeof(FComplexe*) * (Parent::treeHeight));
// We start from the higher level
FReal treeWidthAtLevel = Parent::boxWidth * FReal(1 << Parent::periodicLevels);
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
FReal treeWidthAtLevel = Parent::boxWidth;
for(int idxLevel = 0 ; idxLevel < Parent::treeHeight ; ++idxLevel ){
// Allocate data for this level
preM2LTransitions[idxLevel + Parent::periodicLevels] = reinterpret_cast<RotationM2LTransfer*>(new char[(7 * 7 * 7) * sizeof(RotationM2LTransfer)]);
preM2LTransitions[idxLevel] = reinterpret_cast<RotationM2LTransfer*>(new char[(7 * 7 * 7) * sizeof(RotationM2LTransfer)]);
// Precompute transfer vector
for(int idxX = -3 ; idxX <= 3 ; ++idxX ){
for(int idxY = -3 ; idxY <= 3 ; ++idxY ){
for(int idxZ = -3 ; idxZ <= 3 ; ++idxZ ){
new (&preM2LTransitions[idxLevel + Parent::periodicLevels][indexM2LTransition(idxX,idxY,idxZ)]) RotationM2LTransfer(Parent::devP,devM2lP,Parent::harmonic.getExpSize());
new (&preM2LTransitions[idxLevel][indexM2LTransition(idxX,idxY,idxZ)]) RotationM2LTransfer(Parent::devP,devM2lP,Parent::harmonic.getExpSize());
if(FMath::Abs(idxX) > 1 || FMath::Abs(idxY) > 1 || FMath::Abs(idxZ) > 1){
const FPoint relativePos( FReal(-idxX) * treeWidthAtLevel , FReal(-idxY) * treeWidthAtLevel , FReal(-idxZ) * treeWidthAtLevel );
preM2LTransitions[idxLevel + Parent::periodicLevels][indexM2LTransition(idxX,idxY,idxZ)].transfer_M2L_rotation_Fill(FSpherical(relativePos), rotation_Info);
preM2LTransitions[idxLevel][indexM2LTransition(idxX,idxY,idxZ)].transfer_M2L_rotation_Fill(FSpherical(relativePos), rotation_Info);
}
}
}
......@@ -385,8 +385,8 @@ public:
* @param inBoxWidth the size of the simulation box
* @param inPeriodicLevel the number of level upper to 0 that will be requiried
*/
FSphericalRotationKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter, const int inPeriodicLevel = 0)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter, inPeriodicLevel),
FSphericalRotationKernel(const int inDevP, const int inTreeHeight, const FReal inBoxWidth, const FPoint& inBoxCenter)
: Parent(inDevP, inTreeHeight, inBoxWidth, inBoxCenter),
devM2lP(int(((inDevP*2)+1) * ((inDevP*2)+2) * 0.5)),
preM2LTransitions(0),
rotation_Info(inDevP) {
......@@ -404,11 +404,11 @@ public:
/** Destructor */
~FSphericalRotationKernel(){
if( preM2LTransitions.isLast() ){
for(int idxLevel = -Parent::periodicLevels ; idxLevel < Parent::treeHeight ; ++idxLevel ){
for(int idxLevel = 0 ; idxLevel < Parent::treeHeight ; ++idxLevel ){
for(int idx = 0 ; idx < 7*7*7 ; ++idx ){
preM2LTransitions[idxLevel + Parent::periodicLevels][idx].~RotationM2LTransfer();
preM2LTransitions[idxLevel][idx].~RotationM2LTransfer();
}
delete[] reinterpret_cast<char*>(preM2LTransitions[idxLevel + Parent::periodicLevels]);
delete[] reinterpret_cast<char*>(preM2LTransitions[idxLevel]);
}
}
}
......@@ -419,7 +419,7 @@ public:
// For all neighbors compute M2L
for(int idxNeigh = 0 ; idxNeigh < 343 ; ++idxNeigh){
if(distantNeighbors[idxNeigh]){
const RotationM2LTransfer& transitionVector = preM2LTransitions[inLevel + Parent::periodicLevels][idxNeigh];
const RotationM2LTransfer& transitionVector = preM2LTransitions[inLevel][idxNeigh];
multipoleToLocal(pole->getLocal(), distantNeighbors[idxNeigh]->getMultipole(), transitionVector);
}
}
......
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