]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
22875: debug continue
authorimn <imn@opencascade.com>
Tue, 26 May 2015 11:03:16 +0000 (14:03 +0300)
committerimn <imn@opencascade.com>
Tue, 26 May 2015 11:03:16 +0000 (14:03 +0300)
src/MEDPartitioner/MEDPARTITIONER_MEDPartitioner.cxx
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx
src/MEDPartitioner_Swig/MEDPartitionerTest.py

index 0290e75ebb572f93a76449f082095155831d02bf..d7f93fe5305c9db762e0dc7c15f73accafa4bc56 100644 (file)
@@ -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( &parallelizer );
 
   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( &parallelizer );
@@ -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( &parallelizer );
   _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;
-
 }
index b8f01a26c7ff97e900f579203c25687cedd6ff85..e3a268032c9f18aa1f99101fdbbc6070ec723c22 100644 (file)
@@ -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;
index 252ab0212fe6fee31b2e4afea1ec3fbcf065f08a..818f94953148d4950314929abc676f65261fc7f4 100644 (file)
@@ -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());
+            }
         }
     }
   
index 773bb0fdb38172663eacbd2ac7891ff292f79d45..7a58236c45bef45799aee8998f5efa2444f2508a 100644 (file)
 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()