Commit dc9000d7 authored by berenger-bramas's avatar berenger-bramas

Change the Fmb kernels :

× remove the potentials or forces only
× remove the abstract fmb kernel
× put a attribute to know if we use the mutual P2P or not (a template or inherite model may be faster)

git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/scalfmm/scalfmm/trunk@49 2616d619-271b-44dc-8df4-d4a8f33a7222
parent d5ce31e3
......@@ -6,7 +6,7 @@
#include "../Utils/FComplexe.hpp"
#include "FAbstractFmbKernels.hpp"
#include "FFmbKernels.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
......
......@@ -451,8 +451,8 @@ protected:
/*printf("%d/%d - magnitude=%e ptr_precomputed_cos_and_sin_array real=%e imag=%e p_term real=%e imag=%e\n",
l,m,
magnitude,
(cosSin + m)->getReal(),
(cosSin + m)->getImag(),
cosSin[m].getReal(),
cosSin[m].getImag(),
p_term->getReal(),
p_term->getImag());*/
/*printf("\t p_spherical_harmonic_Inner_coefficients_array = %e \t ptr_associated_Legendre_function_Array = %e \t r_l = %e\n",
......@@ -480,8 +480,8 @@ protected:
/*printf("%d - magnitude=%e ptr_precomputed_cos_and_sin_array real=%e imag=%e p_term real=%e imag=%e\n",
l,
magnitude,
(cosSin + m)->getReal(),
(cosSin + m)->getImag(),
cosSin[m].getReal(),
cosSin[m].getImag(),
p_term->getReal(),
p_term->getImag());*/
/*printf("\t p_spherical_harmonic_Inner_coefficients_array = %e \t ptr_associated_Legendre_function_Array = %e \t r_l = %e\n",
......
This diff is collapsed.
#ifndef FFMBKERNELSPOTENTIAL_HPP
#define FFMBKERNELSPOTENTIAL_HPP
// /!\ Please, you must read the license at the bottom of this page
#include "../Utils/FGlobal.hpp"
#include "FAbstractFmbKernels.hpp"
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
* @class AbstractKernels
* @brief
* Please read the license
*
*
* This class is a Fmb Kernels.
*/
template< class ParticleClass, class CellClass, int TreeHeight>
class FFmbKernelsPotential : public FAbstractFmbKernels<ParticleClass,CellClass, TreeHeight> {
public:
FFmbKernelsPotential(const FReal inTreeWidth)
: FAbstractFmbKernels<ParticleClass,CellClass,TreeHeight>(inTreeWidth) {
}
void changeProgression(int*const start_for_j , FComplexe** const p_target_exp_term){}
/** bodies_L2P
* expansion_L2P_add_to_force_vector
*/
void L2P(const CellClass* const local, FList<ParticleClass*>* const particles){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
typename FList<ParticleClass*>::BasicIterator iterTarget(*particles);
while( iterTarget.isValide() ){
//printf("Morton %lld\n",local->getMortonIndex());
// expansion_Evaluate_local
harmonicInner( positionTsmphere( iterTarget.value()->getPosition() - local->getPosition()),
FAbstractFmbKernels<ParticleClass,CellClass,TreeHeight>::current_thread_Y);
FReal potential;
expansion_Evaluate_local_with_Y_already_computed(local->getLocal(),&potential);
iterTarget.value()->setPotential(potential);
//printf("\t fx = %f \t fy = %f \t fz = %f \n",iterTarget.value()->getForces().getX(),iterTarget.value()->getForces().getY(),iterTarget.value()->getForces().getZ());
//printf("p_potential = %lf\n", potential);
iterTarget.progress();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
void expansion_Evaluate_local_with_Y_already_computed(const FComplexe* local_exp,
FReal* const p_result){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
FReal result = 0.0;
FComplexe* p_Y_term = FAbstractFmbKernels<ParticleClass,CellClass,TreeHeight>::current_thread_Y;
for(int j = 0 ; j<= FMB_Info_P ; ++j){
// k=0
(*p_Y_term) *= (*local_exp);
result += p_Y_term->getReal();
//printf("\t\t p_Y_term->real = %f p_Y_term->imag = %f \t local_exp->real = %f local_exp->imag = %f \n",
// p_Y_term->getReal(), p_Y_term->getImag(), local_exp->getReal(), local_exp->getImag());
++p_Y_term;
++local_exp;
// k>0
for (int k=1; k<=j ;++k, ++p_Y_term, ++local_exp){
(*p_Y_term) *= (*local_exp);
result += 2 * p_Y_term->getReal();
//printf("\t\t p_Y_term->real = %f p_Y_term->imag = %f \t local_exp->real = %f local_exp->imag = %f \n",
// p_Y_term->getReal(), p_Y_term->getImag(), local_exp->getReal(), local_exp->getImag());
}
}
*p_result = result;
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
/** void bodies_Compute_direct_interaction (
* bodies_t *FMB_RESTRICT p_b_target,
* bodies_t *FMB_RESTRICT p_b_src,
* bool mutual
* )
*
*/
void P2P(FList<ParticleClass*>* const FRestrict targets, const FList<ParticleClass*>* const FRestrict sources,
FList<ParticleClass*>* FRestrict const* FRestrict directNeighbors, const int size) {
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
typename FList<ParticleClass*>::BasicIterator iterTarget(*targets);
while( iterTarget.isValide() ){
for(int idxDirectNeighbors = 0 ; idxDirectNeighbors < size ; ++idxDirectNeighbors){
typename FList<ParticleClass*>::ConstBasicIterator iterSource(*directNeighbors[idxDirectNeighbors]);
while( iterSource.isValide() ){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(), iterSource.value());
iterSource.progress();
}
}
typename FList<ParticleClass*>::ConstBasicIterator iterSameBox(*sources);
while( iterSameBox.isValide() ){
if(iterSameBox.value() != iterTarget.value()){
DIRECT_COMPUTATION_NO_MUTUAL_SOFT(&iterTarget.value(), iterSameBox.value());
}
iterSameBox.progress();
}
iterTarget.progress();
}
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
void DIRECT_COMPUTATION_NO_MUTUAL_SOFT(ParticleClass** const target, const ParticleClass* const source){
FTRACE( FTrace::Controller.enterFunction(FTrace::KERNELS, __FUNCTION__ , __FILE__ , __LINE__) );
const FReal dx = (*target)->getPosition().getX() - source->getPosition().getX();
const FReal dy = (*target)->getPosition().getY() - source->getPosition().getY();
const FReal dz = (*target)->getPosition().getZ() - source->getPosition().getZ();
FReal inv_distance = 1.0/FMath::Sqrt(dx*dx + dy*dy + dz*dz + FAbstractFmbKernels<ParticleClass,CellClass,TreeHeight>::FMB_Info_eps_soft_square);
inv_distance *= (*target)->getPhysicalValue() * source->getPhysicalValue();
(*target)->setPotential( inv_distance + (*target)->getPotential());
//source->setPotential( inv_distance + source->getPotential());
FTRACE( FTrace::Controller.leaveFunction(FTrace::KERNELS) );
}
};
#endif //FFMBKERNELSPOTENTIAL_HPP
// [--LICENSE--]
This diff is collapsed.
This diff is collapsed.
......@@ -23,10 +23,8 @@
#include "../Sources/Components/FSimpleLeaf.hpp"
#include "../Sources/Fmb/FFmbKernelsPotentialForcesTsm.hpp"
#include "../Sources/Fmb/FFmbKernelsPotentialForces.hpp"
#include "../Sources/Fmb/FFmbKernelsForces.hpp"
#include "../Sources/Fmb/FFmbKernelsPotential.hpp"
#include "../Sources/Fmb/FFmbKernels.hpp"
#include "../Sources/Files/FFMALoader.hpp"
......@@ -116,10 +114,9 @@ int main(int argc, char ** argv){
std::cout << "Working on particles ..." << std::endl;
counter.tic();
//FFmbKernelsPotentialForces FFmbKernelsForces FFmbKernelsPotential
FFmbKernelsPotentialForcesTsm<FmbParticle, FmbCell, NbLevels> kernels(loader.getBoxWidth());
FFmbKernels<FmbParticle, FmbCell, NbLevels> kernels(loader.getBoxWidth());
//FFmmAlgorithm FFmmAlgorithmThreaded FFmmAlgorithmArray FFmmAlgorithmTask FFmmAlgorithmArrayUs
FFmmAlgorithmArrayUs<FFmbKernelsPotentialForcesTsm, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
FFmmAlgorithmArrayUs<FFmbKernels, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
algo.execute();
counter.tac();
......
......@@ -23,7 +23,7 @@
#include "../Sources/Components/FSimpleLeaf.hpp"
#include "../Sources/Fmb/FFmbKernelsBlas.hpp"
#include "../Sources/Fmb/FFmbKernelsPotentialForces.hpp"
#include "../Sources/Fmb/FFmbKernels.hpp"
#include "../Sources/Files/FFMALoader.hpp"
......@@ -116,7 +116,7 @@ int main(int argc, char ** argv){
std::cout << "Working on particles ..." << std::endl;
counter.tic();
//FFmbKernelsBlas FFmbKernelsPotentialForces
//FFmbKernelsBlas FFmbKernels
FFmbKernelsBlas<FmbParticle, FmbCell, NbLevels> kernels(loader.getBoxWidth());
//FFmmAlgorithm FFmmAlgorithmThreaded FFmmAlgorithmArray FFmmAlgorithmTask
FFmmAlgorithm<FFmbKernelsBlas, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
......
......@@ -25,9 +25,7 @@
#include "../Sources/Components/FSimpleLeaf.hpp"
#include "../Sources/Fmb/FFmbKernelsPotentialForces.hpp"
#include "../Sources/Fmb/FFmbKernelsForces.hpp"
#include "../Sources/Fmb/FFmbKernelsPotential.hpp"
#include "../Sources/Fmb/FFmbKernels.hpp"
#include "../Sources/Files/FFMATsmLoader.hpp"
......@@ -117,10 +115,9 @@ int main(int argc, char ** argv){
std::cout << "Working on particles ..." << std::endl;
counter.tic();
//FFmbKernelsPotentialForces FFmbKernelsForces FFmbKernelsPotential
FFmbKernelsPotentialForces<FmbParticle, FmbCell, NbLevels> kernels(loader.getBoxWidth());
FFmbKernels<FmbParticle, FmbCell, NbLevels> kernels(loader.getBoxWidth());
//FFmmAlgorithm FFmmAlgorithmThreaded FFmmAlgorithmArray FFmmAlgorithmTask
FFmmAlgorithm<FFmbKernelsPotentialForces, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
FFmmAlgorithm<FFmbKernels, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
algo.execute();
counter.tac();
......
......@@ -29,9 +29,7 @@
#include "../Sources/Components/FSimpleLeaf.hpp"
#include "../Sources/Components/FTypedLeaf.hpp"
#include "../Sources/Fmb/FFmbKernelsPotentialForces.hpp"
#include "../Sources/Fmb/FFmbKernelsForces.hpp"
#include "../Sources/Fmb/FFmbKernelsPotential.hpp"
#include "../Sources/Fmb/FFmbKernels.hpp"
// With openmp : g++ testFmbTsmAlgorithm.cpp ../Sources/Utils/FAssertable.cpp ../Sources/Utils/FDebug.cpp ../Sources/Utils/FTrace.cpp -lgomp -fopenmp -O2 -o testFmbTsmAlgorithm.exe
......@@ -130,12 +128,11 @@ int main(int argc, char ** argv){
std::cout << "Working on particles ..." << std::endl;
counter.tic();
//FFmbKernelsPotentialForces FFmbKernelsForces FFmbKernelsPotential
FFmbKernelsPotentialForces<FmbParticle, FmbCell, NbLevels> kernels(BoxWidth);
FFmbKernelsPotentialForces<FmbParticleTyped, FmbCellTyped, NbLevels> kernelsTyped(BoxWidth);
FFmbKernels<FmbParticle, FmbCell, NbLevels> kernels(BoxWidth);
FFmbKernels<FmbParticleTyped, FmbCellTyped, NbLevels> kernelsTyped(BoxWidth);
//FFmmAlgorithm FFmmAlgorithmArray
FFmmAlgorithmArray<FFmbKernelsPotentialForces, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
FFmmAlgorithmArrayTsm<FFmbKernelsPotentialForces, FmbParticleTyped, FmbCellTyped, FTypedLeaf, NbLevels, SizeSubLevels> algoTyped(&treeTyped,&kernelsTyped);
FFmmAlgorithmArray<FFmbKernels, FmbParticle, FmbCell, FSimpleLeaf, NbLevels, SizeSubLevels> algo(&tree,&kernels);
FFmmAlgorithmArrayTsm<FFmbKernels, FmbParticleTyped, FmbCellTyped, FTypedLeaf, NbLevels, SizeSubLevels> algoTyped(&treeTyped,&kernelsTyped);
algo.execute();
algoTyped.execute();
......
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