ParaMEDMEM::MEDFileData* MEDPARTITIONER::MEDPartitioner::getMEDFileData()
{
- return _output_collection->getDriver()->getMEDFileData();
+ return _output_collection->retrieveDriver()->getMEDFileData();
}
MEDPARTITIONER::Graph* MEDPARTITIONER::MEDPartitioner::Graph(ParaMEDMEM::MEDCouplingSkyLineArray* graph, Graph::splitter_type split, int* edgeweight)
MEDPARTITIONER::Graph* cellGraph=0;
ParaMEDMEM::MEDCouplingSkyLineArray* arr = new ParaMEDMEM::MEDCouplingSkyLineArray(graph->getIndexArray(), graph->getValueArray());
switch (split)
- {
+ {
case Graph::METIS:
if ( !cellGraph )
- {
- #ifdef MED_ENABLE_METIS
+ {
+#ifdef MED_ENABLE_METIS
cellGraph=new METISGraph(arr,edgeweight);
- #endif
- }
+#endif
+ }
if ( !cellGraph )
throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : PARMETIS/METIS is not available. Check your products, please.");
- break;
+ break;
case Graph::SCOTCH:
- #ifdef MED_ENABLE_SCOTCH
- cellGraph=new SCOTCHGraph(arr,edgeweight);
- #else
- throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : SCOTCH is not available. Check your products, please.");
- #endif
- break;
- }
+#ifdef MED_ENABLE_SCOTCH
+ cellGraph=new SCOTCHGraph(arr,edgeweight);
+#else
+ throw INTERP_KERNEL::Exception("MEDPartitioner::Graph : SCOTCH is not available. Check your products, please.");
+#endif
+ break;
+ }
return cellGraph;
}
_joint_finder(0)
{
std::vector<std::vector<std::vector<int> > > new2oldIds(initialCollection.getTopology()->nbDomain());
- castCellMeshes(initialCollection, new2oldIds);
+ std::vector<ParaMEDMEM::DataArrayInt*> o2nRenumber;
+
+ castCellMeshes(initialCollection, new2oldIds, o2nRenumber );
//defining the name for the collection and the underlying meshes
setName(initialCollection.getName());
buildBoundaryFaces();
//building the connect zones necessary for writing joints
- buildConnectZones( nodeMapping, initialCollection.getTopology()->nbDomain() );
+ buildConnectZones( nodeMapping, o2nRenumber, initialCollection.getTopology()->nbDomain() );
}
/*!
Creates the meshes using the topology underlying he mesh collection and the mesh data
coming from the ancient collection
\param initialCollection collection from which the data is extracted to create the new meshes
+ \param [out] o2nRenumber returns for each new domain a permutation array returned by sortCellsInMEDFileFrmt()
*/
void MEDPARTITIONER::MeshCollection::castCellMeshes(MeshCollection& initialCollection,
- std::vector<std::vector<std::vector<int> > >& new2oldIds)
+ std::vector<std::vector<std::vector<int> > >& new2oldIds,
+ std::vector<ParaMEDMEM::DataArrayInt*> & o2nRenumber)
{
if (MyGlobals::_Verbose>10)
std::cout << "proc " << MyGlobals::_Rank << " : castCellMeshes" << std::endl;
int nbOldDomain=initialCollection.getTopology()->nbDomain();
_mesh.resize(nbNewDomain);
+ o2nRenumber.resize(nbNewDomain,0);
int rank=MyGlobals::_Rank;
//splitting the initial domains into smaller bits
std::vector<std::vector<ParaMEDMEM::MEDCouplingUMesh*> > splitMeshes;
for (int inew=0; inew<nbNewDomain ;inew++)
{
std::vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
-
+
for (int i=0; i<(int)splitMeshes[inew].size(); i++)
- if (splitMeshes[inew][i]!=0)
+ if (splitMeshes[inew][i]!=0)
if (splitMeshes[inew][i]->getNumberOfCells()>0)
meshes.push_back(splitMeshes[inew][i]);
- if (!isParallelMode()||_domain_selector->isMyDomain(inew))
+ if (!isParallelMode()||_domain_selector->isMyDomain(inew))
+ {
+ if (meshes.size()==0)
{
- if (meshes.size()==0)
- {
_mesh[inew]=CreateEmptyMEDCouplingUMesh();
std::cout << "WARNING : castCellMeshes fusing : no meshes try another number of processors" << std::endl;
}
else
{
_mesh[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(meshes);
+ o2nRenumber[inew]=_mesh[inew]->sortCellsInMEDFileFrmt();
bool areNodesMerged;
int nbNodesMerged;
if (meshes.size()>1)
array->decrRef(); // array is not used in this case
}
_mesh[inew]->zipCoords();
-
}
}
for (int i=0;i<(int)splitMeshes[inew].size();i++)
}
/*!
- \param initialCollection source mesh collection
+ \param initialCollection source mesh collection
\param nodeMapping structure containing the correspondency between nodes in the initial collection and the node(s) in the new collection
*/
void MEDPARTITIONER::MeshCollection::createNodeMapping( MeshCollection& initialCollection, NodeMapping& nodeMapping)
ids12->rearrange( 1 ); // make one component
return ids12;
}
+
+ //================================================================================
+ /*!
+ * \brief Renumber ids according to mesh->sortCellsInMEDFileFrmt()
+ * \param [in,out] ids - cell ids to renumber
+ * \param [in] o2nRenumber - renumbering array in "Old to New" mode
+ */
+ //================================================================================
+
+ void renumber( DataArrayInt* ids, const DataArrayInt* o2nRenumber )
+ {
+ if ( !ids || !o2nRenumber )
+ return;
+ int * id = ids->getPointer();
+ const int * o2n = o2nRenumber->getConstPointer();
+ for ( ; id < ids->end(); ++id )
+ {
+ *id = o2n[ *id ];
+ }
+ }
}
//================================================================================
//================================================================================
void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeMapping,
+ const std::vector<ParaMEDMEM::DataArrayInt*> & o2nRenumber,
int nbInitialDomains)
{
if ( !MyGlobals::_Create_Joints || _topology->nbDomain() < 2 )
ids1 = ids12->selectByTupleId2( 0, corrArray->getLength()+1, 2 );
ids2 = ids12->selectByTupleId2( 1, corrArray->getLength()+1, 2 );
+ // renumber cells according to mesh->sortCellsInMEDFileFrmt()
+ renumber( ids1, o2nRenumber[ cz->getLocalDomainNumber() ]);
+ renumber( ids2, o2nRenumber[ cz->getDistantDomainNumber() ]);
+
// check nb cell types
std::set<INTERP_KERNEL::NormalizedCellType> types1, types2;
types1 = mesh1->getTypesOfPart( ids1->begin(), ids1->end() );
std::multimap<std::pair<int,int>,std::pair<int,int> >& nodeMapping);
void castCellMeshes(MeshCollection& initialCollection,
- std::vector<std::vector<std::vector<int> > >& new2oldIds);
+ std::vector<std::vector<std::vector<int> > >& new2oldIds,
+ std::vector<ParaMEDMEM::DataArrayInt*> & o2nRenumber);
//creates faces on the new collection
void castFaceMeshes(MeshCollection& initialCollection,
std::vector<std::vector<std::vector<int> > >& new2oldIds);
//constructing connect zones
- void buildConnectZones( const NodeMapping& nodeMapping, int nbInitialDomains );
+ void buildConnectZones( const NodeMapping& nodeMapping,
+ const std::vector<ParaMEDMEM::DataArrayInt*> & o2nRenumber,
+ int nbInitialDomains );
// Find faces common with neighbor domains and put them in groups
void buildBoundaryFaces();