Commit daf5fa5b authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Most efficient version is Kernel_Boucle3

parent e883708e
......@@ -469,7 +469,6 @@ public:
void P2M(CellClass* const pole,
const ContainerClass* const particles)
{
// printf("P2M %%%%%%%%%%%%%%%%%%%%%%%%%%\n");
//Variables computed for each power of Multipole
int a,b,c ;
FReal facto, coeff;
......@@ -815,7 +814,7 @@ public:
{
// printf("L2P %%%%%%%%%%%%%%%%%%%%%%%%%%\n");
FPoint locCenter = getLeafCenter(local->getCoordinate());
//Iterator over particles
int nbPart = particles->getNbParticles();
//
......@@ -842,6 +841,7 @@ public:
FReal dx = posX[i] - locCenter.getX();
FReal dy = posY[i] - locCenter.getY();
FReal dz = posZ[i] - locCenter.getZ();
//
// Precompute an arrays of Array[i] = dx^(i-1)
arrayDX[0] = 0.0 ;
......@@ -859,7 +859,10 @@ public:
}
FReal partPhyValue = phyValues[i];
//
FReal locPot = 0.0, locForceX = 0.0, locForceY = 0.0, locForceZ = 0.0 ;
FReal locPot = 0.0;
FReal locForceX = 0.0;
FReal locForceY = 0.0;
FReal locForceZ = 0.0;
int a=0,b=0,c=0;
for(int j=0 ; j<SizeVector ; ++j){
FReal locForce = iterLocal[j];
......@@ -869,7 +872,7 @@ public:
locForceX += FReal(a)*locForce*arrayDX[a]*arrayDY[b+1]*arrayDZ[c+1];
locForceY += FReal(b)*locForce*arrayDX[a+1]*arrayDY[b]*arrayDZ[c+1];
locForceZ += FReal(c)*locForce*arrayDX[a+1]*arrayDY[b+1]*arrayDZ[c];
//
incPowers(&a,&b,&c);
}
targetsPotentials[i] = partPhyValue*locPot ;
......
This diff is collapsed.
This diff is collapsed.
......@@ -152,15 +152,15 @@ private:
int powerToIdx(const int a,const int b,const int c)
{
int t,res,p = a+b+c;
if(p==0) // si p=0 alors res=1/3=0 donc on peut l'enlever
{return 0;}
else
{
res = p*(p+1)*(p+2)/6;
t = p - a;
res += t*(t+1)/2+c;
return res;
}
// if(p==0) // si p=0 alors res=1/3=0 donc on peut l'enlever
// {return 0;}
// else
// {
res = p*(p+1)*(p+2)/6;
t = p - a;
res += t*(t+1)/2+c;
return res;
// }
}
/* Return the factorial of a number
......@@ -415,7 +415,8 @@ private:
}
for(c=2 ; c <= 2*P-b-a ; ++c){
//Computation of derivatives Psi_{a,b,c} with a >= 2
// |x-y|^2*Psi_{a,b,c} + (2*a-1)*dx*Psi_{a-1,b,c} + a*(a-2)*Psi_{a-2,b,c} + 2*b*dy*Psi_{a,b-1,c} + b*(b-1)*Psi_{a,b-2,c} + 2*c= 0
// |x-y|^2*Psi_{a,b,c} + (2*a-1)*dx*Psi_{a-1,b,c} + a*(a-2)*Psi_{a-2,b,c} + 2*b*dy*Psi_{a,b-1,c} + b*(b-1)*Psi_{a,b-2,c}
// + 2*c*dz*Psi_{a,b,c-1}} = 0
idxTarget = powerToIdx(a,b,c);
idxSrc1 = powerToIdx(a-1,b,c);
idxSrc2 = powerToIdx(a,b-1,c);
......@@ -749,21 +750,15 @@ public:
//Iterating over local array : n
for(int i=0 ; i< SizeVector ; ++i){
FReal fctl = fact3int(al,bl,cl);
//FReal coeffL = factorials[al+bl+cl]/(fctl*fctl);
FReal coeffL = FReal(1.0)/(fctl);
//Iterator over multipole array
FReal tmp = 0.0 ;
//Iterating over multipole array : k
// Loc(al,bl,cl) = N(al,bl,cl)/((al,bl,cl)!*(al,bl,cl)!) sum_(am,bm,cm) Psi[am+al,bm+bl,cm+cl] * M[am,bm,cm]
//
am=0; bm=0; cm=0;
//printf("al= %d, bl=%d, cl=%d ==> i =%d \n",al,bl,cl,i);
for(int j = 0 ; j < SizeVector ; ++j){ //corresponding powers am,bm,cm
int idxPsi = powerToIdx(al+am,bl+bm,cl+cm);
tmp += this->_PsiVector[idxPsi]*multipole[j];
// if((al+bl+cl)==0) {printf("coeffL:%f (%d,%d,%d)--> mult x psi ::> %f * %f tmp: %f\n",coeffL,am,bm,cm,multipole[j],_PsiVector[idxPsi],tmp);}
//updating a,b,c
incPowers(&am,&bm,&cm);
}
......
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