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();
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 );
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()
break;
}
return cellGraph;
-
}
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())
// }
// 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 );
if (faceMesh->getNumberOfCells()>0)
{
faceMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10);
- mfm->setMeshAtLevel( -1, cellMesh );
+ mfm->setMeshAtLevel( -1, faceMesh );
}
// ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0;
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;
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());
+ }
}
}
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()