Commit c82fe260 authored by BLANCHARD Pierre's avatar BLANCHARD Pierre

Major modification! Defined rigoreous target-source convention: p(x)=sum_y...

Major modification! Defined rigoreous target-source convention: p(x)=sum_y K(x,y)w(y) with x=target and y=source. Direct computation is done by calling MutualParticles(Target params,Source params) or P2P(Target, Source); Kernel matrices evaluation is done by calling evaluate(x=target,y=source) which returns k(x,y)=k(x-y).
parent 14a6b1c0
......@@ -134,13 +134,13 @@ int main(int argc, char ** argv){
//
for(int idxOther = 0; idxOther < nbParticles ; ++idxOther){
if( idxOther != idxTarget ){
FP2P::NonMutualParticles(
particles[idxOther].getPosition().getX(), particles[idxOther].getPosition().getY(),
particles[idxOther].getPosition().getZ(),particles[idxOther].getPhysicalValue(),
particles[idxTarget].getPosition().getX(), particles[idxTarget].getPosition().getY(),
particles[idxTarget].getPosition().getZ(),particles[idxTarget].getPhysicalValue(),
&particles[idxTarget].setForces()[0],&particles[idxTarget].setForces()[1],
&particles[idxTarget].setForces()[2],particles[idxTarget].setPotential(),&MatrixKernel);
FP2P::NonMutualParticles(particles[idxTarget].getPosition().getX(), particles[idxTarget].getPosition().getY(),
particles[idxTarget].getPosition().getZ(),particles[idxTarget].getPhysicalValue(),
&particles[idxTarget].setForces()[0],&particles[idxTarget].setForces()[1],
&particles[idxTarget].setForces()[2],particles[idxTarget].setPotential(),
particles[idxOther].getPosition().getX(), particles[idxOther].getPosition().getY(),
particles[idxOther].getPosition().getZ(),particles[idxOther].getPhysicalValue(),
&MatrixKernel);
}
}
} // end for
......
This diff is collapsed.
......@@ -58,8 +58,10 @@ namespace FP2P {
const FPoint<FReal> targetPoint(targetsX[idxTarget],targetsY[idxTarget],targetsZ[idxTarget]);
FReal Kxy[1];
FReal dKxy[3];
MatrixKernel->evaluateBlockAndDerivative(sourcePoint.getX(),sourcePoint.getY(),sourcePoint.getZ(),
targetPoint.getX(),targetPoint.getY(),targetPoint.getZ(),Kxy,dKxy);
MatrixKernel->evaluateBlockAndDerivative(targetPoint.getX(),targetPoint.getY(),targetPoint.getZ(),
sourcePoint.getX(),sourcePoint.getY(),sourcePoint.getZ(),
Kxy,dKxy);
const FReal mutual_coeff = MatrixKernel->getMutualCoefficient(); // 1 if symmetric; -1 if antisymmetric
for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){
......@@ -76,7 +78,7 @@ namespace FP2P {
sourcesForcesX[idxSourceValue] -= dKxy[0] * coef;
sourcesForcesY[idxSourceValue] -= dKxy[1] * coef;
sourcesForcesZ[idxSourceValue] -= dKxy[2] * coef;
sourcesPotentials[idxSourceValue] += ( Kxy[0] * targetsPhysicalValues[idxTargetValue] );
sourcesPotentials[idxSourceValue] += ( mutual_coeff * Kxy[0] * targetsPhysicalValues[idxTargetValue] );
} // NVALS
......@@ -109,8 +111,10 @@ namespace FP2P {
const FPoint<FReal> targetPoint(targetsX[idxTarget],targetsY[idxTarget],targetsZ[idxTarget]);
FReal Kxy[1];
FReal dKxy[3];
MatrixKernel->evaluateBlockAndDerivative(sourcePoint.getX(),sourcePoint.getY(),sourcePoint.getZ(),
targetPoint.getX(),targetPoint.getY(),targetPoint.getZ(),Kxy,dKxy);
MatrixKernel->evaluateBlockAndDerivative(targetPoint.getX(),targetPoint.getY(),targetPoint.getZ(),
sourcePoint.getX(),sourcePoint.getY(),sourcePoint.getZ(),
Kxy,dKxy);
const FReal mutual_coeff = MatrixKernel->getMutualCoefficient(); // 1 if symmetric; -1 if antisymmetric
for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){
......@@ -127,7 +131,7 @@ namespace FP2P {
targetsForcesX[idxSourceValue] -= dKxy[0] * coef;
targetsForcesY[idxSourceValue] -= dKxy[1] * coef;
targetsForcesZ[idxSourceValue] -= dKxy[2] * coef;
targetsPotentials[idxSourceValue] += ( Kxy[0] * targetsPhysicalValues[idxTargetValue] );
targetsPotentials[idxSourceValue] += ( mutual_coeff * Kxy[0] * targetsPhysicalValues[idxTargetValue] );
}// NVALS
......@@ -172,8 +176,9 @@ inline void FullRemoteMultiRhs(ContainerClass* const FRestrict inTargets, const
const FPoint<FReal> targetPoint(targetsX[idxTarget],targetsY[idxTarget],targetsZ[idxTarget]);
FReal Kxy[1];
FReal dKxy[3];
MatrixKernel->evaluateBlockAndDerivative(sourcePoint.getX(),sourcePoint.getY(),sourcePoint.getZ(),
targetPoint.getX(),targetPoint.getY(),targetPoint.getZ(),Kxy,dKxy);
MatrixKernel->evaluateBlockAndDerivative(targetPoint.getX(),targetPoint.getY(),targetPoint.getZ(),
sourcePoint.getX(),sourcePoint.getY(),sourcePoint.getZ(),
Kxy,dKxy);
for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){
......
......@@ -25,14 +25,13 @@
*/
namespace FP2PR{
template <class FReal>
inline void MutualParticles(const FReal sourceX,const FReal sourceY,const FReal sourceZ, const FReal sourcePhysicalValue,
FReal* sourceForceX, FReal* sourceForceY, FReal* sourceForceZ, FReal* sourcePotential,
const FReal targetX,const FReal targetY,const FReal targetZ, const FReal targetPhysicalValue,
FReal* targetForceX, FReal* targetForceY, FReal* targetForceZ, FReal* targetPotential
){
FReal dx = sourceX - targetX;
FReal dy = sourceY - targetY;
FReal dz = sourceZ - targetZ;
inline void MutualParticles(const FReal targetX,const FReal targetY,const FReal targetZ, const FReal targetPhysicalValue,
FReal* targetForceX, FReal* targetForceY, FReal* targetForceZ, FReal* targetPotential,
const FReal sourceX,const FReal sourceY,const FReal sourceZ, const FReal sourcePhysicalValue,
FReal* sourceForceX, FReal* sourceForceY, FReal* sourceForceZ, FReal* sourcePotential){
FReal dx = targetX - sourceX;
FReal dy = targetY - sourceY;
FReal dz = targetZ - sourceZ;
FReal inv_square_distance = FReal(1.0) / (dx*dx + dy*dy + dz*dz);
FReal inv_distance = FMath::Sqrt(inv_square_distance);
......@@ -40,9 +39,9 @@ inline void MutualParticles(const FReal sourceX,const FReal sourceY,const FReal
inv_square_distance *= inv_distance;
inv_square_distance *= targetPhysicalValue * sourcePhysicalValue;
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
dx *= - inv_square_distance;
dy *= - inv_square_distance;
dz *= - inv_square_distance;
*targetForceX += dx;
*targetForceY += dy;
......@@ -56,12 +55,12 @@ inline void MutualParticles(const FReal sourceX,const FReal sourceY,const FReal
}
template <class FReal>
inline void NonMutualParticles(const FReal sourceX,const FReal sourceY,const FReal sourceZ, const FReal sourcePhysicalValue,
const FReal targetX,const FReal targetY,const FReal targetZ, const FReal targetPhysicalValue,
FReal* targetForceX, FReal* targetForceY, FReal* targetForceZ, FReal* targetPotential){
FReal dx = sourceX - targetX;
FReal dy = sourceY - targetY;
FReal dz = sourceZ - targetZ;
inline void NonMutualParticles(const FReal targetX,const FReal targetY,const FReal targetZ, const FReal targetPhysicalValue,
FReal* targetForceX, FReal* targetForceY, FReal* targetForceZ, FReal* targetPotential,
const FReal sourceX,const FReal sourceY,const FReal sourceZ, const FReal sourcePhysicalValue){
FReal dx = targetX - sourceX;
FReal dy = targetY - sourceY;
FReal dz = targetZ - sourceZ;
FReal inv_square_distance = FReal(1.0) / (dx*dx + dy*dy + dz*dz);
FReal inv_distance = FMath::Sqrt(inv_square_distance);
......@@ -69,9 +68,10 @@ inline void NonMutualParticles(const FReal sourceX,const FReal sourceY,const FRe
inv_square_distance *= inv_distance;
inv_square_distance *= targetPhysicalValue * sourcePhysicalValue;
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
// d/dx(1/|x-y|)=-(x-y)/r^3
dx *= - inv_square_distance;
dy *= - inv_square_distance;
dz *= - inv_square_distance;
*targetForceX += dx;
*targetForceY += dy;
......@@ -119,9 +119,9 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain
ComputeClass tpo = FMath::Zero<ComputeClass>();
for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){
ComputeClass dx = sourcesX[idxSource] - tx;
ComputeClass dy = sourcesY[idxSource] - ty;
ComputeClass dz = sourcesZ[idxSource] - tz;
ComputeClass dx = tx - sourcesX[idxSource];
ComputeClass dy = ty - sourcesY[idxSource];
ComputeClass dz = tz - sourcesZ[idxSource];
ComputeClass inv_square_distance = mOne / (dx*dx + dy*dy + dz*dz);
const ComputeClass inv_distance = FMath::Sqrt(inv_square_distance);
......@@ -129,9 +129,9 @@ static void GenericFullMutual(ContainerClass* const FRestrict inTargets, Contain
inv_square_distance *= inv_distance;
inv_square_distance *= tv * sourcesPhysicalValues[idxSource];
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
dx *= - inv_square_distance;
dy *= - inv_square_distance;
dz *= - inv_square_distance;
tfx += dx;
tfy += dy;
......@@ -193,18 +193,18 @@ static void GenericInner(ContainerClass* const FRestrict inTargets){
for(FSize idxSource = (idxTarget+NbFRealInComputeClass)/NbFRealInComputeClass ; idxSource < nbParticlesSources ; ++idxSource){
ComputeClass dx = sourcesX[idxSource] - tx;
ComputeClass dy = sourcesY[idxSource] - ty;
ComputeClass dz = sourcesZ[idxSource] - tz;
ComputeClass dx = tx - sourcesX[idxSource];
ComputeClass dy = ty - sourcesY[idxSource];
ComputeClass dz = tz - sourcesZ[idxSource];
ComputeClass inv_square_distance = mOne / (dx*dx + dy*dy + dz*dz);
const ComputeClass inv_distance = FMath::Sqrt(inv_square_distance);
inv_square_distance *= inv_distance;
inv_square_distance *= tv * sourcesPhysicalValues[idxSource];
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
dx *= - inv_square_distance;
dy *= - inv_square_distance;
dz *= - inv_square_distance;
tfx += dx;
tfy += dy;
......@@ -228,9 +228,9 @@ static void GenericInner(ContainerClass* const FRestrict inTargets){
const FSize limitForTarget = NbFRealInComputeClass-(idxTarget%NbFRealInComputeClass);
for(FSize idxS = 1 ; idxS < limitForTarget ; ++idxS){
const FSize idxSource = idxTarget + idxS;
FReal dx = targetsX[idxSource] - targetsX[idxTarget];
FReal dy = targetsY[idxSource] - targetsY[idxTarget];
FReal dz = targetsZ[idxSource] - targetsZ[idxTarget];
FReal dx = targetsX[idxTarget] - targetsX[idxSource];
FReal dy = targetsY[idxTarget] - targetsY[idxSource];
FReal dz = targetsZ[idxTarget] - targetsZ[idxSource];
FReal inv_square_distance = FReal(1.0) / (dx*dx + dy*dy + dz*dz);
const FReal inv_distance = FMath::Sqrt(inv_square_distance);
......@@ -238,9 +238,9 @@ static void GenericInner(ContainerClass* const FRestrict inTargets){
inv_square_distance *= inv_distance;
inv_square_distance *= targetsPhysicalValues[idxTarget] * targetsPhysicalValues[idxSource];
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
dx *= - inv_square_distance;
dy *= - inv_square_distance;
dz *= - inv_square_distance;
targetsForcesX[idxTarget] += dx;
targetsForcesY[idxTarget] += dy;
......@@ -289,9 +289,9 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, const C
ComputeClass tpo = FMath::Zero<ComputeClass>();
for(FSize idxSource = 0 ; idxSource < nbParticlesSources ; ++idxSource){
ComputeClass dx = sourcesX[idxSource] - tx;
ComputeClass dy = sourcesY[idxSource] - ty;
ComputeClass dz = sourcesZ[idxSource] - tz;
ComputeClass dx = tx - sourcesX[idxSource];
ComputeClass dy = ty - sourcesY[idxSource];
ComputeClass dz = tz - sourcesZ[idxSource];
ComputeClass inv_square_distance = mOne / (dx*dx + dy*dy + dz*dz);
const ComputeClass inv_distance = FMath::Sqrt(inv_square_distance);
......@@ -299,9 +299,9 @@ static void GenericFullRemote(ContainerClass* const FRestrict inTargets, const C
inv_square_distance *= inv_distance;
inv_square_distance *= tv * sourcesPhysicalValues[idxSource];
dx *= inv_square_distance;
dy *= inv_square_distance;
dz *= inv_square_distance;
dx *= - inv_square_distance;
dy *= - inv_square_distance;
dz *= - inv_square_distance;
tfx += dx;
tfy += dy;
......
This diff is collapsed.
......@@ -253,15 +253,23 @@ public:
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict inSources,
ContainerClass* const inNeighbors[], const int neighborPositions[],
const int inSize) override {
if(inTargets == inSources){
P2POuter(inPosition, inTargets, inNeighbors, neighborPositions, inSize);
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PInner(inTargets,MatrixKernel);
// Standard FMM separation criterion, i.e. max 27 neighbor clusters per leaf
if(LeafLevelSeparationCriterion==1) {
if(inTargets == inSources){
P2POuter(inPosition, inTargets, inNeighbors, neighborPositions, inSize);
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PInner(inTargets,MatrixKernel);
}
else{
const ContainerClass* const srcPtr[1] = {inSources};
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,srcPtr,1,MatrixKernel);
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel);
}
}
else{
const ContainerClass* const srcPtr[1] = {inSources};
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,srcPtr,1,MatrixKernel);
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel);
// Nearfield interactions are only computed within the target leaf
else if(LeafLevelSeparationCriterion==0){
DirectInteractionComputer<FReal,MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel);
}
// If criterion equals -1 then no P2P need to be performed.
}
void P2POuter(const FTreeCoordinate& /*inLeafPosition*/,
......@@ -281,7 +289,13 @@ public:
ContainerClass* const FRestrict inTargets, const ContainerClass* const FRestrict /*inSources*/,
const ContainerClass* const inNeighbors[], const int /*neighborPositions*/[],
const int inSize) override {
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel);
// Standard FMM separation criterion, i.e. max 27 neighbor clusters per leaf
if(LeafLevelSeparationCriterion==1)
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,inSize,MatrixKernel);
// Nearfield interactions are only computed within the target leaf
if(LeafLevelSeparationCriterion==0)
DirectInteractionComputer<FReal, MatrixKernelClass::NCMP, NVALS>::P2PRemote(inTargets,inNeighbors,0,MatrixKernel);
// If criterion equals -1 then no P2P need to be performed.
}
};
......
......@@ -226,12 +226,14 @@ int main(int argc, char ** argv){
for(int idxOther = 0; idxOther < nbParticles ; ++idxOther){
if( idxOther != idxTarget ){
FP2P::NonMutualParticles(
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
particlesDirect[idxTarget].position.getX(), particlesDirect[idxTarget].position.getY(),
particlesDirect[idxTarget].position.getZ(),particlesDirect[idxTarget].physicalValue,
&particlesDirect[idxTarget].forces[0],&particlesDirect[idxTarget].forces[1],
&particlesDirect[idxTarget].forces[2],&particlesDirect[idxTarget].potential, &MatrixKernel);
particlesDirect[idxTarget].position.getZ(),particlesDirect[idxTarget].physicalValue,
&particlesDirect[idxTarget].forces[0],&particlesDirect[idxTarget].forces[1],
&particlesDirect[idxTarget].forces[2],&particlesDirect[idxTarget].potential,
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
&MatrixKernel
);
}
}
//
......@@ -251,9 +253,10 @@ int main(int argc, char ** argv){
MDParticle<FReal> source = particles[idxSource];
source.position += offset;
FP2P::NonMutualParticles(
source.position.getX(), source.position.getY(),source.position.getZ(),source.physicalValue,
particlesDirect[idxTarget].position.getX(), particlesDirect[idxTarget].position.getY(),particlesDirect[idxTarget].position.getZ(),particlesDirect[idxTarget].physicalValue,
&particlesDirect[idxTarget].forces[0],&particlesDirect[idxTarget].forces[1],&particlesDirect[idxTarget].forces[2],&particlesDirect[idxTarget].potential, &MatrixKernel
&particlesDirect[idxTarget].forces[0],&particlesDirect[idxTarget].forces[1],&particlesDirect[idxTarget].forces[2],&particlesDirect[idxTarget].potential,
source.position.getX(), source.position.getY(),source.position.getZ(),source.physicalValue,
&MatrixKernel
);
}
}
......
......@@ -27,7 +27,7 @@
#include "Files/FFmaGenericLoader.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel_TensorialInteractions.hpp"
#include "Kernels/Chebyshev/FChebCell.hpp"
#include "Kernels/Chebyshev/FChebTensorialKernel.hpp"
......@@ -72,25 +72,30 @@ int main(int argc, char* argv[])
// init timer
FTic time;
// typedefs
typedef FInterpMatrixKernel_R_IJ<FReal> MatrixKernelClass;
const unsigned int NPV = MatrixKernelClass::NPV;
const unsigned int NPOT = MatrixKernelClass::NPOT;
const unsigned int NRHS = MatrixKernelClass::NRHS;
const unsigned int NLHS = MatrixKernelClass::NLHS;
const double CoreWidth = 0.1;
const MatrixKernelClass MatrixKernel(CoreWidth);
// init particles position and physical value
struct TestParticle{
FPoint<FReal> position;
FReal forces[3][NPOT];
FReal physicalValue[NPV];
FReal potential[NPOT];
};
// typedefs and infos
typedef FInterpMatrixKernel_R_IJ<FReal> MatrixKernelClass;
MatrixKernelClass::printInfo();
// useful features of matrix kernel
const unsigned int NPV = MatrixKernelClass::NPV;
const unsigned int NPOT = MatrixKernelClass::NPOT;
const unsigned int NRHS = MatrixKernelClass::NRHS;
const unsigned int NLHS = MatrixKernelClass::NLHS;
const FReal CoreWidth = 0.;
std::cout << "Core width: a=" << CoreWidth << std::endl;
std::cout << std::endl;
// Build matrix kernel
const MatrixKernelClass MatrixKernel(CoreWidth);
// init particles position and physical value
struct TestParticle{
FPoint<FReal> position;
FReal forces[3][NPOT];
FReal physicalValue[NPV];
FReal potential[NPOT];
};
// open particle file
FFmaGenericLoader<FReal> loader(filename);
......
......@@ -102,9 +102,9 @@ void doATest(const FSize NbParticles, const int minP, const int maxP, const int
particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue,
&particles[idxTarget].forces[0],&particles[idxTarget].forces[1],
&particles[idxTarget].forces[2],&particles[idxTarget].potential,
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
&particles[idxOther].forces[0],&particles[idxOther].forces[1],
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
&particles[idxOther].forces[0],&particles[idxOther].forces[1],
&particles[idxOther].forces[2],&particles[idxOther].potential);
}
}
......@@ -311,9 +311,9 @@ int main(int argc, char ** argv){
centeredParticle.position.getZ(),centeredParticle.physicalValue,
&centeredParticle.forces[0],&centeredParticle.forces[1],
&centeredParticle.forces[2],&centeredParticle.potential,
otherParticle.position.getX(), otherParticle.position.getY(),
otherParticle.position.getZ(),otherParticle.physicalValue,
&otherParticle.forces[0],&otherParticle.forces[1],
otherParticle.position.getX(), otherParticle.position.getY(),
otherParticle.position.getZ(),otherParticle.physicalValue,
&otherParticle.forces[0],&otherParticle.forces[1],
&otherParticle.forces[2],&otherParticle.potential);
{ // Check that each particle has been summed with all other
......
......@@ -310,12 +310,13 @@ int main(int argc, char ** argv){
for(FSize idxOther = 0; idxOther < loader->getNumberOfParticles() ; ++idxOther){
if( idxOther != idxTarget ){
FP2P::NonMutualParticles(
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
part.position.getX(), part.position.getY(),
part.position.getZ(),part.physicalValue,
&part.forces[0],&part.forces[1],
&part.forces[2],&part.potential,&MatrixKernel);
part.position.getZ(),part.physicalValue,
&part.forces[0],&part.forces[1],
&part.forces[2],&part.potential,
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
&MatrixKernel);
}
}
//
......@@ -341,10 +342,10 @@ int main(int argc, char ** argv){
source.position += offset;
// std::cout << "Part "<<idxSource<< " " <<source.position.getX()<< " " << source.position.getY()<< " " <<source.position.getZ()<< " " <<source.physicalValue <<std::endl ;
FP2P::NonMutualParticles(
source.position.getX(), source.position.getY(),source.position.getZ(),source.physicalValue,
part.position.getX(), part.position.getY(),part.position.getZ(),part.physicalValue,
&part.forces[0],&part.forces[1],&part.forces[2],&part.potential,&MatrixKernel
);
&part.forces[0],&part.forces[1],&part.forces[2],&part.potential,
source.position.getX(), source.position.getY(),source.position.getZ(),source.physicalValue,
&MatrixKernel);
}
// std::cout <<std::endl<<std::endl<<std::endl;
}
......
......@@ -30,7 +30,7 @@
#include "Files/FFmaGenericLoader.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel.hpp"
#include "Kernels/Interpolation/FInterpMatrixKernel_TensorialInteractions.hpp"
#include "Kernels/Uniform/FUnifCell.hpp"
#include "Kernels/Uniform/FUnifTensorialKernel.hpp"
......@@ -46,7 +46,10 @@
#include "Core/FFmmAlgorithm.hpp"
#include "Core/FFmmAlgorithmThread.hpp"
#include "../../Src/Utils/FParameterNames.hpp"
#include "Utils/FParameterNames.hpp"
// For std::array<> (i.e. for Tensorial kernels purpose)
#include <array>
/**
* This program runs the FMM Algorithm with the Uniform kernel and compares the results with a direct computation.
......@@ -77,8 +80,9 @@ int main(int argc, char* argv[])
FTic time;
// typedefs
// typedefs and infos
typedef FInterpMatrixKernel_R_IJ<FReal> MatrixKernelClass;
MatrixKernelClass::printInfo();
// useful features of matrix kernel
const unsigned int NPV = MatrixKernelClass::NPV;
......@@ -86,7 +90,11 @@ int main(int argc, char* argv[])
const unsigned int NRHS = MatrixKernelClass::NRHS;
const unsigned int NLHS = MatrixKernelClass::NLHS;
const FReal CoreWidth = 0.1;
const FReal CoreWidth = 0.;
std::cout << "Core width: a=" << CoreWidth << std::endl;
std::cout << std::endl;
// Build matrix kernel
const MatrixKernelClass MatrixKernel(CoreWidth);
// init particles position and physical value
......@@ -172,12 +180,14 @@ int main(int argc, char* argv[])
if(MatrixKernelClass::Type==HOMOGENEOUS && BoxWidthExtension>0.)
throw std::runtime_error("Extension of box width is not yet supported for homogeneous kernels! Work-around: artificially set Type to NON_HOMOGENEOUS.");
typedef FP2PParticleContainerIndexed<FReal,NRHS,NLHS> ContainerClass;
const unsigned int NVALS = 1;
typedef FP2PParticleContainerIndexed<FReal,NRHS,NLHS,NVALS> ContainerClass;
typedef FSimpleLeaf<FReal, ContainerClass > LeafClass;
typedef FUnifCell<FReal,ORDER,NRHS,NLHS> CellClass;
typedef FUnifCell<FReal,ORDER,NRHS,NLHS,NVALS> CellClass;
typedef FOctree<FReal, CellClass,ContainerClass,LeafClass> OctreeClass;
typedef FUnifTensorialKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER> KernelClass;
typedef FUnifTensorialKernel<FReal,CellClass,ContainerClass,MatrixKernelClass,ORDER,NVALS> KernelClass;
typedef FFmmAlgorithm<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass;
// typedef FFmmAlgorithmThread<OctreeClass,CellClass,ContainerClass,KernelClass,LeafClass> FmmClass;
......@@ -201,6 +211,22 @@ int main(int argc, char* argv[])
particles[idxPart].physicalValue[0], particles[idxPart].physicalValue[1], particles[idxPart].physicalValue[2]);
else
std::runtime_error("NPV not yet supported in test! Add new case.");
//
// [TODO] Fix insertion of multiple physical values using std::array !!
//
//// Convert FReal[NVALS] to std::array<FReal,NVALS>
//std::array<FReal, (NPV+4*NPOT)*NVALS> physicalState;
//for(int idxVals = 0 ; idxVals < NVALS ; ++idxVals){
// for(int idxPV = 0 ; idxPV < NPV ; ++idxPV)
// physicalState[idxPV*NVALS+idxVals]=particles[idxPart].physicalValue[idxPV];
// physicalState[(NPV+0)*NVALS+idxVals]=0.0;
// physicalState[(NPV+1)*NVALS+idxVals]=0.0;
// physicalState[(NPV+2)*NVALS+idxVals]=0.0;
// physicalState[(NPV+3)*NVALS+idxVals]=0.0;
//}
//tree.insert(particles[idxPart].position, idxPart,physicalState);
}
time.tac();
......@@ -245,6 +271,8 @@ int main(int argc, char* argv[])
//PB: store potential in array[nbParticles]
checkPotential[indexPartOrig][idxPot]=potentials[idxPart];
checkfx[indexPartOrig][idxPot]=forcesX[idxPart];
//if(idxPart<10)
// std::cout << " FMM potentials[idxPartOrigin="<< indexPartOrig <<"]=" << potentials[idxPart] << " DIRECT potentials[idxPartOrigin="<< indexPartOrig <<"]=" << particles[indexPartOrig].potential[idxPot] << std::endl;
potentialDiff[idxPot].add(particles[indexPartOrig].potential[idxPot],potentials[idxPart]);
fx[idxPot].add(particles[indexPartOrig].forces[0][idxPot],forcesX[idxPart]);
......
......@@ -164,10 +164,10 @@ int main(int argc, char ** argv){
FP2PR::MutualParticles(
particles[idxTarget].pos.getX(),particles[idxTarget].pos.getY(), particles[idxTarget].pos.getZ(),
particles[idxTarget].physicalValue, &particles[idxTarget].forces[0], &particles[idxTarget].forces[1],
&particles[idxTarget].forces[2], &particles[idxTarget].pot,
&particles[idxTarget].forces[2], &particles[idxTarget].pot,
particles[idxSource].pos.getX(),particles[idxSource].pos.getY(), particles[idxSource].pos.getZ(),
particles[idxSource].physicalValue, &particles[idxSource].forces[0], &particles[idxSource].forces[1],
&particles[idxSource].forces[2], &particles[idxSource].pot);
&particles[idxSource].forces[2], &particles[idxSource].pot);
}
}
......
......@@ -140,12 +140,12 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
for(FSize idxOther = 0 ; idxOther < loader.getNumberOfParticles() ; ++idxOther){
if(idxTarget != idxOther){
FP2P::NonMutualParticles(
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
particles[idxTarget].position.getX(), particles[idxTarget].position.getY(),
particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue,
&particles[idxTarget].forces[0],&particles[idxTarget].forces[1],
&particles[idxTarget].forces[2],&particles[idxTarget].potential,
particles[idxOther].position.getX(), particles[idxOther].position.getY(),
particles[idxOther].position.getZ(),particles[idxOther].physicalValue,
&MatrixKernel);
}
......@@ -170,12 +170,13 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
source.position += offset;
FP2P::NonMutualParticles(
source.position.getX(), source.position.getY(),
source.position.getZ(),source.physicalValue,
particles[idxTarget].position.getX(), particles[idxTarget].position.getY(),
particles[idxTarget].position.getZ(),particles[idxTarget].physicalValue,
&particles[idxTarget].forces[0],&particles[idxTarget].forces[1],
&particles[idxTarget].forces[2],&particles[idxTarget].potential,&MatrixKernel);
&particles[idxTarget].forces[2],&particles[idxTarget].potential,
source.position.getX(), source.position.getY(),
source.position.getZ(),source.physicalValue,
&MatrixKernel);
}
}
}
......
......@@ -105,12 +105,12 @@ class TestChebyshevDirectTsm : public FUTester<TestChebyshevDirectTsm> {
for(int idxTarget = 0 ; idxTarget < nbTargets ; ++idxTarget){
for(int idxOther = 0 ; idxOther < nbSources ; ++idxOther){
FP2P::NonMutualParticles(
particlesSources[idxOther].getPosition().getX(), particlesSources[idxOther].getPosition().getY(),
particlesSources[idxOther].getPosition().getZ(),particlesSources[idxOther].getPhysicalValue(),
particlesTargets[idxTarget].getPosition().getX(), particlesTargets[idxTarget].getPosition().getY(),
particlesTargets[idxTarget].getPosition().getZ(),particlesTargets[idxTarget].getPhysicalValue(),
&particlesTargets[idxTarget].setForces()[0],&particlesTargets[idxTarget].setForces()[1],
&particlesTargets[idxTarget].setForces()[2],particlesTargets[idxTarget].setPotential(),
particlesSources[idxOther].getPosition().getX(), particlesSources[idxOther].getPosition().getY(),
particlesSources[idxOther].getPosition().getZ(),particlesSources[idxOther].getPhysicalValue(),
&MatrixKernel);
}
}
......
......@@ -104,12 +104,12 @@ class TestRotationDirectTsm : public FUTester<TestRotationDirectTsm> {
for(int idxTarget = 0 ; idxTarget < nbTargets ; ++idxTarget){
for(int idxOther = 0 ; idxOther < nbSources ; ++idxOther){
FP2PR::NonMutualParticles(
particlesSources[idxOther].getPosition().getX(), particlesSources[idxOther].getPosition().getY(),
particlesSources[idxOther].getPosition().getZ(),particlesSources[idxOther].getPhysicalValue(),
particlesTargets[idxTarget].getPosition().getX(), particlesTargets[idxTarget].getPosition().getY(),
particlesTargets[idxTarget].getPosition().getZ(),particlesTargets[idxTarget].getPhysicalValue(),
&particlesTargets[idxTarget].setForces()[0],&particlesTargets[idxTarget].setForces()[1],
&particlesTargets[idxTarget].setForces()[2],particlesTargets[idxTarget].setPotential());
particlesTargets[idxTarget].getPosition().getZ(),particlesTargets[idxTarget].getPhysicalValue(),
&particlesTargets[idxTarget].setForces()[0],&particlesTargets[idxTarget].setForces()[1],
&particlesTargets[idxTarget].setForces()[2],particlesTargets[idxTarget].setPotential(),
particlesSources[idxOther].getPosition().getX(), particlesSources[idxOther].getPosition().getY(),
particlesSources[idxOther].getPosition().getZ(),particlesSources[idxOther].getPhysicalValue());
}
}
......
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