Commit 2f553f25 authored by BRAMAS Berenger's avatar BRAMAS Berenger

Add 3 dimenssional system for the periodic boundary condition, had test it, it looks like it works

parent d74e6aaa
This diff is collapsed.
......@@ -126,6 +126,9 @@ int main(int argc, char ** argv){
repetitions.getZ() << " there are " << totalRepeatedBox << " boxes in total\n";
const long long NbParticlesEntireSystem = NbParticles * totalRepeatedBox;
std::cout << "The total number of particles is " << NbParticlesEntireSystem << "\n";
FTreeCoordinate min, max;
algo.repetitions(&min, &max);
std::cout << "Min is " << min << " Max is " << max << std::endl;
OctreeClass::Iterator octreeIterator(&tree);
octreeIterator.gotoBottomLeft();
......
......@@ -67,8 +67,8 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
const int NbLevels = 3;
const int SizeSubLevels = 2;
const int PeriodicDeep = 3;
const int NbParticles = 10;
const int PeriodicDeep = 2;
const int NbParticles = 1;
FRandomLoader<ParticleClass> loader(NbParticles);
......@@ -87,7 +87,7 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
// Run FMM
Print("Fmm...");
FmmClass algo(&tree,PeriodicDeep);
FmmClass algo(&tree,PeriodicDeep );
KernelClass kernels(algo.treeHeightForKernel(), algo.boxcenterForKernel(loader.getCenterOfBox(), loader.getBoxWidth()),
algo.boxwidthForKernel(loader.getBoxWidth()), epsilon);
algo.setKernel(&kernels);
......@@ -96,9 +96,10 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
// Run direct computation
const MatrixKernelClass MatrixKernel;
Print("Direct...");
const int nbRepetition = algo.repeatedBox();
const int minRep = -(nbRepetition-1)/2;
const int maxRep = (nbRepetition-1)/2;
FTreeCoordinate min, max;
algo.repetitions(&min, &max);
for(int idxTarget = 0 ; idxTarget < loader.getNumberOfParticles() ; ++idxTarget){
for(int idxOther = idxTarget + 1 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){
//kernels.directInteractionMutual(&particles[idxTarget], &particles[idxOther]);
......@@ -115,9 +116,9 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
particles[idxTarget].incForces( force.getX(), force.getY(), force.getZ());
particles[idxOther ].incForces( -force.getX(), -force.getY(), -force.getZ());
}
for(int idxX = minRep ; idxX <= maxRep ; ++idxX){
for(int idxY = minRep ; idxY <= maxRep ; ++idxY){
for(int idxZ = minRep ; idxZ <= maxRep ; ++idxZ){
for(int idxX = min.getX() ; idxX <= max.getX() ; ++idxX){
for(int idxY = min.getY() ; idxY <= max.getY() ; ++idxY){
for(int idxZ = min.getZ() ; idxZ <= max.getZ() ; ++idxZ){
if(idxX ==0 && idxY == 0 && idxZ == 0) continue;
// next lines for test
......
......@@ -58,9 +58,9 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> {
typedef FFmmAlgorithmPeriodic<OctreeClass, ParticleClass, CellClass, ContainerClass, KernelClass, LeafClass > FmmClass;
// Parameters
const int NbLevels = 3;
const int NbLevels = 4;
const int SizeSubLevels = 2;
const int PeriodicDeep = 2;
const int PeriodicDeep = -1;
const int NbParticles = 100;
ParticleClass* const particles = new ParticleClass[NbParticles];
......@@ -69,13 +69,13 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> {
for( int idxPart = 0 ; idxPart < NbParticles ; ++idxPart ){
loader.fillParticle(particles[idxPart]);
particles[idxPart].setIndex(idxPart);
particles[idxPart].setPhysicalValue(FReal(0.10));
particles[idxPart].setPhysicalValue(FReal(0.80));
tree.insert(particles[idxPart]);
}
// Run FMM
Print("Fmm...");
FmmClass algo(&tree,PeriodicDeep);
FmmClass algo(&tree,PeriodicDeep, DirX | DirMinusY | DirPlusZ);
KernelClass kernels( algo.treeHeightForKernel(), algo.boxwidthForKernel(loader.getBoxWidth()),
algo.boxcenterForKernel(loader.getCenterOfBox(), loader.getBoxWidth()));
algo.setKernel(&kernels);
......@@ -83,17 +83,17 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> {
// Run Direct
Print("Run direct...");
const int nbRepetition = algo.repeatedBox();
const int minRep = -(nbRepetition-1)/2;
const int maxRep = (nbRepetition-1)/2;
FTreeCoordinate min, max;
algo.repetitions(&min, &max);
for(int idxTarget = 0 ; idxTarget < NbParticles ; ++idxTarget){
for(int idxSource = idxTarget + 1 ; idxSource < NbParticles ; ++idxSource){
kernels.particlesMutualInteraction(&particles[idxTarget], &particles[idxSource]);
}
for(int idxX = minRep ; idxX <= maxRep ; ++idxX){
for(int idxY = minRep ; idxY <= maxRep ; ++idxY){
for(int idxZ = minRep ; idxZ <= maxRep ; ++idxZ){
if(idxX ==0 && idxY == 0 && idxZ == 0) continue;
for(int idxX = min.getX() ; idxX <= max.getX() ; ++idxX){
for(int idxY = min.getY() ; idxY <= max.getY() ; ++idxY){
for(int idxZ = min.getZ() ; idxZ <= max.getZ() ; ++idxZ){
if(idxX == 0 && idxY == 0 && idxZ == 0) continue;
const FPoint offset(loader.getBoxWidth() * FReal(idxX),
loader.getBoxWidth() * FReal(idxY),
......@@ -130,7 +130,7 @@ class TestRotationDirectPeriodic : public FUTester<TestRotationDirectPeriodic> {
printf("Direct x %e y %e z %e physical %e potential %e fx %e fy %e fz %e\n",
other.getPosition().getX(),other.getPosition().getY(),other.getPosition().getZ(),
other.getPhysicalValue(),other.getPotential(),
other.getForces().getX(),other.getForces().getY(),other.getForces().getZ());*/
other.getForces().getX(),other.getForces().getY(),other.getForces().getZ());//*/
potentialDiff.add(other.getPotential(),leafIter.data().getPotential());
......
......@@ -86,16 +86,16 @@ class TestSphericalDirectPeriodic : public FUTester<TestSphericalDirectPeriodic>
// Run Direct
Print("Run direct...");
const int nbRepetition = algo.repeatedBox();
const int minRep = -(nbRepetition-1)/2;
const int maxRep = (nbRepetition-1)/2;
FTreeCoordinate min, max;
algo.repetitions(&min, &max);
for(int idxTarget = 0 ; idxTarget < NbParticles ; ++idxTarget){
for(int idxSource = idxTarget + 1 ; idxSource < NbParticles ; ++idxSource){
kernels.directInteractionMutual(&particles[idxTarget], &particles[idxSource]);
}
for(int idxX = minRep ; idxX <= maxRep ; ++idxX){
for(int idxY = minRep ; idxY <= maxRep ; ++idxY){
for(int idxZ = minRep ; idxZ <= maxRep ; ++idxZ){
for(int idxX = min.getX() ; idxX <= max.getX() ; ++idxX){
for(int idxY = min.getY() ; idxY <= max.getY() ; ++idxY){
for(int idxZ = min.getZ() ; idxZ <= max.getZ() ; ++idxZ){
if(idxX == 0 && idxY == 0 && idxZ == 0) continue;
const FPoint offset(loader.getBoxWidth() * FReal(idxX),
......
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