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<int> 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<int> 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<int> id_left = M1.getFaceGroupIds("LeftEdge");
+ std::vector<int> 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 );
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() );
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<nbCellsM2; i++)
M2.setGroupAtPlan(xmin,0,eps,"LeftEdge");
M2.setGroupAtPlan(ymin,1,eps,"BottomEdge");
M2.setGroupAtPlan(ymax,1,eps,"TopEdge");
+ std::vector<std::string> 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<int,int> indexFaces=M2.getIndexFacePeriodic();
// 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<nbCellsM2Triangle; i++)
M2Triangle.setGroupAtPlan(ymin,1,eps,"BottomEdge");
M2Triangle.setGroupAtPlan(ymax,1,eps,"TopEdge");
CPPUNIT_ASSERT_EQUAL( 5, int(M2Triangle.getNameOfFaceGroups().size()) );//There is a default group named "Boundary" that is created by the mesh class
- CPPUNIT_ASSERT(M2Triangle.getNameOfFaceGroups()[1].compare("BottomEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfFaceGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfFaceGroups()[1].compare("RightEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfFaceGroups()[2].compare("LeftEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfFaceGroups()[3].compare("BottomEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfFaceGroups()[4].compare("TopEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfNodeGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfNodeGroups()[1].compare("RightEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfNodeGroups()[2].compare("LeftEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfNodeGroups()[3].compare("BottomEdge")==0);
+ CPPUNIT_ASSERT(M2Triangle.getNameOfNodeGroups()[4].compare("TopEdge")==0);
std::map<int,int> indexFacesTriangle=M2Triangle.getIndexFacePeriodic();
double dx2Triangle=M2Triangle.minRatioVolSurf();
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<nbCellsM3; i++)
M3.setGroupAtPlan(zmin,2,eps,"DownEdge");
M3.setGroupAtPlan(zmax,2,eps,"UpEdge");
CPPUNIT_ASSERT_EQUAL( 7, int(M3.getNameOfFaceGroups().size()) );//There is a default group named "Boundary" that is created by the mesh class
- CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[1].compare("DownEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[1].compare("RightEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[2].compare("LeftEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[3].compare("BottomEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[4].compare("TopEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[5].compare("DownEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfFaceGroups()[6].compare("UpEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfNodeGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M3.getNameOfNodeGroups()[1].compare("RightEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfNodeGroups()[2].compare("LeftEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfNodeGroups()[3].compare("BottomEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfNodeGroups()[4].compare("TopEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfNodeGroups()[5].compare("DownEdge")==0);
+ CPPUNIT_ASSERT(M3.getNameOfNodeGroups()[6].compare("UpEdge")==0);
nbFaces=M3.getNumberOfFaces();
M3.setPeriodicFaces();
indexFaces=M3.getIndexFacePeriodic();
testNormals(M3);
// Testing copies
+ CPPUNIT_ASSERT(M1.meshNotDeleted());
Mesh Mcopy1(M1);
+ CPPUNIT_ASSERT(M1.meshNotDeleted());
CPPUNIT_ASSERT_EQUAL( 1, Mcopy1.getSpaceDimension() );
CPPUNIT_ASSERT_EQUAL( 5, Mcopy1.getNumberOfNodes() );
CPPUNIT_ASSERT_EQUAL( 4, Mcopy1.getNumberOfCells() );
CPPUNIT_ASSERT_EQUAL( 5, Mcopy1.getNumberOfFaces() );
CPPUNIT_ASSERT_EQUAL( 4, Mcopy1.getNumberOfEdges() );
+ CPPUNIT_ASSERT(Mcopy1.meshNotDeleted());
+ CPPUNIT_ASSERT(Mcopy1.isStructured());
Mcopy1=M2;
CPPUNIT_ASSERT_EQUAL( 2, Mcopy1.getSpaceDimension() );
CPPUNIT_ASSERT_EQUAL( 16, Mcopy1.getNumberOfCells() );
CPPUNIT_ASSERT_EQUAL( 40, Mcopy1.getNumberOfFaces() );
CPPUNIT_ASSERT_EQUAL( 40, Mcopy1.getNumberOfEdges() );
+ CPPUNIT_ASSERT(Mcopy1.meshNotDeleted());
+ CPPUNIT_ASSERT(Mcopy1.isStructured());
Mesh Mcopy2;
Mcopy2=Mcopy1;
CPPUNIT_ASSERT_EQUAL( 16, Mcopy2.getNumberOfCells() );
CPPUNIT_ASSERT_EQUAL( 40, Mcopy2.getNumberOfFaces() );
CPPUNIT_ASSERT_EQUAL( 40, Mcopy2.getNumberOfEdges() );
+ CPPUNIT_ASSERT(Mcopy2.meshNotDeleted());
+ CPPUNIT_ASSERT(Mcopy2.isStructured());
// Connection with MED
CPPUNIT_ASSERT_EQUAL( 16, M22.getNumberOfCells() );
CPPUNIT_ASSERT_EQUAL( 40, M22.getNumberOfFaces() );
CPPUNIT_ASSERT_EQUAL( 40, M22.getNumberOfEdges() );
+ CPPUNIT_ASSERT(M22.meshNotDeleted());
+ CPPUNIT_ASSERT(!M22.isStructured());
cout<<"Test mesh M22 normals "<<endl;
testNormals(M22);
M3Tetra.setGroupAtPlan(ymax,1,eps,"TopEdge");
M3Tetra.setGroupAtPlan(zmin,2,eps,"DownEdge");
M3Tetra.setGroupAtPlan(zmax,2,eps,"UpEdge");
+ CPPUNIT_ASSERT(M3Tetra.meshNotDeleted());
+ CPPUNIT_ASSERT(!M3Tetra.isStructured());
CPPUNIT_ASSERT_EQUAL( 7, int(M3Tetra.getNameOfFaceGroups().size()) );//There is a default group named "Boundary" that is created by the mesh class
- CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[1].compare("DownEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[1].compare("RightEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[2].compare("LeftEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[3].compare("BottomEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[4].compare("TopEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[5].compare("DownEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfFaceGroups()[6].compare("UpEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfNodeGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfNodeGroups()[1].compare("RightEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfNodeGroups()[2].compare("LeftEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfNodeGroups()[3].compare("BottomEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfNodeGroups()[4].compare("TopEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfNodeGroups()[5].compare("DownEdge")==0);
+ CPPUNIT_ASSERT(M3Tetra.getNameOfNodeGroups()[6].compare("UpEdge")==0);
indexFaces=M3Tetra.getIndexFacePeriodic();
cout<<"Test mesh M3Tetra normals"<<endl;
testNormals(M3Tetra);
//Testing a 2D unstructured mesh (triangles)
- Mesh M23("meshSquare.med");
+ Mesh M23("./meshSquare.med");
CPPUNIT_ASSERT(M23.getNameOfFaceGroups().size() == 5);//There is a default group named "Boundary" that is created by the mesh class;
- CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[3].compare("Bottom")==0);
+ CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[1].compare("Bottom")==0);
CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[2].compare("Left")==0);
- CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[1].compare("Right")==0);
- CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[0].compare("Top")==0);
+ CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[3].compare("Right")==0);
+ CPPUNIT_ASSERT(M23.getNameOfFaceGroups()[4].compare("Top")==0);
+ CPPUNIT_ASSERT(M23.getNameOfNodeGroups()[0].compare("Boundary")==0);
+ CPPUNIT_ASSERT(M23.getNameOfNodeGroups()[1].compare("Bottom")==0);
+ CPPUNIT_ASSERT(M23.getNameOfNodeGroups()[2].compare("Left")==0);
+ CPPUNIT_ASSERT(M23.getNameOfNodeGroups()[3].compare("Right")==0);
+ CPPUNIT_ASSERT(M23.getNameOfNodeGroups()[4].compare("Top")==0);
CPPUNIT_ASSERT(M23.isTriangular());
+ CPPUNIT_ASSERT(M23.meshNotDeleted());
+ CPPUNIT_ASSERT(!M23.isStructured());
int nbCellsM23 = M23.getNumberOfCells();
double areaM23=0;
for(int i=0; i<nbCellsM23; i++)
CPPUNIT_ASSERT_EQUAL( 16, M6.getNumberOfCells() );
CPPUNIT_ASSERT_EQUAL( 40, M6.getNumberOfFaces() );
CPPUNIT_ASSERT_EQUAL( 40, M6.getNumberOfEdges() );
+ CPPUNIT_ASSERT(M6.meshNotDeleted());
+ CPPUNIT_ASSERT(!M6.isStructured());
/*
const MEDCouplingMesh* M1MEDMesh = M2.getMEDCouplingMesh();
//Test of a mesh with spaceDim=3 different from meshDim=2 (triangles)
Mesh M4("meshSphere.med");
CPPUNIT_ASSERT(M4.isTriangular());
+ CPPUNIT_ASSERT(!M4.isStructured());
int nbCellsM4 = M4.getNumberOfCells();
double areaM4=0;
for(int i=0; i<nbCellsM4; i++)
areaM4+=M4.getCell(i).getMeasure();
CPPUNIT_ASSERT_DOUBLES_EQUAL( 4*3.14, areaM4, 1 );
+ CPPUNIT_ASSERT(M4.meshNotDeleted());
cout<<"Test mesh M4 normals"<<endl;
testNormals(M4);
//Testing a 3D unstructured mesh (tétraèdres)
Mesh M5("meshCube.med");
CPPUNIT_ASSERT(M5.isTetrahedral());
+ CPPUNIT_ASSERT(!M5.isStructured());
+ CPPUNIT_ASSERT(M5.meshNotDeleted());
int nbCellsM5 = M5.getNumberOfCells();
double volM5=0;
for(int i=0; i<nbCellsM5; i++)
CPPUNIT_ASSERT_DOUBLES_EQUAL(points[nbNodes-1],xmax,eps);
Mesh M7(points, "Checkerboard mesh");
+ CPPUNIT_ASSERT(!M7.isStructured());
+ CPPUNIT_ASSERT(M7.meshNotDeleted());
+
+ cout<<endl<<"Test mesh M7 normals"<<endl;
+ testNormals(M7);
double volM7=0;
for(int i=0; i<nbCellsM7; i++)
volM7+=M7.getCell(i).getMeasure();
CPPUNIT_ASSERT_DOUBLES_EQUAL( 1., volM7, eps );
+
+ //Testing deletion of MEDCoupling for unstructured meshes (should not deletethe structured meshes)
+ M1.deleteMEDCouplingUMesh();
+ M2.deleteMEDCouplingUMesh();
+ M23.deleteMEDCouplingUMesh();
+ M3.deleteMEDCouplingUMesh();
+ M4.deleteMEDCouplingUMesh();
+ M5.deleteMEDCouplingUMesh();
+ M2Triangle.deleteMEDCouplingUMesh();
+ M3Tetra.deleteMEDCouplingUMesh();
+
+ //Testting boundary functions
+ Mesh M5Boundary = M5.getBoundaryMesh ( );
+ Mesh M3Boundary = M3.getBoundaryMesh ( );
+ Mesh M3TetraBoundary = M3Tetra.getBoundaryMesh ( );
+ cout<<"Mesh M2 spaceDim "<< M2.getSpaceDimension() << " meshDim " <<M2.getMeshDimension()<<endl;
+ Mesh M2Boundary = M2.getBoundaryMesh ( );
+ cout<<"Mesh M23 spaceDim "<< M23.getSpaceDimension() << " meshDim " <<M23.getMeshDimension()<<endl;
+ Mesh M23Boundary = M23.getBoundaryMesh ( );
+ Mesh M23Bottom = M23.getBoundaryGroupMesh ( "Bottom" );
}