Commit de4d2b1d authored by Quentin Khan's avatar Quentin Khan

Modify (u)tests to retrieve correctly kernel data

Change relevant call to getMultipoleData and getLocalExpansionData.
parent 51f8af8c
......@@ -4,13 +4,13 @@
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// abiding by the rules of distribution of free software.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
......@@ -130,18 +130,18 @@ int main(int argc, char ** argv){
const CellClass*const cell2 = octreeIterator2.getCurrentCell();
FReal cumul = 0;
for(int idx = 0; idx < FSphericalCell<FReal>::GetPoleSize(); ++idx){
cumul += FMath::Abs( cell1->getMultipole()[idx].getImag() - cell2->getMultipole()[idx].getImag() );
cumul += FMath::Abs( cell1->getMultipole()[idx].getReal() - cell2->getMultipole()[idx].getReal() );
for(int idx = 0; idx < FSphericalCell<FReal>::multipole_t::getSize(); ++idx){
cumul += FMath::Abs( cell1->getMultipoleData().get()[idx].getImag() - cell2->getMultipoleData().get()[idx].getImag() );
cumul += FMath::Abs( cell1->getMultipoleData().get()[idx].getReal() - cell2->getMultipoleData().get()[idx].getReal() );
}
if( cumul > 0.00001 || FMath::IsNan(cumul)){
std::cout << "Pole Data are different. Cumul " << cumul << " at level " << idxLevel
<< " index is " << octreeIterator1.getCurrentGlobalIndex() << std::endl;
}
cumul = 0;
for(int idx = 0; idx < FSphericalCell<FReal>::GetLocalSize(); ++idx){
cumul += FMath::Abs( cell1->getLocal()[idx].getImag() - cell2->getLocal()[idx].getImag() );
cumul += FMath::Abs( cell1->getLocal()[idx].getReal() - cell2->getLocal()[idx].getReal() );
for(int idx = 0; idx < FSphericalCell<FReal>::local_expansion_t::getSize(); ++idx){
cumul += FMath::Abs( cell1->getLocalExpansionData().get()[idx].getImag() - cell2->getLocalExpansionData().get()[idx].getImag() );
cumul += FMath::Abs( cell1->getLocalExpansionData().get()[idx].getReal() - cell2->getLocalExpansionData().get()[idx].getReal() );
}
if( cumul > 0.00001 || FMath::IsNan(cumul)){
std::cout << "Local Data are different. Cumul " << cumul << " at level " << idxLevel
......@@ -177,7 +177,3 @@ int main(int argc, char ** argv){
return 0;
}
......@@ -4,13 +4,13 @@
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.
//
// abiding by the rules of distribution of free software.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info".
// "http://www.cecill.info".
// "http://www.gnu.org/licenses".
// ===================================================================================
......@@ -121,8 +121,8 @@ int main(int argc, char ** argv){
long long int counterNbPart = 0;
tree.forEachCellLeaf([&](CellClass* cell, LeafClass* leaf){
if(cell->getDataUp() != leaf->getSrc()->getNbParticles() ){
std::cout << "Problem P2M Data up = " << cell->getDataUp() <<
if(cell->getMultipoleData().get() != leaf->getSrc()->getNbParticles() ){
std::cout << "Problem P2M Data up = " << cell->getMultipoleData().get() <<
" Size = " << leaf->getSrc()->getNbParticles() << "\n";
}
// we also count the number of particles.
......@@ -162,6 +162,3 @@ int main(int argc, char ** argv){
return 0;
}
......@@ -185,7 +185,12 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> {
for (int j = 0 ; j <= DevP ; ++j ){
std::cout <<"[" << j << "] ----- level\n";
for (int k=0; k<=j ;++k, ++index_j_k){
std::cout << "[" << k << "] ( " << cell->getMultipole()[index_j_k].getReal() << " , " << cell->getMultipole()[index_j_k].getImag() << " ) ";
std::cout
<< "[" << k << "] ( "
<< cell->getMultipoleData().get()[index_j_k].getReal()
<< " , "
<< cell->getMultipoleData().get()[index_j_k].getImag()
<< " ) ";
}
std::cout << "\n";
}
......@@ -195,7 +200,11 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> {
for (int j = 0 ; j <= DevP ; ++j ){
std::cout <<"[" << j << "] ----- level \n";
for (int k=0; k<=j ;++k, ++index_j_k){
std::cout << "[" << k << "] ( " << cell->getLocal()[index_j_k].getReal() << " , " << cell->getLocal()[index_j_k].getImag() << " ) ";
std::cout
<< "[" << k << "] ( "
<< cell->getLocalExpansionData().get()[index_j_k].getReal()
<< " , " << cell->getLocalExpansionData().get()[index_j_k].getImag()
<< " ) ";
}
std::cout << "\n";
}
......@@ -358,6 +367,3 @@ class TestSphericalDirect : public FUTester<TestSphericalDirect> {
// You must do this
TestClass(TestSphericalDirect)
......@@ -348,8 +348,8 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
FMath::FAccurater<FReal> accurater;
for(int idx = 0; idx < cl->getVectorSize(); ++idx){
accurater.add(cl->getMultipole(0)[idx],
clnonper->getMultipole(0)[idx]);
accurater.add(cl->getMultipoleData().getMultipole(0)[idx],
clnonper->getMultipoleData().getMultipole(0)[idx]);
}
uassert(accurater.getInfNorm() < 1E-10);
uassert(accurater.getL2Norm() < 1E-10);
......@@ -557,8 +557,8 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
FMath::FAccurater<FReal> accurater;
for(int idx = 0; idx < cl->getVectorSize(); ++idx){
accurater.add(cl->getMultipole(0)[idx],
clnonper->getMultipole(0)[idx]);
accurater.add(cl->getMultipoleData().getMultipole(0)[idx],
clnonper->getMultipoleData().getMultipole(0)[idx]);
}
uassert(accurater.getInfNorm() < 1E-10);
uassert(accurater.getL2Norm() < 1E-10);
......@@ -566,8 +566,8 @@ class TestChebyshevDirect : public FUTester<TestChebyshevDirect> {
FMath::FAccurater<FReal> accuraterLocal;
for(int idx = 0; idx < cl->getVectorSize(); ++idx){
accuraterLocal.add(cl->getLocal(0)[idx],
clnonper->getLocal(0)[idx]);
accuraterLocal.add(cl->getLocalExpansionData().getLocal(0)[idx],
clnonper->getLocalExpansionData().getLocal(0)[idx]);
}
uassert(accuraterLocal.getInfNorm() < 1E-8);
uassert(accuraterLocal.getL2Norm() < 1E-8);
......
......@@ -226,8 +226,8 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> {
FMath::FAccurater<FReal> multiPoleDiff;
tree.forEachCell([&](CellClass* cell){
for( int idxRhs = 1 ; idxRhs < NVals ; ++idxRhs){
localDiff.add(cell->getLocal(0), cell->getLocal(idxRhs), cell->getVectorSize());
multiPoleDiff.add(cell->getMultipole(0), cell->getMultipole(idxRhs), cell->getVectorSize());
localDiff.add(cell->getLocalExpansionData().getLocal(0), cell->getLocalExpansionData().getLocal(idxRhs), cell->getLocalExpansionData().getVectorSize());
multiPoleDiff.add(cell->getMultipoleData().getMultipole(0), cell->getMultipoleData().getMultipole(idxRhs), cell->getMultipoleData().getVectorSize());
}
});
Print("Local diff is = ");
......@@ -319,18 +319,13 @@ class TestInterpolationKernel : public FUTester<TestInterpolationKernel> {
/** set test */
void SetTests(){
AddTest(&TestInterpolationKernel::TestUnifKernel,"Test Lagrange/Uniform grid FMM");
//AddTest(&TestInterpolationKernel::TestUnifKernel,"Test Lagrange/Uniform grid FMM");
AddTest(&TestInterpolationKernel::TestChebSymKernel,"Test Symmetric Chebyshev Kernel with 16 small SVDs and symmetries");
AddTest(&TestInterpolationKernel::TestChebKernel,"Test Chebyshev Kernel with 1 large SVD");
}
};
// You must do this
TestClass(TestInterpolationKernel)
......@@ -175,18 +175,18 @@ class TestSphericalWithPrevious : public FUTester<TestSphericalWithPrevious> {
break;
}
for(int idxLocal = 0 ; idxLocal < CellClass::GetLocalSize() ; ++idxLocal){
IsSimilar(testOctreeIterator.getCurrentCell()->getLocal()[idxLocal].getReal(),
goodOctreeIterator.getCurrentCell()->getLocal()[idxLocal].getReal());
IsSimilar(testOctreeIterator.getCurrentCell()->getLocal()[idxLocal].getImag(),
goodOctreeIterator.getCurrentCell()->getLocal()[idxLocal].getImag());
for(int idxLocal = 0 ; idxLocal < CellClass::local_expansion_t::getSize() ; ++idxLocal){
IsSimilar(testOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getReal(),
goodOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getReal());
IsSimilar(testOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getImag(),
goodOctreeIterator.getCurrentCell()->getLocalExpansionData().get()[idxLocal].getImag());
}
for(int idxPole = 0 ; idxPole < CellClass::GetPoleSize() ; ++idxPole){
IsSimilar(testOctreeIterator.getCurrentCell()->getMultipole()[idxPole].getReal(),
goodOctreeIterator.getCurrentCell()->getMultipole()[idxPole].getReal());
IsSimilar(testOctreeIterator.getCurrentCell()->getMultipole()[idxPole].getImag(),
goodOctreeIterator.getCurrentCell()->getMultipole()[idxPole].getImag());
for(int idxPole = 0 ; idxPole < CellClass::multipole_t::getSize() ; ++idxPole){
IsSimilar(testOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getReal(),
goodOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getReal());
IsSimilar(testOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getImag(),
goodOctreeIterator.getCurrentCell()->getMultipoleData().get()[idxPole].getImag());
}
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