]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
add single partitioner and test metis
authorcvw <cvw>
Wed, 21 Mar 2012 14:01:01 +0000 (14:01 +0000)
committercvw <cvw>
Wed, 21 Mar 2012 14:01:01 +0000 (14:01 +0000)
src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx
src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx
src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx
src/MEDPartitioner/Test/Makefile.am

index 2131ff4c04ef87b2c6e05ed5d9b78041053035c8..cbd0f63d9872215a66d53232d003a62493ef0737 100644 (file)
@@ -714,3 +714,461 @@ void MEDPARTITIONERTest::verifyTestMeshWithVecFieldOnNodes()
     }
   mf->decrRef();
 }
+
+void MEDPARTITIONERTest::createTestMeshes()
+{
+  createTestMeshWithoutField();
+  createTestMeshWithVecFieldOnCells();
+  createTestMeshWithVecFieldOnNodes();
+}
+
+void MEDPARTITIONERTest::deleteTestMeshes()
+{
+  string cmd="rm *tmp_testMesh*";
+  if (_verbose) cout<<endl<<cmd<<endl;
+  system(cmd.c_str());  //may be not if debug
+}
+
+void MEDPARTITIONERTest::testMeshCollectionSingle()
+{
+  setSmallSize();
+  createTestMeshes();
+  MyGlobals::_World_Size=1;
+  MyGlobals::_Rank=0;
+  string fileName=_file_name_with_faces;
+  MEDPARTITIONER::ParaDomainSelector parallelizer(false);
+  MEDPARTITIONER::MeshCollection collection(fileName,parallelizer);
+  CPPUNIT_ASSERT(collection.isParallelMode());
+  CPPUNIT_ASSERT_EQUAL(3, collection.getMeshDimension());
+  CPPUNIT_ASSERT(collection.getName()=="testMesh");
+  CPPUNIT_ASSERT_EQUAL(1,collection.getNbOfLocalMeshes());
+  CPPUNIT_ASSERT_EQUAL(1,collection.getNbOfGlobalMeshes());
+  CPPUNIT_ASSERT_EQUAL(_ni*_nj*_nk,collection.getNbOfLocalCells());
+  CPPUNIT_ASSERT_EQUAL(_ni*_nj,collection.getNbOfLocalFaces());
+}
+
+void MEDPARTITIONERTest::testMeshCollectionXml()
+{
+  setSmallSize();
+  createHugeTestMesh(_ni, _nj, _nk, 2, 2, 2, 32); //xml but not so huge
+  MyGlobals::_World_Size=1;
+  MyGlobals::_Rank=0;
+  string fileName=_file_name_huge_xml;
+  MEDPARTITIONER::ParaDomainSelector parallelizer(false);
+  MEDPARTITIONER::MeshCollection collection(fileName,parallelizer);
+  CPPUNIT_ASSERT(collection.isParallelMode());
+  CPPUNIT_ASSERT_EQUAL(3, collection.getMeshDimension());
+  CPPUNIT_ASSERT(collection.getName()=="testMesh");
+  CPPUNIT_ASSERT_EQUAL(8,collection.getNbOfLocalMeshes());
+  CPPUNIT_ASSERT_EQUAL(8,collection.getNbOfGlobalMeshes());
+  CPPUNIT_ASSERT_EQUAL(_ni*_nj*_nk*8,collection.getNbOfLocalCells());
+  CPPUNIT_ASSERT_EQUAL(0,collection.getNbOfLocalFaces());
+}
+
+void MEDPARTITIONERTest::testMeshCollectionSinglePartitionMetis()
+{
+//#if defined(MED_ENABLE_PARMETIS) || defined(MED_ENABLE_METIS)
+  setSmallSize();
+  createTestMeshes();
+  MyGlobals::_World_Size=1;
+  MyGlobals::_Rank=0;
+  //MyGlobals::_Verbose=500;
+  string fileName=_file_name_with_faces;
+  int ndomains=2;
+  bool split_family=false;
+  bool empty_groups=false;
+  MEDPARTITIONER::ParaDomainSelector parallelizer(false);
+  MEDPARTITIONER::MeshCollection collection(fileName,parallelizer);
+  
+  MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology();
+  aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector());
+  //Creating the graph and partitioning it
+  auto_ptr< MEDPARTITIONER::Topology > new_topo;
+  new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::METIS) );
+  //Creating a new mesh collection from the partitioning
+  MEDPARTITIONER::MeshCollection new_collection(collection,new_topo.get(),split_family,empty_groups);
+  
+  //example to create files
+  //MyGlobals::_General_Informations.clear();
+  //MyGlobals::_General_Informations.push_back(SerializeFromString("finalMeshName=Merge"));
+  //if (MyGlobals::_Verbose>100) cout << "generalInformations : \n"<<ReprVectorOfString(MyGlobals::_General_Informations);
+  //new_collection.write("ttmp")
+  
+  CPPUNIT_ASSERT(new_collection.isParallelMode());
+  CPPUNIT_ASSERT_EQUAL(3, new_collection.getMeshDimension());
+  CPPUNIT_ASSERT(new_collection.getName()==collection.getName());
+  CPPUNIT_ASSERT_EQUAL(ndomains,new_collection.getNbOfLocalMeshes());
+  CPPUNIT_ASSERT_EQUAL(ndomains,new_collection.getNbOfGlobalMeshes());
+  CPPUNIT_ASSERT_EQUAL(collection.getNbOfLocalCells(),new_collection.getNbOfLocalCells());
+  CPPUNIT_ASSERT_EQUAL(collection.getNbOfLocalFaces(),new_collection.getNbOfLocalFaces());
+//#endif
+}
+
+void MEDPARTITIONERTest::testMeshCollectionComplexPartitionMetis()
+{
+//#if defined(MED_ENABLE_PARMETIS) || defined(MED_ENABLE_METIS)
+  setSmallSize();
+  createHugeTestMesh(_ni, _nj, _nk, 2, 2, 2, 32); //xml on 2*2*2 meshes but not so huge
+  MyGlobals::_World_Size=1;
+  MyGlobals::_Rank=0;
+  string fileName=_file_name_huge_xml;
+  bool split_family=false;
+  bool empty_groups=false;
+  MEDPARTITIONER::ParaDomainSelector parallelizer(false);
+  MEDPARTITIONER::MeshCollection collection(fileName,parallelizer);
+  
+  MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) collection.getTopology();
+  aPT->setGlobalNumerotationDefault(collection.getParaDomainSelector());
+  
+  for (int ndomains=1 ; ndomains<=16 ; ndomains++)
+    {
+      //Creating the graph and partitioning it
+      auto_ptr< MEDPARTITIONER::Topology > new_topo;
+      new_topo.reset( collection.createPartition(ndomains,MEDPARTITIONER::Graph::METIS) );
+      //Creating a new mesh collection from the partitioning
+      MEDPARTITIONER::MeshCollection new_collection(collection,new_topo.get(),split_family,empty_groups);
+      
+      CPPUNIT_ASSERT_EQUAL(ndomains,new_collection.getNbOfLocalMeshes());
+      CPPUNIT_ASSERT_EQUAL(ndomains,new_collection.getNbOfGlobalMeshes());
+      CPPUNIT_ASSERT_EQUAL(collection.getNbOfLocalCells(),new_collection.getNbOfLocalCells());
+      CPPUNIT_ASSERT_EQUAL(collection.getNbOfLocalFaces(),new_collection.getNbOfLocalFaces());
+    }
+//#endif
+}
+
+void MEDPARTITIONERTest::testMetisSmallSize()
+{
+//#if defined(MED_ENABLE_PARMETIS) || defined(MED_ENABLE_METIS)
+  setSmallSize();
+  createTestMeshes();
+  launchMetisMedpartitionerOnTestMeshes();
+  verifyMetisMedpartitionerOnSmallSizeForMesh();
+  verifyMetisMedpartitionerOnSmallSizeForFieldOnCells();
+  verifyMetisMedpartitionerOnSmallSizeForFieldOnGaussNe();
+//#endif
+}
+
+void MEDPARTITIONERTest::launchMetisMedpartitionerOnTestMeshes()
+{
+  int res;
+  string cmd,execName,sourceName,targetName;
+  
+  execName=getenv("MED_ROOT_DIR");  //.../INSTALL/MED
+  execName+="/bin/salome/medpartitioner";
+  
+  cmd="which "+execName+" 2>/dev/null 1>/dev/null";  //no trace
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  
+  cmd=execName+" --ndomains=2 --split-method=metis";  //on same proc
+  sourceName=_file_name;
+  targetName=_file_name;
+  targetName.replace(targetName.find(".med"),4,"_partitionedTo2_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  
+  cmd=execName+" --ndomains=5 --split-method=metis"; //on less proc
+  sourceName=_file_name;
+  targetName=_file_name;
+  targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  
+  cmd=execName+" --ndomains=1 --split-method=metis";  //on 1 proc
+  sourceName=targetName+".xml";
+  targetName=_file_name;
+  targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+
+  cmd=execName+" --ndomains=1 --split-method=metis";  //on more proc
+  //sourceName=targetName+".xml";
+  targetName=_file_name;
+  targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+}  
+
+void MEDPARTITIONERTest::verifyMetisMedpartitionerOnSmallSizeForMesh()
+{
+  int res;
+  string fileName,cmd,execName,sourceName,targetName,input;
+  execName=getenv("MED_ROOT_DIR");  //.../INSTALL/MED
+  execName+="/bin/salome/medpartitioner";
+  fileName=_file_name_with_faces;
+  
+  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_mesh_name.c_str());
+  ParaMEDMEM::MEDCouplingUMesh* cellMesh=initialMesh->getLevel0Mesh(false);
+  ParaMEDMEM::MEDCouplingUMesh* faceMesh=initialMesh->getLevelM1Mesh(false);
+  
+  cmd=execName+" --ndomains=5 --split-method=metis";  //on same proc
+  sourceName=fileName;
+  targetName=fileName;
+  targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  input=targetName+".xml";
+  
+  MEDPARTITIONER::ParaDomainSelector parallelizer(false);
+  MEDPARTITIONER::MeshCollection collection(input,parallelizer);
+  CPPUNIT_ASSERT_EQUAL(3, collection.getMeshDimension());
+  std::vector<ParaMEDMEM::MEDCouplingUMesh*>cellMeshes=collection.getMesh();
+  CPPUNIT_ASSERT_EQUAL(5, (int) cellMeshes.size());
+  int nbcells=0;
+  for (std::size_t i = 0; i < cellMeshes.size(); i++)
+    nbcells+=cellMeshes[i]->getNumberOfCells();
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), nbcells);
+  
+  std::vector<ParaMEDMEM::MEDCouplingUMesh*>faceMeshes=collection.getFaceMesh();
+  CPPUNIT_ASSERT_EQUAL(5, (int) faceMeshes.size());
+  int nbfaces=0;
+  for (std::size_t i=0; i < faceMeshes.size(); i++)
+    nbfaces+=faceMeshes[i]->getNumberOfCells();
+  CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), nbfaces);
+  
+  //merge split meshes and test equality
+  cmd=execName+" --ndomains=1 --split-method=metis";  //on same proc
+  sourceName=targetName+".xml";
+  targetName=fileName;
+  targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  
+  string refusedName=targetName+"1.med";
+  ParaMEDMEM::MEDFileUMesh* refusedMesh=ParaMEDMEM::MEDFileUMesh::New(refusedName.c_str(),_mesh_name.c_str());
+  ParaMEDMEM::MEDCouplingUMesh* refusedCellMesh=refusedMesh->getLevel0Mesh(false);
+  ParaMEDMEM::MEDCouplingUMesh* refusedFaceMesh=refusedMesh->getLevelM1Mesh(false);
+  
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), refusedCellMesh->getNumberOfCells());
+  CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), refusedFaceMesh->getNumberOfCells());
+  
+  /*not the good job
+    ParaMEDMEM::MEDCouplingMesh* mergeCell=cellMesh->mergeMyselfWith(refusedCellMesh);
+    CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), mergeCell->getNumberOfCells());
+  
+    ParaMEDMEM::MEDCouplingMesh* mergeFace=faceMesh->mergeMyselfWith(refusedFaceMesh);
+    CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), mergeFace->getNumberOfCells());
+  
+    CPPUNIT_ASSERT(faceMesh->isEqual(refusedFaceMesh,1e-12));
+  */
+  
+  std::vector<const MEDCouplingUMesh *> meshes;
+  std::vector<DataArrayInt *> corr;
+  meshes.push_back(cellMesh);
+  refusedCellMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-9);
+  meshes.push_back(refusedCellMesh);
+  MEDCouplingUMesh* fusedCell=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), fusedCell->getNumberOfCells());
+  
+  meshes.resize(0);
+  for (std::size_t i = 0; i < corr.size(); i++)
+    corr[i]->decrRef();
+  corr.resize(0);
+  meshes.push_back(faceMesh);
+  refusedFaceMesh->tryToShareSameCoordsPermute(*faceMesh, 1e-9);
+  meshes.push_back(refusedFaceMesh);
+  MEDCouplingUMesh* fusedFace=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
+  CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), fusedFace->getNumberOfCells());
+  
+  for (std::size_t i = 0; i < corr.size(); i++)
+    corr[i]->decrRef();
+  fusedFace->decrRef();
+  refusedFaceMesh->decrRef();
+  faceMesh->decrRef();
+  fusedCell->decrRef();
+  refusedCellMesh->decrRef();
+  cellMesh->decrRef();
+  //done in ~collection
+  //for (int i = 0; i < faceMeshes.size(); i++) faceMeshes[i]->decrRef();
+  //for (int i = 0; i < cellMeshes.size(); i++) cellMeshes[i]->decrRef();
+}
+
+void MEDPARTITIONERTest::verifyMetisMedpartitionerOnSmallSizeForFieldOnCells()
+{
+  int res;
+  string fileName,cmd,execName,sourceName,targetName,input;
+  execName=getenv("MED_ROOT_DIR");  //.../INSTALL/MED
+  execName+="/bin/salome/medpartitioner";
+  fileName=_file_name;
+  fileName.replace(fileName.find(".med"),4,"_WithVecFieldOnCells.med");
+  
+  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_mesh_name.c_str());
+  ParaMEDMEM::MEDCouplingUMesh* cellMesh=initialMesh->getLevel0Mesh(false);
+  
+  cmd=execName+" --ndomains=5 --split-method=metis";  //on same proc
+  sourceName=fileName;
+  targetName=fileName;
+  targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  input=targetName+".xml";
+  
+  //merge split meshes and test equality
+  cmd=execName+" --ndomains=1 --split-method=metis";  //on same proc
+  sourceName=targetName+".xml";
+  targetName=fileName;
+  targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  
+  string refusedName=targetName+"1.med";
+  ParaMEDMEM::MEDFileUMesh* refusedMesh=ParaMEDMEM::MEDFileUMesh::New(refusedName.c_str(),_mesh_name.c_str());
+  ParaMEDMEM::MEDCouplingUMesh* refusedCellMesh=refusedMesh->getLevel0Mesh(false);
+  
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), refusedCellMesh->getNumberOfCells());
+  
+  std::vector<const MEDCouplingUMesh *> meshes;
+  std::vector<DataArrayInt *> corr;
+  meshes.push_back(cellMesh);
+  refusedCellMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-9);
+  meshes.push_back(refusedCellMesh);
+  MEDCouplingUMesh* fusedCell=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), fusedCell->getNumberOfCells());
+  
+  MEDCouplingFieldDouble* field1=MEDLoader::ReadFieldCell(fileName.c_str(),initialMesh->getName(),0,"VectorFieldOnCells",0,1);
+  MEDCouplingFieldDouble* field2=MEDLoader::ReadFieldCell(refusedName.c_str(),refusedCellMesh->getName(),0,"VectorFieldOnCells",0,1);
+  
+  int nbcells=corr[1]->getNumberOfTuples();
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), nbcells);
+  //use corr to test equality of field
+  DataArrayDouble* f1=field1->getArray();
+  DataArrayDouble* f2=field2->getArray();
+  if (_verbose>300) 
+    {
+      cout<<"\nf1 : "<<f1->reprZip();
+      cout<<"\nf2 : "<<f2->reprZip(); //field2->advancedRepradvancedRepr();
+      for (std::size_t i = 0; i < corr.size(); i++)
+        cout << "\ncorr " << i << " : " << corr[i]->reprZip();
+    
+    }
+  int nbequal=0;
+  int nbcomp=field1->getNumberOfComponents();
+  double* p1=f1->getPointer();
+  double* p2=f2->getPointer();
+  int* pc=corr[1]->getPointer();
+  for (int i = 0; i < nbcells; i++)
+    {
+      int i1=pc[i]*nbcomp;
+      int i2=i*nbcomp;
+      for (int j = 0; j < nbcomp; j++)
+        {
+          if (p1[i1+j]==p2[i2+j]) nbequal++;
+          //cout<<" "<<p1[i1+j]<<"="<<p2[i2+j];
+        }
+    }
+  CPPUNIT_ASSERT_EQUAL(nbcells*nbcomp, nbequal);
+  
+  for (std::size_t i = 0; i < corr.size(); i++)
+    corr[i]->decrRef();
+  field1->decrRef();
+  field2->decrRef();
+  fusedCell->decrRef();
+  refusedCellMesh->decrRef();
+  cellMesh->decrRef();
+}
+
+void MEDPARTITIONERTest::verifyMetisMedpartitionerOnSmallSizeForFieldOnGaussNe()
+{
+  int res;
+  string fileName,cmd,execName,sourceName,targetName,input;
+  execName=getenv("MED_ROOT_DIR");  //.../INSTALL/MED
+  execName+="/bin/salome/medpartitioner";
+  fileName=_file_name;
+  fileName.replace(fileName.find(".med"),4,"_WithVecFieldOnGaussNe.med");
+  
+  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_mesh_name.c_str());
+  ParaMEDMEM::MEDCouplingUMesh* cellMesh=initialMesh->getLevel0Mesh(false);
+  
+  cmd=execName+" --ndomains=5 --split-method=metis";  //on same proc
+  sourceName=fileName;
+  targetName=fileName;
+  targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  input=targetName+".xml";
+  
+  //merge split meshes and test equality
+  cmd=execName+" --ndomains=1 --split-method=metis";  //on same proc
+  sourceName=targetName+".xml";
+  targetName=fileName;
+  targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
+  if (_verbose) cout<<endl<<cmd<<endl;
+  res=system(cmd.c_str());
+  CPPUNIT_ASSERT_EQUAL(0, res);
+  
+  string refusedName=targetName+"1.med";
+  ParaMEDMEM::MEDFileUMesh* refusedMesh=ParaMEDMEM::MEDFileUMesh::New(refusedName.c_str(),_mesh_name.c_str());
+  ParaMEDMEM::MEDCouplingUMesh* refusedCellMesh=refusedMesh->getLevel0Mesh(false);
+  
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), refusedCellMesh->getNumberOfCells());
+  
+  std::vector<const MEDCouplingUMesh *> meshes;
+  std::vector<DataArrayInt *> corr;
+  meshes.push_back(cellMesh);
+  refusedCellMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-9);
+  meshes.push_back(refusedCellMesh);
+  MEDCouplingUMesh* fusedCell=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,0,corr);
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), fusedCell->getNumberOfCells());
+  
+  MEDCouplingFieldDouble* field1=MEDLoader::ReadField(ON_GAUSS_NE,fileName.c_str(),initialMesh->getName(),0,"MyFieldOnGaussNE",5,6);
+  MEDCouplingFieldDouble* field2=MEDLoader::ReadField(ON_GAUSS_NE,refusedName.c_str(),refusedCellMesh->getName(),0,"MyFieldOnGaussNE",5,6);
+  
+  int nbcells=corr[1]->getNumberOfTuples();
+  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), nbcells);
+  //use corr to test equality of field
+  DataArrayDouble* f1=field1->getArray();
+  DataArrayDouble* f2=field2->getArray();
+  if (_verbose>300) 
+    {
+      cout << "\nf1 : " << f1->reprZip(); //123.4 for 12th cell,3rd component, 4th gausspoint
+      cout << "\nf2 : " << f2->reprZip(); //field2->advancedRepradvancedRepr();
+      for (std::size_t i = 0; i < corr.size(); i++)
+        cout << "\ncorr " << i << " : " << corr[i]->reprZip();
+    
+    }
+  int nbequal=0;
+  int nbptgauss=8;
+  int nbcomp=field1->getNumberOfComponents();
+  double* p1=f1->getPointer();
+  double* p2=f2->getPointer();
+  int* pc=corr[1]->getPointer();
+  for (int i = 0; i < nbcells; i++)
+    {
+      int i1=pc[i]*nbcomp*nbptgauss;
+      int i2=i*nbcomp*nbptgauss;
+      for (int j = 0; j < nbcomp*nbptgauss; j++)
+        {
+          if (p1[i1+j]==p2[i2+j]) nbequal++;
+          //cout<<" "<<p1[i1+j]<<"="<<p2[i2+j];
+        }
+    }
+  CPPUNIT_ASSERT_EQUAL(nbcells*nbcomp*nbptgauss, nbequal);
+  
+  for (std::size_t i = 0; i < corr.size(); i++)
+    corr[i]->decrRef();
+  field1->decrRef();
+  field2->decrRef();
+  fusedCell->decrRef();
+  refusedCellMesh->decrRef();
+  cellMesh->decrRef();
+}
+
index 1278b458ebc9297b9411feea7ccabf75ebc96fa8..50b3b8be549f70a063d60c59e3cae3cd54829425 100644 (file)
 class MEDPARTITIONERTest : public CppUnit::TestFixture
 {
   CPPUNIT_TEST_SUITE( MEDPARTITIONERTest );
-  CPPUNIT_TEST( testSmallSize );
-  CPPUNIT_TEST( testMedianSize );
-  CPPUNIT_TEST( testHugeSize );
+  CPPUNIT_TEST( testMeshCollectionSingle );
+  CPPUNIT_TEST( testMeshCollectionXml );
+  CPPUNIT_TEST( testMeshCollectionSinglePartitionMetis );
+  CPPUNIT_TEST( testMeshCollectionComplexPartitionMetis );
+  CPPUNIT_TEST( testMetisSmallSize );
+  
+#if defined(HAVE_MPI2) && defined(MED_ENABLE_PARMETIS)
+  //test with mpi on system
+  CPPUNIT_TEST( testMpirunSmallSize );
+  CPPUNIT_TEST( testMpirunMedianSize );
+  CPPUNIT_TEST( testMpirunHugeSize );
+#endif
+
   //CPPUNIT_TEST( deleteTestMeshes );
   CPPUNIT_TEST_SUITE_END();
 
@@ -68,11 +78,15 @@ public:
   void createTestMeshWithVecFieldOnCells();
   void createTestMeshWithVecFieldOnNodes();
   void verifyTestMeshWithVecFieldOnNodes();
+  void verifyMetisMedpartitionerOnSmallSizeForMesh();
+  void verifyMetisMedpartitionerOnSmallSizeForFieldOnCells();
+  void verifyMetisMedpartitionerOnSmallSizeForFieldOnGaussNe();
   void verifyMedpartitionerOnSmallSizeForMesh();
   void verifyMedpartitionerOnSmallSizeForFieldOnCells();
   void verifyMedpartitionerOnSmallSizeForFieldOnGaussNe();
   void createTestMeshes();
   void createHugeTestMesh(int ni, int nj, int nk, int nbx, int nby, int nbz, int nbTarget);
+  void launchMetisMedpartitionerOnTestMeshes();
   void launchMedpartitionerOnTestMeshes();
   void launchMedpartitionerOnHugeTestMeshes();
   void deleteTestMeshes();
@@ -80,9 +94,17 @@ public:
   //for CPPUNIT_TEST
   void setUp();
   void tearDown();
-  void testSmallSize();
-  void testMedianSize();
-  void testHugeSize();
+  void testMeshCollectionSingle();
+  void testMeshCollectionXml();
+  void testMeshCollectionSinglePartitionMetis();
+  void testMeshCollectionComplexPartitionMetis();
+  void testMetisSmallSize();
+  
+#if defined(HAVE_MPI2) && defined(MED_ENABLE_PARMETIS)
+  void testMpirunSmallSize();
+  void testMpirunMedianSize();
+  void testMpirunHugeSize();
+#endif
 };
 
 #endif
index e5332e2e749d6a320f01931e23943b1a6e890efc..75b1d688e627eea4ab0fe2fe956ce55b146b858b 100644 (file)
@@ -328,21 +328,6 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   cellMesh->decrRef();
 }
 
-void MEDPARTITIONERTest::createTestMeshes()
-{
-  createTestMeshWithoutField();
-  createTestMeshWithVecFieldOnCells();
-  createTestMeshWithVecFieldOnNodes();
-}
-
-
-void MEDPARTITIONERTest::deleteTestMeshes()
-{
-  string cmd="rm *tmp_testMesh*";
-  if (_verbose) cout<<endl<<cmd<<endl;
-  system(cmd.c_str());  //may be not if debug
-}  
-
 void MEDPARTITIONERTest::launchMedpartitionerOnTestMeshes()
 {
   
@@ -424,7 +409,7 @@ void MEDPARTITIONERTest::launchMedpartitionerOnHugeTestMeshes()
   CPPUNIT_ASSERT_EQUAL(0, res);
 }  
 
-void MEDPARTITIONERTest::testSmallSize()
+void MEDPARTITIONERTest::testMpirunSmallSize()
 {
   setSmallSize();
   createTestMeshes();
@@ -434,14 +419,14 @@ void MEDPARTITIONERTest::testSmallSize()
   verifyMedpartitionerOnSmallSizeForFieldOnGaussNe();
 }
 
-void MEDPARTITIONERTest::testMedianSize()
+void MEDPARTITIONERTest::testMpirunMedianSize()
 {
   setMedianSize();
   createTestMeshes();
   launchMedpartitionerOnTestMeshes();
 }
 
-void MEDPARTITIONERTest::testHugeSize()
+void MEDPARTITIONERTest::testMpirunHugeSize()
 {
   //setBigSize(); //may be a lot for now
   setMedianSize();
index cd36f53d7303f9f5c847132d3627b868646a80e4..83053a6e3b49901c6e6d37e1b7bbda98b6c94f65 100644 (file)
@@ -46,28 +46,29 @@ libMEDPARTITIONERTest_la_CPPFLAGS = \
        -I$(srcdir)/../../INTERP_KERNEL/GaussPoints \
        -I$(srcdir)/../../INTERP_KERNEL
 
-libMEDPARTITIONERTest_la_LDFLAGS = $(MED3_LIBS_C_ONLY) $(HDF5_LIBS) $(MPI_LIBS) @CPPUNIT_LIBS@
+libMEDPARTITIONERTest_la_LDFLAGS = \
+       $(MED3_LIBS_C_ONLY) \
+       $(HDF5_LIBS) \
+       $(MPI_LIBS) \
+       @CPPUNIT_LIBS@
 
 # Executables targets
 
 dist_salomescript_DATA = 
 UNIT_TEST_PROG =
 
-if MPI_IS_OK
-  bin_PROGRAMS = TestMEDPARTITIONER
-
-  TestMEDPARTITIONER_SOURCES = TestMEDPARTITIONER.cxx
+bin_PROGRAMS = TestMEDPARTITIONER
+TestMEDPARTITIONER_SOURCES = TestMEDPARTITIONER.cxx
+TestMEDPARTITIONER_CPPFLAGS = $(libMEDPARTITIONERTest_la_CPPFLAGS) 
 
-  TestMEDPARTITIONER_CPPFLAGS = $(libMEDPARTITIONERTest_la_CPPFLAGS) 
-  TestMEDPARTITIONER_LDADD = \
+TestMEDPARTITIONER_LDADD = \
        $(libMEDPARTITIONERTest_la_LDFLAGS) -lm \
        libMEDPARTITIONERTest.la \
        ../../INTERP_KERNEL/libinterpkernel.la \
        ../libmedpartitioner.la
-  UNIT_TEST_PROG += TestMEDPARTITIONER
-endif
+
+UNIT_TEST_PROG += TestMEDPARTITIONER
 
 check: tests
 
-CLEANFILES =            \
-        UnitTestsResult
+CLEANFILES = UnitTestsResult