Attention une mise à jour du serveur va être effectuée le lundi 17 mai entre 13h et 13h30. Cette mise à jour va générer une interruption du service de quelques minutes.

Commit fc133b46 authored by COULAUD Olivier's avatar COULAUD Olivier

Resolved merge conflict by incorporating both suggestions.

parents 54a989b4 cc9a9b37
...@@ -4,7 +4,8 @@ ...@@ -4,7 +4,8 @@
#include <memory> #include <memory>
#include "FAbstractBuffer.hpp" #include "FAbstractBuffer.hpp"
#include "../Utils/FAssert.hpp" #include "FBufferWriter.hpp"
#include "Utils/FAssert.hpp"
/** /**
* \brief Provides memory management and conversion to basic type * \brief Provides memory management and conversion to basic type
...@@ -38,6 +39,23 @@ public : ...@@ -38,6 +39,23 @@ public :
{ {
FAssertLF(array, "Cannot allocate array"); 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; virtual ~FBufferReader() = default;
......
...@@ -98,6 +98,9 @@ public: ...@@ -98,6 +98,9 @@ public:
return array.get(); return array.get();
} }
std::unique_ptr<char[]>* ptrData(){
return &array;
}
/** /**
* \brief Return the written memory size * \brief Return the written memory size
*/ */
......
#ifndef FNEIGHBORINDEXES_HPP #ifndef FNEIGHBORINDEXES_HPP
#define FNEIGHBORINDEXES_HPP #define FNEIGHBORINDEXES_HPP
#include "../Utils/FGlobal.hpp" #include "Utils/FGlobal.hpp"
/** /**
* @brief The FAbstractNeighborIndex class is an abstraction of * @brief The FAbstractNeighborIndex class is an abstraction of
......
...@@ -184,8 +184,9 @@ public: ...@@ -184,8 +184,9 @@ public:
} }
} }
/** Remove a leaf from its morton index /** Create a leaf from its morton index
* @param indexToRemove the index of the leaf to remove * @param indexToCreate the Morton index of the leaf to create
* @return a pointer on the leaf
*/ */
LeafClass* createLeaf(const MortonIndex indexToCreate ){ LeafClass* createLeaf(const MortonIndex indexToCreate ){
const FTreeCoordinate host(indexToCreate); const FTreeCoordinate host(indexToCreate);
...@@ -1398,7 +1399,7 @@ public: ...@@ -1398,7 +1399,7 @@ public:
return idxNeighbors; return idxNeighbors;
} }
#ifdef TOTO
/** This function fill an array with the neighbors of a cell /** This function fill an array with the neighbors of a cell
* @param inNeighbors the array to store the elements * @param inNeighbors the array to store the elements
* @param inIndex the index of the element we want the neighbors * @param inIndex the index of the element we want the neighbors
...@@ -1440,7 +1441,7 @@ public: ...@@ -1440,7 +1441,7 @@ public:
return idxNeighbors; return idxNeighbors;
} }
#endif
/** This function fill an array with the neighbors of a cell /** This function fill an array with the neighbors of a cell
* @param inNeighbors the array to store the elements * @param inNeighbors the array to store the elements
* @param inIndex the index of the element we want the neighbors * @param inIndex the index of the element we want the neighbors
...@@ -1483,7 +1484,7 @@ public: ...@@ -1483,7 +1484,7 @@ public:
return idxNeighbors; return idxNeighbors;
} }
#ifdef TOTO
/** This function fill an array with the neighbors of a cell. The cell is set by its FTreeCordinate center /** 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 * @param[out] outNeighbors the array to store the elements
...@@ -1496,7 +1497,7 @@ public: ...@@ -1496,7 +1497,7 @@ public:
int getPeriodicLeafsNeighbors(ContainerClass* outNeighbors[27], FTreeCoordinate outOffsets[27], int getPeriodicLeafsNeighbors(ContainerClass* outNeighbors[27], FTreeCoordinate outOffsets[27],
bool* const isPeriodic, bool* const isPeriodic,
const FTreeCoordinate& center, const int inLevel, const int inDirection){ 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); const int boxLimite = FMath::pow2(inLevel);
if( center.getX() != 0 && center.getY() != 0 && center.getZ() != 0 && if( center.getX() != 0 && center.getY() != 0 && center.getZ() != 0 &&
...@@ -1580,8 +1581,8 @@ public: ...@@ -1580,8 +1581,8 @@ public:
return idxNeighbors; return idxNeighbors;
} }
#endif
/** This function fill an array with the neighbors of a cell in the tree. /** 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. * 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 * This method is used in the P2P operator in sequential or parallel periodic algorithm
...@@ -1600,18 +1601,22 @@ public: ...@@ -1600,18 +1601,22 @@ public:
* @param[in] inLevel the level of the element * @param[in] inLevel the level of the element
* @return the number of neighbors */ * @return the number of neighbors */
//template< class ARRAY1, class ARRAY2, class ARRAY3 > //template< class ARRAY1, class ARRAY2, class ARRAY3 >
// int getPeriodicLeafsNeighbors(ARRAY1 outNeighbors, ARRAY2 outNeighborPositions, // int getPeriodicLeafsNeighbors(ARRAY1&outNeighbors, ARRAY2 &outNeighborPositions,
// ARRAY3 outOffsets, bool*const isPeriodic, // ARRAY3 &outOffsets, bool*const isPeriodic,
int getPeriodicLeafsNeighbors(ContainerClass* outNeighbors[26], int outNeighborPositions[26], int getPeriodicLeafsNeighbors(ContainerClass* outNeighbors[26],
int outNeighborPositions[26],
FTreeCoordinate outOffsets[26], bool & isPeriodic, FTreeCoordinate outOffsets[26], bool & isPeriodic,
const FTreeCoordinate& center, const int inLevel, const int inDirection){ 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); const int boxLimite = FMath::pow2(inLevel);
if( center.getX() != 0 && center.getY() != 0 && center.getZ() != 0 && if( center.getX() != 0 && center.getY() != 0 && center.getZ() != 0 &&
center.getX() != boxLimite - 1 && center.getY() != boxLimite - 1 && center.getZ() != boxLimite - 1 ){ 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; isPeriodic = false;
return getLeafsNeighbors(outNeighbors, outNeighborPositions, center, inLevel); return getLeafsNeighbors(outNeighbors, outNeighborPositions, center, inLevel);
} }
...@@ -1673,15 +1678,18 @@ public: ...@@ -1673,15 +1678,18 @@ public:
// get the particle structure of the leaf // get the particle structure of the leaf
ContainerClass* const leaf = getLeafSrc(mortonOther); ContainerClass* const leaf = getLeafSrc(mortonOther);
// add to list if the cell exists i.e. the pointer is not null // add to list if the cell exists i.e. the pointer is not null
if(leaf){ if(leaf){
#ifdef SCALFMM_DEBUG_P2P_PERIODIQUE
std::cout << "mortonOther " <<mortonOther << " idx " <<idxX << " idyY " << idxY << " idxZ " <<idxZ std::cout << "mortonOther " <<mortonOther << " idx " <<idxX << " idyY " << idxY << " idxZ " <<idxZ
<< " " << (((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1 <<std::endl; << " " << (((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1 <<std::endl;
#endif
outNeighbors[idxNeighbors] = leaf; outNeighbors[idxNeighbors] = leaf;
outOffsets[idxNeighbors].setPosition(xoffset,yoffset,zoffset); outOffsets[idxNeighbors].setPosition(xoffset,yoffset,zoffset);
outNeighborPositions[idxNeighbors] = (((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1; outNeighborPositions[idxNeighbors] = (((idxX + 1) * 3) + (idxY +1)) * 3 + idxZ + 1;
++idxNeighbors; ++idxNeighbors;
} // if(leaf) }
} // if( idxX || idxY || idxZ ) } // if( idxX || idxY || idxZ )
} }
} }
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include "../Utils/FGlobal.hpp" #include "../Utils/FGlobal.hpp"
#include <cstring> #include <cstring>
#include <vector>
/** /**
* @author Berenger Bramas (berenger.bramas@inria.fr) * @author Berenger Bramas (berenger.bramas@inria.fr)
...@@ -89,9 +90,9 @@ public: ...@@ -89,9 +90,9 @@ public:
// clear current element // clear current element
clear(); clear();
// alloc bigger if needed // alloc bigger if needed
if(capacity < other.getSize()){ if(capacity < other.size()){
delete [] reinterpret_cast< char* >(array); 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]); array = reinterpret_cast< ObjectType* >( new char[sizeof(ObjectType) * capacity]);
} }
...@@ -119,7 +120,20 @@ public: ...@@ -119,7 +120,20 @@ public:
} }
return (*this); 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 *@brief destructor
*/ */
...@@ -136,7 +150,6 @@ public: ...@@ -136,7 +150,6 @@ public:
FSize getCapacity() const{ FSize getCapacity() const{
return capacity; return capacity;
} }
/** /**
*@brief Set the buffer capacity *@brief Set the buffer capacity
*@param inCapacity to change the capacity *@param inCapacity to change the capacity
...@@ -209,9 +222,17 @@ public: ...@@ -209,9 +222,17 @@ public:
* @return The number of element added into the vector * @return The number of element added into the vector
* This is not the capcity * This is not the capcity
*/ */
// [[gnu::deprecated]]
FSize getSize() const{ FSize getSize() const{
return index; 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 * @brief pop the first value
......
#ifndef FP2PEXCLUSION_HPP #ifndef FP2PEXCLUSION_HPP
#define FP2PEXCLUSION_HPP #define FP2PEXCLUSION_HPP
#include "../Containers/FTreeCoordinate.hpp" #include "Containers/FTreeCoordinate.hpp"
/** /**
* This class gives is responsible of the separation of the leaves * 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