From: vbd Date: Fri, 14 Sep 2007 09:09:09 +0000 (+0000) Subject: staffan : X-Git-Tag: trio_trio_coupling~33 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=57819406f8fbe51ee52895fd5f73a4085b0a793a;p=tools%2Fmedcoupling.git staffan : * doc updates --- diff --git a/src/INTERP_KERNEL/BoundingBox.hxx b/src/INTERP_KERNEL/BoundingBox.hxx index 60e361f75..bdce9e4ae 100644 --- a/src/INTERP_KERNEL/BoundingBox.hxx +++ b/src/INTERP_KERNEL/BoundingBox.hxx @@ -7,7 +7,7 @@ namespace INTERP_UTILS { /** - * Class representing the bounding box of a number of points. + * \brief Class representing the bounding box of a number of points. * */ class BoundingBox diff --git a/src/INTERP_KERNEL/Log.hxx b/src/INTERP_KERNEL/Log.hxx index 86591b9be..8e609a532 100644 --- a/src/INTERP_KERNEL/Log.hxx +++ b/src/INTERP_KERNEL/Log.hxx @@ -1,7 +1,9 @@ #ifndef _LOG_H_ #define _LOG_H_ -/* Simple pre-processor logging utility. +/** + * \file Log.hxx + * \brief Simple pre-processor logging utility. * Replaces LOG( lvl, x ) with "if(lvl <= LOG_LEVEL) std::cout << x << std::endl" when logging is active * (LOG_LEVEL > 0 is defined). x is the level at which the message should be logged - if it is smaller or equal to * LOG_LEVEL (which can be defined at compile-time for each file by passing option -DLOG_LEVEL=x to gcc) diff --git a/src/INTERP_KERNEL/MeshElement.hxx b/src/INTERP_KERNEL/MeshElement.hxx index 933397aa1..a6e56e833 100644 --- a/src/INTERP_KERNEL/MeshElement.hxx +++ b/src/INTERP_KERNEL/MeshElement.hxx @@ -16,7 +16,7 @@ namespace INTERP_UTILS { /** - * Class representing a single element of a mesh together with its bounding box. + * \brief Class representing a single element of a mesh together with its bounding box. * It gives access to the element's global number, type and bounding box and allows * easy bounding box intersection tests between MeshElements and collections of MeshElement (MeshRegions) */ diff --git a/src/INTERP_KERNEL/MeshRegion.hxx b/src/INTERP_KERNEL/MeshRegion.hxx index e00936981..e8f5cf9de 100644 --- a/src/INTERP_KERNEL/MeshRegion.hxx +++ b/src/INTERP_KERNEL/MeshRegion.hxx @@ -11,7 +11,7 @@ namespace INTERP_UTILS class MeshElement; /** - * Class representing a set of elements in a mesh together with their bounding box. + * \brief Class representing a set of elements in a mesh together with their bounding box. * It permits to split itself in two, which is used in the depth-first search filtering process. * */ diff --git a/src/INTERP_KERNEL/Test/MeshTestToolkit.cxx b/src/INTERP_KERNEL/Test/MeshTestToolkit.cxx index d206280ad..5fcee5f96 100644 --- a/src/INTERP_KERNEL/Test/MeshTestToolkit.cxx +++ b/src/INTERP_KERNEL/Test/MeshTestToolkit.cxx @@ -32,294 +32,399 @@ using namespace INTERP_UTILS; namespace INTERP_TEST { -double MeshTestToolkit::sumRow(const IntersectionMatrix& m, int i) const -{ - double vol = 0.0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - if(iter->count(i) != 0.0) - { - map::const_iterator iter2 = iter->find(i); - vol += iter2->second; - } - } - return vol; -} - -double MeshTestToolkit::sumCol(const IntersectionMatrix& m, int i) const -{ - double vol = 0.0; - const std::map& col = m[i]; - for(map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) - { - vol += std::abs(iter->second); - } - return vol; -} + /** + * Calculates the sum of a row of an intersection matrix + * + * @param m an intersection matrix + * @param i the index of the row (1 <= i <= #rows) + * @return the sum of the values of row i + * + */ + double MeshTestToolkit::sumRow(const IntersectionMatrix& m, int i) const + { + double vol = 0.0; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + if(iter->count(i) != 0.0) + { + map::const_iterator iter2 = iter->find(i); + vol += iter2->second; + } + } + return vol; + } + /** + * Calculates the sum of a column of an intersection matrix + * + * @param m an intersection matrix + * @param i the index of the column (0 <= i <= #rows - 1) + * @return the sum of the values of column i + * + */ + double MeshTestToolkit::sumCol(const IntersectionMatrix& m, int i) const + { + double vol = 0.0; + const std::map& col = m[i]; + for(map::const_iterator iter = col.begin() ; iter != col.end() ; ++iter) + { + vol += std::abs(iter->second); + } + return vol; + } -void MeshTestToolkit::getVolumes(MESH& mesh, const double*& tab) const -{ - SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); - FIELD* f=mesh.getVolume(sup); - tab = f->getValue(); - delete sup; -} + /** + * Gets the volumes of the elements in a mesh. + * + * @param mesh the mesh + * @param tab pointer to double[no. elements of mesh] array in which to store the volumes + */ + void MeshTestToolkit::getVolumes(MESH& mesh, const double*& tab) const + { + SUPPORT *sup=new SUPPORT(&mesh,"dummy",MED_CELL); + FIELD* f=mesh.getVolume(sup); + tab = f->getValue(); + delete sup; + } -double MeshTestToolkit::sumVolume(const IntersectionMatrix& m) const -{ + /** + * Sums all the elements (volumes) of an intersection matrix + * + * @param m the intersection matrix + * @return the sum of the elements of m + */ + double MeshTestToolkit::sumVolume(const IntersectionMatrix& m) const + { - 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); - } - } + 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 + // sum in ascending order to avoid rounding errors - sort(volumes.begin(), volumes.end()); - const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); + sort(volumes.begin(), volumes.end()); + const double vol = accumulate(volumes.begin(), volumes.end(), 0.0); - return vol; -} + return vol; + } -bool MeshTestToolkit::testVolumes(const IntersectionMatrix& m, MESH& sMesh, MESH& tMesh) const -{ - bool ok = true; - - // source elements - const double* sVol = new double[sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS)]; - getVolumes(sMesh, sVol); - - for(int i = 0; i < sMesh.getNumberOfElements(MED_CELL,MED_ALL_ELEMENTS); ++i) - { - const double sum_row = sumRow(m, i+1); - if(!epsilonEqualRelative(sum_row, sVol[i], VOL_PREC)) - { - LOG(1, "Source volume inconsistent : vol of cell " << i << " = " << sVol[i] << " but the row sum is " << sum_row ); - ok = false; - } - LOG(1, "diff = " <::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + int j = iter2->first; + if(m2.at(j-1).count(i+1) == 0) + { + if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) + { + LOG(2, "V1( " << i << ", " << j << ") exists, but V2( " << j - 1 << ", " << i + 1 << ") " << " does not " ); + LOG(2, "(" << i << ", " << j << ") fails"); + compatitable = false; + } + } + } + ++i; + } + if(!compatitable) + { + LOG(1, "*** matrices are not compatitable"); + } + return compatitable; + } -bool MeshTestToolkit::testSymmetric(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const -{ + /** + * Tests if two intersection matrices are each others' transposes. + * + * @param m1 the first intersection matrix + * @param m2 the second intersection matrix + * @return true if m1 = m2^T, false if not. + */ + bool MeshTestToolkit::testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const + { - int i = 0; - bool isSymmetric = true; - - LOG(1, "Checking symmetry src - target" ); - isSymmetric = isSymmetric & areCompatitable(m1, m2) ; - LOG(1, "Checking symmetry target - src" ); - isSymmetric = isSymmetric & areCompatitable(m2, m1); - - for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double v1 = iter2->second; - //if(m2[j - 1].count(i+1) > 0) - // { - map theMap = m2.at(j-1); - const double v2 = theMap[i + 1]; - if(v1 != v2) - { - LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); - if(!epsilonEqualRelative(v1, v2, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isSymmetric = false; - } - } - } - ++i; - } - if(!isSymmetric) - { - LOG(1, "*** matrices are not symmetric"); - } - return isSymmetric; -} + int i = 0; + bool isSymmetric = true; + + LOG(1, "Checking symmetry src - target" ); + isSymmetric = isSymmetric & areCompatitable(m1, m2) ; + LOG(1, "Checking symmetry target - src" ); + isSymmetric = isSymmetric & areCompatitable(m2, m1); + + for(IntersectionMatrix::const_iterator iter = m1.begin() ; iter != m1.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + int j = iter2->first; + const double v1 = iter2->second; + //if(m2[j - 1].count(i+1) > 0) + // { + map theMap = m2.at(j-1); + const double v2 = theMap[i + 1]; + if(v1 != v2) + { + LOG(2, "V1( " << i << ", " << j << ") = " << v1 << " which is different from V2( " << j - 1 << ", " << i + 1 << ") = " << v2 << " | diff = " << v1 - v2 ); + if(!epsilonEqualRelative(v1, v2, VOL_PREC)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isSymmetric = false; + } + } + } + ++i; + } + if(!isSymmetric) + { + LOG(1, "*** matrices are not symmetric"); + } + return isSymmetric; + } -bool MeshTestToolkit::testDiagonal(const IntersectionMatrix& m) const -{ - LOG(1, "Checking if matrix is diagonal" ); - int i = 1; - bool isDiagonal = true; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - int j = iter2->first; - const double vol = iter2->second; - if(vol != 0.0 && (i != j)) - { - LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); - if(!epsilonEqual(vol, 0.0, VOL_PREC)) - { - LOG(2, "(" << i << ", " << j << ") fails"); - isDiagonal = false; - } - } - } - ++i; - } - if(!isDiagonal) - { - LOG(1, "*** matrix is not diagonal"); - } - return isDiagonal; -} + /** + * Tests if an intersection matrix is diagonal. + * + * @param the intersection matrix + * @return true if m is diagonal; false if not + * + */ + bool MeshTestToolkit::testDiagonal(const IntersectionMatrix& m) const + { + LOG(1, "Checking if matrix is diagonal" ); + int i = 1; + bool isDiagonal = true; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + int j = iter2->first; + const double vol = iter2->second; + if(vol != 0.0 && (i != j)) + { + LOG(2, "V( " << i - 1 << ", " << j << ") = " << vol << " which is not zero" ); + if(!epsilonEqual(vol, 0.0, VOL_PREC)) + { + LOG(2, "(" << i << ", " << j << ") fails"); + isDiagonal = false; + } + } + } + ++i; + } + if(!isDiagonal) + { + LOG(1, "*** matrix is not diagonal"); + } + return isDiagonal; + } -void MeshTestToolkit::dumpIntersectionMatrix(const IntersectionMatrix& m) const -{ - 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) - { + /** + * Outputs the intersection matrix as a list of all its elements to std::cout. + * + * @param m the intersection matrix to output + */ + void MeshTestToolkit::dumpIntersectionMatrix(const IntersectionMatrix& m) const + { + 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; + std::cout << "V(" << i << ", " << iter2->first << ") = " << iter2->second << endl; - } - ++i; - } - std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; -} + } + ++i; + } + std::cout << "Sum of volumes = " << sumVolume(m) << std::endl; + } -void MeshTestToolkit::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const -{ - const string dataBaseDir = getenv("MED_ROOT_DIR"); - const string dataDir = dataBaseDir + string("share/salome/resources/med/"); + /** + * Calculates the intersection matrix for two meshes. + * If the source and target meshes are the same, a CppUnit assertion raised if testVolumes() returns false. + * + * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh1 the name of the source mesh + * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh2 the name of the target mesh + * @param m intersection matrix in which to store the result of the intersection + */ + void MeshTestToolkit::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const + { + const string dataBaseDir = getenv("MED_ROOT_DIR"); + const string dataDir = dataBaseDir + string("share/salome/resources/med/"); - LOG(1, std::endl << "=== -> intersecting src = " << mesh1path << ", target = " << mesh2path ); + LOG(1, std::endl << "=== -> intersecting src = " << mesh1path << ", target = " << mesh2path ); - LOG(5, "Loading " << mesh1 << " from " << mesh1path); - MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); + LOG(5, "Loading " << mesh1 << " from " << mesh1path); + MESH sMesh(MED_DRIVER, dataDir+mesh1path, mesh1); - LOG(5, "Loading " << mesh2 << " from " << mesh2path); - MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); + LOG(5, "Loading " << mesh2 << " from " << mesh2path); + MESH tMesh(MED_DRIVER, dataDir+mesh2path, mesh2); - m = _interpolator->interpol_maillages(sMesh, tMesh); + m = _interpolator->interpol_maillages(sMesh, tMesh); - // if reflexive, check volumes - if(strcmp(mesh1path,mesh2path) == 0) - { - const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); - } + // if reflexive, check volumes + if(strcmp(mesh1path,mesh2path) == 0) + { + const bool row_and_col_sums_ok = testVolumes(m, sMesh, tMesh); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Row or column sums incorrect", true, row_and_col_sums_ok); + } - LOG(1, "Intersection calculation done. " << std::endl ); + LOG(1, "Intersection calculation done. " << std::endl ); -} + } -void MeshTestToolkit::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const -{ - LOG(1, std::endl << std::endl << "=============================" ); + /** + * Tests the intersection algorithm for two meshes. + * Depending on the nature of the meshes, different tests will be performed. The sum of the elements will + * be compared to the given total volume of the intersection in all cases. If the two meshes are the same, then + * it will be confirmed that the intersection matrix is diagonal, otherwise the intersection matrices will be + * calculated once which each mesh as source mesh, and it will be verified that the they are each others' transpose. + * + * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh1 the name of the source mesh + * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh2 the name of the target mesh + * @param correctVol the total volume of the intersection of the two meshes + * @param prec maximum relative error to be tolerated in volume comparisions + * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed + * + */ + void MeshTestToolkit::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const + { + LOG(1, std::endl << std::endl << "=============================" ); - using std::string; - const string path1 = string(mesh1path) + string(mesh1); - const string path2 = string(mesh2path) + string(mesh2); + using std::string; + const string path1 = string(mesh1path) + string(mesh1); + const string path2 = string(mesh2path) + string(mesh2); - const bool isTestReflexive = (path1.compare(path2) == 0); + const bool isTestReflexive = (path1.compare(path2) == 0); - IntersectionMatrix matrix1; - calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); + IntersectionMatrix matrix1; + calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1); #if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix1); + dumpIntersectionMatrix(matrix1); #endif - std::cout.precision(16); + std::cout.precision(16); - const double vol1 = sumVolume(matrix1); + const double vol1 = sumVolume(matrix1); - if(!doubleTest) - { - LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); + if(!doubleTest) + { + LOG(1, "vol = " << vol1 <<" correctVol = " << correctVol ); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(correctVol, vol1)); - if(isTestReflexive) - { - CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); - } - } - else - { + if(isTestReflexive) + { + CPPUNIT_ASSERT_EQUAL_MESSAGE("Reflexive test failed", true, testDiagonal(matrix1)); + } + } + else + { - IntersectionMatrix matrix2; - calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); + IntersectionMatrix matrix2; + calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2); #if LOG_LEVEL >= 2 - dumpIntersectionMatrix(matrix2); + dumpIntersectionMatrix(matrix2); #endif - const double vol2 = sumVolume(matrix2); + const double vol2 = sumVolume(matrix2); - LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); + LOG(1, "vol1 = " << vol1 << ", vol2 = " << vol2 << ", correctVol = " << correctVol ); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); - CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); - CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testSymmetric(matrix1, matrix2)); - } + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol1, prec * std::max(vol1, correctVol)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, vol2, prec * std::max(vol2, correctVol)); + CPPUNIT_ASSERT_DOUBLES_EQUAL(vol1, vol2, prec * std::max(vol1, vol2)); + CPPUNIT_ASSERT_EQUAL_MESSAGE("Symmetry test failed", true, testTranspose(matrix1, matrix2)); + } -} + } -void MeshTestToolkit::intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const + /** + * Utility method used to facilitate the call to intersect meshes. + * It calls intersectMeshes, using "mesh1.med" as file name for the mesh with name "mesh1" and + * "mesh2.med" as file name for the mesh with name "mesh2". The rest of the arguments are passed + * along as they are. + * + * @param mesh1 the name of the source mesh + * @param mesh2 the name of the target mesh + * @param correctVol the total volume of the intersection of the two meshes + * @param prec maximum relative error to be tolerated in volume comparisions + * @param doubleTest if false, only the test with mesh 1 as the source mesh and mesh 2 as the target mesh will be performed + * + */ + void MeshTestToolkit::intersectMeshes(const char* mesh1, const char* mesh2, const double correctVol, const double prec, bool doubleTest) const { const string path1 = string(mesh1) + string(".med"); std::cout << "here :" << path1 << std::endl; @@ -328,25 +433,5 @@ void MeshTestToolkit::intersectMeshes(const char* mesh1, const char* mesh2, cons intersectMeshes(path1.c_str(), mesh1, path2.c_str(), mesh2, correctVol, prec, doubleTest); } -std::pair MeshTestToolkit::countNumberOfMatrixEntries(const IntersectionMatrix& m) -{ - - int numElems = 0; - int numNonZero = 0; - for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) - { - numElems += iter->size(); - for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) - { - if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) - { - ++numNonZero; - } - } - } - return std::make_pair(numElems, numNonZero); -} - - } diff --git a/src/INTERP_KERNEL/Test/MeshTestToolkit.hxx b/src/INTERP_KERNEL/Test/MeshTestToolkit.hxx index 59eed4cc2..c16cfc907 100644 --- a/src/INTERP_KERNEL/Test/MeshTestToolkit.hxx +++ b/src/INTERP_KERNEL/Test/MeshTestToolkit.hxx @@ -13,7 +13,10 @@ using namespace INTERP_UTILS; namespace INTERP_TEST { - + /** + * \brief Class providing services for mesh intersection tests. + * + */ class MeshTestToolkit { @@ -42,16 +45,15 @@ namespace INTERP_TEST bool areCompatitable( const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; - bool testSymmetric(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; + bool testTranspose(const IntersectionMatrix& m1, const IntersectionMatrix& m2) const; bool testDiagonal(const IntersectionMatrix& m) const; void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) const; - std::pair countNumberOfMatrixEntries(const IntersectionMatrix& m); - protected: + /// Interpolation3D object used for interpolation Interpolation3D* _interpolator; }; diff --git a/src/INTERP_KERNEL/Test/PerfTest.cxx b/src/INTERP_KERNEL/Test/PerfTest.cxx index 73432b66b..d847f6fe4 100644 --- a/src/INTERP_KERNEL/Test/PerfTest.cxx +++ b/src/INTERP_KERNEL/Test/PerfTest.cxx @@ -10,12 +10,39 @@ using namespace MEDMEM; using namespace MED_EN; +/** + * \file PerfTest.cxx + * Test program which takes two meshes and calculates their intersection matrix. + * + * USAGE : PerfTest mesh1 mesh2 + * where mesh1 and mesh2 are the names of two meshes located in + * the files mesh1.med, mesh2.med in {$MED_ROOT_DIR}/share/salome/resources/med/ + * + */ + namespace INTERP_TEST { + /** + * \brief Specialization of MeshTestToolkit for the purposes of performance testing. + * + */ class PerfTestToolkit : public MeshTestToolkit { public: + + /** + * Calculates the intersection matrix for two meshes. + * Outputs the names of the meshes intersected, the number of elements in each mesh, + * the number of matrix elements and the number of non-zero matrix elements, etc. + * These values help to determine how well the filtering algorithm is working. + * + * @param mesh1path the path to the file containing the source mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh1 the name of the source mesh + * @param mesh2path the path to the file containing the target mesh, relative to {$MED_ROOT_DIR}/share/salome/resources/med/ + * @param mesh2 the name of the target mesh + * @param m intersection matrix in which to store the result of the intersection + */ void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m) { const string dataBaseDir = getenv("MED_ROOT_DIR"); @@ -46,9 +73,44 @@ namespace INTERP_TEST LOG(1, "Intersection calculation done. " << std::endl ); } + + /** + * Counts the number of elements in an intersection matrix, and the number of these which are non-zero. + * + * @param m the intersection matrix + * @return pair containing as its first element the number of elements in m and as its second element the + * number these which are non-zero + */ + std::pair MeshTestToolkit::countNumberOfMatrixEntries(const IntersectionMatrix& m) + { + + int numElems = 0; + int numNonZero = 0; + for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter) + { + numElems += iter->size(); + for(map::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2) + { + if(!epsilonEqual(iter2->second, 0.0, VOL_PREC)) + { + ++numNonZero; + } + } + } + return std::make_pair(numElems, numNonZero); + } + }; } +/** + * Main method of the program. + * Intersects the meshes and outputs some information about the calculation as well as the + * intersection matrix on std::cout. + * + * @param argc number of arguments given to the program (should be 3, the user giving 2 mesh names) + * @param argv vector to the arguments as strings. + */ int main(int argc, char** argv) { using INTERP_TEST::PerfTestToolkit; diff --git a/src/INTERP_KERNEL/TetraAffineTransform.hxx b/src/INTERP_KERNEL/TetraAffineTransform.hxx index 7a029b973..54bd7cf4f 100644 --- a/src/INTERP_KERNEL/TetraAffineTransform.hxx +++ b/src/INTERP_KERNEL/TetraAffineTransform.hxx @@ -7,7 +7,7 @@ namespace INTERP_UTILS { /** - * Class representing an affine transformation x -> Ax + b that transforms a given tetrahedron + * \brief Class representing an affine transformation x -> Ax + b that transforms a given tetrahedron * into the unit tetrahedron. * */ diff --git a/src/INTERP_KERNEL/TransformedTriangle.cxx b/src/INTERP_KERNEL/TransformedTriangle.cxx index 69c5c6c88..6180698f2 100644 --- a/src/INTERP_KERNEL/TransformedTriangle.cxx +++ b/src/INTERP_KERNEL/TransformedTriangle.cxx @@ -14,7 +14,7 @@ namespace INTERP_UTILS { /** - * Class representing a circular order of a set of points around their barycenter. + * \brief Class representing a circular order of a set of points around their barycenter. * It is used with the STL sort() algorithm to sort the point of the two polygons * */