Commit 156b3cdc authored by berenger-bramas's avatar berenger-bramas

Make the octree arranger to enable periodicity.

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@343 2616d619-271b-44dc-8df4-d4a8f33a7222
parent df17b9ce
......@@ -2,6 +2,7 @@
#define FOCTREEARRANGER_HPP
#include "../Utils/FGlobal.hpp"
#include "../Utils/F3DPosition.hpp"
#include "../Containers/FVector.hpp"
#include "../Utils/FAssertable.hpp"
......@@ -20,10 +21,16 @@ public:
}
/** Arrange */
void rearrange(){
void rearrange(const bool isPeriodic = false){
// This vector is to keep the moving particles
FVector<ParticleClass> tomove;
// For periodic
const FReal boxWidth = tree->getBoxWidth();
const F3DPosition min(tree->getBoxCenter(),-boxWidth/2);
const F3DPosition max(tree->getBoxCenter(),boxWidth/2);
{ // iterate on the leafs and found particle to remove
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
......@@ -32,6 +39,28 @@ public:
typename ContainerClass::BasicIterator iter(*octreeIterator.getCurrentListTargets());
while( iter.hasNotFinished() ){
if(isPeriodic){
F3DPosition partPos = iter.data().getPosition();
while(partPos.getX() < min.getX()){
partPos.incX(boxWidth);
}
while(partPos.getX() > max.getX()){
partPos.incX(-boxWidth);
}
while(partPos.getY() < min.getY()){
partPos.incY(boxWidth);
}
while(partPos.getY() > max.getY()){
partPos.incY(-boxWidth);
}
while(partPos.getZ() < min.getZ()){
partPos.incZ(boxWidth);
}
while(partPos.getZ() > max.getZ()){
partPos.incZ(-boxWidth);
}
iter.data().setPosition(partPos);
}
const MortonIndex particuleIndex = tree->getMortonFromPosition(iter.data().getPosition());
if(particuleIndex != currentIndex){
tomove.push(iter.data());
......
......@@ -43,7 +43,7 @@ public:
}
/** return false if the tree is empty after processing */
bool rearrange(const FMpi::FComm& comm){
bool rearrange(const FMpi::FComm& comm, const bool isPeriodic = false){
// interval of each procs
Interval*const intervals = new Interval[comm.processCount()];
memset(intervals, 0, sizeof(Interval) * comm.processCount());
......@@ -77,6 +77,11 @@ public:
FVector<ParticleClass>*const toMove = new FVector<ParticleClass>[comm.processCount()];
{ // iterate on the leafs and found particle to remove or to send
// For periodic
const FReal boxWidth = tree->getBoxWidth();
const F3DPosition min(tree->getBoxCenter(),-boxWidth/2);
const F3DPosition max(tree->getBoxCenter(),boxWidth/2);
typename OctreeClass::Iterator octreeIterator(tree);
octreeIterator.gotoBottomLeft();
do{
......@@ -84,6 +89,28 @@ public:
typename ContainerClass::BasicIterator iter(*octreeIterator.getCurrentListTargets());
while( iter.hasNotFinished() ){
if(isPeriodic){
F3DPosition partPos = iter.data().getPosition();
while(partPos.getX() < min.getX()){
partPos.incX(boxWidth);
}
while(partPos.getX() > max.getX()){
partPos.incX(-boxWidth);
}
while(partPos.getY() < min.getY()){
partPos.incY(boxWidth);
}
while(partPos.getY() > max.getY()){
partPos.incY(-boxWidth);
}
while(partPos.getZ() < min.getZ()){
partPos.incZ(boxWidth);
}
while(partPos.getZ() > max.getZ()){
partPos.incZ(-boxWidth);
}
iter.data().setPosition(partPos);
}
const MortonIndex particuleIndex = tree->getMortonFromPosition(iter.data().getPosition());
// is this particle need to be changed from its leaf
if(particuleIndex != currentIndex){
......
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