]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
first MEDPARTITIONER operational version
authorvbd <vbd>
Tue, 11 Jan 2011 16:46:23 +0000 (16:46 +0000)
committervbd <vbd>
Tue, 11 Jan 2011 16:46:23 +0000 (16:46 +0000)
src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx
src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx
src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx
src/MEDPartitioner/Makefile.am

index 65addd7cd91abd2c8a6bb7da170630a94e068270..133e5f9512fa780d621e5128453d8302461889f7 100644 (file)
 #include "MEDMEM_Exception.hxx"
 
 #include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingNormalizedUnstructuredMesh.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "PointLocator3DIntersectorP0P0.hxx"
+
 #include "MEDPARTITIONER_utils.hxx" 
 
 #include "MEDPARTITIONER_Graph.hxx"
@@ -38,6 +42,7 @@
 
 #include "MEDPARTITIONER_UserGraph.hxx"
 
+
 #ifdef ENABLE_METIS
 #include "MEDPARTITIONER_METISGraph.hxx"
 #endif
@@ -67,7 +72,7 @@ using namespace std;
 #endif
 
 //template inclusion
-//#include "MEDPARTITIONER_MESHCollection.H"
+//#include "MEDPARTITIONER_MESHCollection.txx"
 
 MESHCollection::MESHCollection()
   : _topology(0),
@@ -93,46 +98,52 @@ MESHCollection::MESHCollection()
  * \param topology topology containing the cell mappings
  */
 
-MESHCollection::MESHCollection(MESHCollection& initial_collection, Topology* topology, bool family_splitting, bool create_empty_groups)
-  : _name(initial_collection._name),
+MESHCollection::MESHCollection(MESHCollection& initialCollection, Topology* topology, bool family_splitting, bool create_empty_groups)
+  : _name(initialCollection._name),
     _topology(topology),
     _owns_topology(false),
     _driver(0),
-    _domain_selector( initial_collection._domain_selector ),
+    _domain_selector( initialCollection._domain_selector ),
     _i_non_empty_mesh(-1),
     _driver_type(MEDPARTITIONER::MedXML),
     _subdomain_boundary_creates(false),
     _family_splitting(family_splitting),
     _create_empty_groups(create_empty_groups)
 {
-  string mesh_name = initial_collection.getName();
+  
   _mesh.resize(_topology->nbDomain());
-       
-       //splitting the initial domains into smaller bits
   
-       std::vector<std::vector<ParaMEDMEM::MEDCouplingUMesh*> > splitMeshes;
+  //splitting the initial domains into smaller bits
+  
+  std::vector<std::vector<ParaMEDMEM::MEDCouplingUMesh*> > splitMeshes;
   splitMeshes.resize(topology->nbDomain());
   for (int inew=0; inew<topology->nbDomain();inew++)
-    splitMeshes[inew].resize(initial_collection.getTopology()->nbDomain());
+    splitMeshes[inew].resize(initialCollection.getTopology()->nbDomain());
   
-  for (int iold=0; iold<initial_collection.getTopology()->nbDomain();iold++)
+  std::vector<std::vector<std::vector<int> > > new2oldIds(initialCollection.getTopology()->nbDomain());
+
+  for (int iold=0; iold<initialCollection.getTopology()->nbDomain();iold++)
     {
-      if (!isParallelMode() || initial_collection._domain_selector->isMyDomain(iold))
+      if (!isParallelMode() || initialCollection._domain_selector->isMyDomain(iold))
         {
-          int size=(initial_collection._mesh)[iold]->getNumberOfCells();
+          int size=(initialCollection._mesh)[iold]->getNumberOfCells();
           std::vector<int> globalids(size);
-          initial_collection.getTopology()->getCellList(iold, &globalids[0]);
+          initialCollection.getTopology()->getCellList(iold, &globalids[0]);
           std::vector<int> ilocalnew(size);
           std::vector<int> ipnew(size);
           topology->convertGlobalCellList(&globalids[0],size,&ilocalnew[0],&ipnew[0]);
-          std::vector<std::vector<int> > ids(topology->nbDomain());
+          new2oldIds[iold].resize(topology->nbDomain());
           for (int i=0; i<ilocalnew.size();i++)
             {
-              ids[ipnew[i]].push_back(i);
+              new2oldIds[iold][ipnew[i]].push_back(i);
             }
           for (int inew=0;inew<topology->nbDomain();inew++)
             {
-              splitMeshes[inew][iold]=(ParaMEDMEM::MEDCouplingUMesh*)(initial_collection.getMesh())[iold]->buildPartOfMySelf(&ids[inew][0],&ids[inew][0]+ids[inew].size(),true);
+              //               cout <<"inew:"<<inew<<" iold:"<<iold<<endl;
+              //               for (int i=0; i<new2oldIds[iold][inew].size();i++)
+              //                 cout<<new2oldIds[iold][inew][i]<<" ";
+              //               cout<<endl;
+              splitMeshes[inew][iold]=(ParaMEDMEM::MEDCouplingUMesh*)(initialCollection.getMesh())[iold]->buildPartOfMySelf(&new2oldIds[iold][inew][0],&new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),true);
               //              cout <<"small domain "<<iold<<" "<<inew<<" has "<<splitMeshes[inew][iold]->getNumberOfCells()<<" cells"<<endl;
             }
         }
@@ -144,7 +155,7 @@ MESHCollection::MESHCollection(MESHCollection& initial_collection, Topology* top
     }
   
   //fusing the split meshes
-  for (int inew=0; inew<topology->nbDomain()   ;inew++)
+  for (int inew=0; inew<topology->nbDomain()  ;inew++)
     {
       std::vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes(splitMeshes[inew].size());
       for (int i=0; i< splitMeshes[inew].size();i++)
@@ -152,29 +163,59 @@ MESHCollection::MESHCollection(MESHCollection& initial_collection, Topology* top
       
       if (!isParallelMode()||_domain_selector->isMyDomain(inew))
         {
-          _mesh[inew]=ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes(meshes);
+          _mesh[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(meshes);
           _mesh[inew]->zipCoords();
          
           //          std::cout<<"creating mesh #"<<inew+1<<" with "<<_mesh[inew]->getNumberOfCells()<<" cells and "<<_mesh[inew]->getNumberOfNodes()<<" nodes"<<std::endl;
         }
       for (int i=0; i< splitMeshes[inew].size();i++)
         splitMeshes[inew][i]->decrRef();
-    }  
+    }  
+  //casting cell families on new meshes
+  _cellFamilyIds.resize(topology->nbDomain());
+  castIntField(initialCollection.getMesh(), this->getMesh(),initialCollection.getCellFamilyIds(),_cellFamilyIds, new2oldIds);
+
+  //defining the name for the collection and the underlying meshes
+  setName(initialCollection.getName());
+
+  /////////////////:
+  // treating faces
+  /////////////////
+
   std::multimap<pair<int,int>, pair<int,int> > nodeMapping;
-  createNodeMapping(initial_collection, nodeMapping);
-  castMeshes(initial_collection.getFaceMesh(), this->getFaceMesh(),initial_collection, nodeMapping);
-  int nbOfGroups =  initial_collection.getGroupMeshes(0).size();
-  _groupMesh.resize(nbOfGroups);
-  for (int igroup=0; igroup<nbOfGroups; igroup++)
+  createNodeMapping(initialCollection, nodeMapping);
+  std::vector<std::vector<std::vector<int> > > new2oldFaceIds;
+  castMeshes(initialCollection.getFaceMesh(), this->getFaceMesh(),initialCollection, nodeMapping, new2oldFaceIds);
+
+
+  _faceFamilyIds.resize(topology->nbDomain());
+
+  //allocating family ids arrays
+  for (int inew=0; inew<topology->nbDomain();inew++)
     {
-      castMeshes((initial_collection.getGroupMeshes())[igroup],
-                 (this->getGroupMeshes())[igroup],
-                 initial_collection, nodeMapping);
-      for (int inew=0; inew<_topology->nbDomain(); inew++)
-        _groupMesh[igroup][inew]->setName((initial_collection.getGroupMeshes())[igroup][0]->getName());
+      _cellFamilyIds[inew]=ParaMEDMEM::DataArrayInt::New();
+      int* ptrCellIds=new int[_mesh[inew]->getNumberOfCells()];
+      _cellFamilyIds[inew]->useArray(ptrCellIds,true, ParaMEDMEM::CPP_DEALLOC,_mesh[inew]->getNumberOfCells(),1);
+      _faceFamilyIds[inew]=ParaMEDMEM::DataArrayInt::New();
+      int* ptrFaceIds=new int[_faceMesh[inew]->getNumberOfCells()];
+      _faceFamilyIds[inew]->useArray(ptrFaceIds,true, ParaMEDMEM::CPP_DEALLOC,_faceMesh[inew]->getNumberOfCells(),1); 
     }
+
+  castIntField(initialCollection.getFaceMesh(), this->getFaceMesh(),initialCollection.getFaceFamilyIds(),_faceFamilyIds,new2oldFaceIds);
+
+
+  ///////////////////////
+  ////treating groups
+  //////////////////////
+  _familyInfo=initialCollection.getFamilyInfo();
+  _groupInfo=initialCollection.getGroupInfo();
+
 }
 
+/*!
+  \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 MESHCollection::createNodeMapping( MESHCollection& initialCollection, std::multimap<pair<int,int>,pair<int,int> >& nodeMapping)
 {
   for (int iold=0; iold<initialCollection.getTopology()->nbDomain();iold++)
@@ -204,11 +245,11 @@ void MESHCollection::createNodeMapping( MESHCollection& initialCollection, std::
 }
 
 /*!
-creates the face meshes on the new domains from the faces on the old domain and the node mapping
-faces at the interface are duplicated
+  creates the face meshes on the new domains from the faces on the old domain and the node mapping
+  faces at the interface are duplicated
 */
 
-void MESHCollection::castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo, MESHCollection& initialCollection,const multimap<pair<int,int>,pair<int,int> >& nodeMapping)
+void MESHCollection::castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo, MESHCollection& initialCollection,const multimap<pair<int,int>,pair<int,int> >& nodeMapping, std::vector<std::vector<std::vector<int> > >& new2oldIds)
 {
 
   //splitMeshes structure will contain the partition of 
@@ -225,11 +266,13 @@ void MESHCollection::castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& mesh
     }
 
 
+  new2oldIds.resize(meshesCastFrom.size());
   //loop over the old domains to analyse the faces and decide 
   //on which new domain they belong
-         for (int iold=0; iold<meshesCastFrom.size();iold++)
+
+  for (int iold=0; iold<meshesCastFrom.size();iold++)
     {
-      vector<vector<int> > newFaceMeshesIds(newSize);
+      new2oldIds[iold].resize(newSize);
       for (int ielem=0;ielem<meshesCastFrom[iold]->getNumberOfCells();ielem++)
         {
           std::vector<int> nodes;
@@ -258,22 +301,22 @@ void MESHCollection::castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& mesh
                iter++)
             {
               if (iter->second==nodes.size())
-                newFaceMeshesIds[iter->first].push_back(ielem);
+                new2oldIds[iold][iter->first].push_back(ielem);
             }
         }        
       
       //creating the splitMeshes from the face ids
       for (int inew=0;inew<_topology->nbDomain();inew++)
         {
-          //          cout<<"nb faces "<<newFaceMeshesIds[inew].size()<<endl;
-          splitMeshes[inew][iold]=(ParaMEDMEM::MEDCouplingUMesh*)(meshesCastFrom[iold]->buildPartOfMySelf(&newFaceMeshesIds[inew][0],&newFaceMeshesIds[inew][0]+newFaceMeshesIds[inew].size(),true));
+          cout<<"nb faces "<<new2oldIds[iold][inew].size()<<endl;
+          splitMeshes[inew][iold]=(ParaMEDMEM::MEDCouplingUMesh*)(meshesCastFrom[iold]->buildPartOfMySelf(&new2oldIds[iold][inew][0],&new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),true));
         }
     }
       
-// send/receive stuff
+  // send/receive stuff
 
 
-//recollecting the bits of splitMeshes to fuse them into one
+  //recollecting the bits of splitMeshes to fuse them into one
   meshesCastTo.resize(newSize);
   for (int inew=0; inew < newSize;inew++)
     {
@@ -286,14 +329,30 @@ void MESHCollection::castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& mesh
           cout<<"dimension "<<splitMeshes[inew][iold]->getMeshDimension()<<endl;
           
         }
-      meshesCastTo[inew]=ParaMEDMEM::MEDCouplingUMesh::mergeUMeshes(myMeshes);
+      meshesCastTo[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(myMeshes);
+      meshesCastTo[inew]->checkCoherency();
       meshesCastTo[inew]->zipCoords();
+      meshesCastTo[inew]->checkCoherency();
       for (int iold=0; iold < meshesCastFrom.size();iold++)
-             splitMeshes[inew][iold]->decrRef();
+        splitMeshes[inew][iold]->decrRef();
       cout<<"creating face mesh #"<<inew<<" with "<<meshesCastTo[inew]->getNumberOfCells()<<" cells and "<<meshesCastTo[inew]->getNumberOfNodes()<<" nodes"<<endl;
     }
 }
 
+void MESHCollection::castIntField(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo,  std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom,  std::vector<ParaMEDMEM::DataArrayInt*>& arrayTo, std::vector< std::vector< std::vector<int> > >& new2oldMapping)
+{
+  for (int inew=0; inew < meshesCastTo.size();inew++)
+    {
+      vector<const ParaMEDMEM::DataArrayInt*> splitIds;
+      for (int iold=0; iold < meshesCastFrom.size();iold++)
+        {
+          int* ptr=&(new2oldMapping[iold][inew][0]);
+          splitIds.push_back(arrayFrom[iold]->selectByTupleId(ptr,ptr+new2oldMapping[iold][inew].size()));
+        }
+      arrayTo[inew]=ParaMEDMEM::DataArrayInt::Aggregate(splitIds);
+    }
+}
+
 
 /*! constructing the MESH collection from a distributed file
  *
@@ -425,9 +484,6 @@ MESHCollection::~MESHCollection()
     if (_mesh[i]!=0) {/*delete*/ _mesh[i]->decrRef(); }
   for (int i=0; i<_faceMesh.size();i++)
     if (_mesh[i]!=0) {/*delete*/ _faceMesh[i]->decrRef(); }
-  for (int i=0; i<_groupMesh.size();i++)
-    for (int j=0; j<_groupMesh[i].size(); j++)
-      _groupMesh[i][j]->decrRef();
   for (int i=0; i<_connect_zones.size();i++)
     if (_connect_zones[i]!=0) {delete _connect_zones[i];}
   if (_driver !=0) {delete _driver; _driver=0;}
@@ -449,8 +505,8 @@ void MESHCollection::write(const string& filename)
 {
   //building the connect zones necessary for writing joints
   cout<<"Building Connect Zones"<<endl;
-//   if (_topology->nbDomain()>1)
-//     buildConnectZones();
+  //   if (_topology->nbDomain()>1)
+  //     buildConnectZones();
   cout <<"End of connect zones building"<<endl;
   //suppresses link with driver so that it can be changed for writing
   if (_driver!=0)delete _driver;
@@ -492,23 +548,19 @@ MESHCollectionDriver* MESHCollection::getDriver() const
   return _driver;
 }
 // /*! retrieves the mesh dimension*/
- int MESHCollection::getMeshDimension() const
- {
-   return _i_non_empty_mesh < 0 ? -1 : _mesh[_i_non_empty_mesh]->getMeshDimension();
- }
-
- vector<ParaMEDMEM::MEDCouplingUMesh*>& MESHCollection::getMesh() 
- {
-   return _mesh;
- }
- vector<ParaMEDMEM::MEDCouplingUMesh*>& MESHCollection::getFaceMesh() 
- {
-   return _faceMesh;
- }
-vector<vector<ParaMEDMEM::MEDCouplingUMesh*> >& MESHCollection::getGroupMeshes() 
- {
-   return _groupMesh;
- }
+int MESHCollection::getMeshDimension() const
+{
+  return _i_non_empty_mesh < 0 ? -1 : _mesh[_i_non_empty_mesh]->getMeshDimension();
+}
+
+vector<ParaMEDMEM::MEDCouplingUMesh*>& MESHCollection::getMesh() 
+{
+  return _mesh;
+}
+vector<ParaMEDMEM::MEDCouplingUMesh*>& MESHCollection::getFaceMesh() 
+{
+  return _faceMesh;
+}
 ParaMEDMEM::MEDCouplingUMesh* MESHCollection::getMesh(int idomain)
 {
   return _mesh[idomain];
@@ -518,29 +570,25 @@ ParaMEDMEM::MEDCouplingUMesh* MESHCollection::getFaceMesh(int idomain)
 {
   return _faceMesh[idomain];
 }
-vector<ParaMEDMEM::MEDCouplingUMesh*>& MESHCollection::getGroupMeshes(int idomain)
+vector<MEDPARTITIONER::CONNECTZONE*>& MESHCollection::getCZ()
 {
-  return _groupMesh[idomain];
+  return _connect_zones;
 }
- vector<MEDPARTITIONER::CONNECTZONE*>& MESHCollection::getCZ()
- {
-   return _connect_zones;
- }
 
 Topology* MESHCollection::getTopology() const 
- {
-   return _topology;
- }
+{
+  return _topology;
+}
 
 void MESHCollection::setTopology(Topology* topo)
- {
-   if (_topology!=0)
-   {
-     throw MEDMEM::MEDEXCEPTION("Erreur : topology is already set");
-   }
-   else
-     _topology = topo;
- }
+{
+  if (_topology!=0)
+    {
+      throw MEDMEM::MEDEXCEPTION("Erreur : topology is already set");
+    }
+  else
+    _topology = topo;
+}
 
 
 /*! Method creating the cell graph
@@ -635,199 +683,199 @@ void MESHCollection::buildCellGraph(MEDPARTITIONER::MEDSKYLINEARRAY* & array,int
 
   array=new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
   cout<<"taille du graphe créé "<<array->getNumberOf()<<endl;
-//   int cell_number=1;
-//   int node_number=1;
-//   for (int i=0; i<_topology->nbDomain(); i++)
-//     {
-//       cell_number+=_topology->getCellNumber(i);
-//       node_number+=_topology->getNodeNumber(i);
-//     }
-//   //list of cells for a given node
-//   //vector< vector<int> > node2cell(node_number);
-//   map< int, vector<int> > node2cell;
-
-//   //list of nodes for a given cell
-//   //vector< vector <int> > cell2node(cell_number);
-//   map< int, vector <int> > cell2node;
-
-//   //  map<MED_EN::medGeometryElement,int*> type_cell_list;
-
-//   //tagging for the indivisible regions
-//   int* indivisible_tag=0;
-//   bool has_indivisible_regions=false;
-// //   if (!_indivisible_regions.empty())
-// //     {
-// //       has_indivisible_regions=true;
-// //       indivisible_tag=new int[_topology->nbCells()];
-// //       treatIndivisibleRegions(indivisible_tag);
-// //     }
-
-//   fillGlobalConnectivity(node2cell, cell2node );
-
-//   cout << "beginning of skyline creation"<<endl;
-//   //creating the MEDMEMSKYLINEARRAY containing the graph
-
-//   int* size = new int[_topology->nbCells()];
-//   int** temp=new int*[_topology->nbCells()];
-//   int** temp_edgeweight=0;
-// //   if (has_indivisible_regions)
-// //     temp_edgeweight=new int*[_topology->nbCells()];
-
-//   int cell_glob_shift = 0;
-
-//   // Get connection to cells on other procs
-//   multimap< int, int > loc2dist; // global cell ids on this proc -> other proc cells
-//   if ( isParallelMode() )
-//     {
-//       cell_glob_shift = _domain_selector->getProcShift();
-
-//       set<int> loc_domains; // domains on this proc
-//       for ( int idom = 0; idom < _mesh.size(); ++idom )
-//         if ( _mesh[ idom ] )
-//           loc_domains.insert( idom );
-
-//       for ( int idom = 0; idom < _mesh.size(); ++idom )
-//         {
-//           if ( !_mesh[idom] ) continue;
-//           vector<int> loc2glob_corr; // pairs of corresponding cells (loc_loc & glob_dist)
-//           retrieveDriver()->readLoc2GlobCellConnect(idom, loc_domains, _domain_selector, loc2glob_corr);
-//           //MEDMEM::STRING out;
-//           for ( int i = 0; i < loc2glob_corr.size(); i += 2 )
-//             {
-//               int glob_here  = _topology->convertCellToGlobal(idom,loc2glob_corr[i]); 
-//               int glob_there = loc2glob_corr[i+1]; 
-//               loc2dist.insert ( make_pair( glob_here, glob_there));
-//               //out << glob_here << "-" << glob_there << " ";
-//             }
-//           //cout << "\nRank " << _domain_selector->rank() << ": BndCZ: " << out << endl;
-//         }
-//     }
-
-//   //going across all cells
-
-//   map<int,int> cells_neighbours;
-//   for (int i=0; i< _topology->nbCells(); i++)
-//     {
-
-
-//       vector<int> cells(50);
-
-//       //     /*// cout << "size cell2node "<<cell2node[i+1].size()<<endl;
-//       //      for (vector<int>::const_iterator iternode=cell2node[i+1].begin();
-//       //            iternode!=cell2node[i+1].end();
-//       //            iternode++)
-//       //        {
-//       //          int nodeid=*iternode;
-//       //       //   cout << "size node2cell "<<node2cell[nodeid].size()<<endl;
-//       //          for (vector<int>::const_iterator iter=node2cell[nodeid].begin();
-//       //             iter != node2cell[nodeid].end();
-//       //             iter++)
-//       //              cells_neighbours[*iter]++;
-//       //        }*/
-
-//       for (int inode=0; inode< cell2node[i+1].size(); inode++)
-//         {
-//           int nodeid=cell2node[i+1][inode];
-//           //   cout << "size node2cell "<<node2cell[nodeid].size()<<endl;
-//           for (int icell=0; icell<node2cell[nodeid].size();icell++)
-//             cells_neighbours[node2cell[nodeid][icell]]++;
-//         }
-//       size[i]=0;
-//       int dimension = getMeshDimension();
-//       cells.clear();
-
-//       for (map<int,int>::const_iterator iter=cells_neighbours.begin(); iter != cells_neighbours.end(); iter++)  
-//         {
-//           if (iter->second >= dimension && iter->first != i+1) 
-//             {
-//               cells.push_back(iter->first + cell_glob_shift);
-//               //       cells[isize++]=iter->first;
-//             }
-//         }
-//       // add neighbour cells from distant domains
-//       multimap< int, int >::iterator loc_dist = loc2dist.find( i+1 );
-//       for (; loc_dist!=loc2dist.end() && loc_dist->first==( i+1 ); ++loc_dist )
-//         cells.push_back( loc_dist->second );
-
-//       size[i]=cells.size();
-//       //   size[i]=isize;
-
-//       //cout << cells.size()<<endl;
-//       //cout << cells_neighbours.size()<<endl;
-
-//       temp[i]=new int[size[i]];
-// //       if (has_indivisible_regions)
-// //         temp_edgeweight[i]=new int[size[i]];
-//       //    
-//       int itemp=0;
-
-//       // memcpy(temp[i],cells,isize*sizeof(int));
-
-//       for (vector<int>::const_iterator iter=cells.begin(); iter!=cells.end();iter++)
-//         //for(int j=0; j<isize; j++)
-//         {
-//           temp[i][itemp]=*iter;
-//           //temp[i][itemp]=cells[j];
-//  //          if (has_indivisible_regions)
-// //             {
-// //               int tag1 = indivisible_tag[(i+1)-1];
-// //               //int tag2 = indivisible_tag[iter->first-1];
-// //               int tag2 = indivisible_tag[*iter-1];
-// //               if (tag1==tag2 && tag1!=0)
-// //                 temp_edgeweight[i][itemp]=_topology->nbCells()*100000;
-// //               else
-// //                 temp_edgeweight[i][itemp]=1;
-// //             } 
-//           itemp++;
-//         }
-//       cells_neighbours.clear();
-//     }
-//   cout <<"end of graph definition"<<endl;
-//   int* index=new int[_topology->nbCells()+1];
-//   index[0]=1;
-//   for (int i=0; i<_topology->nbCells(); i++)
-//     index[i+1]=index[i]+size[i];
-
-//   node2cell.clear();
-//   cell2node.clear();
-//   // if (indivisible_tag!=0) delete [] indivisible_tag;
-
-//   //SKYLINEARRAY structure holding the cell graph
-//   array= new MEDMEM::MEDSKYLINEARRAY(_topology->nbCells(),index[_topology->nbCells()]-index[0]);
-//   array->setIndex(index);
-
-//   for (int i=0; i<_topology->nbCells(); i++)
-//     {
-//       array->setI(i+1,temp[i]);
-//       delete[]temp[i];
-//     }
-
-//   {// DEBUG
-//     //     MEDMEM::STRING out;
-//     //     const int* index= array->getIndex();
-//     //     const int* value =array->getValue();
-//     //     out << "\nRank " << (_domain_selector?_domain_selector->rank():0) << ": Index: ";
-//     //     for ( int i = 0; i <= array->getNumberOf(); ++i )
-//     //       out << index[i] << " ";
-//     //     out << "\nRank " << (_domain_selector?_domain_selector->rank():0) << ": Value: ";
-//     //     for ( int i = 0; i < array->getLength(); ++i )
-//     //       out << value[i] << " ";
-//     //     cout << out << endl;
-//   }
-// //   if (has_indivisible_regions)
-// //     {
-// //       edgeweights=new int[array->getLength()];
-// //       for (int i=0; i<_topology->nbCells(); i++)
-// //         {
-// //           for (int j=index[i]; j<index[i+1];j++)
-// //             edgeweights[j-1]=temp_edgeweight[i][j-index[i]];
-// //           delete[] temp_edgeweight[i];  
-// //         }
-// //       delete[]temp_edgeweight;
-// //     }
-//   delete[] index;
-//   delete[] temp;
-//   delete[] size;
+  //   int cell_number=1;
+  //   int node_number=1;
+  //   for (int i=0; i<_topology->nbDomain(); i++)
+  //     {
+  //       cell_number+=_topology->getCellNumber(i);
+  //       node_number+=_topology->getNodeNumber(i);
+  //     }
+  //   //list of cells for a given node
+  //   //vector< vector<int> > node2cell(node_number);
+  //   map< int, vector<int> > node2cell;
+
+  //   //list of nodes for a given cell
+  //   //vector< vector <int> > cell2node(cell_number);
+  //   map< int, vector <int> > cell2node;
+
+  //   //  map<MED_EN::medGeometryElement,int*> type_cell_list;
+
+  //   //tagging for the indivisible regions
+  //   int* indivisible_tag=0;
+  //   bool has_indivisible_regions=false;
+  // //   if (!_indivisible_regions.empty())
+  // //     {
+  // //       has_indivisible_regions=true;
+  // //       indivisible_tag=new int[_topology->nbCells()];
+  // //       treatIndivisibleRegions(indivisible_tag);
+  // //     }
+
+  //   fillGlobalConnectivity(node2cell, cell2node );
+
+  //   cout << "beginning of skyline creation"<<endl;
+  //   //creating the MEDMEMSKYLINEARRAY containing the graph
+
+  //   int* size = new int[_topology->nbCells()];
+  //   int** temp=new int*[_topology->nbCells()];
+  //   int** temp_edgeweight=0;
+  // //   if (has_indivisible_regions)
+  // //     temp_edgeweight=new int*[_topology->nbCells()];
+
+  //   int cell_glob_shift = 0;
+
+  //   // Get connection to cells on other procs
+  //   multimap< int, int > loc2dist; // global cell ids on this proc -> other proc cells
+  //   if ( isParallelMode() )
+  //     {
+  //       cell_glob_shift = _domain_selector->getProcShift();
+
+  //       set<int> loc_domains; // domains on this proc
+  //       for ( int idom = 0; idom < _mesh.size(); ++idom )
+  //         if ( _mesh[ idom ] )
+  //           loc_domains.insert( idom );
+
+  //       for ( int idom = 0; idom < _mesh.size(); ++idom )
+  //         {
+  //           if ( !_mesh[idom] ) continue;
+  //           vector<int> loc2glob_corr; // pairs of corresponding cells (loc_loc & glob_dist)
+  //           retrieveDriver()->readLoc2GlobCellConnect(idom, loc_domains, _domain_selector, loc2glob_corr);
+  //           //MEDMEM::STRING out;
+  //           for ( int i = 0; i < loc2glob_corr.size(); i += 2 )
+  //             {
+  //               int glob_here  = _topology->convertCellToGlobal(idom,loc2glob_corr[i]); 
+  //               int glob_there = loc2glob_corr[i+1]; 
+  //               loc2dist.insert ( make_pair( glob_here, glob_there));
+  //               //out << glob_here << "-" << glob_there << " ";
+  //             }
+  //           //cout << "\nRank " << _domain_selector->rank() << ": BndCZ: " << out << endl;
+  //         }
+  //     }
+
+  //   //going across all cells
+
+  //   map<int,int> cells_neighbours;
+  //   for (int i=0; i< _topology->nbCells(); i++)
+  //     {
+
+
+  //       vector<int> cells(50);
+
+  //       //     /*// cout << "size cell2node "<<cell2node[i+1].size()<<endl;
+  //       //      for (vector<int>::const_iterator iternode=cell2node[i+1].begin();
+  //       //            iternode!=cell2node[i+1].end();
+  //       //            iternode++)
+  //       //        {
+  //       //          int nodeid=*iternode;
+  //       //       //   cout << "size node2cell "<<node2cell[nodeid].size()<<endl;
+  //       //          for (vector<int>::const_iterator iter=node2cell[nodeid].begin();
+  //       //             iter != node2cell[nodeid].end();
+  //       //             iter++)
+  //       //              cells_neighbours[*iter]++;
+  //       //        }*/
+
+  //       for (int inode=0; inode< cell2node[i+1].size(); inode++)
+  //         {
+  //           int nodeid=cell2node[i+1][inode];
+  //           //   cout << "size node2cell "<<node2cell[nodeid].size()<<endl;
+  //           for (int icell=0; icell<node2cell[nodeid].size();icell++)
+  //             cells_neighbours[node2cell[nodeid][icell]]++;
+  //         }
+  //       size[i]=0;
+  //       int dimension = getMeshDimension();
+  //       cells.clear();
+
+  //       for (map<int,int>::const_iterator iter=cells_neighbours.begin(); iter != cells_neighbours.end(); iter++)  
+  //         {
+  //           if (iter->second >= dimension && iter->first != i+1) 
+  //             {
+  //               cells.push_back(iter->first + cell_glob_shift);
+  //               //       cells[isize++]=iter->first;
+  //             }
+  //         }
+  //       // add neighbour cells from distant domains
+  //       multimap< int, int >::iterator loc_dist = loc2dist.find( i+1 );
+  //       for (; loc_dist!=loc2dist.end() && loc_dist->first==( i+1 ); ++loc_dist )
+  //         cells.push_back( loc_dist->second );
+
+  //       size[i]=cells.size();
+  //       //   size[i]=isize;
+
+  //       //cout << cells.size()<<endl;
+  //       //cout << cells_neighbours.size()<<endl;
+
+  //       temp[i]=new int[size[i]];
+  // //       if (has_indivisible_regions)
+  // //         temp_edgeweight[i]=new int[size[i]];
+  //       //    
+  //       int itemp=0;
+
+  //       // memcpy(temp[i],cells,isize*sizeof(int));
+
+  //       for (vector<int>::const_iterator iter=cells.begin(); iter!=cells.end();iter++)
+  //         //for(int j=0; j<isize; j++)
+  //         {
+  //           temp[i][itemp]=*iter;
+  //           //temp[i][itemp]=cells[j];
+  //  //          if (has_indivisible_regions)
+  // //             {
+  // //               int tag1 = indivisible_tag[(i+1)-1];
+  // //               //int tag2 = indivisible_tag[iter->first-1];
+  // //               int tag2 = indivisible_tag[*iter-1];
+  // //               if (tag1==tag2 && tag1!=0)
+  // //                 temp_edgeweight[i][itemp]=_topology->nbCells()*100000;
+  // //               else
+  // //                 temp_edgeweight[i][itemp]=1;
+  // //             } 
+  //           itemp++;
+  //         }
+  //       cells_neighbours.clear();
+  //     }
+  //   cout <<"end of graph definition"<<endl;
+  //   int* index=new int[_topology->nbCells()+1];
+  //   index[0]=1;
+  //   for (int i=0; i<_topology->nbCells(); i++)
+  //     index[i+1]=index[i]+size[i];
+
+  //   node2cell.clear();
+  //   cell2node.clear();
+  //   // if (indivisible_tag!=0) delete [] indivisible_tag;
+
+  //   //SKYLINEARRAY structure holding the cell graph
+  //   array= new MEDMEM::MEDSKYLINEARRAY(_topology->nbCells(),index[_topology->nbCells()]-index[0]);
+  //   array->setIndex(index);
+
+  //   for (int i=0; i<_topology->nbCells(); i++)
+  //     {
+  //       array->setI(i+1,temp[i]);
+  //       delete[]temp[i];
+  //     }
+
+  //   {// DEBUG
+  //     //     MEDMEM::STRING out;
+  //     //     const int* index= array->getIndex();
+  //     //     const int* value =array->getValue();
+  //     //     out << "\nRank " << (_domain_selector?_domain_selector->rank():0) << ": Index: ";
+  //     //     for ( int i = 0; i <= array->getNumberOf(); ++i )
+  //     //       out << index[i] << " ";
+  //     //     out << "\nRank " << (_domain_selector?_domain_selector->rank():0) << ": Value: ";
+  //     //     for ( int i = 0; i < array->getLength(); ++i )
+  //     //       out << value[i] << " ";
+  //     //     cout << out << endl;
+  //   }
+  // //   if (has_indivisible_regions)
+  // //     {
+  // //       edgeweights=new int[array->getLength()];
+  // //       for (int i=0; i<_topology->nbCells(); i++)
+  // //         {
+  // //           for (int j=index[i]; j<index[i+1];j++)
+  // //             edgeweights[j-1]=temp_edgeweight[i][j-index[i]];
+  // //           delete[] temp_edgeweight[i];  
+  // //         }
+  // //       delete[]temp_edgeweight;
+  // //     }
+  //   delete[] index;
+  //   delete[] temp;
+  //   delete[] size;
 
   cout<< "end of graph creation"<<endl;
 }
@@ -1767,7 +1815,7 @@ Topology* MESHCollection::createPartition(const int* partition)
 // void MESHCollection::createNodalConnectivity(const MESHCollection& initial_collection,int idomain, int entity)
 // {
 
-       
+  
 //   int dimension=0;
 //   int nb_elems=0;
 //   ParaMEDMEM::MEDCouplingUMesh* mesh_builder = m_mesh[idomain];
@@ -1884,10 +1932,10 @@ Topology* MESHCollection::createPartition(const int* partition)
 
 //   //Treating nodes
 
-//     DataArrayInt* conn_index = (initial_collection.getMesh())[idomain].getConnIndex();
-//     DataArrayInt* index=(initial_collection.getMesh())[idomain].getIndex();
-       
-       
+//   DataArrayInt* conn_index = (initial_collection.getMesh())[idomain].getConnIndex();
+//   DataArrayInt* index=(initial_collection.getMesh())[idomain].getIndex();
+  
+  
 //   _topology->convertGlobalCellList(cell_list,nb_cells,local,ip);
 //   for (iter = type_numbers.begin();iter != type_numbers.end(); iter++)  
 //   {
@@ -2157,3 +2205,12 @@ Topology* MESHCollection::createPartition(const int* partition)
 
 //   return face_model;
 // }
+void MESHCollection::setDomainNames(const std::string& name)
+{
+  for (int i=0; i<_topology->nbDomain(); i++)
+    {
+      ostringstream oss;
+      oss<<name<<"_"<<i;
+      _mesh[i]->setName(oss.str().c_str());
+    }
+}
index de082505ac757b719106a51e62694a5515977d32..766224c9b8ce2047bd04d7d60d2a0e8e8057a307 100644 (file)
 namespace ParaMEDMEM
 {
   class MEDCouplingUMesh;
+  class DataArrayInt;
 }
 
+
 namespace MEDPARTITIONER
 {
 
@@ -128,23 +130,26 @@ namespace MEDPARTITIONER
      ParaMEDMEM::MEDCouplingUMesh* getFaceMesh(int idomain);
      std::vector<ParaMEDMEM::MEDCouplingUMesh*>& getGroupMeshes(int idomain);
 
-//     //getting a reference to a domain mesh
-//     MEDMEM::MESH* getMesh(int) const;
+     std::vector<ParaMEDMEM::DataArrayInt*>& getCellFamilyIds() {return _cellFamilyIds;}
+     std::vector<ParaMEDMEM::DataArrayInt*>& getFaceFamilyIds() {return _faceFamilyIds;}
 
+     std::map<std::string,int>& getFamilyInfo(){return _familyInfo;}
+     std::map<std::string, std::vector<std::string> >& getGroupInfo(){return _groupInfo;}
 //     //getting a reference to connect zones vector
     std::vector<MEDPARTITIONER::CONNECTZONE*>& getCZ();
 
     //getting a pointer to topology
     Topology* getTopology() const ;
-
-
-    //settig a new topology
+   
+  //settig a new topology
     void setTopology(Topology* topology);
 
     //getting/setting the name of the global mesh (as opposed 
     //to the name of a subdomain \a nn, which is name_nn) 
     std::string getName() const {return _name;}
-    void setName(const std::string& name) {_name=name;}
+    void setName(const std::string& name){_name=name;}
+    void setDomainNames(const std::string& name);
 
     //getting/setting the description of the global mesh
     std::string getDescription() const {return _description;}
@@ -157,10 +162,11 @@ namespace MEDPARTITIONER
     void castFaceMeshes( MESHCollection& initialCollection,const std::multimap<std::pair<int,int>,std::pair<int,int> >& nodeMapping);
 
     //creates faces on the new collection
-    void castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshCastTo,   MESHCollection& initialCollection,const std::multimap<std::pair<int,int>,std::pair<int,int> >& nodeMapping);
+    void castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshCastTo,   MESHCollection& initialCollection,const std::multimap<std::pair<int,int>,std::pair<int,int> >& nodeMapping, std::vector<std::vector<std::vector<int> > >& old2newIds);
+    
 
     //!transfers families from an old MESHCollection to new mesh
-               //    void castFamilies(const MESHCollection& old_collection);
+   //    void castFamilies(const MESHCollection& old_collection);
 
     //void castSupport(const MESHCollection& old_collection, std::vector<const MEDMEM::SUPPORT*>& old_support, std::vector<MEDMEM::SUPPORT*>& new_support);
 
@@ -199,15 +205,17 @@ namespace MEDPARTITIONER
  //    //!creates connectivities for a domain and an entity (face or cell)
 //     void createNodalConnectivity(const MESHCollection & initial_collection, int idomain, MED_EN::medEntityMesh entity);
 
-//     //!creates the tags for indivisible groups
-//     void treatIndivisibleRegions(int* tag);
 
 //     //!projects a field from an old collection to the present one
 //     //!field is identified by (name, dt, it)
-//     template <class T>
-//     void castFields(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber);
 
-//     void getFaces(int idomain, std::map<MED_EN::medGeometryElement, std::vector<MEDPARTITIONER_FaceModel*> >&);
+    
+    void castIntField(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo,  std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom,  std::vector<ParaMEDMEM::DataArrayInt*>& arrayTo, std::vector<std::vector< std::vector<int> > > & old2newMapping);
+
+  //     template <class T>
+    //     void castFields(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber);
+    
+    //     void getFaces(int idomain, std::map<MED_EN::medGeometryElement, std::vector<MEDPARTITIONER_FaceModel*> >&);
 
 //     MEDPARTITIONER_FaceModel* getCommonFace(int ip1,int ilocal1,int ip2,int ilocal2,int face_index);
 
@@ -232,14 +240,21 @@ namespace MEDPARTITIONER
     //!links to meshes
     std::vector<ParaMEDMEM::MEDCouplingUMesh*>        _mesh;
     std::vector<ParaMEDMEM::MEDCouplingUMesh*>        _faceMesh;
-    std::vector< std::vector<ParaMEDMEM::MEDCouplingUMesh*> >        _groupMesh;
-    
-    //!index of a non empty mesh within _mesh (in parallel mode all of meshes can be empty)
+   
+ //!index of a non empty mesh within _mesh (in parallel mode all of meshes can be empty)
     int                               _i_non_empty_mesh;
 
     //!links to connectzones
     std::vector<MEDPARTITIONER::CONNECTZONE*> _connect_zones;
 
+    //!family ids storages
+    std::vector<ParaMEDMEM::DataArrayInt*> _cellFamilyIds;
+    std::vector<ParaMEDMEM::DataArrayInt*> _faceFamilyIds;
+
+    //!group family conversion
+    std::map<std::string,int> _familyInfo;
+    std::map<std::string, std::vector<std::string> > _groupInfo;
+  
     //!list of groups that are not to be splitted
     std::vector<std::string>          _indivisible_regions;
 
index 3a6aa35d1afbe26fefc2d1fc86dcabec100ab317..7f5aeec425e16648cdcdbaa229d5d2fa7d88b13a 100644 (file)
@@ -32,6 +32,7 @@
 #include <sys/time.h>
 #include "MEDCouplingUMesh.hxx"
 #include "MEDLoader.hxx"
+#include "MEDFileMesh.hxx"
 #include "MEDMEM_Exception.hxx"
 extern "C" {
 #include "med.h"
@@ -85,23 +86,33 @@ int MESHCollectionDriver::readSeq(char* filename, char* meshname)
 
   _filename.resize(1);
   _filename[0]=string(filename);
+
+  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(filename,meshname);
   //puts the only mesh in the mesh vector
-  (_collection->getMesh()).push_back(MEDLoader::ReadUMeshFromFile(filename, meshname, 0));
-  (_collection->getFaceMesh()).push_back(MEDLoader::ReadUMeshFromFile(filename,meshname,-1));
+  (_collection->getMesh()).push_back(mfm->getLevel0Mesh(false));
+  (_collection->getFaceMesh()).push_back(mfm->getLevelM1Mesh(false));
+
+  //reading family ids
+
+  ParaMEDMEM::DataArrayInt* cellIds(mfm->getFamilyFieldAtLevel(0)->deepCpy());
+  ParaMEDMEM::DataArrayInt* faceIds(mfm->getFamilyFieldAtLevel(-1)->deepCpy());
+  (_collection->getCellFamilyIds()).push_back(cellIds);
+  (_collection->getFaceFamilyIds()).push_back(faceIds); 
 
   //reading groups
-  vector<string> groupNames = MEDLoader::GetMeshGroupsNames(filename,meshname);
-  (_collection->getGroupMeshes()).resize(groupNames.size());
+  (_collection->getFamilyInfo())=mfm->getFamilyInfo();
+  (_collection->getGroupInfo())=mfm->getGroupInfo();
   
-  for (int i=0; i< groupNames.size();i++)
-    {
-      vector<string> myGroup;
-      myGroup.push_back(groupNames[i]);
-      (_collection->getGroupMeshes())[i].push_back(MEDLoader::ReadUMeshFromGroups(filename,meshname,-1,myGroup));
-    }
+// (_collection->getGroupMeshes()).resize(groupNames.size());
+  
+//   for (int i=0; i< groupNames.size();i++)
+//     {
+//       vector<string> myGroup;
+//       myGroup.push_back(groupNames[i]);
+//       (_collection->getGroupMeshes())[i].push_back(MEDLoader::ReadUMeshFromGroups(filename,meshname,-1,myGroup));
+//     }
 
 
-  _collection->setName(meshname);
   (_collection->getCZ()).clear();
   vector<int*> cellglobal,nodeglobal,faceglobal;
   cellglobal.resize(1);
@@ -115,180 +126,13 @@ int MESHCollectionDriver::readSeq(char* filename, char* meshname)
   ParallelTopology* aPT = new ParallelTopology
     ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
   _collection->setTopology(aPT);
+  _collection->setName(meshname);
+  _collection->setDomainNames(meshname);
+
   //  END_OF_MED(LOC);
   return 0;
 }
 
-// /*!
-//  * Reads the file structure to determine the list
-//  * of all the available fields
-//  *
-//  * \param field_names, vector<string> containing the field names
-//  * \param iternumber, vector<int> containing the iteration numbers
-//  * \param ordernumber, vector<int> containing the order numbers
-//  * \param types, vector<int> containing 0 for int fields and 1 for double fields
-//  * 
-//  */
-
-// void MESHCollectionDriver::readFileStruct(vector <string>&  field_names,vector<int>& iternumber,vector <int>&  ordernumber, vector <int>& types)
-// {
-//   const char* LOC = "MEDPARTITIONER::MESHCollectionDriver::readFileStruct()";
-//   BEGIN_OF_MED(LOC);
-
-//   const MEDMEM::MED med_struct (MEDMEM::MED_DRIVER,_filename[0]);
-//   int nb_fields = med_struct.getNumberOfFields();
-
-//   MESSAGE_MED("found "<<nb_fields<<" fields in file")
-//     deque<string> names = med_struct.getFieldNames();
-//   for (int ifield = 0; ifield < nb_fields; ifield++)
-//   {
-//     deque<MEDMEM::DT_IT_> dtit=med_struct.getFieldIteration(names[ifield]);
-
-//     for (deque<MEDMEM::DT_IT_>::const_iterator iter =dtit.begin(); iter!=dtit.end(); iter++)
-//     {
-//       field_names.push_back(names[ifield]);
-//       iternumber.push_back(iter->dt);
-//       ordernumber.push_back(iter->it);  
-
-//       // testing whether the field is of double or int type   
-//       MEDMEM::FIELD_* field = med_struct.getField(names[ifield],iter->dt,iter->it);
-//       if (dynamic_cast<MEDMEM::FIELD<double>*>(field))
-//         types.push_back(1);
-//       else
-//         types.push_back(0);
-
-//     }
-//   }
-//   END_OF_MED(LOC);
-// }
-
-// //!retrieves the type of a field for a given fieldname
-// int MESHCollectionDriver::getFieldType(const string& fieldname)
-// {
-//   const char* LOC = "MEDPARTITIONER::MESHCollectionDriver::getFieldType()";
-//   BEGIN_OF_MED(LOC);
-//   const MEDMEM::MED med_struct (MEDMEM::MED_DRIVER,_filename[0]);
-
-//   deque<MEDMEM::DT_IT_> dtit=med_struct.getFieldIteration(fieldname);
-//   deque<MEDMEM::DT_IT_>::const_iterator iter =dtit.begin();
-
-//   // testing whether the field is of double or int type   
-//   MEDMEM::FIELD_* field = med_struct.getField(fieldname,iter->dt,iter->it);
-
-//   END_OF_MED(LOC);
-
-//   if (dynamic_cast<MEDMEM::FIELD<double>*>(field))
-//     return 1;
-//   else
-//     return 0;     
-
-// }
-// namespace
-// {
-// //================================================================================
-// /*!
-//  * \brief Structure used in the method below
-//  */
-// struct TJointData
-// {
-//   char             _name[MED_TAILLE_NOM+1];
-//   int              _nb_couples;
-//   med_int _distant_domain;
-//   med_geometrie_element _geo_local, _geo_dist;
-// };
-// }
-
-// //================================================================================
-// /*!
-//  * \brief Read CELL-CELL correspondences of joints with domains on other procs
-//  *  \param idomain - domain index to return correspondence for
-//  *  \param loc_domains - domians on this pocessor
-//  *  \param domain_selector - info on cell distribution among procs
-//  *  \param loc2glob_corr - out, correspondence pairs where distant ids are global
-//  */
-// //================================================================================
-
-// void MESHCollectionDriver::readLoc2GlobCellConnect(int                 idomain,
-//                                                    const set<int>&     loc_domains,
-//                                                    ParaDomainSelector* domain_selector,
-//                                                    vector<int> &       loc2glob_corr)
-// {
-//   using namespace med_2_3;
-//   med_err err;
-
-//   // find joints of domains touching idomain and loaded on other processors
-
-//   TJointData joint;
-//   list< TJointData > joints;
-//   int total_nb_couples = 0;
-
-//   MEDMEM::MESH* loc_mesh = _collection->getMesh()[idomain];
-//   char* meshname = (char*) _meshname[idomain].c_str();
-//   char* filename = (char*) _filename[idomain].c_str();
-//   //cout << "#" << domain_selector->rank() << ": mesh - " << meshname << endl;
-
-//     med_idt fid = MEDouvrir( filename, MED_LECTURE);
-//   int njoint = MEDnJoint(fid, meshname);
-//   for (int ijoint=0; ijoint<njoint; ijoint++)
-//   {
-//     char joint_description[MED_TAILLE_DESC+1], name_distant[MED_TAILLE_NOM+1];
-
-//     err = MEDjointInfo(fid, meshname, ijoint+1, joint._name, 
-//                        joint_description, &joint._distant_domain, name_distant);
-//     if ( err || loc_domains.count( joint._distant_domain ))
-//       continue;  // distant is on this proc
-
-//     MED_EN::medGeometryElement* types = loc_mesh->getTypesWithPoly(MED_EN::MED_CELL);
-//     int                       nbtypes = loc_mesh->getNumberOfTypesWithPoly(MED_EN::MED_CELL);
-//     const list<MED_EN::medGeometryElement>& all_types = MED_EN::meshEntities[ MED_EN::MED_CELL ];
-//     for (int itype=0; itype<nbtypes;itype++)
-//     {
-//       joint._geo_local = (med_geometrie_element) types[itype];
-//       list<MED_EN::medGeometryElement>::const_iterator dist_type = all_types.begin();
-//       for ( ; dist_type != all_types.end(); ++dist_type )
-//       {
-//         if ( !_collection->isDimensionOK( *dist_type, loc_mesh->getMeshDimension() ))
-//           continue;
-//         joint._geo_dist = (med_geometrie_element) *dist_type;
-//         joint._nb_couples = MEDjointnCorres(fid, meshname, joint._name,
-//                                             MED_MAILLE, joint._geo_local,
-//                                             MED_MAILLE, joint._geo_dist );
-//         if ( joint._nb_couples > 0 )
-//         {
-//           joints.push_back( joint );
-//           total_nb_couples += joint._nb_couples;
-//         }
-//       }
-//     }
-//     delete [] types;
-//   }
-
-//   // read cell pairs of found joints and replace distant local ids with global ones
-
-//   loc2glob_corr.resize( 2 * total_nb_couples );
-//   if ( total_nb_couples > 0 )
-//   {
-//     int* cell_corresp = & loc2glob_corr[0];
-
-//     list< TJointData >::iterator jnt = joints.begin();
-//     for ( ; jnt != joints.end(); ++jnt )
-//     {
-//       // read cell couples
-//       if ( MEDjointLire( fid, meshname, jnt->_name,
-//                          cell_corresp, 2 * jnt->_nb_couples,
-//                          MED_MAILLE, jnt->_geo_local,
-//                          MED_MAILLE, jnt->_geo_dist ) < 0 ) continue;
-
-//       // distant local ids -> global ids
-//       if ( int shift_to_global = domain_selector->getDomainShift( jnt->_distant_domain ))
-//         for ( int i = 0 ; i < jnt->_nb_couples; ++i )
-//           cell_corresp[ 2*i + 1 ] += shift_to_global;
-
-//       cell_corresp += 2 * jnt->_nb_couples;
-//     }
-//   }
-//   MEDfermer( fid );
-// }
 
 //================================================================================
 /*!
@@ -296,18 +140,6 @@ int MESHCollectionDriver::readSeq(char* filename, char* meshname)
  */
 //================================================================================
 
-// int MESHCollectionDriver::readMeshDimension() const
-// {
-//   const char* LOC = "MESHCollectionDriver::readMeshDimension(): ";
-//   if ( _filename.empty() || _meshname.empty() )
-//     throw MEDMEM::MED_EXCEPTION( "file name or mesh name not available");
-
-//   MEDMEM::MED med(MEDMEM::MED_DRIVER, _filename[0]);
-//   if ( MEDMEM::MESH* mesh = med.getMesh( _meshname[0] ))
-//     return mesh->getMeshDimension();
-  
-//   throw MEDMEM::MED_EXCEPTION( MEDMEM::STRING(LOC) << "mesh name is invalid");
-// }
 
 void MESHCollectionDriver::readSubdomain(vector<int*>& cellglobal,
                                          vector<int*>& faceglobal,
@@ -322,20 +154,21 @@ void MESHCollectionDriver::readSubdomain(vector<int*>& cellglobal,
   strcpy(file,_filename[idomain].c_str());
   cout << "Reading "<<_meshname[idomain]<<" in "<<_filename[idomain]<<endl;
   //(_collection->getMesh())[idomain]=new MEDMEM::MESH(MEDMEM::MED_DRIVER,file, meshname);
-  (_collection->getMesh())[idomain]=MEDLoader::ReadUMeshFromFile(file,meshname,0);
-  (_collection->getFaceMesh())[idomain]=MEDLoader::ReadUMeshFromFile(file,meshname,-1);
+ ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file,meshname);
+ (_collection->getMesh())[idomain]=mfm->getLevel0Mesh(false);
+  (_collection->getFaceMesh())[idomain]=mfm->getLevelM1Mesh(false);
+
+  //reading families
+  ParaMEDMEM::DataArrayInt* cellIds(mfm->getFamilyFieldAtLevel(0)->deepCpy());
+  ParaMEDMEM::DataArrayInt* faceIds(mfm->getFamilyFieldAtLevel(-1)->deepCpy());
+
+  (_collection->getCellFamilyIds())[idomain]=cellIds;
+  (_collection->getFaceFamilyIds())[idomain]=faceIds; 
 
   //reading groups
-  vector<string> groupNames = MEDLoader::GetMeshGroupsNames(file,meshname);
-  if (idomain==0)
-      (_collection->getGroupMeshes()).resize(groupNames.size());
-  
-  for (int i=0; i< groupNames.size();i++)
-    {
-      vector<string> myGroup;
-      myGroup.push_back(groupNames[i]);
-      (_collection->getGroupMeshes())[i].push_back(MEDLoader::ReadUMeshFromGroups(file,meshname,-1,myGroup));
-    }
+  _collection->getFamilyInfo()=mfm->getFamilyInfo();
+  _collection->getGroupInfo()=mfm->getGroupInfo();
 
   cout <<"End of Read"<<endl;
   //reading MEDPARTITIONER::CONNECTZONEs NODE/NODE and CELL/CELL
@@ -476,222 +309,8 @@ void MESHCollectionDriver::writeSubdomain(int idomain, int nbdomains, char* dist
   char meshchar[MED_TAILLE_NOM+1];
   strcpy(meshchar,(_collection->getMesh())[idomain]->getName());
   
-  // Writing cell global numbering
-//   // 
-//   {
-//     int ncell=_collection->getTopology()->getCellNumber(idomain);
-//     int* array=new int[ncell];
-//     _collection->getTopology()->getCellList(idomain,array);
-//     int offset=0;
-
-   //  MED_EN::MESH_ENTITIES::const_iterator currentEntity;
-//     list<MED_EN::medGeometryElement>::const_iterator iter;
-//     currentEntity  = MED_EN::meshEntities.find(MED_EN::MED_CELL);
-
-//     int nbtypes = (_collection->getMesh())[idomain]->getNumberOfTypesWithPoly(MED_EN::MED_CELL);
-//     MED_EN::medGeometryElement* types =(_collection->getMesh())[idomain]->getTypesWithPoly(MED_EN::MED_CELL);
-//     for (int itype=0; itype<nbtypes;itype++)
-//     {
-//       MED_EN::medGeometryElement type=types[itype];
-//       if (!_collection->isDimensionOK(type,_collection->getMeshDimension())) continue;
-//       int ntype = (_collection->getMesh())[idomain]->getNumberOfElementsWithPoly(MED_EN::MED_CELL,type);
-//       if (ntype==0) continue;
-//       MEDglobalNumEcr(fid,meshchar, array+offset, ntype,
-//                                MED_MAILLE, (med_geometrie_element)type);
-//       offset+=ntype;
-
-//     }
-//    delete[] types;
-  //   delete[] array;
-  //  }
-
-//   MED_EN::medEntityMesh constituent_entity;
-//   if (_collection->getMeshDimension()==3)
-//     constituent_entity=MED_EN::MED_FACE;
-//   else if (_collection->getMeshDimension()==2)
-//     constituent_entity=MED_EN::MED_EDGE;
-//   else throw MEDEXCEPTION("Wrong dimension");
-
-
-//   //writing face global numbering
-//   {
-//     int * array;
-//     int offset=0;
-//     int nface= _collection->getTopology()->getFaceNumber(idomain);
-//     if (nface >0)
-//       array=new int[nface];
-//     _collection->getTopology()->getFaceList(idomain,array);
-
-//     int nbfacetypes = (_collection->getMesh())[idomain]->getNumberOfTypesWithPoly(constituent_entity);
-//     MED_EN::medGeometryElement* facetypes;
-//     if (nbfacetypes>0) 
-//       facetypes =(_collection->getMesh())[idomain]->getTypesWithPoly(constituent_entity);
-
-//     for (int itype=0; itype<nbfacetypes;itype++)
-//     {
-//       MED_EN::medGeometryElement type=facetypes[itype];
-//       if (!_collection->isDimensionOK(type,_collection->getMeshDimension()-1)) continue;
-
-//       int ntype = (_collection->getMesh())[idomain]->getNumberOfElementsWithPoly(constituent_entity,type);
-//       if (ntype==0) continue;
-//       MEDglobalNumEcr(fid,meshchar, array+offset, ntype,
-//                                MED_MAILLE, (med_geometrie_element)type);
-
-//       offset+=ntype;
-//     }
-//     if (nface>0) delete[] array;
-//     if (nbfacetypes>0) delete[] facetypes;
-//   }
-
-
-//   //writing node global numbering
-//   {
-//     int nnode=_collection->getTopology()->getNodeNumber(idomain);
-//     int* array = new int[nnode];
-//     _collection->getTopology()->getNodeList(idomain,array);
-//     MEDglobalNumEcr(fid,meshchar, array, nnode,
-//                              MED_NOEUD, MED_POINT1);
-//     delete[] array;
-//   }
 
   MEDfermer(fid);
   std::cout<<"End of writing"<<std::endl;
 
 }
-
-// void MESHCollectionDriver::writeElementJoint(medEntityMesh entity ,
-//                                              int icz, 
-//                                              int idomain, 
-//                                              int idistant, 
-//                                              char* mesh_name, 
-//                                              char* joint_name,  
-//                                              med_idt fid )
-// {
-//   //////////////////////////////////////////
-//   //writing cell/cell correspondency
-//   //////////////////////////////////////////
-//   int nbcells=(_collection->getCZ())[icz]->getEntityCorrespNumber(entity,entity);
-//   const int* index = (_collection->getCZ())[icz]->getEntityCorrespIndex(entity,entity);
-//   const int* value = (_collection->getCZ())[icz]->getEntityCorrespValue(entity,entity);
-//   if ( nbcells==0 ) return; // e.g. domains have 1 common node
-
-//   map <pair <MED_EN::medGeometryElement, MED_EN::medGeometryElement> , vector<int> > cellmap;
-//   map <MED_EN::medGeometryElement, int> local_offset;
-//   map <MED_EN::medGeometryElement, int> distant_offset;
-
-//   //definition of the local offsets for the types present on local
-//   //and distant domains
-//   // for a mesh containing 2 triangles and 3 quads
-//   //local_offset[TRIA3]=0
-//   //local_offset[QUAD4]=2
-
-//   int nb_types_local=(_collection->getMesh())[idomain]-> getNumberOfTypes(entity);
-//   const MED_EN::medGeometryElement* local_types = (_collection->getMesh())[idomain]->getTypes(entity);
-//   const int* local_gni = (_collection->getMesh())[idomain]-> getGlobalNumberingIndex(entity);
-//   for (int i=0; i< nb_types_local; i++)
-//   {
-//     local_offset[local_types[i]]=local_gni[i]-1;
-//   }                                      
-
-//   int nb_types_distant=(_collection->getMesh())[idistant]-> getNumberOfTypes(entity);
-//   const MED_EN::medGeometryElement* distant_types = (_collection->getMesh())[idistant]->getTypes(entity);
-//   const int* distant_gni = (_collection->getMesh())[idistant]-> getGlobalNumberingIndex(entity);
-//   for (int i=0; i< nb_types_distant; i++)
-//   {
-//     distant_offset[distant_types[i]]=distant_gni[i]-1;
-//   } 
-
-//   if (nb_types_local==1 && nb_types_distant==1)
-//   {
-//     MED_EN::medGeometryElement local_type =  (_collection->getMesh())[idomain]->getElementType(entity,1);
-//     MED_EN::medGeometryElement distant_type = (_collection->getMesh())[idistant]->getElementType(entity,1);
-//     vector<int> corresp;
-//     for (int i=0; i<nbcells; i++)
-//       for (int icol = index[i]-1; icol<index[i+1]-1; icol++)
-//       {
-//         corresp.push_back(i+1);
-//         corresp.push_back(value[icol]);
-//       }
-//     int size_joint = corresp.size()/2;
-//     MEDjointEcr(fid, mesh_name, joint_name, &corresp[0], 
-//                          size_joint, MED_MAILLE,
-//                          (med_geometrie_element)local_type    ,MED_MAILLE, 
-//                          (med_geometrie_element)distant_type    );
-//   }
-//   else
-//   {
-//     //classifying all the cell/cell relationships into geomtype/geomtype relationships
-//     //there exists a vector for each geomtype/geomtype pair
-//     // the vectors are stored in cellmap, a std::map with a pair<geomtype,geomtype> key 
-
-//     for (int i=0; i<nbcells; i++)
-//       for (int icol = index[i]-1; icol<index[i+1]-1; icol++)
-//       {
-//         MED_EN::medGeometryElement local_type =  (_collection->getMesh())[idomain]->getElementType(entity,i+1);
-//         MED_EN::medGeometryElement distant_type = (_collection->getMesh())[idistant]->getElementType(entity,value[icol]);
-
-//         cellmap[make_pair(local_type, distant_type)].push_back(i+1-local_offset[local_type]);
-//         cellmap[make_pair(local_type, distant_type)].push_back(value[icol]-distant_offset[distant_type]);
-
-//       }
-//     map <pair <MED_EN::medGeometryElement, MED_EN::medGeometryElement> , vector<int> >::const_iterator iter;
-
-//     //going through all the (geom,geom) pairs and writing the joints
-//     for (iter= cellmap.begin(); iter != cellmap.end(); iter++)
-//     {
-//       int size= iter->second.size();
-//       int *corresp = new int[size];
-//       for (int ind=0; ind < size; ind++)
-//         corresp[ind]=(iter->second)[ind];
-//       med_geometrie_element local_geo_elem=(med_geometrie_element)iter->first.first;
-//       med_geometrie_element distant_geo_elem=(med_geometrie_element)iter->first.second;
-//       int size_joint=size/2;
-//       //med_err error =
-//       MEDjointEcr(fid, mesh_name, joint_name, corresp, size_joint, MED_MAILLE,
-//                            local_geo_elem,MED_MAILLE, distant_geo_elem);
-//       delete[] corresp;
-//     }
-//     // MED v 2.3.1 returns an error code when
-//     // writing a joint that is already present in the file.
-//     // Also, it returns an error code if a joint
-//     // concerns 3D elements.
-//     // Until these two items are not
-//     // changed, the following line must be commented out
-
-//     //if (error==-1) throw MEDEXCEPTION("Error filling joint");
-
-
-//   }
-// }
-
-// void MESHCollectionDriver::jointSort(int* elems, int nbelems, bool is_first)
-// {
-//   //filling an ordered structure with the elem ids
-//   map <int,int> nodemap;
-//   if (is_first)
-//     for (int i=0; i<nbelems; i++) 
-//       nodemap.insert(make_pair(elems[2*i],elems[2*i+1]));
-
-//   else
-//     for (int i=0; i<nbelems; i++)
-//       nodemap.insert(make_pair(elems[2*i+1],elems[2*i]));
-
-//   int* ptr_elems=elems;      
-
-//   //filling the vector in appropriate order 
-//   for (map<int,int>::const_iterator iter=nodemap.begin(); iter!=nodemap.end(); iter++)
-//   {
-//     if (is_first)
-//     {
-//       *ptr_elems++=iter->first; 
-//       *ptr_elems++=iter->second;
-//     }
-//     else
-//     {
-//       *ptr_elems++=iter->second;
-//       *ptr_elems++=iter->first;
-//     }
-//   }    
-  
-
-//}
index 1735e3a4a6cb5ea110848a545dc395c86daaedeb..ef9d5bdef074013b6bc23b74cb59f811493ac0cf 100644 (file)
@@ -49,7 +49,7 @@ ParallelTopology::ParallelTopology():m_nb_domain(0),m_mesh_dimension(0)
 
 //!constructing topology according to mesh collection
 ParallelTopology::ParallelTopology(const vector<ParaMEDMEM::MEDCouplingUMesh*>& meshes, 
-                                                                                                                                        const vector<MEDPARTITIONER::CONNECTZONE*>& cz,
+                                   const vector<MEDPARTITIONER::CONNECTZONE*>& cz,
                                    vector<int*>& cellglobal,
                                    vector<int*>& nodeglobal,
                                    vector<int*>& faceglobal):m_nb_domain(meshes.size())/*,m_mesh_dimension(meshes[0]->getMeshDimension())*/
@@ -61,11 +61,11 @@ ParallelTopology::ParallelTopology(const vector<ParaMEDMEM::MEDCouplingUMesh*>&
 
   m_nb_cells.resize(m_nb_domain);
   m_nb_nodes.resize(m_nb_domain);
-       //  m_nb_faces.resize(m_nb_domain);
+  //  m_nb_faces.resize(m_nb_domain);
 
   m_loc_to_glob.resize(m_nb_domain);
   m_node_loc_to_glob.resize(m_nb_domain);
-       //  m_face_loc_to_glob.resize(m_nb_domain);
+  //  m_face_loc_to_glob.resize(m_nb_domain);
 
   //MED_EN::medEntityMesh constituent_entity;
 
index 8f47d930f89b0ec265cfa4333f7cdc0df56408bc..0032fc256110616ee77f69a172872919a0c0fa12 100644 (file)
@@ -79,7 +79,7 @@ libmedsplitter_la_CPPFLAGS= $(MPI_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) @C
        $(BOOST_CPPFLAGS) $(LIBXML_INCLUDES) \
        -I$(srcdir)/../MEDMEM -I$(srcdir)/../MEDWrapper/V2_1/Core \
        -I$(srcdir)/../INTERP_KERNEL/Bases -I$(srcdir)/../MEDCoupling \
-  -I$(srcdir)/../MEDLoader
+  -I$(srcdir)/../MEDLoader -I$(srcdir)/../INTERP_KERNEL
 
 libmedsplitter_la_LDFLAGS= 
 #libmedsplitter_la_LDFLAGS= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) \