From: vbd Date: Fri, 14 Sep 2007 12:26:42 +0000 (+0000) Subject: staffan : X-Git-Tag: trio_trio_coupling~24 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=27ba9e4f7a4ae901305f5e4c034898e160a4939a;p=tools%2Fmedcoupling.git staffan : * fixed bug in testUnitTetra --- diff --git a/src/INTERP_KERNEL/testUnitTetra.cxx b/src/INTERP_KERNEL/testUnitTetra.cxx index 0b9b81521..c82b59e9d 100644 --- a/src/INTERP_KERNEL/testUnitTetra.cxx +++ b/src/INTERP_KERNEL/testUnitTetra.cxx @@ -5,6 +5,44 @@ using namespace MEDMEM; // simple test to see if a certain mesh is diagonal when intersected with itself +void dumpIntersectionMatrix(const IntersectionMatrix& m) +{ + int i = 0; + std::cout << "Intersection matrix is " << endl; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + + std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; + + } + ++i; + } + std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; +} + +double sumVolume(const IntersectionMatrix& m) +{ + + vector volumes; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + volumes.push_back(iter2->second); + // vol += std::abs(iter2->second); + } + } + + // sum in ascending order to avoid rounding errors + + sort(volumes.begin(), volumes.end()); + const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); + + return vol; +} + int main() { MEDMEM::MESH mesh1(MED_DRIVER,"/home/vb144235/resources/DividedUnitTetraSimpler.med","DividedUnitTetraSimpler"); @@ -13,17 +51,5 @@ int main() vector > matrix = interpolator.interpol_maillages(mesh1,mesh2); // dump - int i = 0; - std::cout << "Intersection matrix is " << endl; - for(IntersectionMatrix::const_iterator iter = matrix.begin() ; iter != matrix.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - - std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; - - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; + dumpIntersectionMatrix(matrix); }