Commit cc9a9b37 authored by COULAUD Olivier's avatar COULAUD Olivier

Looking for the bug in the periodic algorithm (continue) ; Improve...

Looking for the bug in the periodic algorithm (continue) ; Improve documentations, include, ... Add functionalities to be more comptible with std lib
parent f3683c88
......@@ -70,9 +70,9 @@ using FmmClassProcPER = FFmmAlgorithmThreadProcPeriodic<FReal,OctreeClass,CellC
int main(int argc, char* argv[])
{
///////// PARAMETERS HANDLING //////////////////////////////////////
// const FParameterNames LocalOptionPeriodicDeep { {"-periodic","-per"}, "Perdiodic boundary condition (-per 5) the box grow by a facor (3L)^5"};
FHelpDescribeAndExit(argc, argv,
"Driver for Chebyshev Interpolation kernel using MPI (1/r kernel). "
//
FHelpDescribeAndExit(argc, argv,
"Driver for Interpolation Laplace kernel using MPI. "
"Usully run using : mpirun -np nb_proc_needed ./ChebyshevInterpolationAlgorithm [params].",
FParameterDefinitions::OctreeHeight,
FParameterDefinitions::OctreeSubHeight,
......@@ -127,7 +127,7 @@ int main(int argc, char* argv[])
FSize localParticlesNumber = 0 ;
{ // -----------------------------------------------------
// -----------------------------------------------------
if(app.global().processId() == 0){
std::cout << "Loading & Inserting " << loader.getNumberOfParticles()
<< " particles ..." << std::endl;
......@@ -207,7 +207,7 @@ int main(int argc, char* argv[])
<< " readinsert-time-max:" << maxTime
<< std::endl;
}
}
// -----------------------------------------------------
std::vector<MortonIndex> mortonLeafDistribution(2*app.global().processCount());
FAbstractAlgorithm * algorithm = nullptr;
......
......@@ -4,7 +4,8 @@
#include <memory>
#include "FAbstractBuffer.hpp"
#include "../Utils/FAssert.hpp"
#include "FBufferWriter.hpp"
#include "Utils/FAssert.hpp"
/**
* \brief Provides memory management and conversion to basic type
......@@ -38,6 +39,23 @@ public :
{
FAssertLF(array, "Cannot allocate array");
}
/**
* \brief Construct the reader
*
* \param capacity Buffer capacity in bytes
*/
explicit FBufferReader( FBufferWriter& buf)
: arrayCapacity(buf.getCapacity() )
{
this->cleanAndResize(arrayCapacity) ;
std::unique_ptr<char[]> arraytmp(new char[arrayCapacity]);
std::copy(buf.data(),buf.data()+arrayCapacity, arraytmp.get());
array = std::move(arraytmp);
currentIndex = buf.getSize() ;
FAssertLF(array, "Cannot allocate array");
}
virtual ~FBufferReader() = default;
......
......@@ -98,6 +98,9 @@ public:
return array.get();
}
std::unique_ptr<char[]>* ptrData(){
return &array;
}
/**
* \brief Return the written memory size
*/
......
#ifndef FNEIGHBORINDEXES_HPP
#define FNEIGHBORINDEXES_HPP
#include "../Utils/FGlobal.hpp"
#include "Utils/FGlobal.hpp"
/**
* @brief The FAbstractNeighborIndex class is an abstraction of
......
......@@ -184,8 +184,9 @@ public:
}
}
/** Remove a leaf from its morton index
* @param indexToRemove the index of the leaf to remove
/** Create a leaf from its morton index
* @param indexToCreate the Morton index of the leaf to create
* @return a pointer on the leaf
*/
LeafClass* createLeaf(const MortonIndex indexToCreate ){
const FTreeCoordinate host(indexToCreate);
......@@ -1398,7 +1399,7 @@ public:
return idxNeighbors;
}
#ifdef TOTO
/** This function fill an array with the neighbors of a cell
* @param inNeighbors the array to store the elements
* @param inIndex the index of the element we want the neighbors
......@@ -1440,7 +1441,7 @@ public:
return idxNeighbors;
}
#endif
/** This function fill an array with the neighbors of a cell
* @param inNeighbors the array to store the elements
* @param inIndex the index of the element we want the neighbors
......@@ -1483,7 +1484,7 @@ public:
return idxNeighbors;
}
#ifdef TOTO
/** This function fill an array with the neighbors of a cell. The cell is set by its FTreeCordinate center
*
* @param[out] outNeighbors the array to store the elements
......@@ -1496,7 +1497,7 @@ public:
int getPeriodicLeafsNeighbors(ContainerClass* outNeighbors[27], FTreeCoordinate outOffsets[27],
bool* const isPeriodic,
const FTreeCoordinate& center, const int inLevel, const int inDirection){
std::cout << " FOCTREE::getPeriodicLeafsNeighbors "<< std::endl;
std::cout << " FOCTREE::getPeriodicLeafsNeighbors ?????? "<< std::endl;
const int boxLimite = FMath::pow2(inLevel);
if( center.getX() != 0 && center.getY() != 0 && center.getZ() != 0 &&
......@@ -1580,8 +1581,8 @@ public:
return idxNeighbors;
}
/** This function fill an array with the neighbors of a cell in the tree.
#endif
/** This function fill an array with the non empty adjacents cells of a cell in the tree.
* In the parallel case, we return only cells of the local octree.
*
* This method is used in the P2P operator in sequential or parallel periodic algorithm
......@@ -1600,18 +1601,22 @@ public:
* @param[in] inLevel the level of the element
* @return the number of neighbors */
//template< class ARRAY1, class ARRAY2, class ARRAY3 >
// int getPeriodicLeafsNeighbors(ARRAY1 outNeighbors, ARRAY2 outNeighborPositions,
// ARRAY3 outOffsets, bool*const isPeriodic,
int getPeriodicLeafsNeighbors(ContainerClass* outNeighbors[26], int outNeighborPositions[26],
FTreeCoordinate outOffsets[26], bool & isPeriodic,
// int getPeriodicLeafsNeighbors(ARRAY1&outNeighbors, ARRAY2 &outNeighborPositions,
// ARRAY3 &outOffsets, bool*const isPeriodic,
int getPeriodicLeafsNeighbors(ContainerClass* outNeighbors[26],
int outNeighborPositions[26],
FTreeCoordinate outOffsets[26], bool & isPeriodic,
const FTreeCoordinate& center, const int inLevel, const int inDirection){
std::cout << " FOCTREE::getPeriodicLeafsNeighbors "<< center.getMortonIndex() <<std::endl;
#ifdef SCALFMM_DEBUG_P2P_PERIODIQUE
std::cout << " FOCTREE::getPeriodicLeafsNeighbors ARRAY "<< center.getMortonIndex() <<std::endl;
#endif
const int boxLimite = FMath::pow2(inLevel);
if( center.getX() != 0 && center.getY() != 0 && center.getZ() != 0 &&
center.getX() != boxLimite - 1 && center.getY() != boxLimite - 1 && center.getZ() != boxLimite - 1 ){
#ifdef SCALFMM_DEBUG_P2P_PERIODIQUE
std::cout << " No periodic conditions the cell is not near the boundary " << std::endl;
#endif
isPeriodic = false;
return getLeafsNeighbors(outNeighbors, outNeighborPositions, center, inLevel);
}
......@@ -1673,15 +1678,18 @@ public:
// get the particle structure of the leaf
ContainerClass* const leaf = getLeafSrc(mortonOther);
// add to list if the cell exists i.e. the pointer is not null
if(leaf){
#ifdef SCALFMM_DEBUG_P2P_PERIODIQUE
std::cout << "mortonOther " <<mortonOther << " idx " <<idxX << " idyY " << idxY << " idxZ " <<idxZ
<< " " << (((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1 <<std::endl;
#endif
outNeighbors[idxNeighbors] = leaf;
outOffsets[idxNeighbors].setPosition(xoffset,yoffset,zoffset);
outNeighborPositions[idxNeighbors] = (((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1;
++idxNeighbors;
} // if(leaf)
}
} // if( idxX || idxY || idxZ )
}
}
......
......@@ -6,6 +6,7 @@
#include "../Utils/FGlobal.hpp"
#include <cstring>
#include <vector>
/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
......@@ -89,9 +90,9 @@ public:
// clear current element
clear();
// alloc bigger if needed
if(capacity < other.getSize()){
if(capacity < other.size()){
delete [] reinterpret_cast< char* >(array);
capacity = FSize(double(other.getSize()) * 1.5);
capacity = FSize(double(other.size()) * 1.5);
array = reinterpret_cast< ObjectType* >( new char[sizeof(ObjectType) * capacity]);
}
......@@ -119,7 +120,20 @@ public:
}
return (*this);
}
/**
*@brief Copy operator
*/
FVector& operator=(std::vector<ObjectType> && other){
if(&other != this){
clear();
delete [] reinterpret_cast< char* >(array);
array = other.data();
capacity = other.capacity();
index = other.size();
other.clear();
}
return (*this);
}
/**
*@brief destructor
*/
......@@ -136,7 +150,6 @@ public:
FSize getCapacity() const{
return capacity;
}
/**
*@brief Set the buffer capacity
*@param inCapacity to change the capacity
......@@ -209,9 +222,17 @@ public:
* @return The number of element added into the vector
* This is not the capcity
*/
// [[gnu::deprecated]]
FSize getSize() const{
return index;
}
/**
* @return The number of element added into the vector
* This is not the capcity
*/
FSize size() const{
return index;
}
/**
* @brief pop the first value
......
This source diff could not be displayed because it is too large. You can view the blob instead.
#ifndef FP2PEXCLUSION_HPP
#define FP2PEXCLUSION_HPP
#include "../Containers/FTreeCoordinate.hpp"
#include "Containers/FTreeCoordinate.hpp"
/**
* This class gives is responsible of the separation of the leaves
......
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