From 641dabe9a011c0da5b29d49e321c9b6d63e381e3 Mon Sep 17 00:00:00 2001 From: imn Date: Tue, 26 May 2015 14:03:16 +0300 Subject: [PATCH] 22875: debug continue --- .../MEDPARTITIONER_MEDPartitioner.cxx | 12 ++++++- .../MEDPARTITIONER_MeshCollectionDriver.cxx | 13 ++++++-- ...PARTITIONER_MeshCollectionMedXmlDriver.cxx | 17 ++++++++-- src/MEDPartitioner_Swig/MEDPartitionerTest.py | 33 ++++++++----------- 4 files changed, 50 insertions(+), 25 deletions(-) diff --git a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx index 0290e75eb..d7f93fe53 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx @@ -44,8 +44,12 @@ MEDPARTITIONER::MEDPartitioner *MEDPARTITIONER::MEDPartitioner::New(const ParaME MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory) { + MyGlobals::_World_Size=1; + MyGlobals::_Rank=0; + ParaDomainSelector parallelizer(mesure_memory); _input_collection=new MeshCollection(filename,parallelizer); + _input_collection->setParaDomainSelector( ¶llelizer ); MEDPARTITIONER::ParallelTopology* aPT = (MEDPARTITIONER::ParallelTopology*) _input_collection->getTopology(); @@ -58,6 +62,9 @@ MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const std::string& filename, int MEDPARTITIONER::MEDPartitioner::MEDPartitioner(const ParaMEDMEM::MEDFileData* filedata, int ndomains, const std::string& library,bool creates_boundary_faces, bool create_joints, bool mesure_memory) { + MyGlobals::_World_Size=1; + MyGlobals::_Rank=0; + ParaDomainSelector parallelizer(mesure_memory); _input_collection=new MeshCollection(); _input_collection->setParaDomainSelector( ¶llelizer ); @@ -81,11 +88,15 @@ void MEDPARTITIONER::MEDPartitioner::createPartitionCollection(int ndomains, con else new_topo.reset(_input_collection->createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH)); _output_collection=new MeshCollection(*_input_collection,new_topo.get(),false,false); + _output_collection->filterFaceOnCell(); } void MEDPARTITIONER::MEDPartitioner::Write(const std::string& filename) { + ParaDomainSelector parallelizer(false); + _output_collection->setParaDomainSelector( ¶llelizer ); _output_collection->write(filename); + parallelizer.evaluateMemory(); } ParaMEDMEM::MEDFileData* MEDPARTITIONER::MEDPartitioner::getMEDFileData() @@ -118,5 +129,4 @@ MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(ParaMEDMEM::MEDCoup break; } return cellGraph; - } diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx index b8f01a26c..e3a268032 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx @@ -196,7 +196,6 @@ ParaMEDMEM::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain); ParaMEDMEM::MEDCouplingUMesh* faceMesh=_collection->getFaceMesh(idomain); - std::string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); // std::string cleFilter=Cle1ToStr("filterFaceOnCell",idomain); // ParaMEDMEM::DataArrayInt* filter=0; // if (_collection->getMapDataArrayInt().find(cleFilter)!=_collection->getMapDataArrayInt().end()) @@ -208,6 +207,16 @@ ParaMEDMEM::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const // } // if (faceMeshFilter!=0) // faceMeshFilter->decrRef(); + std::size_t found=MyGlobals::_General_Informations[0].find("finalMeshName="); + std::string finalMeshName; + if ((found!=std::string::npos) && (found>0)) + { + finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); + } + else + { + finalMeshName=(_collection->getMesh())[idomain]->getName(); + } cellMesh->setName(finalMeshName); mfm->setMeshAtLevel( 0, cellMesh ); @@ -215,7 +224,7 @@ ParaMEDMEM::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const if (faceMesh->getNumberOfCells()>0) { faceMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10); - mfm->setMeshAtLevel( -1, cellMesh ); + mfm->setMeshAtLevel( -1, faceMesh ); } // ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0; diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx index 252ab0212..818f94953 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx @@ -245,7 +245,12 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* int nbdomains= _collection->getMesh().size(); //loop on the domains - std::string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); + std::string finalMeshName=""; + std::size_t found=MyGlobals::_General_Informations[0].find("finalMeshName="); + if ((found!=std::string::npos) && (found>0)) + { + finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); + } for (int idomain=nbdomains-1; idomain>=0;idomain--) { std::string distfilename; @@ -276,8 +281,14 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* node = xmlNewChild(mesh_node,0, BAD_CAST "chunk",0); xmlNewProp(node, BAD_CAST "subdomain", BAD_CAST buff); - xmlNewChild(node,0,BAD_CAST "name", BAD_CAST finalMeshName.c_str()); - //xmlNewChild(node,0,BAD_CAST "name", BAD_CAST (_collection->getMesh())[idomain]->getName()); + if (finalMeshName!="") + { + xmlNewChild(node,0,BAD_CAST "name", BAD_CAST finalMeshName.c_str()); + } + else + { + xmlNewChild(node,0,BAD_CAST "name", BAD_CAST ((_collection->getMesh())[idomain]->getName()).c_str()); + } } } diff --git a/src/MEDPartitioner_Swig/MEDPartitionerTest.py b/src/MEDPartitioner_Swig/MEDPartitionerTest.py index 773bb0fdb..7a58236c4 100644 --- a/src/MEDPartitioner_Swig/MEDPartitionerTest.py +++ b/src/MEDPartitioner_Swig/MEDPartitionerTest.py @@ -20,28 +20,23 @@ from MEDPartitioner import * from MEDLoader import * import unittest +from MEDLoaderDataForTest import MEDLoaderDataForTest class MEDPartitionerTest(unittest.TestCase): - # def test1(self): + def testPartition(self): from MEDCoupling import MEDCouplingCMesh - arr=DataArrayDouble(100) ; arr.iota() - c=MEDCouplingCMesh() ; c.setCoords(arr,arr) - m=c.buildUnstructured() - d=MEDFileData.New("/dn20/salome/imn/SALOME7YA/MED_BUILD/src/MEDLoader/Swig/splitted_blade1.med") - p=MEDPartitioner.New(d,2); - part=p.Graph(m.generateGraph()) - part.partGraph(2) - #a=part.getGraph() - pass - def test2(self): - from MEDCoupling import MEDCouplingCMesh - arr=DataArrayDouble(100) ; arr.iota() - c=MEDCouplingCMesh() ; c.setCoords(arr,arr) - m=c.buildUnstructured() - p=MEDPartitioner.New("/dn20/salome/imn/SALOME7YA/MED_BUILD/src/MEDLoader/Swig/splitted_blade1.med"); - part=p.Graph(m.generateGraph()) - part.partGraph(2) - #a=part.getGraph() + fname="PyPartitionTest.med" + data=MEDLoaderDataForTest.buildACompleteMEDDataStructureWithFieldsOnCells_1() + data.write(fname,2) + part_file=MEDPartitioner.New(fname,2) + part_data=MEDPartitioner.New(data,2) + part_file.Write("splitted_PyPartitionTest_1") + part_data.Write("splitted_PyPartitionTest_2") + part_file_xml=MEDPartitioner.New("splitted_PyPartitionTest_1.xml",2) + part_data_xml=MEDPartitioner.New("splitted_PyPartitionTest_2.xml",2) + data1=part_file.getMEDFileData() + data2=part_data.getMEDFileData() pass + unittest.main() -- 2.39.2