]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
*** empty log message ***
authorcvw <cvw>
Fri, 16 Mar 2012 12:53:57 +0000 (12:53 +0000)
committercvw <cvw>
Fri, 16 Mar 2012 12:53:57 +0000 (12:53 +0000)
src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx
src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx
src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx

index ab4333bfeabddcaee7a73eb2db35cd291817a5c0..0fbf68817f5dafdb31e11dbbe9c4048c50c4d60a 100644 (file)
@@ -59,10 +59,10 @@ void MEDPARTITIONERTest::setSize(int ni, int nj, int nk)
   this->_ntot=_ni*_nj*_nk;
   string ijk=IntToStr(ni)+"x"+IntToStr(nj)+"x"+IntToStr(nk);
   this->_fileName="tmp_testMesh_"+ijk+".med";
-  this->_fileNameWithFaces="tmp_testMeshWithFaces_"+ijk+".med";
+  this->_file_name_with_faces="tmp_testMeshWithFaces_"+ijk+".med";
   string ij=IntToStr(ni)+"x"+IntToStr(nj);
-  this->_fileName2="tmp_testMesh_"+ij+".med";
-  this->_meshName="testMesh";
+  this->_file_name2="tmp_testMesh_"+ij+".med";
+  this->_mesh_name="testMesh";
 }
 
 void MEDPARTITIONERTest::setSmallSize()
@@ -88,7 +88,7 @@ void MEDPARTITIONERTest::setbigSize()
 // ============================================================================
 void MEDPARTITIONERTest::setUp()
 {
-  this->_verbose=100;
+  this->_verbose=0;
 }
 
 // ============================================================================
@@ -170,7 +170,7 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildCUBE3DMesh()
   myCoords->alloc(nbv,3);
   std::copy(coor.begin(),coor.end(),myCoords->getPointer());
   mesh->setCoords(myCoords);
-  mesh->setName(_meshName.c_str());
+  mesh->setName(_mesh_name.c_str());
   myCoords->decrRef();
   mesh->checkCoherency();
   return mesh;
@@ -238,7 +238,7 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildCARRE3DMesh()
   myCoords->alloc(nbv,3);
   std::copy(coor.begin(),coor.end(),myCoords->getPointer());
   mesh->setCoords(myCoords);
-  mesh->setName(_meshName.c_str());
+  mesh->setName(_mesh_name.c_str());
   myCoords->decrRef();
   mesh->checkCoherency();
   return mesh;
@@ -307,7 +307,7 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildFACE3DMesh()
   myCoords->alloc(nbv,3);
   std::copy(coor.begin(),coor.end(),myCoords->getPointer());
   mesh->setCoords(myCoords);
-  mesh->setName(_meshName.c_str());
+  mesh->setName(_mesh_name.c_str());
   myCoords->decrRef();
   mesh->checkCoherency();
   return mesh;
@@ -326,7 +326,7 @@ MEDCouplingFieldDouble * MEDPARTITIONERTest::buildVecFieldOnCells(string myfileN
           field.push_back(k+.3);
         }
   //cvwat
-  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(myfileName.c_str(),_meshName.c_str(),0);
+  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(myfileName.c_str(),_mesh_name.c_str(),0);
   int nbOfCells=mesh->getNumberOfCells();
   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
   f1->setName("VectorFieldOnCells");
@@ -359,7 +359,7 @@ MEDCouplingFieldDouble * MEDPARTITIONERTest::buildVecFieldOnNodes()
           field.push_back(k+.3);
         }
   
-  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(_fileName.c_str(),_meshName.c_str(),0);
+  MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(_fileName.c_str(),_mesh_name.c_str(),0);
   int nbOfNodes=mesh->getNumberOfNodes();
   MEDCouplingFieldDouble *f1=MEDCouplingFieldDouble::New(ON_NODES,ONE_TIME);
   f1->setName("VectorFieldOnNodes");
@@ -407,9 +407,9 @@ void MEDPARTITIONERTest::createTestMeshWithoutField()
     mesh1->checkCoherency();
     meshes.push_back(mesh1);
     meshes.push_back(mesh2);
-    MEDLoader::WriteUMeshes(_fileNameWithFaces.c_str(), meshes, true);
+    MEDLoader::WriteUMeshes(_file_name_with_faces.c_str(), meshes, true);
   
-    ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_fileNameWithFaces.c_str(), mesh1->getName());
+    ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_file_name_with_faces.c_str(), mesh1->getName());
     DataArrayInt* FacesFam=DataArrayInt::New();
     FacesFam->alloc(mfm->getSizeAtLevel(-1),1);
     FacesFam->fillWithValue(-1);
@@ -427,23 +427,23 @@ void MEDPARTITIONERTest::createTestMeshWithoutField()
     theGroups["GroupCells"].push_back("FamilyCells");
     mfm->setFamilyInfo(theFamilies);
     mfm->setGroupInfo(theGroups);
-    mfm->write(_fileNameWithFaces.c_str(),0);
+    mfm->write(_file_name_with_faces.c_str(),0);
     FacesFam->decrRef();
     CellsFam->decrRef();
   
     /*ce truc marche pas!
-      ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_fileNameWithFaces.c_str(), mesh1->getName());
+      ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_file_name_with_faces.c_str(), mesh1->getName());
       vector<const ParaMEDMEM::MEDCouplingUMesh*> ms;
       ms.push_back(mesh2);
       mfm->setGroupsFromScratch(-1, ms);
-      mfm->write(_fileNameWithFaces.c_str(),0);
+      mfm->write(_file_name_with_faces.c_str(),0);
     */
   
-    if (_verbose) cout<<endl<<_fileNameWithFaces<<" created"<<endl;
+    if (_verbose) cout<<endl<<_file_name_with_faces<<" created"<<endl;
     if (_ntot<1000000) //too long
       {
-        MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileNameWithFaces.c_str(),mesh1->getName(),0);
-        if (_verbose) cout<<_fileNameWithFaces<<" reread"<<endl;
+        MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_file_name_with_faces.c_str(),mesh1->getName(),0);
+        if (_verbose) cout<<_file_name_with_faces<<" reread"<<endl;
         CPPUNIT_ASSERT(mesh1->isEqual(mesh_rw,1e-12));
         mesh_rw->decrRef();
       }
@@ -453,20 +453,23 @@ void MEDPARTITIONERTest::createTestMeshWithoutField()
    
   {
     MEDCouplingUMesh * mesh = buildCARRE3DMesh();
-    MEDLoader::WriteUMesh(_fileName2.c_str(),mesh,true);
-    if (_verbose) cout<<endl<<_fileName2<<" created"<<endl;
-    MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileName2.c_str(),mesh->getName(),0);
-    if (_verbose) cout<<_fileName2<<" reread"<<endl;
+    MEDLoader::WriteUMesh(_file_name2.c_str(),mesh,true);
+    if (_verbose) cout<<endl<<_file_name2<<" created"<<endl;
+    MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_file_name2.c_str(),mesh->getName(),0);
+    if (_verbose) cout<<_file_name2<<" reread"<<endl;
     CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12));
     mesh_rw->decrRef();
     mesh->decrRef();
   }
 }
 
+/*
+create a set of nbx*nby*nbz files mesh of ni*ny*nz cells
+*/
 void MEDPARTITIONERTest::createHugeTestMesh(int ni, int nj, int nk, int nbx, int nby, int nbz, int nbTarget)
 {
   setSize(ni,nj,nk);
-  _nbTargetHuge=nbTarget;
+  _nb_target_huge=nbTarget;
   MEDCouplingUMesh * mesh = buildCUBE3DMesh();
   //int nbx=1, nby=1, nbz=2;
   std::vector< double > cooDep,cooFin;
@@ -560,8 +563,8 @@ void MEDPARTITIONERTest::createHugeTestMesh(int ni, int nj, int nk, int nbx, int
   tagXml.replace(tagXml.find("$tagMesh"),8,tagMeshes);
 
   string nameFileXml;
-  _fileNameHugeXml="tmp_testMeshHuge_"+IntToStr(_ni)+"x"+IntToStr(_nj)+"x"+IntToStr(_nk)+"_"+sxyz+".xml";
-  std::ofstream f(_fileNameHugeXml.c_str());
+  _file_name_huge_xml="tmp_testMeshHuge_"+IntToStr(_ni)+"x"+IntToStr(_nj)+"x"+IntToStr(_nk)+"_"+sxyz+".xml";
+  std::ofstream f(_file_name_huge_xml.c_str());
   f<<tagXml;
   f.close();
   //cout<<"\n"<<tagXml<<endl;
@@ -648,7 +651,7 @@ void MEDPARTITIONERTest::createTestMeshWithVecFieldOnCells()
     f3->decrRef();
   }
   {
-    string name=_fileNameWithFaces;
+    string name=_file_name_with_faces;
     MEDCouplingFieldDouble *f1=buildVecFieldOnCells(name);
     name.replace(name.find(".med"),4,"_WithVecFieldOnCells.med");
     MEDLoader::WriteField(name.c_str(),f1,true);
@@ -685,7 +688,7 @@ void MEDPARTITIONERTest::verifyTestMeshWithVecFieldOnNodes()
 {
   string name=_fileName;
   name.replace(name.find(".med"),4,"_WithVecFieldOnNodes.med");
-  MEDCouplingUMesh * m=MEDLoader::ReadUMeshFromFile(name.c_str(),_meshName.c_str(),0);
+  MEDCouplingUMesh * m=MEDLoader::ReadUMeshFromFile(name.c_str(),_mesh_name.c_str(),0);
   const std::set<INTERP_KERNEL::NormalizedCellType>& types=m->getAllTypes();
   if (_verbose)
     {
index 4d7ec7b0b8a4834ce7d2ded36fa937b880046173..8af687247c9b3be72dace5e4a9d86be7f00aa695 100644 (file)
@@ -35,6 +35,7 @@ class MEDPARTITIONERTest : public CppUnit::TestFixture
   CPPUNIT_TEST_SUITE( MEDPARTITIONERTest );
   CPPUNIT_TEST( testSmallSize );
   CPPUNIT_TEST( testMedianSize );
+  CPPUNIT_TEST( testHugeSize );
   //CPPUNIT_TEST( deleteTestMeshes );
   CPPUNIT_TEST_SUITE_END();
 
@@ -46,11 +47,11 @@ public:
   int _nk;
   int _ntot;
   std::string _fileName; //initial test mesh file med CUBE3D
-  std::string _fileNameWithFaces; //initial test mesh file med CUBE3D plus a set of faces
-  std::string _fileName2; //initial test mesh file med CARRE3D
-  std::string _fileNameHugeXml;
-  int _nbTargetHuge;
-  std::string _meshName; //initial test mesh file med
+  std::string _file_name_with_faces; //initial test mesh file med CUBE3D plus a set of faces
+  std::string _file_name2; //initial test mesh file med CARRE3D
+  std::string _file_name_huge_xml;
+  int _nb_target_huge;
+  std::string _mesh_name; //initial test mesh file med
   int _verbose;
   
   //for utils
@@ -81,6 +82,7 @@ public:
   void tearDown();
   void testSmallSize();
   void testMedianSize();
+  void testHugeSize();
 };
 
 #endif
index 83f176c7a7b98bc5e2baf0df0a5d22489fd029e5..2fab79d5494f0ad8e705f8e141874f7a05059755 100644 (file)
@@ -55,9 +55,9 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForMesh()
   string fileName,cmd,execName,sourceName,targetName,input;
   execName=getenv("MED_ROOT_DIR");  //.../INSTALL/MED
   execName+="/bin/salome/medpartitioner_para";
-  fileName=_fileNameWithFaces;
+  fileName=_file_name_with_faces;
   
-  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_meshName.c_str());
+  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);
   
@@ -103,7 +103,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForMesh()
   CPPUNIT_ASSERT_EQUAL(0, res);
   
   string refusedName=targetName+"1.med";
-  ParaMEDMEM::MEDFileUMesh* refusedMesh=ParaMEDMEM::MEDFileUMesh::New(refusedName.c_str(),_meshName.c_str());
+  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);
   
@@ -160,7 +160,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnCells()
   fileName=_fileName;
   fileName.replace(fileName.find(".med"),4,"_WithVecFieldOnCells.med");
   
-  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_meshName.c_str());
+  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_mesh_name.c_str());
   ParaMEDMEM::MEDCouplingUMesh* cellMesh=initialMesh->getLevel0Mesh(false);
   
   cmd="mpirun -np 5 "+execName+" --ndomains=5 --split-method=metis";  //on same proc
@@ -184,7 +184,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnCells()
   CPPUNIT_ASSERT_EQUAL(0, res);
   
   string refusedName=targetName+"1.med";
-  ParaMEDMEM::MEDFileUMesh* refusedMesh=ParaMEDMEM::MEDFileUMesh::New(refusedName.c_str(),_meshName.c_str());
+  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());
@@ -205,7 +205,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnCells()
   //use corr to test equality of field
   DataArrayDouble* f1=field1->getArray();
   DataArrayDouble* f2=field2->getArray();
-  if (_verbose) 
+  if (_verbose>300
     {
       cout<<"\nf1 : "<<f1->reprZip();
       cout<<"\nf2 : "<<f2->reprZip(); //field2->advancedRepradvancedRepr();
@@ -248,7 +248,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   fileName=_fileName;
   fileName.replace(fileName.find(".med"),4,"_WithVecFieldOnGaussNe.med");
   
-  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_meshName.c_str());
+  ParaMEDMEM::MEDFileUMesh* initialMesh=ParaMEDMEM::MEDFileUMesh::New(fileName.c_str(),_mesh_name.c_str());
   ParaMEDMEM::MEDCouplingUMesh* cellMesh=initialMesh->getLevel0Mesh(false);
   
   cmd="mpirun -np 5 "+execName+" --ndomains=5 --split-method=metis";  //on same proc
@@ -272,7 +272,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   CPPUNIT_ASSERT_EQUAL(0, res);
   
   string refusedName=targetName+"1.med";
-  ParaMEDMEM::MEDFileUMesh* refusedMesh=ParaMEDMEM::MEDFileUMesh::New(refusedName.c_str(),_meshName.c_str());
+  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());
@@ -293,7 +293,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   //use corr to test equality of field
   DataArrayDouble* f1=field1->getArray();
   DataArrayDouble* f2=field2->getArray();
-  if (_verbose) 
+  if (_verbose>300
     {
       cout << "\nf1 : " << f1->reprZip(); //123.4 for 12th cell,3rd component, 4th gausspoint
       cout << "\nf2 : " << f2->reprZip(); //field2->advancedRepradvancedRepr();
@@ -412,10 +412,10 @@ void MEDPARTITIONERTest::launchMedpartitionerOnHugeTestMeshes()
   execName=getenv("MED_ROOT_DIR");  //.../INSTALL/MED
   execName+="/bin/salome/medpartitioner_para";
 
-  string snbTarget=IntToStr(_nbTargetHuge);
+  string snbTarget=IntToStr(_nb_target_huge);
   cmd="mpirun -np "+snbTarget+" "+execName+" --ndomains="+snbTarget+" --split-method=metis";  //on same proc
-  sourceName=_fileNameHugeXml;
-  targetName=_fileNameHugeXml;
+  sourceName=_file_name_huge_xml;
+  targetName=_file_name_huge_xml;
   string tmp="_partitionedTo"+snbTarget+"_";
   targetName.replace(targetName.find(".xml"),4,tmp);
   cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
@@ -439,6 +439,15 @@ void MEDPARTITIONERTest::testMedianSize()
   setMedianSize();
   createTestMeshes();
   launchMedpartitionerOnTestMeshes();
-  createHugeTestMesh(_ni, _nj, _nk, 2, 2, 2, 20); //it is now to know how far we are going to test
+}
+
+void MEDPARTITIONERTest::testHugeSize()
+{
+  //setBigSize(); //may be a lot for now
+  setMedianSize();
+  //create a set of nbx*nby*nbz files mesh of ni*ny*nz cells
+  //_verbose=1;
+  createHugeTestMesh(_ni, _nj, _nk, 2, 2, 2, 32); //it is now to know how far we are going to test
   launchMedpartitionerOnHugeTestMeshes();
 }
+