From fae9b0df14c0f23aab6c88df6522b90416fee0c5 Mon Sep 17 00:00:00 2001 From: michael Date: Fri, 10 Dec 2021 14:23:39 +0100 Subject: [PATCH] Tested the possibility to retrieve boundary groups and to delete the mescouplingumesh object --- CDMATH/tests/cdmath/MeshTests.cxx | 169 +++++++++++++++++++++++++++--- 1 file changed, 153 insertions(+), 16 deletions(-) mode change 100644 => 100755 CDMATH/tests/cdmath/MeshTests.cxx diff --git a/CDMATH/tests/cdmath/MeshTests.cxx b/CDMATH/tests/cdmath/MeshTests.cxx old mode 100644 new mode 100755 index de4b431..1603c6c --- a/CDMATH/tests/cdmath/MeshTests.cxx +++ b/CDMATH/tests/cdmath/MeshTests.cxx @@ -81,21 +81,51 @@ MeshTests::testClassMesh( void ) CPPUNIT_ASSERT_EQUAL( 3., M1.getNode(3).x() ); CPPUNIT_ASSERT_EQUAL( 4., M1.getFace(4).x() ); CPPUNIT_ASSERT_EQUAL( 4., M1.getNode(4).x() ); + CPPUNIT_ASSERT(M1.meshNotDeleted()); + CPPUNIT_ASSERT(M1.isStructured()); + double x11=M1.getCells()[1].x(); double y11=M1.getCells()[1].y(); CPPUNIT_ASSERT_EQUAL( x11, 1.5 ); CPPUNIT_ASSERT_EQUAL( y11, 0.0 ); M1.setGroupAtFaceByCoords(0.,0.,0.,1.E-14,"LeftEdge") ; M1.setGroupAtFaceByCoords(4.,0.,0.,1.E-14,"RightEdge") ; + M1.setGroupAtNodeByCoords(0.,0.,0.,1.E-14,"LeftEdge") ; + M1.setGroupAtNodeByCoords(4.,0.,0.,1.E-14,"RightEdge") ; CPPUNIT_ASSERT(M1.getFace(0).isBorder()==true); CPPUNIT_ASSERT(M1.getFace(1).isBorder()==false); CPPUNIT_ASSERT(M1.getFace(2).isBorder()==false); CPPUNIT_ASSERT(M1.getFace(3).isBorder()==false); CPPUNIT_ASSERT(M1.getFace(4).isBorder()==true); CPPUNIT_ASSERT(M1.getNameOfFaceGroups().size() == 3);//There is a default group named "Boundary" that is created by the mesh class - CPPUNIT_ASSERT(M1.getNameOfFaceGroups()[0].compare("RightEdge")==0); + CPPUNIT_ASSERT(M1.getNameOfFaceGroups()[0].compare("Boundary")==0); CPPUNIT_ASSERT(M1.getNameOfFaceGroups()[1].compare("LeftEdge")==0); - CPPUNIT_ASSERT(M1.getNameOfFaceGroups()[2].compare("Boundary")==0); + CPPUNIT_ASSERT(M1.getNameOfFaceGroups()[2].compare("RightEdge")==0); + CPPUNIT_ASSERT(M1.getNameOfNodeGroups()[0].compare("Boundary")==0); + CPPUNIT_ASSERT(M1.getNameOfNodeGroups()[1].compare("LeftEdge")==0); + CPPUNIT_ASSERT(M1.getNameOfNodeGroups()[2].compare("RightEdge")==0); + + //Test the duplication of a group + M1.setGroupAtPlan(0.,0,1.E-14,"LeftEdge") ; + M1.setGroupAtPlan(4.,0,1.E-14,"RightEdge") ; + CPPUNIT_ASSERT(M1.getNameOfFaceGroups().size() == 3);//There is a default group named "Boundary" that is created by the mesh class + + std::vector id_nodes=M1.getBoundaryNodeIds(); + int id_size_nodes = id_nodes.size(); + CPPUNIT_ASSERT_EQUAL( 2, id_size_nodes ); + CPPUNIT_ASSERT_EQUAL( 0, id_nodes[0] ); + CPPUNIT_ASSERT_EQUAL( 4, id_nodes[1] ); + + std::vector id_faces=M1.getBoundaryFaceIds(); + CPPUNIT_ASSERT_EQUAL( 2, int(id_faces.size()) ); + CPPUNIT_ASSERT_EQUAL( 0, id_faces[0] ); + CPPUNIT_ASSERT_EQUAL( 4, id_faces[1] ); + + std::vector id_left = M1.getFaceGroupIds("LeftEdge"); + std::vector id_right = M1.getFaceGroupIds("RightEdge"); + CPPUNIT_ASSERT_EQUAL( 0, id_left[0] ); + CPPUNIT_ASSERT_EQUAL( 4, id_right[0] ); + double dx1=M1.minRatioVolSurf(); CPPUNIT_ASSERT_DOUBLES_EQUAL( dx1, 1., eps ); @@ -108,6 +138,9 @@ MeshTests::testClassMesh( void ) double ymin=0.0; double ymax=4.0; Mesh M2(xmin,xmax,4,ymin,ymax,4); + CPPUNIT_ASSERT(M2.isQuadrangular()); + CPPUNIT_ASSERT(M2.meshNotDeleted()); + CPPUNIT_ASSERT(M2.isStructured()); CPPUNIT_ASSERT_EQUAL( 4, M2.getNx() ); CPPUNIT_ASSERT_EQUAL( 4, M2.getNy() ); CPPUNIT_ASSERT_EQUAL( 2, M2.getSpaceDimension() ); @@ -115,7 +148,7 @@ MeshTests::testClassMesh( void ) CPPUNIT_ASSERT_EQUAL( 16, M2.getNumberOfCells() ); CPPUNIT_ASSERT_EQUAL( 40, M2.getNumberOfFaces() ); CPPUNIT_ASSERT_EQUAL( 40, M2.getNumberOfEdges() ); - CPPUNIT_ASSERT(M2.isQuadrangular()); + int nbCellsM2 = M2.getNumberOfCells(); double areaM2=0; for(int i=0; i nameOfFaceGroups = M2.getNameOfFaceGroups(); CPPUNIT_ASSERT_EQUAL( 5, int(M2.getNameOfFaceGroups().size()) );//There is a default group named "Boundary" that is created by the mesh class - CPPUNIT_ASSERT(M2.getNameOfFaceGroups().size() == 5); - CPPUNIT_ASSERT(M2.getNameOfFaceGroups()[1].compare("BottomEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfFaceGroups()[0].compare("Boundary")==0); + CPPUNIT_ASSERT(M2.getNameOfFaceGroups()[1].compare("RightEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfFaceGroups()[2].compare("LeftEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfFaceGroups()[3].compare("BottomEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfFaceGroups()[4].compare("TopEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfNodeGroups()[0].compare("Boundary")==0); + CPPUNIT_ASSERT(M2.getNameOfNodeGroups()[1].compare("RightEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfNodeGroups()[2].compare("LeftEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfNodeGroups()[3].compare("BottomEdge")==0); + CPPUNIT_ASSERT(M2.getNameOfNodeGroups()[4].compare("TopEdge")==0); int nbFaces=M2.getNumberOfFaces(); M2.setPeriodicFaces(); std::map indexFaces=M2.getIndexFacePeriodic(); @@ -165,14 +207,16 @@ MeshTests::testClassMesh( void ) // Testing 2D simplexization (regular triangle mesh) int splittingPolicy =0; Mesh M2Triangle(xmin,xmax,4,ymin,ymax,4,splittingPolicy); - CPPUNIT_ASSERT_EQUAL( 4, M2Triangle.getNx() ); - CPPUNIT_ASSERT_EQUAL( 4, M2Triangle.getNy() ); + CPPUNIT_ASSERT(M2Triangle.isTriangular()); + CPPUNIT_ASSERT(M2Triangle.meshNotDeleted()); + CPPUNIT_ASSERT(!M2Triangle.isStructured()); + CPPUNIT_ASSERT_EQUAL( 2, M2Triangle.getSpaceDimension() ); CPPUNIT_ASSERT_EQUAL( 25, M2Triangle.getNumberOfNodes() ); CPPUNIT_ASSERT_EQUAL( 32, M2Triangle.getNumberOfCells() ); CPPUNIT_ASSERT_EQUAL( 40+16, M2Triangle.getNumberOfFaces() ); CPPUNIT_ASSERT_EQUAL( 40+16, M2Triangle.getNumberOfEdges() ); - CPPUNIT_ASSERT(M2Triangle.isTriangular()); + int nbCellsM2Triangle = M2Triangle.getNumberOfCells(); double areaM2Triangle=0; for(int i=0; i indexFacesTriangle=M2Triangle.getIndexFacePeriodic(); double dx2Triangle=M2Triangle.minRatioVolSurf(); @@ -201,12 +254,19 @@ MeshTests::testClassMesh( void ) double zmin=0.0; double zmax=1.0; Mesh M3(xmin,xmax,4,ymin,ymax,4,zmin,zmax,4); + CPPUNIT_ASSERT(M3.isHexahedral()); + CPPUNIT_ASSERT(M3.meshNotDeleted()); + CPPUNIT_ASSERT(M3.isStructured()); + + CPPUNIT_ASSERT_EQUAL( 4, M3.getNx() ); + CPPUNIT_ASSERT_EQUAL( 4, M3.getNy() ); + CPPUNIT_ASSERT_EQUAL( 4, M3.getNz() ); CPPUNIT_ASSERT_EQUAL( 3, M3.getSpaceDimension() ); CPPUNIT_ASSERT_EQUAL( 5*5*5, M3.getNumberOfNodes() ); CPPUNIT_ASSERT_EQUAL( 4*4*4, M3.getNumberOfCells() ); CPPUNIT_ASSERT_EQUAL( 5*4*4*3, M3.getNumberOfFaces() ); CPPUNIT_ASSERT_EQUAL( 5*5*4*3, M3.getNumberOfEdges() ); - CPPUNIT_ASSERT(M3.isHexahedral()); + int nbCellsM3 = M3.getNumberOfCells(); double volM3=0; for(int i=0; i