Commit 6ee28dd9 authored by PIACIBELLO Cyrille's avatar PIACIBELLO Cyrille

Api updated : Error spotted by D Barbier fixed alongside another one, and add...

Api updated : Error spotted by D Barbier fixed alongside another one, and add a definition of scalfmm_call_delete()
parent f47afb0a
...@@ -1073,6 +1073,10 @@ extern "C" void scalfmm_generic_partition(scalfmm_handle handle, FSize nbThings, ...@@ -1073,6 +1073,10 @@ extern "C" void scalfmm_generic_partition(scalfmm_handle handle, FSize nbThings,
((ScalFmmCoreHandle<double> * ) handle)->engine->generic_partition(nbThings,sizeofthing,arrayOfThing,newArray); ((ScalFmmCoreHandle<double> * ) handle)->engine->generic_partition(nbThings,sizeofthing,arrayOfThing,newArray);
} }
extern "C" void scalfmm_call_delete(void * inPtr){
delete [] static_cast<double*>(inPtr);
}
#endif #endif
#endif #endif
...@@ -431,6 +431,8 @@ public: ...@@ -431,6 +431,8 @@ public:
~FUserKernelDistrEngine(){ ~FUserKernelDistrEngine(){
delete comm; delete comm;
comm = nullptr; comm = nullptr;
delete kernel;
delete octreeDist;
} }
//Qu'est-ce qu'il faut que je surcharge ? //Qu'est-ce qu'il faut que je surcharge ?
...@@ -486,15 +488,20 @@ public: ...@@ -486,15 +488,20 @@ public:
for(int id = 0 ; id<nbPoints ; ++id){ for(int id = 0 ; id<nbPoints ; ++id){
FTreeCoordinate host; FTreeCoordinate host;
arrayToBeSorted[id].position = FPoint<FReal>(particleXYZ[id+0],particleXYZ[id+1],particleXYZ[id+2]); arrayToBeSorted[id].position = FPoint<FReal>(particleXYZ[3*id+0],
particleXYZ[3*id+1],
particleXYZ[3*id+2]);
arrayToBeSorted[id].orIndex = id + Ind.getoriIntervals(myRank).first; arrayToBeSorted[id].orIndex = id + Ind.getoriIntervals(myRank).first;
arrayToBeSorted[id].orOwner = myRank; arrayToBeSorted[id].orOwner = myRank;
//Evaluate Morton Index //Evaluate Morton Index
host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+0] - this->getBoxCorner().getX(),this->getBoxWidth(),this->getBoxWidthAtLeafLevel(), host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+0] - this->getBoxCorner().getX(),
this->getBoxWidth(),this->getBoxWidthAtLeafLevel(),
this->getTreeHeight())); this->getTreeHeight()));
host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+1] - this->getBoxCorner().getY(),this->getBoxWidth(),this->getBoxWidthAtLeafLevel(), host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+1] - this->getBoxCorner().getY(),
this->getBoxWidth(),this->getBoxWidthAtLeafLevel(),
this->getTreeHeight())); this->getTreeHeight()));
host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+2] - this->getBoxCorner().getZ(),this->getBoxWidth(),this->getBoxWidthAtLeafLevel(), host.setX(FCoordinateComputer::GetTreeCoordinate<FReal>(particleXYZ[id*3+2] - this->getBoxCorner().getZ(),
this->getBoxWidth(),this->getBoxWidthAtLeafLevel(),
this->getTreeHeight())); this->getTreeHeight()));
arrayToBeSorted[id].index = host.getMortonIndex(); arrayToBeSorted[id].index = host.getMortonIndex();
} }
...@@ -603,12 +610,13 @@ public: ...@@ -603,12 +610,13 @@ public:
//Then, i need to find the index where current index //Then, i need to find the index where current index
//is sorted inside currentArray; //is sorted inside currentArray;
FSize idSearch = 0; FSize idSearch = 0;
for(idSearch=0 ; idSearch < Ind.getCount(myRank) && (Ind.getCurrentArrayValue(idSearch) != currentIndex) ; ++idSearch); for(idSearch=0 ; idSearch < Ind.getCount(myRank) && (Ind.getCurrentArrayValue(idSearch) != currentIndex) ; ++idSearch){
memcpy(&output[idSearch*stride],&recvBuffer[idRead*stride],stride); memcpy(&output[idSearch*stride],&recvBuffer[idRead*stride],stride);
} }
}
//C Part //C Part
*newArray = malloc(output.size()); *newArray = new char[output.size()];
memcpy(*newArray,output.data(),output.size()); memcpy(*newArray,output.data(),output.size());
} }
......
...@@ -175,9 +175,9 @@ void on_leaf(int level, FSize nbParts, const FSize * idxParts, long long morton_ ...@@ -175,9 +175,9 @@ void on_leaf(int level, FSize nbParts, const FSize * idxParts, long long morton_
double pot = 0; double pot = 0;
for(int i=0 ; i<nbParts ; ++i){ for(int i=0 ; i<nbParts ; ++i){
pot += potentials[i]; ptrToUserData->totalEnergy += potentials[i]*(ptrToUserData->myPhyValues[idxParts[i]]);
} }
ptrToUserData->totalEnergy += pot*(ptrToUserData->myPhyValues[idxParts[i]]);
} }
/* printf("I'm leaf at %lld pos, of center [%e %e %e], containing %lld parts\n", */ /* printf("I'm leaf at %lld pos, of center [%e %e %e], containing %lld parts\n", */
/* morton_index,center[0],center[1],center[2],nbParts); */ /* morton_index,center[0],center[1],center[2],nbParts); */
...@@ -319,8 +319,6 @@ int main(int argc, char ** argv){ ...@@ -319,8 +319,6 @@ int main(int argc, char ** argv){
//Only read, so no split needed //Only read, so no split needed
userDatas.insertedPositions = outputArray; // Set the position userDatas.insertedPositions = outputArray; // Set the position
//Need to get the good ones...
double * newPhyValues = malloc(sizeof(double) * outputNbPoint);
//In this part, we store the physicalvalues //In this part, we store the physicalvalues
//Create as many array of forces as there are threads in order to //Create as many array of forces as there are threads in order to
...@@ -364,6 +362,7 @@ int main(int argc, char ** argv){ ...@@ -364,6 +362,7 @@ int main(int argc, char ** argv){
//Dealloc scalfmm handle //Dealloc scalfmm handle
scalfmm_dealloc_handle(Handle,cheb_free_cell); scalfmm_dealloc_handle(Handle,cheb_free_cell);
{//This part will write generated particles to a file at ScalFMM {//This part will write generated particles to a file at ScalFMM
//format in order to verify numercal results //format in order to verify numercal results
/* if(my_rank==0){ */ /* if(my_rank==0){ */
...@@ -395,8 +394,9 @@ int main(int argc, char ** argv){ ...@@ -395,8 +394,9 @@ int main(int argc, char ** argv){
/* } */ /* } */
} }
free(outputIndexes); scalfmm_call_delete(outputIndexes);
free(outputArray); scalfmm_call_delete(outputArray);
scalfmm_call_delete(*outputPhyValPtr);
MPI_Finalize(); MPI_Finalize();
......
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