Commit a8808f9a authored by Berenger Bramas's avatar Berenger Bramas

Merge branch 'bugfix/loadtreespherical' into 'devel'

Bugfix/loadtreespherical

See merge request !7
parents bf29aa84 8fea8b1e
...@@ -165,7 +165,7 @@ private: ...@@ -165,7 +165,7 @@ private:
*/ */
template<class... Types> template<class... Types>
FSize getSavedSize_impl(std::tuple<Types*...>) const { FSize getSavedSize_impl(std::tuple<Types*...>) const {
FSize tmp = sizeof(this->size()); FSize tmp = sizeof(FSize);
// Sum, for T in Types, of (sizeof(T) * this->size()) // Sum, for T in Types, of (sizeof(T) * this->size())
auto l = {(tmp += sizeof(Types) * this->size(), 0)..., 0}; auto l = {(tmp += sizeof(Types) * this->size(), 0)..., 0};
(void)l; (void)l;
...@@ -198,7 +198,7 @@ private: ...@@ -198,7 +198,7 @@ private:
*/ */
template<class BufferWriter, std::size_t ... Is> template<class BufferWriter, std::size_t ... Is>
void save_impl(BufferWriter& buffer, inria::index_sequence<Is...>) const { void save_impl(BufferWriter& buffer, inria::index_sequence<Is...>) const {
buffer << this->size(); buffer << FSize(this->size());
// For each sub-array `s`, write `s` to the buffer // For each sub-array `s`, write `s` to the buffer
auto l = { auto l = {
(buffer.write(std::get<Is>(this->data()), this->size()),0)..., (buffer.write(std::get<Is>(this->data()), this->size()),0)...,
......
...@@ -192,6 +192,7 @@ public: ...@@ -192,6 +192,7 @@ public:
FSize sizeOfLeaf = 0; FSize sizeOfLeaf = 0;
file.read((char*)&sizeOfLeaf, sizeof(FSize)); file.read((char*)&sizeOfLeaf, sizeof(FSize));
buffer.seek(0);
buffer.reserve(sizeOfLeaf); buffer.reserve(sizeOfLeaf);
file.read((char*)buffer.data(), sizeOfLeaf); file.read((char*)buffer.data(), sizeOfLeaf);
...@@ -226,6 +227,7 @@ public: ...@@ -226,6 +227,7 @@ public:
FSize sizeOfCell = 0; FSize sizeOfCell = 0;
file.read((char*)&sizeOfCell, sizeof(FSize)); file.read((char*)&sizeOfCell, sizeof(FSize));
buffer.seek(0);
buffer.reserve(sizeOfCell); buffer.reserve(sizeOfCell);
file.read((char*)buffer.data(), sizeOfCell); file.read((char*)buffer.data(), sizeOfCell);
......
...@@ -97,7 +97,7 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> { ...@@ -97,7 +97,7 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> {
algo.execute(); algo.execute();
// If needed save the result // If needed save the result
//FTreeIO<FReal>::Save<OctreeClass, CellClass, LeafClass, ContainerClass >(DataFile.c_str(), testTree); // FTreeIO<FReal>::Save<OctreeClass, CellClass, LeafClass, ContainerClass >(DataFile.c_str(), testTree);
// Load previous result // Load previous result
OctreeClass goodTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox()); OctreeClass goodTree(NbLevels, SizeSubLevels, loader.getBoxWidth(), loader.getCenterOfBox());
...@@ -127,10 +127,10 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> { ...@@ -127,10 +127,10 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> {
const ContainerClass* goodLeaf = goodOctreeIterator.getCurrentListSrc(); const ContainerClass* goodLeaf = goodOctreeIterator.getCurrentListSrc();
for(FSize idxPart = 0 ; idxPart < testLeaf->getNbParticles() ; ++idxPart ){ for(FSize idxPart = 0 ; idxPart < testLeaf->getNbParticles() ; ++idxPart ){
uassert( IsSimilar(goodLeaf->getPotentials()[idxPart], testLeaf->getPotentials()[idxPart]) ); uassert( IsSimilar(goodLeaf->getPotentials()[idxPart], testLeaf->getPotentials()[idxPart]) );
uassert( IsSimilar(goodLeaf->getForcesX()[idxPart], testLeaf->getForcesX()[idxPart]) ); uassert( IsSimilar(goodLeaf->getForcesX()[idxPart], testLeaf->getForcesX()[idxPart]) );
uassert( IsSimilar(goodLeaf->getForcesY()[idxPart], testLeaf->getForcesY()[idxPart]) ); uassert( IsSimilar(goodLeaf->getForcesY()[idxPart], testLeaf->getForcesY()[idxPart]) );
uassert( IsSimilar(goodLeaf->getForcesZ()[idxPart], testLeaf->getForcesZ()[idxPart]) ); uassert( IsSimilar(goodLeaf->getForcesZ()[idxPart], testLeaf->getForcesZ()[idxPart]) );
} }
if(!testOctreeIterator.moveRight()){ if(!testOctreeIterator.moveRight()){
......
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