From 6c2f2938923964a77db2b90468a98e8a74dff718 Mon Sep 17 00:00:00 2001 From: cvw Date: Fri, 16 Mar 2012 12:53:57 +0000 Subject: [PATCH] *** empty log message *** --- .../Test/MEDPARTITIONERTest.cxx | 55 ++++++++++--------- .../Test/MEDPARTITIONERTest.hxx | 12 ++-- .../Test/MEDPARTITIONERTestPara.cxx | 35 +++++++----- 3 files changed, 58 insertions(+), 44 deletions(-) diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx index ab4333bfe..0fbf68817 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx @@ -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 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<getName(),0); - if (_verbose) cout<<_fileNameWithFaces<<" reread"<getName(),0); + if (_verbose) cout<<_file_name_with_faces<<" reread"<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<getName(),0); - if (_verbose) cout<<_fileName2<<" reread"<getName(),0); + if (_verbose) cout<<_file_name2<<" reread"<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<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& types=m->getAllTypes(); if (_verbose) { diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx b/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx index 4d7ec7b0b..8af687247 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx @@ -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 diff --git a/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx b/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx index 83f176c7a..2fab79d54 100644 --- a/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx +++ b/src/MEDPartitioner/Test/MEDPARTITIONERTestPara.cxx @@ -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 : "<reprZip(); cout<<"\nf2 : "<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(); } + -- 2.39.2