void Interpolation3DTest::dumpIntersectionMatrix(IntersectionMatrix m)
{
int i = 0;
+ cout << "Intersection matrix is " << endl;
for(IntersectionMatrix::const_iterator iter = m.begin() ; iter != m.end() ; ++iter)
{
for(map<int, double>::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2)
{
std::cout << std::endl << std::endl << "=============================" << std::endl;
std::cout << " Reflexive tetra " << endl;
- MESH unitMesh(MED_DRIVER, "meshes/tetra1.med", "Mesh_1");
+ MESH unitMesh(MED_DRIVER, "meshes/UnitTetra.med", "UnitTetra");
std::cout << std::endl << "*** unit tetra" << std::endl;
IntersectionMatrix matrix1 = interpolator->interpol_maillages(unitMesh, unitMesh);
-
+
+#if 0
std::cout << std::endl << "*** non-unit large tetra" << std::endl;
MESH largeMesh(MED_DRIVER, "meshes/tetra2.med", "Mesh_1");
IntersectionMatrix matrix2 = interpolator->interpol_maillages(largeMesh, largeMesh);
std::cout << std::endl << "*** non-unit small tetra" << std::endl;
MESH smallMesh(MED_DRIVER, "meshes/tetra2_scaled.med", "Mesh_2");
IntersectionMatrix matrix3 = interpolator->interpol_maillages(smallMesh, smallMesh);
-
+#endif
CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0 / 6.0, sumVolume(matrix1), ERR_TOL);
+#if 0
CPPUNIT_ASSERT_DOUBLES_EQUAL(48.0, sumVolume(matrix2), ERR_TOL);
CPPUNIT_ASSERT_DOUBLES_EQUAL(0.75, sumVolume(matrix3), ERR_TOL);
-
+#endif
+}
+
+void Interpolation3DTest::calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m)
+{
+ std::cout << std::endl << "=== -> intersecting src = " << mesh1 << ", target = " << mesh2 << std::endl;
+
+ std::cout << "Loading " << mesh1 << " from " << mesh1path << endl;
+ MESH sMesh(MED_DRIVER, mesh1path, mesh1);
+
+ std::cout << "Loading " << mesh2 << " from " << mesh2path << endl;
+ MESH tMesh(MED_DRIVER, mesh2path, mesh2);
+
+ m = interpolator->interpol_maillages(sMesh, tMesh);
+
+ dumpIntersectionMatrix(m);
+
+ std::cout << "Intersection calculation done. " << std::endl << std::endl;
}
-void Interpolation3DTest::tetraTetraTransl()
+void Interpolation3DTest::intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol)
{
std::cout << std::endl << std::endl << "=============================" << std::endl;
- std::cout << " Translated tetra " << endl;
- MESH srcMesh(MED_DRIVER, "meshes/tetra1.med", "Mesh_1");
- MESH targetMesh(MED_DRIVER, "meshes/tetra1_transl_delta.med", "Mesh_3");
+ IntersectionMatrix matrix1;
+ calcIntersectionMatrix(mesh1path, mesh1, mesh2path, mesh2, matrix1);
- std::cout << std::endl << "*** src - target" << std::endl;
- IntersectionMatrix matrix1 = interpolator->interpol_maillages(srcMesh, targetMesh);
- std::cout << std::endl << std::endl << "*** target - src" << std::endl;
- IntersectionMatrix matrix2 = interpolator->interpol_maillages(targetMesh, srcMesh);
- std::cout << std::endl << std::endl << "*** target - target" << std::endl;
- IntersectionMatrix matrix3 = interpolator->interpol_maillages(targetMesh, targetMesh);
+ dumpIntersectionMatrix(matrix1);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.152112, sumVolume(matrix1), 1.0e-6);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(0.152112, sumVolume(matrix2), 1.0e-6);
- CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0 / 6.0, sumVolume(matrix3), ERR_TOL);
+ IntersectionMatrix matrix2;
+ calcIntersectionMatrix(mesh2path, mesh2, mesh1path, mesh1, matrix2);
+
+ dumpIntersectionMatrix(matrix2);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, sumVolume(matrix1), 1.0e-6);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(correctVol, sumVolume(matrix2), 1.0e-6);
}
+
+
void Interpolation3DTest::tetraTetraScale()
{
std::cout << std::endl << std::endl << "=============================" << std::endl;
{
CPPUNIT_TEST_SUITE( Interpolation3DTest );
- CPPUNIT_TEST( reflexiveTetra );
- CPPUNIT_TEST( tetraTetraTransl );
- CPPUNIT_TEST( tetraTetraScale );
+#if 0
+ CPPUNIT_TEST( tetraReflexiveUnit );
+ CPPUNIT_TEST( tetraReflexiveGeneral );
+ CPPUNIT_TEST( tetraNudgedSimpler );
+ CPPUNIT_TEST( tetraNudged );
+ CPPUNIT_TEST( tetraCorner );
+ CPPUNIT_TEST( tetraHalfstripOnly );
+ CPPUNIT_TEST( tetraHalfstripOnly2 );
+ CPPUNIT_TEST( tetraSimpleHalfstripOnly );
+#endif
+ CPPUNIT_TEST( tetraBoxes );
+ //CPPUNIT_TEST( tetraTetraScale );
// CPPUNIT_TEST( box1 );
// CPPUNIT_TEST( cyl1 );
- CPPUNIT_TEST( tetra1 );
+ //CPPUNIT_TEST( tetra1 );
// CPPUNIT_TEST( tetra3 );
CPPUNIT_TEST_SUITE_END();
void tearDown();
// tests
+
+ void tetraReflexiveUnit()
+ {
+ intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/UnitTetra.med", "UnitTetra", 1.0/6.0);
+ }
+
+ void tetraReflexiveGeneral()
+ {
+ intersectMeshes("meshes/GeneralTetra.med", "GeneralTetra", "meshes/GeneralTetra.med", "GeneralTetra", 0.428559);
+ }
+
+ void tetraNudgedSimpler()
+ {
+ intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/NudgedSimpler.med", "NudgedSimpler", 0.152112);
+ }
+
+ void tetraNudged()
+ {
+ intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/NudgedTetra.med", "NudgedTetra", 0.142896);
+ }
+
+ void tetraCorner()
+ {
+ intersectMeshes("meshes/UnitTetra.med", "UnitTetra", "meshes/CornerTetra.med", "CornerTetra", 0.0135435);
+ }
+
+ void tetraHalfstripOnly()
+ {
+ // NB this test is not completely significant : we should also verify that
+ // there are triangles on the element that give a non-zero volume
+ intersectMeshes("meshes/HalfstripOnly.med", "HalfstripOnly", "meshes/UnitTetra.med", "UnitTetra", 0.0);
+ }
+
+ void tetraHalfstripOnly2()
+ {
+ // NB this test is not completely significant : we should also verify that
+ // there are triangles on the element that give a non-zero volume
+ intersectMeshes("meshes/HalfstripOnly2.med", "HalfstripOnly2", "meshes/UnitTetra.med", "UnitTetra", 0.0);
+ }
+ void tetraSimpleHalfstripOnly()
+ {
+ // NB this test is not completely significant : we should also verify that
+ // there are triangles on the element that give a non-zero volume
+ intersectMeshes("meshes/SimpleHalfstripOnly.med", "SimpleHalfstripOnly", "meshes/UnitTetra.med", "UnitTetra", 0.0);
+ }
+
+ void tetraBoxes()
+ {
+ intersectMeshes("meshes/Box1.med", "Box1", "meshes/Box2.med", "Box2", 124.197);
+ }
+
+#if 0
+ void tetraHalfstripOnly()
+ {
+ std::cout << std::endl << std::endl << "=============================" << std::endl;
+ IntersectionMatrix matrix;
+ // we want no transformation - unit tetra is target
+ calcIntersectionMatrix("meshes/HalfstripOnly.med", "HalfstripOnly", "meshes/UnitTetra.med", "UnitTetra", matrix);
+
+ // check that the total volume is zero
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, sumVolume(matrix), 1.0e-6);
+
+ // check that we have non-zero volumes that cancel
+ bool allVolumesZero = true;
+
+ for(IntersectionMatrix::const_iterator iter = matrix.begin() ; iter != matrix.end() ; ++iter)
+ {
+ for(map<int, double>::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2)
+ {
+ allVolumesZero = allVolumesZero && (iter2->second == 0.0);
+ }
+ }
+
+ CPPUNIT_ASSERT_EQUAL(false, allVolumesZero);
+
+ }
+
+ void tetraHalfstripOnly2()
+ {
+ std::cout << std::endl << std::endl << "=============================" << std::endl;
+ IntersectionMatrix matrix;
+ // we want no transformation - unit tetra is target
+ calcIntersectionMatrix("meshes/HalfstripOnly2.med", "HalfstripOnly2", "meshes/UnitTetra.med", "UnitTetra", matrix);
+
+ // check that the total volume is zero
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, sumVolume(matrix), 1.0e-6);
+
+ // check that we have non-zero volumes that cancel
+ bool allVolumesZero = true;
+
+ for(IntersectionMatrix::const_iterator iter = matrix.begin() ; iter != matrix.end() ; ++iter)
+ {
+ for(map<int, double>::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2)
+ {
+ allVolumesZero = allVolumesZero && (iter2->second == 0.0);
+ }
+ }
+
+ CPPUNIT_ASSERT_EQUAL(false, allVolumesZero);
+
+ }
+
+ void tetraSimpleHalfstripOnly()
+ {
+ std::cout << std::endl << std::endl << "=============================" << std::endl;
+ IntersectionMatrix matrix;
+ // we want no transformation - unit tetra is target
+ calcIntersectionMatrix("meshes/SimpleHalfstripOnly.med", "SimpleHalfstripOnly", "meshes/UnitTetra.med", "UnitTetra", matrix);
+
+ // check that the total volume is zero
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, sumVolume(matrix), 1.0e-6);
+
+ // check that we have non-zero volumes that cancel
+ bool allVolumesZero = true;
+
+ for(IntersectionMatrix::const_iterator iter = matrix.begin() ; iter != matrix.end() ; ++iter)
+ {
+ for(map<int, double>::const_iterator iter2 = iter->begin() ; iter2 != iter->end() ; ++iter2)
+ {
+ allVolumesZero = allVolumesZero && (iter2->second == 0.0);
+ }
+ }
+ CPPUNIT_ASSERT_EQUAL(false, allVolumesZero);
+
+ }
+#endif
void reflexiveTetra();
- void tetraTetraTransl();
-
void tetraTetraScale();
void cyl1();
void dumpIntersectionMatrix(IntersectionMatrix m);
+ void intersectMeshes(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, const double correctVol);
+
+ void calcIntersectionMatrix(const char* mesh1path, const char* mesh1, const char* mesh2path, const char* mesh2, IntersectionMatrix& m);
+
};
#endif