]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
gnu indent and rules
authorcvw <cvw>
Tue, 6 Mar 2012 10:05:14 +0000 (10:05 +0000)
committercvw <cvw>
Tue, 6 Mar 2012 10:05:14 +0000 (10:05 +0000)
35 files changed:
src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.hxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.H [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.cxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.hxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.H [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.cxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.hxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_METISGraph.cxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_METISGraph.hxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_MetisGraph.hxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_SCOTCHGraph.cxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_SCOTCHGraph.hxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_Utils.cxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_Utils.hxx [new file with mode: 0644]
src/MEDPartitioner/MEDPARTITIONER_utils.cxx [deleted file]
src/MEDPartitioner/MEDPARTITIONER_utils.hxx [deleted file]
src/MEDPartitioner/Makefile.am
src/MEDPartitioner/Test/MEDPARTITIONERTest.cxx
src/MEDPartitioner/Test/MEDPARTITIONERTest.hxx
src/MEDPartitioner/Test/TestMEDPARTITIONER.cxx
src/MEDPartitioner/medpartitioner.cxx [deleted file]

diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx
deleted file mode 100644 (file)
index eaab9f5..0000000
+++ /dev/null
@@ -1,1971 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingNormalizedUnstructuredMesh.hxx"
-#include "MEDCouplingMemArray.hxx"
-#include "PointLocator3DIntersectorP0P0.hxx"
-#include "BBTree.txx"
-#include "MEDPARTITIONER_utils.hxx" 
-
-#include "MEDPARTITIONER_Graph.hxx"
-
-#include "MEDPARTITIONER_ParallelTopology.hxx"
-#include "MEDPARTITIONER_ParaDomainSelector.hxx"
-
-#include "MEDPARTITIONER_MESHCollection.hxx"
-#include "MEDPARTITIONER_MESHCollectionDriver.hxx"
-#include "MEDPARTITIONER_MESHCollectionMedXMLDriver.hxx"
-#include "MEDPARTITIONER_MESHCollectionMedAsciiDriver.hxx"
-#include "MEDPARTITIONER_JointFinder.hxx"
-#include "MEDPARTITIONER_UserGraph.hxx"
-#include "MEDLoader.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-
-#ifdef HAVE_MPI2
-#include <mpi.h>
-#endif
-
-#ifdef ENABLE_METIS
-#include "MEDPARTITIONER_METISGraph.hxx"
-#endif
-#ifdef ENABLE_SCOTCH
-#include "MEDPARTITIONER_SCOTCHGraph.hxx"
-#endif
-
-#include <vector>
-#include <string>
-#include <limits>
-
-#include <set>
-
-#include <iostream>
-#include <fstream>
-
-using namespace MEDPARTITIONER;
-
-#ifndef WNT
-using namespace __gnu_cxx;
-#else
-using namespace std;
-#endif
-
-
-MESHCollection::MESHCollection()
-  : _topology(0),
-    _owns_topology(false),
-    _driver(0),
-    _domain_selector( 0 ),
-    _i_non_empty_mesh(-1),
-    _driver_type(MEDPARTITIONER::MedXML),
-    _subdomain_boundary_creates(false),
-    _family_splitting(false),
-    _create_empty_groups(false),
-    _joint_finder(0)
-{
-}
-
-/*!constructor creating a new mesh collection (mesh series + topology)
- *from an old collection and a new topology
- * 
- * On output, the constructor has built the meshes corresponding to the new mesh collection.
- * The new topology has been updated so that face and node mappings are included.
- * The families have been cast to their projections in the new topology.
- * 
- * \param initial_collection collection from which the data (coordinates, connectivity) are taken
- * \param topology topology containing the cell mappings
- */
-
-MESHCollection::MESHCollection(
-      MESHCollection& initialCollection, 
-      Topology* topology, 
-      bool family_splitting, 
-      bool create_empty_groups) //cvwat04
-  : _name(initialCollection._name),
-    _topology(topology),
-    _owns_topology(false),
-    _driver(0),
-    _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),
-    _joint_finder(0)
-{
-  std::vector<std::vector<std::vector<int> > > new2oldIds(initialCollection.getTopology()->nbDomain());
-  if (MyGlobals::_verbose>10) std::cout<<"proc "<<MyGlobals::_rank<<" : castCellMeshes"<<std::endl;
-  castCellMeshes(initialCollection, new2oldIds);
-
-  //defining the name for the collection and the underlying meshes
-  setName(initialCollection.getName());
-
-  /////////////////
-  //treating faces
-  /////////////////
-
-  if (MyGlobals::_is0verbose) std::cout<<"treating faces"<<std::endl;
-  NodeMapping nodeMapping;
-  //nodeMapping contains the mapping between old nodes and new nodes
-  // (iolddomain,ioldnode)->(inewdomain,inewnode)
-  createNodeMapping(initialCollection, nodeMapping);
-  //cvw std::cout<<"castMeshes"<<std::endl;
-  std::vector<std::vector<std::vector<int> > > new2oldFaceIds;
-  castFaceMeshes(initialCollection, nodeMapping, new2oldFaceIds);
-
-  ////////////////////
-  //treating families
-  ////////////////////
-
-  if (MyGlobals::_is0verbose) 
-    if (isParallelMode()) std::cout<<"ParallelMode on "<<topology->nbDomain()<<" Domains"<<std::endl;
-    else std::cout<<"NOT ParallelMode on "<<topology->nbDomain()<<" Domains"<<std::endl;
-    
-  if (MyGlobals::_is0verbose>10) std::cout<<"treating cell and face families"<<std::endl;
-  
-  castIntField2(initialCollection.getMesh(),
-                this->getMesh(),
-                initialCollection.getCellFamilyIds(),
-                "cellFamily");
-  castIntField2(initialCollection.getFaceMesh(), 
-                this->getFaceMesh(),
-                initialCollection.getFaceFamilyIds(),
-                "faceFamily");
-
-  //////////////////
-  //treating groups
-  //////////////////
-  if (MyGlobals::_is0verbose) std::cout<<"treating groups"<<std::endl;
-  _familyInfo=initialCollection.getFamilyInfo();
-  _groupInfo=initialCollection.getGroupInfo();
-  
-  //////////////////
-  //treating fields
-  //////////////////
-  if (MyGlobals::_is0verbose) std::cout<<"treating fields"<<std::endl;
-  //cvwat08
-  castAllFields(initialCollection,"cellFieldDouble");
-  //castAllFields(initialCollection,"faceFieldsIds");
-}
-
-/*!
-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
- */
-
-void MESHCollection::castCellMeshes(
-      MESHCollection& initialCollection,
-      std::vector<std::vector<std::vector<int> > >& new2oldIds)
-{
-  if (_topology==0) throw INTERP_KERNEL::Exception(LOCALIZED("Topology has not been defined on call to castCellMeshes"));
-  
-  int nbNewDomain=_topology->nbDomain();
-  int nbOldDomain=initialCollection.getTopology()->nbDomain();
-  
-  _mesh.resize(nbNewDomain);
-  int rank=MyGlobals::_rank;
-  //if (MyGlobals::_verbose>10) std::cout<<"proc "<<rank<<" : castCellMeshes splitting"<<std::endl;
-  //splitting the initial domains into smaller bits
-  std::vector<std::vector<ParaMEDMEM::MEDCouplingUMesh*> > splitMeshes;
-  splitMeshes.resize(nbNewDomain);
-  for (int inew=0; inew<nbNewDomain; inew++)
-  {
-    splitMeshes[inew].resize(nbOldDomain, (ParaMEDMEM::MEDCouplingUMesh*)0);
-    /*std::fill( &(splitMeshes[inew][0]), 
-               &(splitMeshes[inew][0])+splitMeshes[inew].size(), 
-               (ParaMEDMEM::MEDCouplingUMesh*)0 );*/
-  }
-  
-  for (int iold=0; iold<nbOldDomain; iold++)
-  {
-    if (!isParallelMode() || initialCollection._domain_selector->isMyDomain(iold))
-    {
-      int size=(initialCollection._mesh)[iold]->getNumberOfCells();
-      std::vector<int> globalids(size);
-      initialCollection.getTopology()->getCellList(iold, &globalids[0]);
-      std::vector<int> ilocalnew(size); //local
-      std::vector<int> ipnew(size);     //idomain old
-      //cvw work locally
-      _topology->convertGlobalCellList(&globalids[0],size,&ilocalnew[0],&ipnew[0]);
-      
-      new2oldIds[iold].resize(nbNewDomain);
-      for (int i=0; i<ilocalnew.size(); i++)
-      {
-        new2oldIds[iold][ipnew[i]].push_back(i);
-      }
-      for (int inew=0; inew<nbNewDomain; inew++)
-      {
-        splitMeshes[inew][iold]=(ParaMEDMEM::MEDCouplingUMesh*)
-            (initialCollection.getMesh())[iold]->buildPartOfMySelf(
-                &new2oldIds[iold][inew][0],
-                &new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),
-                true);
-        if (MyGlobals::_verbose>400)
-          std::cout<<"proc "<<rank<<" : a splitMesh iold inew NbCells "<<iold<<" "<<inew<<" "
-                   <<splitMeshes[inew][iold]->getNumberOfCells()<<std::endl;
-      }
-    }
-  }
-
-  if (isParallelMode())
-  {
-    //if (MyGlobals::_verbose>300) std::cout<<"proc "<<rank<<" : castCellMeshes send/receive"<<std::endl;
-    for (int iold=0; iold<nbOldDomain; iold++)
-      for(int inew=0; inew<nbNewDomain; inew++)
-      {
-        if (initialCollection._domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)) continue;
-
-        if(initialCollection._domain_selector->isMyDomain(iold))
-          _domain_selector->sendMesh(*(splitMeshes[inew][iold]),_domain_selector->getProcessorID(inew));
-
-        if (_domain_selector->isMyDomain(inew))
-          _domain_selector->recvMesh(splitMeshes[inew][iold],_domain_selector->getProcessorID(iold));
-
-      }
-  }
-  
-  //fusing the split meshes
-  if (MyGlobals::_verbose>200) std::cout<<"proc "<<rank<<" : castCellMeshes fusing"<<std::endl;
-  for (int inew=0; inew<nbNewDomain ;inew++)
-  {
-    std::vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
-    
-    for (int i=0; i< splitMeshes[inew].size();i++)
-      if (splitMeshes[inew][i]!=0) 
-        if (splitMeshes[inew][i]->getNumberOfCells()>0)
-          meshes.push_back(splitMeshes[inew][i]);
-
-    if (!isParallelMode()||_domain_selector->isMyDomain(inew))
-    {
-      if (meshes.size()==0) 
-      {
-        _mesh[inew]=createEmptyMEDCouplingUMesh();
-        //throw INTERP_KERNEL::Exception(LOCALIZED("castCellMeshes fusing : no meshes"));
-        cout<<"WARNING : castCellMeshes fusing : no meshes try another number of processors"<<endl;
-      }
-      else
-      {
-        _mesh[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(meshes);
-        bool areNodesMerged;
-        int nbNodesMerged;
-        ParaMEDMEM::DataArrayInt* array=_mesh[inew]->mergeNodes(1e-12,areNodesMerged,nbNodesMerged);
-        array->decrRef(); // array is not used in this case
-        _mesh[inew]->zipCoords();
-      }
-    }
-    for (int i=0; i< splitMeshes[inew].size(); i++)
-      if (splitMeshes[inew][i]!=0) splitMeshes[inew][i]->decrRef();
-  }  
-  if (MyGlobals::_verbose>300) std::cout<<"proc "<<rank<<" : castCellMeshes end fusing"<<std::endl;
-}
-
-/*!
-  \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, NodeMapping& nodeMapping)
-{
-  using std::vector;
-  using std::make_pair;
-  //  NodeMapping reverseNodeMapping;
-  for (int iold=0; iold<initialCollection.getTopology()->nbDomain();iold++)
-    {
-
-      double* bbox;
-      BBTree<3>* tree; 
-      if (!isParallelMode() || (_domain_selector->isMyDomain(iold)))
-        {
-          //      std::map<pair<double,pair<double, double> >, int > nodeClassifier;
-          int nvertices=initialCollection.getMesh(iold)->getNumberOfNodes();
-          bbox=new double[nvertices*6];
-          ParaMEDMEM::DataArrayDouble* coords = initialCollection.getMesh(iold)->getCoords();
-          double* coordsPtr=coords->getPointer();
-
-          for (int i=0; i<nvertices*3;i++)
-            {
-              bbox[i*2]=coordsPtr[i]-1e-6;
-              bbox[i*2+1]=coordsPtr[i]+1e-6;
-            }
-          tree=new BBTree<3>(bbox,0,0,nvertices,1e-9);
-        }
-
-      for (int inew=0; inew<_topology->nbDomain(); inew++) //cvwat12
-        {
-          //sending meshes for parallel computation
-          if (isParallelMode() && _domain_selector->isMyDomain(inew) && !_domain_selector->isMyDomain(iold))  
-              _domain_selector->sendMesh(*(getMesh(inew)), _domain_selector->getProcessorID(iold));
-          else if (isParallelMode() && !_domain_selector->isMyDomain(inew)&& _domain_selector->isMyDomain(iold))
-            {
-              ParaMEDMEM::MEDCouplingUMesh* mesh;
-              _domain_selector->recvMesh(mesh, _domain_selector->getProcessorID(inew));
-              ParaMEDMEM::DataArrayDouble* coords = mesh->getCoords();
-              for (int inode=0; inode<mesh->getNumberOfNodes();inode++)
-                {
-                  double* coordsPtr=coords->getPointer()+inode*3;
-                  vector<int> elems;
-                  tree->getElementsAroundPoint(coordsPtr,elems);
-                  if (elems.size()==0) continue;
-                  nodeMapping.insert(make_pair(make_pair(iold,elems[0]),make_pair(inew,inode)));
-                }
-              mesh->decrRef();
-            }
-          else if (!isParallelMode() || (_domain_selector->isMyDomain(inew) && _domain_selector->isMyDomain(iold)))
-            {
-              ParaMEDMEM::DataArrayDouble* coords = getMesh(inew)->getCoords();
-              for (int inode=0; inode<_mesh[inew]->getNumberOfNodes();inode++)
-                {
-                  double* coordsPtr=coords->getPointer()+inode*3;
-                  vector<int> elems;
-                  tree->getElementsAroundPoint(coordsPtr,elems);
-                  if (elems.size()==0) continue;
-                  nodeMapping.insert(make_pair(make_pair(iold,elems[0]),make_pair(inew,inode)));
-                }
-            }
-        }
-      if (!isParallelMode() || (_domain_selector->isMyDomain(iold)))
-        {
-          delete tree;
-          delete[] bbox;
-        }
-    } 
-
-}
-
-//getNodeIds(meshCell, meshFace, nodeIds)
-//inodeCell=nodeIds[inodeFace]
-//(put the biggest mesh in One)
-//if no corresponding node then inodeCell==-1
-void getNodeIds(ParaMEDMEM::MEDCouplingUMesh& meshOne, ParaMEDMEM::MEDCouplingUMesh& meshTwo, vector<int>& nodeIds)
-{
-  using std::vector;
-  if (!&meshOne || !&meshTwo) return;  //empty or not existing
-  double* bbox;
-  BBTree<3>* tree;
-  int nv1=meshOne.getNumberOfNodes();
-  bbox=new double[nv1*6];
-  ParaMEDMEM::DataArrayDouble* coords=meshOne.getCoords();
-  double* coordsPtr=coords->getPointer();
-  for (int i=0; i<nv1*3; i++)
-  {
-    bbox[i*2]=coordsPtr[i]-1e-6;
-    bbox[i*2+1]=coordsPtr[i]+1e-6;
-  }
-  tree=new BBTree<3>(bbox,0,0,nv1,1e-9);
-  
-  int nv2=meshTwo.getNumberOfNodes();
-  nodeIds.resize(nv2,-1);
-  coords=meshTwo.getCoords();
-  for (int inode=0; inode<nv2; inode++)
-  {
-    double* coordsPtr=coords->getPointer()+inode*3;
-    vector<int> elems;
-    tree->getElementsAroundPoint(coordsPtr,elems);
-    if (elems.size()==0) continue;
-    nodeIds[inode]=elems[0];
-  }
-  delete tree;
-  delete[] bbox;
-}
-
-/*!
-  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::castFaceMeshes(MESHCollection& initialCollection,
-                    const std::multimap<std::pair<int,int>, std::pair<int,int> >& nodeMapping,
-                    std::vector<std::vector<std::vector<int> > >& new2oldIds)
-{
-
-  //splitMeshes structure will contain the partition of 
-  //the old faces on the new ones
-  //splitMeshes[4][2] contains the faces from old domain 2
-  //that have to be added to domain 4
-  
-  using std::vector;
-  using std::map;
-  using std::multimap;
-  using std::pair;
-  using std::make_pair;
-  
-  vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom=initialCollection.getFaceMesh();
-  vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo=this->getFaceMesh();
-  
-  vector< vector<ParaMEDMEM::MEDCouplingUMesh*> > splitMeshes;
-  int newSize=_topology->nbDomain();
-  int fromSize=meshesCastFrom.size();
-  
-  splitMeshes.resize(newSize);
-  for (int inew=0;inew<newSize;inew++) splitMeshes[inew].resize(fromSize);
-  new2oldIds.resize(fromSize);
-  for (int iold=0;iold<fromSize;iold++) new2oldIds[iold].resize(newSize);
-  
-  //init null pointer for empty meshes
-  for (int inew=0;inew<newSize;inew++)
-  {
-    for (int iold=0;iold<fromSize;iold++)
-    {
-       splitMeshes[inew][iold]=0; //null for empty meshes
-       new2oldIds[iold][inew].clear();
-    }
-  }
-
-  //loop over the old domains to analyse the faces and decide 
-  //on which new domain they belong
-  
-  for (int iold=0; iold<fromSize;iold++)
-  {
-    if (isParallelMode() && !_domain_selector->isMyDomain(iold)) continue;
-    if (meshesCastFrom[iold] != 0)
-    {
-      for (int ielem=0; ielem<meshesCastFrom[iold]->getNumberOfCells(); ielem++)
-      {
-          vector<int> nodes;
-          meshesCastFrom[iold]->getNodeIdsOfCell(ielem,nodes);
-          
-          map <int,int> faces;
-
-          //analysis of element ielem
-          //counters are set for the element
-          //for each source node, the mapping is interrogated and the domain counters 
-          //are incremented for each target node
-          //the face is considered as going to target domains if the counter of the domain 
-          //is equal to the number of nodes
-          for (int inode=0; inode<nodes.size(); inode++)
-          {
-              typedef multimap<pair<int,int>,pair<int,int> >::const_iterator MI;
-              int mynode=nodes[inode];
-
-              pair <MI,MI> myRange = nodeMapping.equal_range(make_pair(iold,mynode));
-              for (MI iter=myRange.first; iter!=myRange.second; iter++)
-              {
-                  int inew=iter->second.first;
-                  if (faces.find(inew)==faces.end())
-                    faces[inew]=1;
-                  else
-                    faces[inew]++;
-              }
-          }
-          
-          for (map<int,int>::iterator iter=faces.begin(); iter!=faces.end(); iter++)
-          {
-              if (iter->second==nodes.size())
-                //cvw eligible but may be have to be face of a cell of this->getMesh()[inew]?
-                //it is not sure here...
-                //done before writeMedfile on option?... see filterFaceOnCell()
-                new2oldIds[iold][iter->first].push_back(ielem);
-          }
-      }
-      
-      //creating the splitMeshes from the face ids
-      for (int inew=0;inew<_topology->nbDomain();inew++)
-      {
-          if (meshesCastFrom[iold]->getNumberOfCells() > 0) //cvw
-          {
-            splitMeshes[inew][iold]=
-              (ParaMEDMEM::MEDCouplingUMesh*) 
-              ( meshesCastFrom[iold]->buildPartOfMySelf(
-                  &new2oldIds[iold][inew][0],
-                  &new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),
-                  true) 
-              );
-            splitMeshes[inew][iold]->zipCoords();
-          }
-          else
-          {
-            //std::cout<<"one empty mesh from "<<iold<<std::endl; //cvw
-            splitMeshes[inew][iold]=createEmptyMEDCouplingUMesh();
-          }
-      }
-    }
-    else
-    {
-      std::cout<<"proc "<<MyGlobals::_rank<<" : castFaceMeshes empty mesh from iodDomain "<<iold<<std::endl;
-    }
-  }
-  
-  // send/receive stuff
-  if (isParallelMode())
-  {
-  ParaMEDMEM::MEDCouplingUMesh *empty=createEmptyMEDCouplingUMesh();
-  for (int iold=0; iold<fromSize; iold++)
-    for (int inew=0; inew<newSize; inew++)
-      {
-        /*std::cout<<"iold inew "<<iold<<" "<<inew<<" "<<
-                   _domain_selector->isMyDomain(iold)<<" "<<
-                   _domain_selector->isMyDomain(inew)<<std::endl;*/
-        if (_domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew))
-          if (splitMeshes[inew][iold] != 0) {
-           //cvw std::cout<<"send NOT empty mesh "<<splitMeshes[inew][iold]->getName()<<" "<<inew<<"<-"<<iold<<std::endl;
-           _domain_selector->sendMesh(*(splitMeshes[inew][iold]), _domain_selector->getProcessorID(inew));
-          }
-          else {
-           //std::cout<<"send empty mesh "<<inew<<"<-"<<iold<<std::endl;
-           _domain_selector->sendMesh(*(empty), _domain_selector->getProcessorID(inew));
-          }
-        if (!_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew))
-          _domain_selector->recvMesh(splitMeshes[inew][iold], _domain_selector->getProcessorID(iold));
-      }
-  empty->decrRef();
-  }
-  
-  //recollecting the bits of splitMeshes to fuse them into one
-  if (MyGlobals::_verbose>300) std::cout<<"proc "<<MyGlobals::_rank<<" : fuse splitMeshes"<<std::endl;
-  meshesCastTo.resize(newSize);
-  for (int inew=0; inew < newSize; inew++)
-    {
-      vector<const ParaMEDMEM::MEDCouplingUMesh*> myMeshes;
-      for (int iold=0; iold<fromSize; iold++)
-        {
-          ParaMEDMEM::MEDCouplingUMesh *umesh=splitMeshes[inew][iold];
-          if (umesh!=0)
-           if (umesh->getNumberOfCells()>0) {
-             myMeshes.push_back(umesh);
-           }
-           //else {
-           //  std::cout<<"one empty mesh "<<inew<<" "<<iold<<std::endl;
-           //}
-        }
-      
-      if (myMeshes.size()>0)
-      {
-        meshesCastTo[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(myMeshes);
-      }
-      else
-      {
-        //std::cout<<"one empty meshes to merge "<<inew<<std::endl;
-        //ParaMEDMEM::MEDCouplingUMesh *empty=ParaMEDMEM::MEDCouplingUMesh::New(); //empty one
-        //empty->setName("emptyMesh");
-        //empty->setMeshDimension(3);
-        //empty->allocateCells(0);
-        ParaMEDMEM::MEDCouplingUMesh *empty=createEmptyMEDCouplingUMesh();
-        meshesCastTo[inew]=empty;
-      }
-      //      meshesCastTo[inew]->zipCoords();
-      for (int iold=0; iold<fromSize; iold++)
-        if (splitMeshes[inew][iold]!=0) splitMeshes[inew][iold]->decrRef();
-    }
-  //if (MyGlobals::_verbose>1) std::cout<<"proc "<<MyGlobals::_rank<<" : end fuse"<<std::endl;
-}
-
-void MESHCollection::remapIntField(
-      const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
-      const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
-      const int* fromArray,
-      int* toArray)
-{
-  using std::vector;
-  if (sourceMesh.getNumberOfCells()<=0) return; //empty mesh could exist
-  //cvw std::cout<<"remapIntField "<<sourceMesh.getNumberOfCells()<<" "<<targetMesh.getNumberOfCells()<<std::endl;
-  ParaMEDMEM::DataArrayDouble* sourceCoords=sourceMesh.getBarycenterAndOwner();
-  ParaMEDMEM::DataArrayDouble* targetCoords=targetMesh.getBarycenterAndOwner();
-   
-  ParaMEDMEM::MEDCouplingUMesh* tmpMesh=ParaMEDMEM::MEDCouplingUMesh::New();
-  tmpMesh->setCoords(sourceCoords);
-  vector<int> c;
-  vector<int> cI;
-  tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetMesh.getNumberOfCells(),1e-10,c,cI);
-  if (cI.size()!= targetMesh.getNumberOfCells()+1) 
-    throw INTERP_KERNEL::Exception(LOCALIZED("Error in source/target projection"));
-  for (int itargetnode=0; itargetnode<targetMesh.getNumberOfCells();itargetnode++)    
-    {
-      if (cI[itargetnode]==cI[itargetnode+1]) continue;
-      int isourcenode=c[cI[itargetnode]];
-      toArray[itargetnode]=fromArray[isourcenode];
-    } 
-  sourceCoords->decrRef();
-  targetCoords->decrRef();
-  tmpMesh->decrRef();
-}
-
-void MESHCollection::castIntField2(  //cvwat08
-      std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,
-      std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo,
-      std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom,
-      std::string nameArrayTo)
-{
-  using std::vector;
-  
-  int ioldMax=meshesCastFrom.size();
-  int inewMax=meshesCastTo.size();
-  // send-recv operations
-  for (int inew=0; inew<inewMax; inew++)
-  {
-    for (int iold=0; iold<ioldMax; iold++)
-    {
-      //sending arrays for distant domains
-      if (isParallelMode() && _domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew))
-      {
-        //send mesh
-        _domain_selector->sendMesh(*meshesCastFrom[iold],_domain_selector->getProcessorID(inew));
-        //send vector
-        int size=arrayFrom[iold]->getNumberOfTuples(); //cvw may be -1!
-        vector<int>sendIds;
-        if (MyGlobals::_verbose>400) std::cout<<"proc "<<_domain_selector->rank()<<" : castIntField sendIntVec size "<<size<<std::endl;
-        if (size>0) //no empty
-        {
-          sendIds.resize(size);
-          std::copy(arrayFrom[iold]->getPointer(),arrayFrom[iold]->getPointer()+size,&sendIds[0]);
-        }
-        else //empty
-        {
-          size=0;
-          sendIds.resize(size);
-        }
-        //std::cout<<"proc "<<_domain_selector->rank()<<" : castIntField sendIntVec "<<size<<std::endl;
-        sendIntVec(sendIds, _domain_selector->getProcessorID(inew));
-      }
-      //receiving arrays from distant domains
-      if (isParallelMode() && !_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew))
-      {
-        //receive mesh
-        vector<int> recvIds;
-        ParaMEDMEM::MEDCouplingUMesh* recvMesh;
-        _domain_selector->recvMesh(recvMesh,_domain_selector->getProcessorID(iold));
-        //receive vector
-        if (MyGlobals::_verbose>400) std::cout<<"proc "<<_domain_selector->rank()<<" : castIntField recIntVec "<<std::endl;
-        recvIntVec(recvIds, _domain_selector->getProcessorID(iold));
-        remapIntField2(inew,iold,*recvMesh,*meshesCastTo[inew],&recvIds[0],nameArrayTo);
-        recvMesh->decrRef(); //cww is it correct?
-      }
-    }
-  }
-  
-  //local contributions and aggregation
-  for (int inew=0; inew<inewMax; inew++)    
-  {
-    for (int iold=0; iold<ioldMax; iold++)
-      if (!isParallelMode() || ( _domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)))
-      {
-        remapIntField2(inew,iold,*meshesCastFrom[iold],*meshesCastTo[inew],arrayFrom[iold]->getConstPointer(),nameArrayTo);
-      }
-  }
-}
-
-void MESHCollection::remapIntField2(int inew,int iold,
-      const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
-      const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
-      const int* fromArray,
-      string nameArrayTo)
-//here we store ccI for next use in future call of castAllFields and remapDoubleField2
-{
-  using std::vector;
-  //cout<<"remapIntField2 "<<cle2ToStr(nameArrayTo,inew,iold)<<endl;
-  if (sourceMesh.getNumberOfCells()<=0) return; //empty mesh could exist
-  //cvw std::cout<<"remapIntField "<<sourceMesh.getNumberOfCells()<<" "<<targetMesh.getNumberOfCells()<<std::endl;
-  ParaMEDMEM::DataArrayDouble* sourceCoords=sourceMesh.getBarycenterAndOwner();
-  ParaMEDMEM::DataArrayDouble* targetCoords=targetMesh.getBarycenterAndOwner();
-   
-  ParaMEDMEM::MEDCouplingUMesh* tmpMesh=ParaMEDMEM::MEDCouplingUMesh::New();
-  tmpMesh->setCoords(sourceCoords);
-  vector<int> c;
-  vector<int> cI;
-  vector<int> ccI; //memorize intersection target<-source(inew,iold)
-  string str,cle;
-  str=nameArrayTo+"_toArray";
-  cle=cle1ToStr(str,inew);
-  int* toArray;
-  int targetSize=targetMesh.getNumberOfCells();
-  //first time iold : create and initiate 
-  if (_mapDataArrayInt.find(cle)==_mapDataArrayInt.end())
-  {
-    if (MyGlobals::_is0verbose>100) cout<<"create "<<cle<<" size "<<targetSize<<endl;
-    ParaMEDMEM::DataArrayInt* p=DataArrayInt::New();
-    p->alloc(targetSize,1);
-    p->fillWithZero();
-    toArray=p->getPointer();
-    _mapDataArrayInt[cle]=p;
-  }
-  else //other times iold: refind and complete
-  {
-    toArray=_mapDataArrayInt.find(cle)->second->getPointer();
-  }
-  tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetSize,1e-10,c,cI);
-  if (cI.size()!=targetSize+1) 
-    throw INTERP_KERNEL::Exception(LOCALIZED("Error in source/target projection"));
-  for (int itargetnode=0; itargetnode<targetSize; itargetnode++)    
-  {
-    if (cI[itargetnode]==cI[itargetnode+1]) continue;
-    int isourcenode=c[cI[itargetnode]];
-    toArray[itargetnode]=fromArray[isourcenode];
-    //memorize intersection 
-    ccI.push_back(itargetnode); //next we'll do toArray[ccI[i]]=fromArray[ccI[i+1]]
-    ccI.push_back(isourcenode);
-  }
-  //ccI.push_back(sourceMesh.getNumberOfCells()); //additionnal information at end??
-  
-  //memories intersection for future same job on fields (if no existing cle=no intersection)
-  str=cle2ToStr(nameArrayTo+"_ccI",inew,iold);
-  if (MyGlobals::_verbose>700) cout<<"proc "<<MyGlobals::_rank<<" : map memorize '"<<str<<"'\n";
-  _mapDataArrayInt[str]=createDataArrayIntFromVector(ccI, 2);
-  sourceCoords->decrRef();
-  targetCoords->decrRef();
-  tmpMesh->decrRef();
-}
-
-void MESHCollection::castAllFields(MESHCollection& initialCollection, string nameArrayTo) //cvwat08
-{
-  using std::vector;
-  if (nameArrayTo!="cellFieldDouble") 
-    throw INTERP_KERNEL::Exception(LOCALIZED("Error castAllField only on cellFieldDouble"));
-
-  string nameTo="typeData=6"; //resume the type of field casted 
-  // send-recv operations
-  int ioldMax=initialCollection.getMesh().size();
-  int inewMax=this->getMesh().size();
-  int iFieldMax=initialCollection.getFieldDescriptions().size();
-  if (MyGlobals::_verbose>10) cout<<"castAllFields with:\n"<<reprVectorOfString(initialCollection.getFieldDescriptions())<<endl;
-  //std::vector<std::string> initialCollection.getFieldDescriptions()
-  //getFieldDescriptions() is a string description of field coherent and tested and set BEFORE.
-  //see collection.prepareFieldDescriptions()
-  for (int ifield=0; ifield<iFieldMax; ifield++)
-  {
-    string descriptionField=initialCollection.getFieldDescriptions()[ifield];
-    if (descriptionField.find(nameTo)==string::npos) continue; //only nameTo accepted in Fields name description
-    for (int inew=0; inew<inewMax; inew++)
-    {
-      for (int iold=0; iold<ioldMax; iold++)
-      {
-        //sending arrays for distant domains
-        if (isParallelMode() && _domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew))
-        {
-          int target=_domain_selector->getProcessorID(inew);
-          ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); //cvwat14
-          //getField look for and read it if not done, and assume decrRef() in ~MESHCollection;
-          if (MyGlobals::_verbose>10) 
-            std::cout<<"proc "<<_domain_selector->rank()<<" : castAllFields sendDouble"<<std::endl;
-          sendDataArrayDouble(field, target);
-        }
-        //receiving arrays from distant domains
-        if (isParallelMode() && !_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew))
-        {
-          int source=_domain_selector->getProcessorID(iold);
-          //receive vector
-          if (MyGlobals::_verbose>10) 
-            std::cout<<"proc "<<_domain_selector->rank()<<" : castAllFields recvDouble"<<std::endl;
-          ParaMEDMEM::DataArrayDouble* field=recvDataArrayDouble(source);
-          remapDoubleField3(inew,iold,field,nameArrayTo,descriptionField);
-        }
-      }
-    }
-  
-    //local contributions and aggregation
-    for (int inew=0; inew<inewMax; inew++)
-    {
-    for (int iold=0; iold<ioldMax; iold++)
-      if (!isParallelMode() || ( _domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)))
-      {
-        ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); //cvwat14
-        remapDoubleField3(inew,iold,field,nameArrayTo,descriptionField);
-      }
-    }
-  }
-}
-
-void MESHCollection::remapDoubleField3(int inew, int iold, 
-                                       ParaMEDMEM::DataArrayDouble* fromArray,
-                                       string nameArrayTo,
-                                       string descriptionField)
-//here we use 'cellFamily_ccI inew iold' set in remapIntField2
-{
-  using std::vector;
-  if (nameArrayTo!="cellFieldDouble") 
-    throw INTERP_KERNEL::Exception(LOCALIZED("Error remapDoubleField3 only on cellFieldDouble"));
-  string cle=cle2ToStr("cellFamily_ccI",inew,iold);
-  
-  map<string,ParaMEDMEM::DataArrayInt*>::iterator it1;
-  it1=_mapDataArrayInt.find(cle);
-  if (it1==_mapDataArrayInt.end())
-  {
-    cerr<<"proc "<<MyGlobals::_rank<<" : remapDoubleField3 cle '"<<cle<<"' not found"<<endl;
-    cerr<<" trying remap of field double on cells : "<<descriptionField<<endl;
-    return;
-  }
-  //create ccI in remapIntField2
-  ParaMEDMEM::DataArrayInt* ccI=it1->second;
-  if (MyGlobals::_verbose>300) cout<<"proc "<<MyGlobals::_rank<<" : remapDoubleField3 "<<cle<<" size "<<ccI->getNbOfElems()<<endl;
-  //cout<<descriptionField<<endl;
-  
-  int nbcell=this->getMesh()[inew]->getNumberOfCells(); //number of cell of mesh
-  int nbcomp=fromArray->getNumberOfComponents();
-  int nbPtGauss=strToInt(extractFromDescription(descriptionField, "nbPtGauss="));
-  
-  //int nbk=fromArray->getNumberOfTuples();
-  
-  //cle=reprGenericDescription(descriptionField)+" "+intToStr(inew);
-  string tag="inewFieldDouble="+intToStr(inew);
-  cle=descriptionField+serializeFromString(tag);
-  //cout<<"descriptionField in remapDoubleField3 : "<<descriptionField<<endl;
-  int fromArrayNbOfElem=fromArray->getNbOfElems();
-  int fromArrayNbOfComp=fromArray->getNumberOfComponents();
-  int fromArrayNbOfCell=fromArrayNbOfElem/fromArrayNbOfComp/nbPtGauss;
-  
-  if (MyGlobals::_verbose>1000)
-  {
-    cout<<"proc "<<MyGlobals::_rank<<" nbcell "<<nbcell<<" nbcomp "<<nbcomp<<" nbPtGauss "<<nbPtGauss<<
-          " fromArray nbOfElems "<<fromArrayNbOfElem<<
-          " nbTuples "<<fromArray->getNumberOfTuples()<<
-          " nbcells "<<fromArrayNbOfCell<<
-          " nbComponents "<<fromArray->getNumberOfComponents()<<endl;
-  }
-
-  ParaMEDMEM::DataArrayDouble* field=0;
-  map<string,ParaMEDMEM::DataArrayDouble*>::iterator it2;
-  it2=_mapDataArrayDouble.find(cle);
-  if (it2==_mapDataArrayDouble.end())
-  {
-    if (MyGlobals::_verbose>300) cout<<"proc "<<MyGlobals::_rank<<" : remapDoubleField3 cle '"<<cle<<"' not found and create it"<<endl;
-    field=DataArrayDouble::New();
-    _mapDataArrayDouble[cle]=field;
-    field->alloc(nbcell*nbPtGauss,nbcomp);
-    field->fillWithZero();
-  }
-  else
-  {
-    field=it2->second;
-    if (field->getNumberOfTuples()!=nbcell*nbPtGauss || field->getNumberOfComponents()!=nbcomp)
-    {
-      cerr<<"proc "<<MyGlobals::_rank<<" : remapDoubleField3 pb of size "<<
-            " trying remap of field double on cells : \n"<<descriptionField<<endl;
-      return;
-    }
-  }
-  //cout<<"proc "<<MyGlobals::_rank<<" : remapDoubleField3 "<<cle<<" size "<<ccI->getNbOfElems()<<endl;
-  
-  if (nbPtGauss==1)
-  {
-    field->setPartOfValuesAdv(fromArray,ccI);
-  }
-  else
-  {
-    //replaced by setPartOfValuesAdv if nbPtGauss==1
-    int iMax=ccI->getNbOfElems();
-    int* pccI=ccI->getPointer();
-    double* pField=field->getPointer();
-    double* pFrom=fromArray->getPointer();
-    int itarget, isource, delta=nbPtGauss*nbcomp;
-    for (int i=0; i<iMax; i=i+2)  //cell
-    {
-      itarget=pccI[i];
-      isource=pccI[i+1];
-      if ((itarget<0) || (itarget>=nbcell) || (isource<0) || (isource>=fromArrayNbOfCell))
-            throw INTERP_KERNEL::Exception(LOCALIZED("Error field override"));
-      int ita=itarget*delta;
-      int iso=isource*delta;
-      for (int k=0; k<delta; k++) pField[ita+k]=pFrom[iso+k]; //components and gausspoints
-    }
-  }
-}
-
-/*
-void MESHCollection::remapFields(
-      const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
-      const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
-      mapOfFields* fromFields,
-      mapOfFields* toFields)
-      //const int* fromArray,int* toArray)
-{
-  using std::vector;
-  if (sourceMesh.getNumberOfCells()<=0) return; //empty mesh could exist
-  //cvw std::cout<<"remapIntField "<<sourceMesh.getNumberOfCells()<<" "<<targetMesh.getNumberOfCells()<<std::endl;
-  ParaMEDMEM::DataArrayDouble* sourceCoords=sourceMesh.getBarycenterAndOwner();
-  ParaMEDMEM::DataArrayDouble* targetCoords=targetMesh.getBarycenterAndOwner();
-   
-  ParaMEDMEM::MEDCouplingUMesh* tmpMesh=ParaMEDMEM::MEDCouplingUMesh::New();
-  tmpMesh->setCoords(sourceCoords);
-  vector<int> c;
-  vector<int> cI;
-  tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetMesh.getNumberOfCells(),1e-10,c,cI);
-  if (cI.size()!= targetMesh.getNumberOfCells()+1) 
-    throw INTERP_KERNEL::Exception(LOCALIZED("Error in source/target projection"));
-
-  for (int itargetnode=0; itargetnode<targetMesh.getNumberOfCells();itargetnode++)    
-    {
-      if (cI[itargetnode]==cI[itargetnode+1]) continue;
-      int isourcenode=c[cI[itargetnode]];
-      toArray[itargetnode]=fromArray[isourcenode];
-    }
-  
-  sourceCoords->decrRef();
-  targetCoords->decrRef();
-  tmpMesh->decrRef();
-}
-*/
-
-/*! constructing the MESH collection from a distributed file
- *
- * \param filename name of the master file containing the list of all the MED files
- */
-MESHCollection::MESHCollection(const std::string& filename)
-  : _topology(0),
-    _owns_topology(true),
-    _driver(0),
-    _domain_selector( 0 ),
-    _i_non_empty_mesh(-1),
-    _driver_type(MEDPARTITIONER::Undefined),
-    _subdomain_boundary_creates(false),
-    _family_splitting(false),
-    _create_empty_groups(false),
-    _joint_finder(0)
-{
-  // char filenamechar[256];
-  // strcpy(filenamechar,filename.c_str());
-  try
-    {
-      _driver=new MESHCollectionMedXMLDriver(this);
-      _driver->read (filename.c_str());
-      _driver_type = MedXML;
-    }
-  catch(...) 
-    {  // Handle all exceptions
-      if ( _driver ) delete _driver; _driver=0;
-      try
-        {
-          _driver=new MESHCollectionMedAsciiDriver(this);
-          _driver->read (filename.c_str());
-          _driver_type=MedAscii;
-        }
-      catch(...)
-        {
-          if ( _driver ) delete _driver; _driver=0;
-          throw INTERP_KERNEL::Exception(LOCALIZED("file does not comply with any recognized format"));
-        }
-    }
-  for ( int idomain = 0; idomain < _mesh.size(); ++idomain )
-    if ( _mesh[idomain] && _mesh[idomain]->getNumberOfNodes() > 0 )
-      _i_non_empty_mesh = idomain;
-}
-
-/*! Constructing the MESH collection from selected domains of a distributed file
- * 
- * \param filename  - name of the master file containing the list of all the MED files
- * \param domainSelector - selector of domains to load
- */
-MESHCollection::MESHCollection(const std::string& filename, ParaDomainSelector& domainSelector) //cvwat01
-  : _topology(0),
-    _owns_topology(true),
-    _driver(0),
-    //cvw _domain_selector( domainSelector.nbProcs() > 1 ? & domainSelector : 0 ),
-    _domain_selector( &domainSelector ),
-    _i_non_empty_mesh(-1),
-    _driver_type(MEDPARTITIONER::Undefined),
-    _subdomain_boundary_creates(false),
-    _family_splitting(false),
-    _create_empty_groups(false),
-    _joint_finder(0)
-{
-  std::string myfile=filename;
-  std::size_t found=myfile.find(".xml");
-  if (found!=std::string::npos) //file .xml
-  {
-    try
-    {
-      _driver=new MESHCollectionMedXMLDriver(this); //cvwat02
-      _driver->read ( (char*)filename.c_str(), _domain_selector );
-      _driver_type = MedXML;
-    }
-    catch(...)
-    {  // Handle all exceptions
-      if ( _driver ) delete _driver; _driver=0;
-      throw INTERP_KERNEL::Exception(LOCALIZED("file .xml does not comply with any recognized format"));
-    }
-  }
-  else 
-  {
-    found=myfile.find(".med");
-    if (found!=std::string::npos) //file .med single
-    {
-      //make a temporary file .xml and retry MedXMLDriver
-      std::string xml="\
-<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n \
-<root>\n \
-  <version maj=\"2\" min=\"3\" ver=\"1\"/>\n \
-  <description what=\"\" when=\"\"/>\n \
-  <content>\n \
-    <mesh name=\"$meshName\"/>\n \
-  </content>\n \
-  <splitting>\n \
-    <subdomain number=\"1\"/>\n \
-    <global_numbering present=\"no\"/>\n \
-  </splitting>\n \
-  <files>\n \
-    <subfile id=\"1\">\n \
-      <name>$fileName</name>\n \
-      <machine>localhost</machine>\n \
-    </subfile>\n \
-  </files>\n \
-  <mapping>\n \
-    <mesh name=\"$meshName\">\n \
-      <chunk subdomain=\"1\">\n \
-        <name>$meshName</name>\n \
-      </chunk>\n \
-    </mesh>\n \
-  </mapping>\n \
-</root>\n";
-      std::vector<std::string> meshNames=MEDLoader::GetMeshNames(myfile.c_str());
-      xml.replace(xml.find("$fileName"),9,myfile);
-      xml.replace(xml.find("$meshName"),9,meshNames[0]);
-      xml.replace(xml.find("$meshName"),9,meshNames[0]);
-      xml.replace(xml.find("$meshName"),9,meshNames[0]);
-      //std::cout<<xml<<std::endl;
-      std::string nameFileXml=myfile;
-      nameFileXml.replace(nameFileXml.find(".med"),4,".xml");
-      nameFileXml="medpartitioner_"+nameFileXml;
-      if (_domain_selector->rank()==0) //only on to write it
-      {
-        std::ofstream f(nameFileXml.c_str());
-        f<<xml;
-        f.close();
-      }
-#ifdef HAVE_MPI2
-      MPI_Barrier(MPI_COMM_WORLD); //wait for creation of nameFileXml
-#endif
-      try
-      {
-        _driver=new MESHCollectionMedXMLDriver(this);
-        _driver->read ( (char*)nameFileXml.c_str(), _domain_selector );
-        _driver_type = MedXML;
-      }
-      catch(...)
-      {  // Handle all exceptions
-        if ( _driver ) delete _driver; _driver=0;
-        throw INTERP_KERNEL::Exception(LOCALIZED("file medpartitioner_xxx.xml does not comply with any recognized format"));
-      }
-    }
-    else //no extension
-    {
-      try
-        {
-          _driver=new MESHCollectionMedAsciiDriver(this);
-          _driver->read ( (char*)filename.c_str(), _domain_selector );
-          _driver_type=MedAscii;
-        }
-      catch(...)
-        {
-          if ( _driver ) delete _driver; _driver=0;
-          throw INTERP_KERNEL::Exception(LOCALIZED("file name with no extension does not comply with any recognized format"));
-        }
-    }
-  }
-  
-  /*done in MESHCollectionMedXMLDriver read
-  if ( isParallelMode() )
-    // to know nb of cells on each proc to compute global cell ids from locally global
-    _domain_selector->gatherNbOf( getMesh() );*/
-
-  // find non-empty domain mesh
-  for ( int idomain = 0; idomain < _mesh.size(); ++idomain )
-    if ( _mesh[idomain] && _mesh[idomain]->getNumberOfNodes() > 0 )
-      _i_non_empty_mesh = idomain;
-  
-  try
-  {
-    //check for all proc/file compatibility of _fieldDescriptions
-    //*MyGlobals::_fileNames=allgathervVectorOfString(*MyGlobals::_fileNames);
-    _fieldDescriptions=allgathervVectorOfString(MyGlobals::_fieldDescriptions); //cvwat07
-  }
-  catch(INTERP_KERNEL::Exception& e)
-  {
-    cerr<<"proc "<<MyGlobals::_rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
-    throw INTERP_KERNEL::Exception(LOCALIZED("Something wrong verifying coherency of files med ands fields"));
-  }
-  
-  try
-  {
-    //check for all proc/file compatibility of _familyInfo //cvwat05
-    vector<string> v2=allgathervVectorOfString(vectorizeFromMapOfStringInt(_familyInfo));
-    _familyInfo=devectorizeToMapOfStringInt(v2);
-  }
-  catch(INTERP_KERNEL::Exception& e)
-  {
-    cerr<<"proc "<<MyGlobals::_rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
-    throw INTERP_KERNEL::Exception(LOCALIZED("Something wrong merging all familyInfo"));
-  }
-
-  try
-  {
-   //check for all proc/file compatibility of _groupInfo
-    vector<string> v2=allgathervVectorOfString(
-                      vectorizeFromMapOfStringVectorOfString(_groupInfo));
-    _groupInfo=deleteDuplicatesInMapOfStringVectorOfString(
-               devectorizeToMapOfStringVectorOfString(v2));
-  }
-  catch(INTERP_KERNEL::Exception& e)
-  {
-    cerr<<"proc "<<MyGlobals::_rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
-    throw INTERP_KERNEL::Exception(LOCALIZED("Something wrong merging all groupInfo"));
-  }
-
-  
-  //std::vector< std::string > _meshes=MEDLoader::GetMeshNames(filename);
-  //std::vector< std::string > _fields=MEDLoader::GetAllFieldNamesOnMesh(filename,meshname[0]);
-  //cout<<"number of fields "<<_fields.size()<<endl;
-  
-}
-
-/*! constructing the MESH collection from a sequential MED-file
- * 
- * \param filename MED file
- * \param meshname name of the mesh that is to be read
- */
-MESHCollection::MESHCollection(const std::string& filename, const std::string& meshname)
-  : _name(meshname),
-    _topology(0),
-    _owns_topology(true),
-    _driver(0),
-    _domain_selector( 0 ),
-    _i_non_empty_mesh(-1),
-    _driver_type(MEDPARTITIONER::MedXML),
-    _subdomain_boundary_creates(false),
-    _family_splitting(false),
-    _create_empty_groups(false),
-    _joint_finder(0)
-{
-  //char filenamechar[256];
-  //char meshnamechar[256];
-  //strcpy(filenamechar,filename.c_str());
-  //strcpy(meshnamechar,meshname.c_str());
-  try // avoid memory leak in case of inexistent filename
-    {
-      retrieveDriver()->readSeq (filename.c_str(),meshname.c_str());
-    }
-  catch (...)
-    {
-      if ( _driver ) delete _driver; _driver=0;
-      throw INTERP_KERNEL::Exception(LOCALIZED("problem reading .med files"));
-    }
-  if ( _mesh[0] && _mesh[0]->getNumberOfNodes() > 0 )
-    _i_non_empty_mesh = 0;
-}
-
-MESHCollection::~MESHCollection()
-{
-  for (int i=0; i<_mesh.size();i++)
-    if (_mesh[i]!=0) _mesh[i]->decrRef(); 
-  
-  for (int i=0; i<_cellFamilyIds.size();i++)
-    if (_cellFamilyIds[i]!=0) _cellFamilyIds[i]->decrRef();
-  
-  for (int i=0; i<_faceMesh.size();i++)
-    if (_faceMesh[i]!=0) _faceMesh[i]->decrRef();
-  
-  for (int i=0; i<_faceFamilyIds.size();i++)
-    if (_faceFamilyIds[i]!=0) _faceFamilyIds[i]->decrRef();
-  
-  for (map<string, ParaMEDMEM::DataArrayInt*>::iterator it=_mapDataArrayInt.begin() ; it!=_mapDataArrayInt.end(); it++ )
-    if ((*it).second!=0) (*it).second->decrRef();
-  
-  for (map<string, ParaMEDMEM::DataArrayDouble*>::iterator it=_mapDataArrayDouble.begin() ; it!=_mapDataArrayDouble.end(); it++ )
-    if ((*it).second!=0) (*it).second->decrRef();
-  
-  if (_driver !=0) {delete _driver; _driver=0;}
-  if (_topology!=0 && _owns_topology) {delete _topology; _topology=0;}
-  
-  if (_joint_finder!=0) {delete _joint_finder; _joint_finder=0;}
-}
-
-/*! constructing the MESH collection from a file
- * 
- * The method creates as many MED-files as there are domains in the 
- * collection. It also creates a master file that lists all the MED files.
- * The MED files created in ths manner contain joints that describe the 
- * connectivity between subdomains.
- * 
- * \param filename name of the master file that will contain the list of the MED files
- * 
- */
-void MESHCollection::write(const std::string& filename)
-{
-  //building the connect zones necessary for writing joints
-  //   if (_topology->nbDomain()>1)
-  //     buildConnectZones();
-  //suppresses link with driver so that it can be changed for writing
-  if (_driver!=0) delete _driver;
-  _driver=0;
-
-  //char filenamechar[256];
-  //  strcpy(filenamechar,filename.c_str());
-  retrieveDriver()->write (filename.c_str(), _domain_selector);
-}
-
-/*! creates or gets the link to the collection driver
- */
-MESHCollectionDriver* MESHCollection::retrieveDriver()
-{
-  if (_driver==0)
-    {
-      switch(_driver_type)
-        {
-        case MedXML:
-          _driver=new MESHCollectionMedXMLDriver(this);
-          break;
-        case MedAscii:
-          _driver=new MESHCollectionMedAsciiDriver(this);
-          break;
-        default:
-          throw INTERP_KERNEL::Exception(LOCALIZED("Unrecognized driver"));
-        }
-    }
-  return _driver;
-}
-
-
-/*! gets an existing driver
- * 
- */
-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();
-}
-
-std::vector<ParaMEDMEM::MEDCouplingUMesh*>& MESHCollection::getMesh() {
-  return _mesh;
-}
-
-std::vector<ParaMEDMEM::MEDCouplingUMesh*>& MESHCollection::getFaceMesh() {
-  return _faceMesh;
-}
-
-ParaMEDMEM::MEDCouplingUMesh* MESHCollection::getMesh(int idomain) const {
-  return _mesh[idomain];
-}
-
-ParaMEDMEM::MEDCouplingUMesh* MESHCollection::getFaceMesh(int idomain) {
-  return _faceMesh[idomain];
-}
-
-std::vector<MEDPARTITIONER::CONNECTZONE*>& MESHCollection::getCZ() {
-  return _connect_zones;
-}
-
-Topology* MESHCollection::getTopology() const {
-  return _topology;
-}
-
-void MESHCollection::setTopology(Topology* topo) {
-  if (_topology!=0)
-    {
-      throw INTERP_KERNEL::Exception(LOCALIZED("topology is already set"));
-    }
-  else
-    _topology = topo;
-}
-
-/*! Method creating the cell graph
- * 
- * \param array returns the pointer to the structure that contains the graph 
- * \param edgeweight returns the pointer to the table that contains the edgeweights
- *        (only used if indivisible regions are required)
- */
-void MESHCollection::buildCellGraph(MEDPARTITIONER::MEDSKYLINEARRAY* & array, int *& edgeweights ) //cvwat09
-{
-  using std::multimap;
-  using std::vector;
-  using std::make_pair;
-  using std::pair;
-  
-  multimap< int, int > node2cell;
-  multimap< int, int > cell2cell;
-  multimap< int, int > cell2node;
-
-  vector<vector<multimap<int,int> > > commonDistantNodes;
-  int nbdomain=_topology->nbDomain();
-  if (isParallelMode())
-  {
-    _joint_finder=new JointFinder(*this);
-    _joint_finder->findCommonDistantNodes();
-    commonDistantNodes=_joint_finder->getDistantNodeCell();
-  }
-
-  if (MyGlobals::_verbose>500) _joint_finder->print();
-  
-  //looking for reverse nodal connectivity i global numbering
-  for (int idomain=0; idomain<nbdomain; idomain++)
-  {
-    if (isParallelMode() && !_domain_selector->isMyDomain(idomain)) continue;
-    
-    /*obsolete
-    int offsetCell=0, offsetNode=0;
-    if (isParallelMode())
-    {
-      offsetCell=_domain_selector->getDomainCellShift(idomain);
-      offsetNode=_domain_selector->getDomainNodeShift(idomain);
-    }*/
-    
-    ParaMEDMEM::DataArrayInt* index=ParaMEDMEM::DataArrayInt::New();
-    ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New();
-    int nbNodes=_mesh[idomain]->getNumberOfNodes();
-    //cout<<"proc "<<MyGlobals::_rank<<" idomain "<<idomain<<" nbNodes "<<nbNodes<<" offsetCell "<<offsetCell<<" offsetNode "<<offsetNode<<endl;
-    _mesh[idomain]->getReverseNodalConnectivity(revConn,index);
-    //problem saturation over 1 000 000 nodes for 1 proc
-    if (MyGlobals::_verbose>100) cout<<"proc "<<MyGlobals::_rank<<" getReverseNodalConnectivity done on "<<nbNodes<<" nodes"<<endl;
-    int* index_ptr=index->getPointer();
-    int* revConnPtr=revConn->getPointer();
-    //if (MyGlobals::_verbose>100) cout<<"proc "<<MyGlobals::_rank<<" create node2cell on local nodes with global numerotation idomain|inode|icell\n";
-    for (int i=0; i<nbNodes; i++)
-    {
-      for (int icell=index_ptr[i]; icell<index_ptr[i+1]; icell++)
-      {
-        /*cvw local
-        node2cell.insert(make_pair(i, revConnPtr[icell]));
-        cout<<" "<<idomain<<"|"<<i<<"|"<<revConnPtr[icell];
-        cell2node.insert(make_pair(revConnPtr[icell], i));
-        */
-        int globalNode=_topology->convertNodeToGlobal(idomain,i);
-        int globalCell=_topology->convertCellToGlobal(idomain,revConnPtr[icell]);
-        node2cell.insert(make_pair(globalNode, globalCell));
-        //cvw cout<<" "<<idomain<<"|"<<i<<"#"<< globalNode<<"|"<<revConnPtr[icell]<<"#"<<globalCell;
-        cell2node.insert(make_pair(globalCell, globalNode));
-      }
-    }
-    revConn->decrRef();
-    index->decrRef();
-    //vector<vector<multimap<int,int> > > dNC=getDistantNodeCell()
-    for (int iother=0; iother<nbdomain; iother++)
-    {
-      std::multimap<int,int>::iterator it;
-      int isource=idomain;
-      int itarget=iother;
-      for (it=_joint_finder->_distant_node_cell[isource][itarget].begin(); 
-           it!=_joint_finder->_distant_node_cell[isource][itarget].end(); it++)
-      {
-        int globalNode=_topology->convertNodeToGlobal(idomain,(*it).first);
-        int globalCell=(*it).second;
-        node2cell.insert(make_pair(globalNode, globalCell));
-        //cout<<"processor "<<MyGlobals::_rank<<" : isource "<<isource<<" itarget "<<itarget<<
-        //      " "<<(*it).first<<"~"<<globalNode<<"~"<<globalCell<<endl;
-        cell2node.insert(make_pair(globalCell, globalNode));
-      }
-    }
-  }  //endfor idomain
-
-  //creating graph arcs (cell to cell relations)
-  //arcs are stored in terms of (index,value) notation
-  // 0 3 5 6 6
-  // 1 2 3 2 3 3 
-  // means 6 arcs (0,1), (0,2), (0,3), (1,2), (1,3), (2,3)
-  // in present version arcs are not doubled but reflexive (1,1) arcs are present for each cell
-  //warning here one node have less than or equal effective number of cell with it
-  //but cell could have more than effective nodes
-  //because other equals nodes in other domain (with other global inode)
-  if (MyGlobals::_verbose>100) cout<<"proc "<<MyGlobals::_rank<<" creating graph arcs on nbNodes "<<_topology->nbNodes()<<endl;
-  for (int inode=0; inode<_topology->nbNodes(); inode++)  //on all nodes
-  {
-    typedef multimap<int,int>::const_iterator MI;
-    pair <MI,MI> myRange=node2cell.equal_range(inode);
-    for (MI cell1=myRange.first; cell1!=myRange.second; cell1++)  //on cells with inode
-    {
-      pair <MI,MI> myNodes1=cell2node.equal_range(cell1->second);  //nodes of one cell
-      for (MI cell2=myRange.first; cell2!=myRange.second; cell2++)  //on one of these cell
-      {
-        if (cell1->second!=cell2->second)  //in cells of my domain
-        {
-          pair <MI,MI> myNodes2=cell2node.equal_range(cell2->second); //on nodes of this cell
-          int nbcn=0; //number of common nodes between cells: at least 3 for cells
-          for (MI it1=myNodes1.first; it1!=myNodes1.second; ++it1)
-          {
-            for (MI it2=myNodes2.first; it2!=myNodes2.second; ++it2)
-            {
-              if ((*it1).second==(*it2).second)
-              {
-                nbcn=nbcn+1 ; break;
-              }
-            }
-          }
-          if (nbcn>=3)  //cvw TODO if 2d cells set at 2
-            cell2cell.insert(make_pair(cell1->second,cell2->second));
-            //note here there is some global numerotation of cell which come from other domain (not mydomain)
-            //cout<<" "<<MyGlobals::_rank<<"!"<<cell1->second<<"!"<<cell2->second; //cvw
-        }
-      }
-    }
-  }
-  
-  if (MyGlobals::_verbose>100) cout<<"proc "<<MyGlobals::_rank<<" create skylinearray"<<endl;
-  //filling up index and value to create skylinearray structure
-  vector <int> index,value;
-  index.push_back(0);
-  int idep=0;
-  
-  for (int idomain=0; idomain<nbdomain; idomain++)
-  {
-    if (isParallelMode() && !_domain_selector->isMyDomain(idomain)) continue;
-    int nbCells=_mesh[idomain]->getNumberOfCells();
-    for (int icell=0; icell<nbCells; icell++)
-    {
-      int size=0;
-      int globalCell=_topology->convertCellToGlobal(idomain,icell);
-      multimap<int,int>::iterator it;
-      pair<multimap<int,int>::iterator,multimap<int,int>::iterator> ret;
-      ret=cell2cell.equal_range(globalCell);
-      //cout<<" "<<MyGlobals::_rank<<"$"<<icell<<"$"<<globalCell;
-      for (it=ret.first; it!=ret.second; ++it)
-      {
-        //cout<<" "<<MyGlobals::_rank<<"$"<<icell<<"$"<<globalCell<<"$"<<(*it).second<<endl;
-        int ival=(*it).second; //no adding one existing yet
-        for (int i=idep ; i<idep+size ; i++)
-        {
-          if (value[i]==ival)
-          {
-            ival=-1; break;
-          }
-        }
-        if (ival!=-1)
-        {
-          value.push_back(ival);
-          //cout<<"|"<<ival;
-          size++;
-        }
-      }
-      //cout<<" ";
-      idep=index[index.size()-1]+size;
-      index.push_back(idep);
-    }
-  }
-  
-  array=new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
-
-  if (MyGlobals::_verbose>100)
-  {
-    std::cout<<"\nproc "<<_domain_selector->rank()<<" : end MESHCollection::buildCellGraph "<<
-               index.size()-1<<" "<<value.size()<<std::endl;
-    if (index.size()>1)
-    {
-      for (int i=0; i<10; ++i) cout<<index[i]<<" ";
-      cout<<"... "<<index[index.size()-1]<<endl;
-      for (int i=0; i<15; ++i) cout<<value[i]<<" ";
-      int ll=index[index.size()-1]-1;
-      cout<<"... ("<<ll<<") "<<value[ll-1]<<" "<<value[ll]<<endl;
-    }
-  }
-  
-}
-
-/*
-void MESHCollection::buildCellGraph_old(MEDPARTITIONER::MEDSKYLINEARRAY* & array,int *& edgeweights ) //cvwat09
-{
-  using std::multimap;
-  using std::vector;
-  using std::make_pair;
-  using std::pair;
-  
-  multimap< int, int > node2cell;
-  multimap< int, int > cell2cell;
-  
-  vector<vector<multimap<int,int> > > commonDistantNodes;
-  int nbdomain=_topology->nbDomain();
-  if (isParallelMode())
-    {
-      _joint_finder=new JointFinder(*this);
-      _joint_finder->findCommonDistantNodes();
-      commonDistantNodes=_joint_finder->getDistantNodeCell();
-    }
-
-  //looking for reverse nodal connectivity i global numbering
-  for (int idomain=0; idomain<nbdomain; idomain++)
-    {
-      if (isParallelMode() && !_domain_selector->isMyDomain(idomain)) continue;
-      int offset=0, procOffset=0;
-      if (isParallelMode())
-        {
-          offset=_domain_selector->getDomainCellShift(idomain);
-          procOffset=_domain_selector->getProcShift();
-        }
-      ParaMEDMEM::DataArrayInt* index=ParaMEDMEM::DataArrayInt::New();
-      ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New();
-      _mesh[idomain]->getReverseNodalConnectivity(revConn,index);
-      int* index_ptr=index->getPointer();
-      ParaMEDMEM::DataArrayInt* globalRevConn=revConn->deepCpy();
-      _topology->convertCellToGlobal(idomain,
-                                     revConn->getPointer(),
-                                     index_ptr[_mesh[idomain]->getNumberOfNodes()],
-                                     globalRevConn->getPointer());
-
-      int min=std::numeric_limits<int>::max(),max=-1;
-      for (int i=0; i< index_ptr[_mesh[idomain]->getNumberOfNodes()];i++)
-        {
-          if (revConn->getPointer()[i]<min) min=revConn->getPointer()[i];
-          if (revConn->getPointer()[i]>max) max=revConn->getPointer()[i];
-        }
-      int* globalNodeIds=new int[_mesh[idomain]->getNumberOfNodes()];
-      _topology->getNodeList(idomain,globalNodeIds);
-      
-      int* globalRevConnPtr=globalRevConn->getPointer();
-      for (int i=0; i<_mesh[idomain]->getNumberOfNodes();i++)
-        {
-          for (int icell=index_ptr[i]; icell<index_ptr[i+1]; icell++)
-          {
-            node2cell.insert(make_pair(globalNodeIds[i], globalRevConnPtr[icell]+procOffset));
-          }
-        }
-      if (isParallelMode())
-        {
-          for (int mydomain=0; mydomain<_topology->nbDomain();mydomain++)
-            {
-              if (_domain_selector->isMyDomain(mydomain)) continue;
-                  multimap<int,int>::iterator iter;
-                  for (iter=commonDistantNodes[idomain][mydomain].begin();iter!=commonDistantNodes[idomain][mydomain].end();iter++)
-                    {
-                      int ilocnode=iter->first;
-                      int icell=iter->second;
-                      node2cell.insert(make_pair(globalNodeIds[ilocnode],icell+offset));
-                    }
-            }
-        }
-
-      globalRevConn->decrRef();
-      revConn->decrRef();
-      index->decrRef();
-      delete[] globalNodeIds;
-    }
-
-  //creating graph arcs (cell to cell relations)
-  //arcs are stored in terms of (index,value) notation
-  // 0 3 5 6 6
-  // 1 2 3 2 3 3 
-  // means 6 arcs (0,1), (0,2), (0,3), (1,2), (1,3), (2,3)
-  // in present version arcs are not doubled but reflexive (1,1) arcs are present for each cell
-  //warning here one node have effective number of cell with it
-  //but cell could have more than effective nodes 
-  //is it normal??? because other equals nodes in other domain (with other inode)???
-  
-  int mincell,maxcell;
-  if (isParallelMode())
-    {
-      mincell=_domain_selector->getProcShift();
-      maxcell=mincell;
-      for (int i=0; i<nbdomain;i++)
-        if (_domain_selector->isMyDomain(i)) maxcell+=_mesh[i]->getNumberOfCells();
-    }
-  else
-    {
-      mincell=0;
-      maxcell=_topology->nbCells();
-    }
-  for (int inode=0; inode<_topology->nbNodes(); inode++)  //on all nodes
-    {
-      typedef multimap<int,int>::const_iterator MI;
-      pair <MI,MI> myRange = node2cell.equal_range(inode);
-      
-      
-      for (MI cell1=myRange.first; cell1!=myRange.second; cell1++)  //on cells with inode
-        {
-          for (MI cell2 = myRange.first; cell2!=myRange.second; cell2++)  //on one of these cell
-            {
-              if (cell1->second!=cell2->second && cell1->second>=mincell && cell1->second<maxcell)  //in cells of my domain
-              {
-                cell2cell.insert(make_pair(cell1->second,cell2->second));
-              }
-            }
-        }
-    }
-  //cout<<"proc "<<MyGlobals::_rank<<" end create skylinearray"<<endl;
-  //filling up index and value to create skylinearray structure
-
-  multimap<int,int>::const_iterator iter;
-
-  iter=cell2cell.begin();
-  vector <int> index,value;
-  index.push_back(0);
-  int idep=0;
-  while (iter != cell2cell.end())
-  {
-    multimap<int,int>::const_iterator next_iter = cell2cell.upper_bound(iter->first);
-    int size=0;
-    for (multimap<int,int>::const_iterator current_iter=iter; current_iter!=next_iter; current_iter++)
-    {
-      int ival=current_iter->second; //no adding one existing yet
-      for (int i=idep ; i<idep+size ; i++)
-      {
-        if (value[i]==ival)
-        {
-          ival=-1;
-          break;
-        }
-      }
-      if (ival!=-1)
-      {
-        value.push_back(ival);
-        size++;
-      }
-    }
-    idep=index[index.size()-1]+size;
-    index.push_back(idep);
-    iter=next_iter;
-  }
-  array=new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
-}*/
-
-/*! Creates the partition corresponding to the cell graph and the partition number
- * 
- * \param nbdomain number of subdomains for the newly created graph
- * 
- * returns a topology based on the new graph
- */
-Topology* MESHCollection::createPartition(int nbdomain, //cvwat06
-                                          Graph::splitter_type split, 
-                                          const std::string& options_string,
-                                          int* user_edge_weights,
-                                          int* user_vertices_weights)
-{
-  using std::cout;
-  using std::endl;
-  
-  if (MyGlobals::_verbose>10) cout<<"proc "<<MyGlobals::_rank<<" : MESHCollection::createPartition : Building cell graph"<<endl;
-  
-  if (nbdomain <1) throw INTERP_KERNEL::Exception(LOCALIZED("Number of subdomains must be > 0"));
-  MEDPARTITIONER::MEDSKYLINEARRAY* array=0;
-  int* edgeweights=0;
-
-  //cout<<"Building cell graph... ";
-  //   if ( _domain_selector )
-  //     buildCellGraphParallel(array,edgeweights);
-  //   else
-  buildCellGraph(array,edgeweights); //cvwat09
-  //MPI_Barrier(MPI_COMM_WORLD);
-  //cout<<"proc "<<MyGlobals::_rank<<" :end barrier CellGraph done"<<endl;
-  Graph* cellGraph;
-  switch (split)
-    {
-    case Graph::METIS:
-#ifdef ENABLE_METIS
-      if (MyGlobals::_verbose>10) cout<<"METISGraph"<<endl;
-      cellGraph=(Graph*)(new METISGraph(array,edgeweights));
-#else
-      throw INTERP_KERNEL::Exception(LOCALIZED("METIS Graph is not available. Check your products, please."));
-#endif
-      break;
-    case Graph::SCOTCH:
-#ifdef ENABLE_SCOTCH
-      if (MyGlobals::_verbose>10) cout<<"SCOTCHGraph"<<endl;
-      cellGraph=(Graph*)(new SCOTCHGraph(array,edgeweights));
-#else
-      throw INTERP_KERNEL::Exception(LOCALIZED("SCOTCH Graph is not available. Check your products, please."));
-#endif
-      break;
-    }
-
-  //!user-defined weights
-  if (user_edge_weights!=0) 
-    cellGraph->setEdgesWeights(user_edge_weights);
-  if (user_vertices_weights!=0)
-    cellGraph->setVerticesWeights(user_vertices_weights);
-
-  if (MyGlobals::_is0verbose>10) cout<<"partitioning graph on "<<nbdomain<<" domains"<<endl;
-  cellGraph->partGraph(nbdomain, options_string, _domain_selector);  //cvwat10
-
-  if (MyGlobals::_is0verbose>10) cout<<"building new topology"<<endl;
-  //cellGraph is a shared pointer 
-  Topology* topology=new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension());
-
-  //cleaning
-  if (edgeweights!=0) delete[] edgeweights;
-  // if (array!=0) delete array;
-  delete cellGraph;
-  if (MyGlobals::_verbose>11) cout<<"proc "<<MyGlobals::_rank<<" : end MESHCollection::createPartition"<<endl;
-  return topology;
-}
-
-/*! Creates a topology for a partition specified by the user
- * 
- * \param table user-specified partition (for each cell contains the domain number from 0 to n-1)
- * 
- * returns a topology based on the new partition
- */
-Topology* MESHCollection::createPartition(const int* partition)
-{
-  using std::set;
-  
-  MEDPARTITIONER::MEDSKYLINEARRAY* array=0;
-  int* edgeweights=0;
-
-  buildCellGraph(array,edgeweights);
-  Graph* cellGraph;
-  set<int> domains;
-  for (int i=0; i<_topology->nbCells(); i++)
-    {
-      domains.insert(partition[i]);
-    }
-  int nbdomain=domains.size();
-  
-  cellGraph=(Graph*)(new UserGraph(array, partition, _topology->nbCells()));
-  
-  //cellGraph is a shared pointer 
-  Topology* topology = new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension());
-  
-  //  if (array!=0) delete array;
-  delete cellGraph;
-  return topology;
-}
-
-void MESHCollection::setDomainNames(const std::string& name)
-{
-  for (int i=0; i<_topology->nbDomain(); i++)
-    {
-      std::ostringstream oss;
-      oss<<name<<"_"<<i;
-      if (!isParallelMode() || _domain_selector->isMyDomain(i))
-      _mesh[i]->setName(oss.str().c_str());
-    }
-}
-
-ParaMEDMEM::DataArrayDouble* MESHCollection::getField(std::string descriptionField, int iold)
-//getField look for and read it if not done, and assume decrRef() in ~MESHCollection;
-//something like MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
- {
-  int rank=MyGlobals::_rank;
-  string tag="ioldFieldDouble="+intToStr(iold);
-  string descriptionIold=descriptionField+serializeFromString(tag);
-  if (_mapDataArrayDouble.find(descriptionIold)!=_mapDataArrayDouble.end())
-  {
-    if (MyGlobals::_verbose>300) cout<<"proc "<<rank<<" : YET READ getField : "<<descriptionIold<<endl;
-    DataArrayDouble* res=_mapDataArrayDouble[descriptionIold];
-    //cout<<res->reprZip()<<endl;
-    return res;
-  }
-  if (MyGlobals::_verbose>200) cout<<"proc "<<rank<<" : TO BE READ getField : "<<descriptionIold<<endl;
-  string description, fileName, meshName, fieldName;
-  int idomain, typeField, DT, IT, entity;
-  idomain=iold;
-  fileName=MyGlobals::_fileNames[iold];
-  if (MyGlobals::_verbose>10) 
-    cout<<"proc "<<MyGlobals::_rank<<" : in "<<fileName<<" "<<iold<<" "<<descriptionIold<<endl;
-  //cout<<"\n\n"<<"ON_CELLS "<<ON_CELLS<<" ON_NODES "<<ON_NODES<<" ON_GAUSS_PT "<<ON_GAUSS_PT<<" ON_GAUSS_NE "<<ON_GAUSS_NE<<endl;;
-  //typeField ON_CELLS 0 ON_NODES 1 ON_GAUSS_PT 2 ON_GAUSS_NE 3;
-  //fieldDescriptionToData(descriptionField, &idomain, &fileName, &meshName, &fieldName, &typeField, &DT, &IT);
-  fieldShortDescriptionToData(descriptionIold, fieldName, typeField, entity, DT, IT);
-  meshName=MyGlobals::_meshNames[iold];
-  
-  //MEDCouplingFieldDouble* f2=MEDLoader::ReadFieldCell(
-  //         fileName.c_str(), meshName.c_str(), meshDimRelToMax, fieldName.c_str(), DT, IT);
-  MEDCouplingFieldDouble* f2=MEDLoader::ReadField((ParaMEDMEM::TypeOfField) typeField,
-           fileName.c_str(), meshName.c_str(), 0, fieldName.c_str(), DT, IT);
-  
-  DataArrayDouble* res=f2->getArray();
-  //to know names of components
-  vector <string> browse=browseFieldDouble(f2);
-  //done yet 
-  //double time=f2->getTime(IT,DT);
-  //browse.push_back("time="+doubleToStr(time));
-  string localFieldInformation=descriptionIold+serializeFromVectorOfString(browse);
-  if (MyGlobals::_verbose>10) cout<<"proc "<<MyGlobals::_rank<<" : localFieldInformation : "<<localFieldInformation<<endl;
-  MyGlobals::_generalInformations.push_back(localFieldInformation);
-  res->incrRef();  //free field, keep res
-  f2->decrRef();
-  _mapDataArrayDouble[descriptionIold]=res; 
-  
-  //duplicate it! because f2->decRef!!
-  //DataArrayDouble* res=f2->getArray()->deepCpy();
-  //f2->decrRef();
-  //cout<<res->reprZip()<<endl;
-  //have to put it in map for next needs.. decRef later...~MESHCollection
-  return res;
-}
-
-void MESHCollection::prepareFieldDescriptions()
-//to have unique valid fields names/pointers/descriptions for partitionning
-//filter _fieldDescriptions to be in all procs compliant and equal
-{
-  int nbfiles=MyGlobals::_fileNames.size(); //nb domains
-  vector<string> r2;
-  //from allgatherv then vector(procs) of serialised vector(fields) of vector(description) data
-  for (int i=0; i<_fieldDescriptions.size(); i++)
-  {
-    vector<string> r1=deserializeToVectorOfString(_fieldDescriptions[i]);
-    for (int i=0; i<r1.size(); i++) r2.push_back(r1[i]);
-  }
-  //here vector(procs*fields) of serialised vector(description) data
-  _fieldDescriptions=r2;
-  int nbfields=_fieldDescriptions.size(); //on all domains
-  if ((nbfields%nbfiles)!=0)
-  {
-    if (MyGlobals::_rank==0)
-    {
-      cerr<<"\nERROR : incoherent number of fields references in all files .med\n"<<endl
-          <<"fileMedNames :"<<endl
-          <<reprVectorOfString(MyGlobals::_fileNames)
-          <<"fieldDescriptions :"<<endl
-          <<reprVectorOfString(MyGlobals::_fieldDescriptions); //cvwat07
-    }
-    throw INTERP_KERNEL::Exception(LOCALIZED("incoherent number of fields references in all files .med\n"));
-  }
-  _fieldDescriptions.resize(nbfields/nbfiles);
-  for (int i=0; i<_fieldDescriptions.size(); i++)
-  {
-    string str=_fieldDescriptions[i];
-    str=eraseTagSerialized(str,"idomain=");
-    str=eraseTagSerialized(str,"fileName=");
-    _fieldDescriptions[i]=str;
-  }
-}
-
-//returns true if inodes of a face are in inodes of a cell
-bool isFaceOncell(vector< int >& inodesFace,vector< int >&  inodesCell)
-{
-  int ires=0;
-  int nbok=inodesFace.size();
-  for (int i=0; i<nbok; i++)
-  {
-    int ii=inodesFace[i];
-    if (ii<0) cout<<"isFaceOncell problem inodeface<0"<<endl;
-    for (int j=0; j<inodesCell.size(); j++)
-    {
-      if (ii==inodesCell[j])
-      {
-        ires=ires+1; break; //inode of face found
-      }
-    }
-    if (ires<i+1) break; //inode of face not found do not continue...
-  }
-  return (ires==nbok);
-}
-
-void MESHCollection::filterFaceOnCell()
-{
-  //meshesCells=_mesh;
-  //meshesFaces=_faceMesh;
-  for (int inew=0; inew<_topology->nbDomain(); inew++)
-  {
-    if (isParallelMode() && _domain_selector->isMyDomain(inew))
-    {
-      if (MyGlobals::_verbose>200) 
-        std::cout<<"proc "<<MyGlobals::_rank<<" : filterFaceOnCell on inewDomain "<<inew<<
-                   " nbOfFaces "<<_faceMesh[inew]->getNumberOfCells()<<endl;
-      ParaMEDMEM::MEDCouplingUMesh* mcel=_mesh[inew];
-      ParaMEDMEM::MEDCouplingUMesh* mfac=_faceMesh[inew];
-      
-      //to have cellnode=f(facenode)... inodeCell=nodeIds[inodeFace]
-      vector<int> nodeIds;
-      //cout<<"proc "<<MyGlobals::_rank<<" : nodeIds beg "<<inew<<" "<<mcel<<" "<<mfac<<endl;
-      getNodeIds(*mcel, *mfac, nodeIds);
-      if (nodeIds.size()==0) continue;  //one empty mesh nothing to do
-      
-      DataArrayInt *revNodalCel=DataArrayInt::New();
-      DataArrayInt *revNodalIndxCel=DataArrayInt::New();
-      mcel->getReverseNodalConnectivity(revNodalCel,revNodalIndxCel);
-      int *revC=revNodalCel->getPointer();
-      int *revIndxC=revNodalIndxCel->getPointer();
-      
-      vector< int > faceOnCell;
-      vector< int > faceNotOnCell;
-      int nbface=mfac->getNumberOfCells();
-      for (int iface=0; iface<nbface; iface++)
-      {
-        bool ok;
-        vector< int > inodesFace;
-        mfac->getNodeIdsOfCell(iface, inodesFace);
-        int nbnodFace=inodesFace.size();
-        //set inodesFace in mcel
-        for (int i=0; i<nbnodFace; i++) inodesFace[i]=nodeIds[inodesFace[i]];
-        int inod=inodesFace[0];
-        if (inod<0) cout<<"filterFaceOnCell problem 1"<<endl;
-        int nbcell=revIndxC[inod+1]-revIndxC[inod];
-        for (int j=0; j<nbcell; j++) //look for each cell with inod
-        {
-          int icel=revC[revIndxC[inod]+j];
-          vector< int > inodesCell;
-          mcel->getNodeIdsOfCell(icel, inodesCell);
-          ok=isFaceOncell(inodesFace, inodesCell);
-          if (ok) break;
-        }
-        if (ok)
-        {
-          faceOnCell.push_back(iface);
-          //if (MyGlobals::_is0verbose) cout<<"face on cell "<<iface<<" "<<faceOnCell.size()-1<<endl;
-        }
-        else
-        {
-          faceNotOnCell.push_back(iface);
-          if (MyGlobals::_is0verbose) cout<<"face NOT on cell "<<iface<<" "<<faceOnCell.size()-1<<endl;
-        }
-      }
-      
-      revNodalCel->decrRef();
-      revNodalIndxCel->decrRef();
-      
-      string cle;
-      cle=cle1ToStr("filterFaceOnCell",inew);
-      _mapDataArrayInt[cle]=createDataArrayIntFromVector(faceOnCell);
-      cle=cle1ToStr("filterNotFaceOnCell",inew);
-      _mapDataArrayInt[cle]=createDataArrayIntFromVector(faceNotOnCell);
-      
-      /*ParaMEDMEM::DataArrayInt* index=ParaMEDMEM::DataArrayInt::New();
-      ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New();
-      _mesh[idomain]->getReverseNodalConnectivity(revConn,index);
-      int* index_ptr=index->getPointer();*/
-      
-      /*if (MyGlobals::_is0verbose)
-      {
-        cout<<"proc "<<MyGlobals::_rank<<" : nodeIds end "<<inew<<" "<<nodeIds.size()<<endl;
-        for (int i=0; i<nodeIds.size(); i++) cout<<" "<<nodeIds[i];
-        cout<<endl;
-      }*/
-
-    }
-  }
-}
-
-/*
-void MESHCollection::buildBoundaryOnCellMeshes()
-//no used... yet
-{
-  //cout<<"buildBoundaryOnCellMeshes"<<endl;
-  //meshesCells=_mesh;
-  //meshesFaces=_faceMesh;
-  for (int inew=0; inew<_topology->nbDomain(); inew++)
-  {
-    if (isParallelMode() && _domain_selector->isMyDomain(inew))
-    {
-      if (MyGlobals::_verbose>1) std::cout<<"proc "<<MyGlobals::_rank<<" : filterFaceOnCell on "<<inew<<" "<<_faceMesh[inew]->getNumberOfCells()<<endl;
-      ParaMEDMEM::MEDCouplingUMesh* mcel=_mesh[inew];
-      //ParaMEDMEM::MEDCouplingUMesh& mfac=_faceMesh[inew];
-      
-      DataArrayInt *desc=DataArrayInt::New();
-      DataArrayInt *descIndx=DataArrayInt::New();
-      DataArrayInt *revDesc=DataArrayInt::New();
-      DataArrayInt *revDescIndx=DataArrayInt::New();
-      //
-      MEDCouplingUMesh *meshDM1=mcel->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
-      revDesc->decrRef();
-      desc->decrRef();
-      descIndx->decrRef();
-      int nbOfCells=meshDM1->getNumberOfCells();
-      const int *revDescIndxC=revDescIndx->getConstPointer();
-      std::vector<int> boundaryCells;
-      for(int i=0; i<nbOfCells; i++)
-        if(revDescIndxC[i+1]-revDescIndxC[i]==1)
-          boundaryCells.push_back(i);
-      revDescIndx->decrRef();
-      bool keepCoords=true;
-      MEDCouplingUMesh *ret=(MEDCouplingUMesh *)meshDM1->buildPartOfMySelf(&boundaryCells[0],&boundaryCells[0]+boundaryCells.size(),keepCoords);
-      meshDM1->decrRef();
-      //don't know what to do with result yet..
-      //_faceMesh[inew]->decrRef();
-      //_faceMesh[inew]=ret;
-    }
-  }
-}
-*/
-
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx
deleted file mode 100644 (file)
index e30a9b6..0000000
+++ /dev/null
@@ -1,249 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef __MEDPARTITIONER_MESHCOLLECTION_HXX__
-#define __MEDPARTITIONER_MESHCOLLECTION_HXX__
-
-#include "MEDPARTITIONER.hxx"
-
-#include "MEDPARTITIONER_Graph.hxx"
-#include "MEDCouplingUMesh.hxx"
-
-//#include "MEDPARTITIONER_FaceModel.hxx"
-//#include "boost/shared_ptr.hpp"
-#include <vector>
-#include <map>
-#include <string>
-namespace ParaMEDMEM
-{
-  class MEDCouplingUMesh;
-  class DataArrayInt;
-}
-
-
-namespace MEDPARTITIONER
-{
-
-  class Topology;
-  class MESHCollectionDriver;
-  class ParaDomainSelector;
-  class MEDSKYLINEARRAY;
-  class CONNECTZONE;
-  class JointFinder;
-  typedef enum{MedAscii, MedXML, Undefined} DriverType;
-
-  typedef std::multimap<std::pair<int,int>, std::pair<int,int> > NodeMapping ;
-  typedef std::vector<std::pair<int,int> >  NodeList;
-  
-  class MEDPARTITIONER_EXPORT MESHCollection
-  {
-
-  public:
-
-    //Default constructor
-    MESHCollection();
-
-    //Constructing from an existing mesh and a new topology
-    MESHCollection(MESHCollection&, Topology*, bool family_splitting=false, bool create_empty_groups=false);
-
-    //Constructing the mesh collection from a file
-    MESHCollection(const std::string& filename);
-
-    //Constructing the mesh collection from a file
-    MESHCollection(const std::string& filename, ParaDomainSelector& domainSelector);
-
-    //Constructing the mesh collection from a file
-    MESHCollection(const std::string& filename, const std::string& meshname);
-
-    ~MESHCollection();
-        
-    bool isParallelMode() const { return _domain_selector; }
-        
-    //writing to a distributed file
-    void write(const std::string& filename);
-
-    //getting the driver
-    MESHCollectionDriver* retrieveDriver();
-    MESHCollectionDriver* getDriver() const;
-    void setDriverType(MEDPARTITIONER::DriverType type) {_driver_type=type;}
-
-    //creation of the cell graph
-    void buildCellGraph(MEDPARTITIONER::MEDSKYLINEARRAY* & array,int *& edgeweights );
-
-    //creation and partition of the associated graph
-    Topology* createPartition(int nbdomain, Graph::splitter_type type = Graph::METIS,
-                              const std::string& ="", int* edgeweights=0, int* verticesweights=0);
-
-    //creation of a user specified partition
-    Topology* createPartition(const int* partition);
-    
-     //getting mesh dimension
-     int getMeshDimension() const ;
-
-     //getting a reference to mesh vector
-     std::vector<ParaMEDMEM::MEDCouplingUMesh*>& getMesh();
-     std::vector<ParaMEDMEM::MEDCouplingUMesh*>& getFaceMesh();
-     std::vector<std::vector<ParaMEDMEM::MEDCouplingUMesh*> >& getGroupMeshes();
-
-     ParaMEDMEM::MEDCouplingUMesh* getMesh(int idomain) const;
-     ParaMEDMEM::MEDCouplingUMesh* getFaceMesh(int idomain);
-     std::vector<ParaMEDMEM::MEDCouplingUMesh*>& getGroupMeshes(int idomain);
-
-     std::vector<ParaMEDMEM::DataArrayInt*>& getCellFamilyIds() {return _cellFamilyIds;}
-     std::vector<ParaMEDMEM::DataArrayInt*>& getFaceFamilyIds() {return _faceFamilyIds;}
-     
-     std::map<std::string, ParaMEDMEM::DataArrayInt*>& getMapDataArrayInt() {return _mapDataArrayInt;}
-     std::map<std::string, ParaMEDMEM::DataArrayDouble*>& getMapDataArrayDouble() {return _mapDataArrayDouble;}
-
-     std::map<std::string,int>& getFamilyInfo() {return _familyInfo;}
-     std::map<std::string, std::vector<std::string> >& getGroupInfo() {return _groupInfo;}
-
-     ParaMEDMEM::DataArrayDouble* getField(std::string descriptionField, int iold);
-     std::vector<std::string>&  getFieldDescriptions() {return _fieldDescriptions;}
-     void prepareFieldDescriptions();
-     void filterFaceOnCell();
-     
-    //getting a reference to connect zones vector
-    std::vector<MEDPARTITIONER::CONNECTZONE*>& getCZ();
-
-    //getting a pointer to topology
-    Topology* getTopology() const ;
-    ParaDomainSelector* getParaDomainSelector() const{return _domain_selector;}
-    //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 setDomainNames(const std::string& name);
-
-    //getting/setting the description of the global mesh
-    std::string getDescription() const {return _description;}
-    void setDescription(const std::string& name) { _description=name;}
-
-    //creates the node mapping between an old collection and the present one
-    void createNodeMapping(MESHCollection& initialCollection, 
-                           std::multimap<std::pair<int,int>,std::pair<int,int> >& nodeMapping);
-
-    void castCellMeshes(MESHCollection& initialCollection, 
-                        std::vector<std::vector<std::vector<int> > >& new2oldIds);
-    
-    //creates faces on the new collection
-    void castFaceMeshes(MESHCollection& initialCollection,
-                    const std::multimap<std::pair<int,int>, std::pair<int,int> >& nodeMapping,
-                    std::vector<std::vector<std::vector<int> > >& new2oldIds);
-
-  private:
-
-    void castIntField2(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,
-                       std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo,
-                       std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom,
-                       std::string nameArrayTo);
-
-    void castAllFields(MESHCollection& initialCollection,
-                       std::string nameArrayTo);
-
-    void findCommonDistantNodes(std::vector<std::vector<std::multimap<int,int> > >& commonDistantNodes);
-
-    void remapIntField(const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
-                       const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
-                       const int* fromArray,
-                       int* toArray);
-    
-    void remapIntField2(int inew, int iold, 
-                       const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
-                       const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
-                       const int* fromArray,
-                       std::string nameArrayTo);
-
-    void remapDoubleField3(int inew, int iold,
-                           ParaMEDMEM::DataArrayDouble* fromArray,
-                           std::string nameArrayTo,
-                           std::string descriptionField);
-
-    //!link to mesh_collection topology
-    Topology* _topology;
-
-    //!control over topology
-    bool _owns_topology;
-
-    //!link to graph
-    //Graph* _cell_graph;
-
-    //! Driver for read/write operations
-    MESHCollectionDriver* _driver;
-
-    //! Parallelizer - mark of parallel execution mode
-    ParaDomainSelector* _domain_selector;
-
-    //!links to meshes
-    std::vector<ParaMEDMEM::MEDCouplingUMesh*> _mesh;
-    std::vector<ParaMEDMEM::MEDCouplingUMesh*> _faceMesh;
-   
-    //!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;
-    
-    //!DataArrayInt* storages
-    std::map<std::string, ParaMEDMEM::DataArrayInt*> _mapDataArrayInt;
-    //!DataArrayDouble* storages
-    std::map<std::string, ParaMEDMEM::DataArrayDouble*> _mapDataArrayDouble;
-    
-    std::vector<std::string> _fieldDescriptions; //fields to be partitioned
-    
-    //!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;
-
-    //!name of global mesh
-    std::string _name;
-
-    //!description of global mesh
-    std::string _description;
-
-    //! specifies the driver associated to the collection
-    DriverType _driver_type;
-
-    /*! flag specifying that the splitter should create boundary constituent entity
-      so that they are written in joints*/
-    bool _subdomain_boundary_creates;
-
-        /*! flag specifying that families must be preserved by the
-                splitting*/
-    bool _family_splitting;
-
-        /*! flag specifying that groups must be created on all domains, 
-                even if they are empty*/
-    bool _create_empty_groups;
-
-    JointFinder* _joint_finder;
-  };
-
-}//of namespace
-
-#endif /*MESHCOLLECTION_*/
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx
deleted file mode 100644 (file)
index 78b1e5e..0000000
+++ /dev/null
@@ -1,557 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include <vector>
-#include <string>
-#include <map>
-#include <set>
-
-#include <iostream>
-#include <fstream>
-
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-
-#include <sys/time.h>
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "MEDLoader.hxx"
-#include "MEDFileMesh.hxx"
-
-extern "C" {
-#include "med.h"
-}
-//MEDPARTITIONER includes
-#include "MEDPARTITIONER_ParallelTopology.hxx"
-#include "MEDPARTITIONER_MESHCollectionDriver.hxx"
-#include "MEDPARTITIONER_MESHCollection.hxx"
-#include "MEDPARTITIONER_ParaDomainSelector.hxx"
-#include "MEDPARTITIONER_utils.hxx"
-
-using namespace MEDPARTITIONER;
-using namespace std;
-
-//template inclusion
-//#include "MEDPARTITIONER_MESHCollectionDriver.H"
-
-// med_geometrie_element typmai[MED_NBR_GEOMETRIE_MAILLE+2] = { MED_POINT1,
-//                                                              MED_SEG2,
-//                                                              MED_SEG3,
-//                                                              MED_TRIA3,
-//                                                              MED_TRIA6,
-//                                                              MED_QUAD4,
-//                                                              MED_QUAD8,
-//                                                              MED_TETRA4,
-//                                                              MED_TETRA10,
-//                                                              MED_HEXA8,
-//                                                              MED_HEXA20,
-//                                                              MED_PENTA6,
-//                                                              MED_PENTA15,
-//                                                              MED_PYRA5,
-//                                                              MED_PYRA13,
-//                                                              MED_POLYGONE,
-//                                                              MED_POLYEDRE };
-
-MESHCollectionDriver::MESHCollectionDriver(MESHCollection* collection):_collection(collection)
-{
-}
-
-
-/*!reads a unique MED File v>=2.1
- * and mounts the corresponding mesh in memory
- *\param filename binary file
- *\param meshname mesh name in the MED file
- * */
-int MESHCollectionDriver::readSeq(const char* filename, const char* meshname)
-{
-  cout<<"readSeq"<<endl;
-  MyGlobals::_fileNames.resize(1);
-  MyGlobals::_fileNames[0]=string(filename);
-
-  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(filename,meshname);
-  //puts the only mesh in the mesh vector
-  (_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
-  (_collection->getFamilyInfo())=mfm->getFamilyInfo();
-  (_collection->getGroupInfo())=mfm->getGroupInfo();
-  
-// (_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->getCZ()).clear();
-  /*cvw 
-  vector<int*> cellglobal,nodeglobal,faceglobal;
-  cellglobal.resize(1);
-  nodeglobal.resize(1);
-  faceglobal.resize(1);
-  cellglobal[0]=0;
-  nodeglobal[0]=0;
-  faceglobal[0]=0;
-  //creation of topology from mesh 
-  //connectzone argument is 0
-  ParallelTopology* aPT = new ParallelTopology
-    ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
-  */
-  
-  ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()));
-  _collection->setTopology(aPT);
-  _collection->setName(meshname);
-  _collection->setDomainNames(meshname);
-  return 0;
-}
-
-
-//================================================================================
-/*!
- * \brief Return mesh dimension from distributed med file had being read
- */
-//================================================================================
-
-void MESHCollectionDriver::readSubdomain(vector<int*>& cellglobal, //cvwat03
-                                         vector<int*>& faceglobal,
-                                         vector<int*>& nodeglobal, int idomain)
-{
-  string meshname=MyGlobals::_meshNames[idomain];
-  string file=MyGlobals::_fileNames[idomain];
-
-  //cout << "Reading "<<meshname<<" in "<<file<<endl; //cvw
-
-  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file.c_str(),meshname.c_str());
-  vector<int> nonEmpty=mfm->getNonEmptyLevels();
-  
-  try 
-  { 
-    (_collection->getMesh())[idomain]=mfm->getLevel0Mesh(false); 
-    //reading families groups
-    ParaMEDMEM::DataArrayInt* cellIds(mfm->getFamilyFieldAtLevel(0)->deepCpy());
-    (_collection->getCellFamilyIds())[idomain]=cellIds;
-  }
-  catch(...)
-  { 
-    (_collection->getMesh())[idomain]=createEmptyMEDCouplingUMesh(); // or 0 if you want tests;
-    ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
-    empty->alloc(0,1);
-    (_collection->getCellFamilyIds())[idomain]=empty;
-    cout<<"\nNO Level0Mesh (Cells)\n";
-  }
-  try 
-  { 
-    if (nonEmpty.size()>1 && nonEmpty[1]==-1)
-    {
-      (_collection->getFaceMesh())[idomain]=mfm->getLevelM1Mesh(false);
-      //reading families groups
-      ParaMEDMEM::DataArrayInt* faceIds(mfm->getFamilyFieldAtLevel(-1)->deepCpy());
-      (_collection->getFaceFamilyIds())[idomain]=faceIds;
-    }
-    else
-    {
-      throw "no faces";
-    }
-  }
-  catch(...)
-  {
-    //ParaMEDMEM::MEDCouplingUMesh *umesh=ParaMEDMEM::MEDCouplingUMesh::New(); //empty one
-    //umesh->setMeshDimension(3);
-    //umesh->allocateCells(0);
-    //int nb=umesh->getNumberOfCells(); //no use if no allocateCells(0)! because thrown exception
-    //cout<<"\nempty mesh"<<nb<<endl;
-    
-    (_collection->getFaceMesh())[idomain]=createEmptyMEDCouplingUMesh(); // or 0 if you want test;
-    ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
-    (_collection->getFaceFamilyIds())[idomain]=empty;
-    if (MyGlobals::_verbose>10) cout<<"proc "<<MyGlobals::_rank<<" : NO LevelM1Mesh (Faces)\n";
-  }
-  
-  //reading groups
-  _collection->getFamilyInfo()=mfm->getFamilyInfo();
-  _collection->getGroupInfo()=mfm->getGroupInfo();
-
-  mfm->decrRef();
-  
-  vector<string> localInformation;
-  string str;
-  localInformation.push_back(str+"ioldDomain="+intToStr(idomain));
-  localInformation.push_back(str+"meshName="+meshname);
-  MyGlobals::_generalInformations.push_back(serializeFromVectorOfString(localInformation));
-  vector<string> localFields=browseAllFieldsOnMesh(file, meshname, idomain); //cvwat07
-  if (localFields.size()>0) 
-    MyGlobals::_fieldDescriptions.push_back(serializeFromVectorOfString(localFields));
-  //cout<< "End Reading "<<meshname<<" in "<<file<<endl;
-}
-
-
-void MESHCollectionDriver::readSubdomain(int idomain)
-{
-  string meshname=MyGlobals::_meshNames[idomain];
-  string file=MyGlobals::_fileNames[idomain];
-
-  //cout << "Reading "<<meshname<<" in "<<file<<endl; //cvw
-
-  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file.c_str(),meshname.c_str());
-  vector<int> nonEmpty=mfm->getNonEmptyLevels();
-  
-  try 
-  { 
-    (_collection->getMesh())[idomain]=mfm->getLevel0Mesh(false); 
-    //reading families groups
-    ParaMEDMEM::DataArrayInt* cellIds(mfm->getFamilyFieldAtLevel(0)->deepCpy());
-    (_collection->getCellFamilyIds())[idomain]=cellIds;
-  }
-  catch(...)
-  { 
-    (_collection->getMesh())[idomain]=createEmptyMEDCouplingUMesh(); // or 0 if you want tests;
-    ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
-    empty->alloc(0,1);
-    (_collection->getCellFamilyIds())[idomain]=empty;
-    cout<<"\nNO Level0Mesh (Cells)\n";
-  }
-  try 
-  { 
-    if (nonEmpty.size()>1 && nonEmpty[1]==-1)
-    {
-      (_collection->getFaceMesh())[idomain]=mfm->getLevelM1Mesh(false);
-      //reading families groups
-      ParaMEDMEM::DataArrayInt* faceIds(mfm->getFamilyFieldAtLevel(-1)->deepCpy());
-      (_collection->getFaceFamilyIds())[idomain]=faceIds;
-    }
-    else
-    {
-      throw "no faces";
-    }
-  }
-  catch(...)
-  {
-    (_collection->getFaceMesh())[idomain]=createEmptyMEDCouplingUMesh(); // or 0 if you want test;
-    ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
-    (_collection->getFaceFamilyIds())[idomain]=empty;
-    if (MyGlobals::_verbose>10) cout<<"proc "<<MyGlobals::_rank<<" : NO LevelM1Mesh (Faces)\n";
-  }
-  
-  //reading groups
-  _collection->getFamilyInfo()=mfm->getFamilyInfo();
-  _collection->getGroupInfo()=mfm->getGroupInfo();
-
-  mfm->decrRef();
-  
-  vector<string> localInformation;
-  string str;
-  localInformation.push_back(str+"ioldDomain="+intToStr(idomain));
-  localInformation.push_back(str+"meshName="+meshname);
-  MyGlobals::_generalInformations.push_back(serializeFromVectorOfString(localInformation));
-  vector<string> localFields=browseAllFieldsOnMesh(file, meshname, idomain); //cvwat07
-  if (localFields.size()>0) 
-    MyGlobals::_fieldDescriptions.push_back(serializeFromVectorOfString(localFields));
-  //cout<< "End Reading "<<meshname<<" in "<<file<<endl;
-}
-
-
-void MESHCollectionDriver::writeMedFile(int idomain, const string& distfilename)
-{
-  vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
-  ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain);
-  ParaMEDMEM::MEDCouplingUMesh* faceMesh=_collection->getFaceMesh(idomain);
-  ParaMEDMEM::MEDCouplingUMesh* faceMeshFilter=0;
-  
-  string finalMeshName=extractFromDescription(MyGlobals::_generalInformations[0], "finalMeshName=");
-  string cleFilter=cle1ToStr("filterFaceOnCell",idomain);
-  DataArrayInt* filter=0;
-  if (_collection->getMapDataArrayInt().find(cleFilter)!=_collection->getMapDataArrayInt().end())
-  {
-    filter=_collection->getMapDataArrayInt().find(cleFilter)->second;
-    int* index=filter->getPointer();
-    faceMeshFilter=(MEDCouplingUMesh *) faceMesh->buildPartOfMySelf(index,index+filter->getNbOfElems(),true);
-    faceMesh=faceMeshFilter;
-  }
-  cellMesh->setName(finalMeshName.c_str());
-  meshes.push_back(cellMesh);
-  
-  //cellMesh->zipCoords();
-  //faceMesh->zipCoords();
-  
-  faceMesh->checkCoherency();
-  if (faceMesh->getNumberOfCells()>0)
-  {
-    faceMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10);
-    meshes.push_back(faceMesh);
-  }
-  
-  /*do not work
-  ParaMEDMEM::MEDFileUMesh* mfm2=ParaMEDMEM::MEDFileUMesh::New();
-  MEDFileUMesh* mfm2 = static_cast<MEDFileUMesh*>(cellMesh->getMeshes()->getMeshAtPos(0));
-  MEDFileUMesh* mfm2 = ParaMEDMEM::MEDFileUMesh::New(cellMesh);
-  string fname="FUM_"+distfilename;
-  mfm2->setMeshAtLevel(0, cellMesh );
-  mfm2->setMeshAtLevel(-1, faceMesh );
-  mfm2->write(fname.c_str(),0);
-  mfm2->decrRef();
-  */
-  
-  ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0;
-  //ParaMEDMEM::MEDCouplingUMesh* boundaryMesh1=0;
-  //ParaMEDMEM::MEDCouplingUMesh* finalboundaryMesh=0;
-  if (MyGlobals::_creates_boundary_faces>0)
-  {
-    //try to write Boundary meshes
-    bool keepCoords=false; //TODO or true
-    boundaryMesh=(MEDCouplingUMesh *) cellMesh->buildBoundaryMesh(keepCoords);
-    boundaryMesh->setName("boundaryMesh");
-    //cout<<"boundaryMesh "<<boundaryMesh->getNumberOfCells()<<endl;
-    //do not work if faceMesh present yet //The mesh dimension of meshes must be different each other!
-    //boundaryMesh->checkCoherency();
-    //boundaryMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10);
-    //meshes.push_back(boundaryMesh);
-    //string boundary="boundary_"+distfilename;
-    
-    /*try to find joint do no work
-    int rang=MyGlobals::_rank;
-    if (rang==1) (_collection->getParaDomainSelector())->sendMesh(*(boundaryMesh),0);
-    if (rang==0) 
-    {
-      (_collection->getParaDomainSelector())->recvMesh(boundaryMesh1,1);
-      //vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
-      //vector<DataArrayInt* > corr;
-      //meshes.push_back(boundaryMesh);
-      //meshes.push_back(boundaryMesh1);
-      //need share the same coords
-      //boundaryMesh1->tryToShareSameCoordsPermute(*boundaryMesh, 1e-10);
-      //finalboundaryMesh=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,2, corr);
-      //boundaryMesh=finalboundaryMesh;
-      
-      boundaryMesh->zipCoords();
-      boundaryMesh1->zipCoords();
-      finalboundaryMesh=MEDCouplingUMesh::MergeUMeshes(boundaryMesh,boundaryMesh1);
-      DataArrayInt* commonNodes=0;
-      commonNodes=finalboundaryMesh->zipCoordsTraducer();
-      boundaryMesh=finalboundaryMesh;
-      cout<<"zipcoords"<<commonNodes->repr()<<endl;
-    }
-    */
-  }
-  
-  MEDLoader::WriteUMeshes(distfilename.c_str(), meshes, true);
-  if (faceMeshFilter!=0) faceMeshFilter->decrRef();
-  
-  
-  if (boundaryMesh!=0)
-  {
-    //doing that testMesh becomes second mesh sorted by alphabetical order of name
-    MEDLoader::WriteUMesh(distfilename.c_str(), boundaryMesh, false);
-    boundaryMesh->decrRef();
-  }
-
-  //cout<<"familyInfo :\n"<<reprMapOfStringInt(_collection->getFamilyInfo())<<endl;
-  //cout<<"groupInfo :\n"<<reprMapOfStringVectorOfString(_collection->getGroupInfo())<<endl;
-  
-  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename.c_str(), _collection->getMesh(idomain)->getName());
-       
-  /*example of adding new family
-  (_collection->getFamilyInfo())["FaceNotOnCell"]=-500;
-  vector<string> FaceNotOnCell;
-  FaceNotOnCell.push_back("FaceNotOnCell");
-  (_collection->getGroupInfo())["FaceNotOnCell"]=FaceNotOnCell;
-  */
-  
-  mfm->setFamilyInfo(_collection->getFamilyInfo());
-  mfm->setGroupInfo(_collection->getGroupInfo());
-  
-  //cvwat08 
-  //without filter mfm->setFamilyFieldArr(-1,(_collection->getFaceFamilyIds())[idomain]);
-  
-  string cle=cle1ToStr("faceFamily_toArray",idomain);
-  if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end())
-  {
-    DataArrayInt* fam=_collection->getMapDataArrayInt().find(cle)->second;
-    DataArrayInt* famFilter=0;
-    if (filter!=0)
-    {
-      int* index=filter->getPointer();
-      int nbTuples=filter->getNbOfElems();
-      //not the good one...buildPartOfMySelf do not exist for DataArray 
-      //Filter=fam->renumberAndReduce(index, filter->getNbOfElems());
-      famFilter=DataArrayInt::New();
-      famFilter->alloc(nbTuples,1);
-      int* pfamFilter=famFilter->getPointer();
-      int* pfam=fam->getPointer();
-      for (int i=0; i<nbTuples; i++) pfamFilter[i]=pfam[index[i]];
-      fam=famFilter;
-      mfm->setFamilyFieldArr(-1,fam);
-      famFilter->decrRef();
-    }
-    //cout<<"proc "<<MyGlobals::_rank<<"cvw111 "<<nbTuples<<endl;
-    //mfm->setFamilyFieldArr(-1,fam);
-   // if (famFilter!=0) famFilter->decrRef();
-  }
-  
-  /*example visualisation of filter
-  if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end())
-  {
-    DataArrayInt* fam=_collection->getMapDataArrayInt().find(cle)->second;
-    string cle2=cle1ToStr("filterNotFaceOnCell",idomain);
-    if (_collection->getMapDataArrayInt().find(cle2)!=_collection->getMapDataArrayInt().end())
-    {
-      DataArrayInt* filter=_collection->getMapDataArrayInt().find(cle2)->second;
-      int* index=filter->getPointer();
-      int* pfam=fam->getPointer();
-      for (int i=0; i<filter->getNbOfElems(); i++) pfam[index[i]]=-500;
-    }
-    mfm->setFamilyFieldArr(-1,fam);
-    //mfm->setFamilyFieldArr(-1,_collection->getMapDataArrayInt().find(cle)->second);
-  }
-  */
-  
-  cle=cle1ToStr("cellFamily_toArray",idomain);
-  if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end())
-    mfm->setFamilyFieldArr(0,_collection->getMapDataArrayInt().find(cle)->second);
-  
-  mfm->write(distfilename.c_str(),0);
-  cle="/inewFieldDouble="+intToStr(idomain)+"/";
-    
-  map<string,ParaMEDMEM::DataArrayDouble*>::iterator it;
-  int nbfFieldFound=0;
-  for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++)
-  {
-    string desc=(*it).first;
-    size_t found=desc.find(cle);
-    if (found==string::npos) continue;
-    if (MyGlobals::_verbose>20) cout<<"proc "<<MyGlobals::_rank<<" : write field "<<desc<<endl;
-    string meshName, fieldName;
-    int typeField, DT, IT, entity;
-    fieldShortDescriptionToData(desc, fieldName, typeField, entity, DT, IT);
-    double time=strToDouble(extractFromDescription(desc, "time="));
-    int typeData=strToInt(extractFromDescription(desc, "typeData="));
-    //int nbPtGauss=strToInt(extractFromDescription(desc, "nbPtGauss="));
-    string entityName=extractFromDescription(desc, "entityName=");
-    MEDCouplingFieldDouble* field=0;
-    if (typeData!=6)
-    {
-      cout<<"WARNING : writeMedFile : typeData "<<typeData<<" not implemented for fields\n";
-      continue;
-    }
-    if (entityName=="MED_CELL")
-    {
-      //there is a field of idomain to write
-      field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
-    }
-    if (entityName=="MED_NODE_ELEMENT")
-    {
-      //there is a field of idomain to write
-      field=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME);
-    }
-    if (!field)
-    {
-      cout<<"WARNING : writeMedFile : entityName "<<entityName<<" not implemented for fields\n";
-      continue;
-    }
-    nbfFieldFound++;
-    field->setName(fieldName.c_str());
-    field->setMesh(mfm->getLevel0Mesh(false));
-    DataArrayDouble* da=(*it).second;
-    
-    //get information for components etc..
-    vector<string> r1;
-    r1=selectTagsInVectorOfString(MyGlobals::_generalInformations,"fieldName="+fieldName);
-    r1=selectTagsInVectorOfString(r1,"typeField="+intToStr(typeField));
-    r1=selectTagsInVectorOfString(r1,"DT="+intToStr(DT));
-    r1=selectTagsInVectorOfString(r1,"IT="+intToStr(IT));
-    //not saved in file? field->setDescription(extractFromDescription(r1[0], "fieldDescription=").c_str());
-    int nbc=strToInt(extractFromDescription(r1[0], "nbComponents="));
-    //double time=strToDouble(extractFromDescription(r1[0], "time="));
-    if (nbc==da->getNumberOfComponents())
-    {
-      for (int i=0; i<nbc; i++) 
-        da->setInfoOnComponent(i,extractFromDescription(r1[0], "componentInfo"+intToStr(i)+"=").c_str());
-    }
-    else
-    {
-      cerr<<"Problem On field "<<fieldName<<" : number of components unexpected "<<da->getNumberOfComponents()<<endl;
-    }
-    
-    field->setArray(da);
-    field->setTime(time,DT,IT);
-    field->checkCoherency();
-    try
-    {
-      MEDLoader::WriteField(distfilename.c_str(),field,false);
-      //if entityName=="MED_NODE_ELEMENT"
-      //AN INTERP_KERNEL::EXCEPTION HAS BEEN THROWN : Not implemented other profile fitting from already written mesh for fields than on NODES and on CELLS.**********
-      //modification MEDLoader.cxx done
-    }
-    catch(INTERP_KERNEL::Exception& e)
-    {
-      //cout trying rewrite all data, only one field defined
-      string tmp,newName=distfilename;
-      tmp+="_"+fieldName+"_"+intToStr(nbfFieldFound)+".med";
-      newName.replace(newName.find(".med"),4,tmp);
-      cout<<"WARNING : writeMedFile : new file name with only one field :"<<newName<<endl;
-      MEDLoader::WriteField(newName.c_str(),field,true);
-    }
-    //cout<<"proc "<<MyGlobals::_rank<<" : write field "<<cle<<" done"<<endl;
-  }
-
-  mfm->decrRef();
-
-}
-
-/*
-void writeFieldNodeCellTryingToFitExistingMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f)
-{
-  med_int numdt,numo;
-  med_float dt;
-  int nbComp=f->getNumberOfComponents();
-  med_idt fid=appendFieldSimpleAtt(fileName,f,numdt,numo,dt);
-  std::list<MEDLoader::MEDFieldDoublePerCellType> split;
-  prepareCellFieldDoubleForWriting(f,thisMeshCellIdsPerType,split);
-  const double *pt=f->getArray()->getConstPointer();
-  int number=0;
-  for(std::list<MEDLoader::MEDFieldDoublePerCellType>::const_iterator iter=split.begin();iter!=split.end();iter++)
-    {
-      INTERP_KERNEL::AutoPtr<char> nommaa=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
-      MEDLoaderBase::safeStrCpy(f->getMesh()->getName(),MED_NAME_SIZE,nommaa,MEDLoader::_TOO_LONG_STR);
-      INTERP_KERNEL::AutoPtr<char> profileName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
-      std::ostringstream oss; oss << "Pfl" << f->getName() << "_" << number++;
-      MEDLoaderBase::safeStrCpy(oss.str().c_str(),MED_NAME_SIZE,profileName,MEDLoader::_TOO_LONG_STR);
-      const std::vector<int>& ids=(*iter).getCellIdPerType();
-      int *profile=new int [ids.size()];
-      std::transform(ids.begin(),ids.end(),profile,std::bind2nd(std::plus<int>(),1));
-      MEDprofileWr(fid,profileName,ids.size(),profile);
-      delete [] profile;
-      MEDfieldValueWithProfileWr(fid,f->getName(),numdt,numo,dt,MED_NODE_CELL,typmai3[(int)(*iter).getType()],MED_COMPACT_PFLMODE,profileName,
-                                 MED_NO_LOCALIZATION,MED_FULL_INTERLACE,MED_ALL_CONSTITUENT,(*iter).getNbOfTuple(),(const unsigned char*)pt);
-      pt+=(*iter).getNbOfTuple()*nbComp;
-    }
-  MEDfileClose(fid);
-}*/
-
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.hxx
deleted file mode 100644 (file)
index 53ec045..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef MEDPARTITIONER_MESHCOLLECTIONDRIVER_HXX_
-#define MEDPARTITIONER_MESHCOLLECTIONDRIVER_HXX_
-
-#include "MEDPARTITIONER.hxx"
-
-#include <vector>
-#include <string>
-
-namespace MEDPARTITIONER
-{
-  class MESHCollection;
-  class ParaDomainSelector;
-
-  class MEDPARTITIONER_EXPORT MESHCollectionDriver
-  {
-  public:
-
-    MESHCollectionDriver(MESHCollection*);
-    virtual ~MESHCollectionDriver(){}
-
-    virtual int read(const char*, ParaDomainSelector* sel=0)=0;
-    int readSeq(const char*,const char*);
-
-    virtual void write(const char*, ParaDomainSelector* sel=0)=0;
-
-  protected:
-
-    void readSubdomain(std::vector<int*>& cellglobal,
-                       std::vector<int*>& faceglobal,
-                       std::vector<int*>& nodeglobal, int idomain);
-    void readSubdomain(int idomain);
-    void writeMedFile(int idomain, const std::string& distfilename);
-
-
-    MESHCollection* _collection;
-
-    //to Globals
-    //std::vector <std::string> _filename;
-    //std::vector <std::string> _meshname;
-
-  };
-
-}
-
-
-#endif /*MESHCOLLECTIONDRIVER_HXX_*/
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.H b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.H
deleted file mode 100644 (file)
index c253b58..0000000
+++ /dev/null
@@ -1,66 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef MEDSPLITTER_MESHCOLLECTIONMEDASCIIDRIVER_H
-#define MEDSPLITTER_MESHCOLLECTIONMEDASCIIDRIVER_H
-
-
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-
-/*!reads a distributed field
- * 
- * \param fields vector of fields (one field per subdomain)
- * \param fieldname name of the field
- * \param itnumber number of iteration
- * \param ordernumber internal number inside the iteration
- * */
-template <class T>
-void MESHCollectionMedAsciiDriver::_readFields(vector<MEDMEM::FIELD<T>* >& fields,char* fieldname, int itnumber, int ordernumber)
-{
-  for (int i=0; i<_collection->getMesh().size(); i++)
-  {
-    char filename[256];
-    strcpy(filename,_filename[i].c_str());
-    cout << "maillage : " << filename << " champ : " << fieldname << endl;
-    //    MEDMEM::FIELD<T>* field = new MEDMEM::FIELD<T>(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber);
-    fields.push_back (new MEDMEM::FIELD<T>(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber));
-  }
-}
-
-
-/*!writes a distributed field
- * 
- * \param fields vector of fields (one field per subdomain)
- * \param fieldname name of the field
- * */
-template <class T>
-void MESHCollectionMedAsciiDriver::_writeFields(vector<MEDMEM::FIELD<T>* >& fields,char* fieldname)
-{
-  for (int i=0; i<_collection->getMesh().size(); i++)
-  {
-    char filename[256];
-    strcpy(filename,_filename[i].c_str());
-    int driverid = fields[i]->addDriver(MEDMEM::MED_DRIVER, filename, fieldname);
-    fields[i]->write(driverid);    
-  }
-}
-
-#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.cxx
deleted file mode 100644 (file)
index 515b1f8..0000000
+++ /dev/null
@@ -1,182 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include <vector>
-#include <string>
-#include <map>
-#include <set>
-
-#include <iostream>
-#include <fstream>
-
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-
-#include <sys/time.h>
-
-#include "MEDCouplingUMesh.hxx"
-#include "MEDLoader.hxx"
-
-//MEDPARTITIONER includes
-#include "MEDPARTITIONER_ParallelTopology.hxx"
-#include "MEDPARTITIONER_MESHCollectionDriver.hxx"
-#include "MEDPARTITIONER_MESHCollection.hxx"
-#include "MEDPARTITIONER_MESHCollectionMedAsciiDriver.hxx"
-#include "MEDPARTITIONER_ParaDomainSelector.hxx"
-#include "MEDPARTITIONER_utils.hxx"
-
-using namespace MEDPARTITIONER;
-using namespace std;
-
-//template inclusion
-//#include "MEDPARTITIONER_MESHCollectionMedAsciiDriver.H"
-
-
-MESHCollectionMedAsciiDriver::MESHCollectionMedAsciiDriver(MESHCollection* collection):MESHCollectionDriver(collection)
-{
-}
-
-/*!reads a MED File v>=2.3
- * and mounts the corresponding meshes in memory
- * the connect zones are created from the joints
- * 
- *\param filename ascii file containing the list of MED v2.3 files
- * */
-
-int MESHCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* domainSelector)
-{
-  //distributed meshes
-  vector<int*> cellglobal;
-  vector<int*> nodeglobal;
-  vector<int*> faceglobal;
-  int nbdomain;
-
-  // reading ascii master file
-  try
-  {
-    ifstream asciiinput(filename);
-    if (!asciiinput) throw INTERP_KERNEL::Exception(LOCALIZED("Master ASCII File does not exist"));
-    char charbuffer[512];
-    asciiinput.getline(charbuffer,512);
-
-    while (charbuffer[0]=='#')
-    {
-      asciiinput.getline(charbuffer,512);
-    }
-
-    //reading number of domains
-    nbdomain=atoi(charbuffer);
-    //cout << "nb domain "<<nbdomain<<endl;
-    //    asciiinput>>nbdomain;
-    MyGlobals::_fileNames.resize(nbdomain);
-    MyGlobals::_meshNames.resize(nbdomain);
-    (_collection->getMesh()).resize(nbdomain);
-    cellglobal.resize(nbdomain);
-    nodeglobal.resize(nbdomain);
-    faceglobal.resize(nbdomain);
-
-    if (nbdomain == 0) throw INTERP_KERNEL::Exception(LOCALIZED("Empty ASCII master file"));
-    for (int i=0; i<nbdomain;i++)
-    {
-      //reading information about the domain
-      string mesh;
-      int idomain;
-      string host;
-      cellglobal[i]=0;
-      faceglobal[i]=0;
-      nodeglobal[i]=0;
-      
-      asciiinput >> mesh >> idomain >> MyGlobals::_meshNames[i] >> host >> MyGlobals::_fileNames[i];
-
-      //Setting the name of the global mesh (which should be is the same for all the subdomains)
-      if (i==0)
-        _collection->setName(mesh);
-
-      if (idomain!=i+1)
-      {
-        throw INTERP_KERNEL::Exception(LOCALIZED("domain must be written from 1 to N in ASCII file descriptor"));
-      }
-      if ( !domainSelector || domainSelector->isMyDomain(i))
-        readSubdomain(cellglobal,faceglobal,nodeglobal, i);
-
-    }//loop on domains
-  }//of try
-  catch(...)
-  {
-    throw INTERP_KERNEL::Exception(LOCALIZED("I/O error reading parallel MED file"));
-  }
-
-  //creation of topology from mesh and connect zones
-  ParallelTopology* aPT = new ParallelTopology
-    ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
-  _collection->setTopology(aPT);
-
-  for (int i=0; i<nbdomain; i++)
-  {
-    if (cellglobal[i]!=0) delete[] cellglobal[i];
-    if (nodeglobal[i]!=0) delete[] nodeglobal[i];
-    if (faceglobal[i]!=0) delete[] faceglobal[i];
-  }
-  return 0;
-}
-
-
-/*! writes the collection of meshes in a MED v2.3 file
- * with the connect zones being written as joints
- * \param filename name of the ascii file containing the meshes description
- */
-void MESHCollectionMedAsciiDriver::write(const char* filename, ParaDomainSelector* domainSelector)
-{
-  int nbdomains=_collection->getMesh().size();
-  vector<string> filenames;
-  filenames.resize(nbdomains);
-
-  //loop on the domains
-  for (int idomain=0; idomain<nbdomains; idomain++)
-  {
-    string distfilename;
-    ostringstream suffix;
-    suffix<<filename<<idomain+1<<".med";
-    distfilename=suffix.str();
-    filenames[idomain]=distfilename;
-
-    if ( !domainSelector || domainSelector->isMyDomain( idomain ) )
-    {
-      if ( !_collection->getMesh()[idomain]->getNumberOfCells()==0 ) continue;//empty domain
-      MEDLoader::WriteUMesh(distfilename.c_str(),(_collection->getMesh())[idomain],true);
-      //      writeSubdomain(idomain, nbdomains, distfilename.c_str(), domainSelector);
-    }
-  }
-
-  // write master file
-  if ( !domainSelector || domainSelector->rank() == 0 )
-  {
-    ofstream file(filename);
-    file << "#MED Fichier V 2.3"<<" "<<endl;
-    file << "#"<<" "<<endl;
-    file << _collection->getMesh().size()<<" "<<endl;
-
-    for (int idomain=0; idomain<nbdomains; idomain++)
-      file << _collection->getName() <<" "<< idomain+1 << " "
-           << (_collection->getMesh())[idomain]->getName() << " localhost "
-           << filenames[idomain] << " "<<endl;
-  }
-
-}
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedAsciiDriver.hxx
deleted file mode 100644 (file)
index 6f1be71..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef MESHCOLLECTIONMEDASCIIDRIVER_HXX_
-#define MESHCOLLECTIONMEDASCIIDRIVER_HXX_
-
-#include "MEDPARTITIONER_MESHCollectionDriver.hxx"
-
-namespace MEDPARTITIONER
-{
-  class MESHCollection;
-
-  class MESHCollectionMedAsciiDriver:public MESHCollectionDriver
-  {
-  public:
-
-    MESHCollectionMedAsciiDriver(MESHCollection*);
-    virtual ~MESHCollectionMedAsciiDriver(){}
-
-    int read(const char*, ParaDomainSelector* sel=0);
-
-    void write(const char*, ParaDomainSelector* sel=0);
-
-//     void readFields(vector <MEDMEM::FIELD<int> *>& filenames, char* fieldname,
-//                     int itnumber, int ordernumber)
-//     {
-//       _readFields(filenames,fieldname,itnumber,ordernumber);
-//     }
-//     void readFields(vector <MEDMEM::FIELD<double> *>& filenames, char* fieldname,
-//                     int itnumber, int ordernumber)
-//     {
-//       _readFields(filenames,fieldname,itnumber,ordernumber);
-//     }
-
-//     void writeFields(vector <MEDMEM::FIELD<int> *>& filenames, char* fieldname)
-//     {
-//       _writeFields( filenames, fieldname);
-//     }
-
-//     void writeFields(vector <MEDMEM::FIELD<double> *>& filenames, char* fieldname)
-//     {
-//       _writeFields( filenames, fieldname);
-//     }
-
-
-  private :
-//     template <class T> void _readFields(vector <MEDMEM::FIELD<T> *>& filenames, char* fieldname,
-//                                         int itnumber, int ordernumber);
-
-//     template <class T>
-//     void _writeFields(vector <MEDMEM::FIELD<T> *>& filenames, char* fieldname);
-
-
-
-    std::string _master_filename;
-  };
-
-}
-
-
-#endif /*MESHCOLLECTIONDRIVER_HXX_*/
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.H b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.H
deleted file mode 100644 (file)
index 54b9c18..0000000
+++ /dev/null
@@ -1,122 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef MEDSPLITTER_MESHCOLLECTIONMEDXMLDRIVER_H
-#define MEDSPLITTER_MESHCOLLECTIONMEDXMLDRIVER_H
-
-
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-
-
-
-/*!reads a distributed field
- * 
- * \param fields vector of fields (one field per subdomain)
- * \param fieldname name of the field
- * \param itnumber number of iteration
- * \param ordernumber internal number inside the iteration
- * */
-template <class T>
-void MESHCollectionMedXMLDriver::_readFields(vector<MEDMEM::FIELD<T>* >& fields,char* fieldname, int itnumber, int ordernumber)
-{
-  for (int i=0; i<_collection->getMesh().size(); i++)
-  {
-    char filename[256];
-    strcpy(filename,_filename[i].c_str());
-    cout << "maillage : " << filename << " champ : " << fieldname << endl;
-    //    MEDMEM::FIELD<T>* field = new MEDMEM::FIELD<T>(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber);
-    fields.push_back (new MEDMEM::FIELD<T>(MEDMEM::MED_DRIVER,filename,fieldname,itnumber,ordernumber));
-  }
-}
-
-
-/*!writes a distributed field
- * 
- * \param fields vector of fields (one field per subdomain)
- * \param fieldname name of the field
- * */
-template <class T>
-void MESHCollectionMedXMLDriver::_writeFields(vector<MEDMEM::FIELD<T>* >& fields,const char* fieldname)
-{
-  xmlDocPtr master_doc=xmlParseFile(_master_filename.c_str());
-
-  if (!master_doc)    
-    throw MEDEXCEPTION("MEDSPLITTER writeFields - Master File does not exist");
-
-  //number of domains
-
-  xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc);
-  xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//mapping/mesh", xpathCtx);
-  //assuming there is only one mesh in the XML file
-  xmlNodePtr mesh_node= xpathObj->nodesetval->nodeTab[0];
-
-  //adds the field to the master file if necessary
-  bool exist_field =false;
-  xpathObj = xmlXPathEvalExpression(BAD_CAST "//mapping/mesh/field", xpathCtx);
-  //assuming there is only one mesh in the XML file
-  int field_nr =  xpathObj->nodesetval->nodeNr;
-  for (int i=0; i<field_nr; i++)
-  {
-    //field node has only one property
-    if ( strcmp((const char*)xpathObj->nodesetval->nodeTab[i]->properties->children->content, fieldname)==0)
-      exist_field = true;
-  }
-
-  xmlNodePtr field_node;
-  if (!exist_field)
-  {
-    field_node = xmlNewChild(mesh_node, 0, BAD_CAST "field",0);
-    xmlNewProp(field_node,BAD_CAST "name",BAD_CAST fieldname);
-  }
-
-
-  for (int i=0; i<_collection->getMesh().size(); i++)
-  {
-    char filename[256];
-    strcpy(filename,_filename[i].c_str());
-    int driverid = fields[i]->addDriver(MEDMEM::MED_DRIVER, filename, fieldname);
-    fields[i]->write(driverid);
-
-    //adds the partition to the master file if the field had not been 
-    //added already
-    if (!exist_field)
-    {
-      xmlNodePtr chunk_node= xmlNewChild(field_node,0,BAD_CAST "chunk",0);
-      char id[8];
-      sprintf(id,"%d",i+1);
-      xmlNewProp(chunk_node,BAD_CAST "subdomain",BAD_CAST id);
-      //xmlNewProp(chunk_node,BAD_CAST "name", BAD_CAST fieldname);
-      //xmlNodePtr fieldname_node=
-      xmlNewChild(chunk_node,0,BAD_CAST "name", BAD_CAST fieldname);
-    }
-  }
-  //Writing file
-  xmlKeepBlanksDefault(0);
-  xmlSaveFormatFileEnc(_master_filename.c_str(), master_doc, "UTF-8", 1);
-
-  //Clean up
-  xmlXPathFreeContext(xpathCtx); 
-  xmlFreeDoc(master_doc);
-  //xmlCleanupParser();
-
-}
-
-#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.cxx
deleted file mode 100644 (file)
index 49c2ac3..0000000
+++ /dev/null
@@ -1,335 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include <vector>
-#include <string>
-#include <map>
-#include <set>
-#include <cstring>
-#include <iostream>
-#include <fstream>
-#include <sstream>
-#include <libxml/tree.h>
-#include <libxml/parser.h>
-#include <libxml/xpath.h>
-#include <libxml/xpathInternals.h>
-
-#include <sys/time.h>
-
-//MEDSPLITTER includes
-#include "MEDCouplingUMesh.hxx"
-#include "MEDLoader.hxx"
-#include "MEDFileMesh.hxx"
-#include "MEDPARTITIONER_ParallelTopology.hxx"
-#include "MEDPARTITIONER_MESHCollectionDriver.hxx"
-#include "MEDPARTITIONER_MESHCollection.hxx"
-#include "MEDPARTITIONER_MESHCollectionMedXMLDriver.hxx"
-#include "MEDPARTITIONER_ParaDomainSelector.hxx"
-#include "MEDPARTITIONER_utils.hxx"
-
-using namespace MEDPARTITIONER;
-using namespace std;
-
-//template inclusion
-//#include "MEDPARTITIONER_MESHCollectionMedXMLDriver.H"
-
-/*!\class MESHCollectionMedXMLDriver
- *
- *\brief Driver for MED 3.2 files having XML master files
- *
- * Driver for reading and writing distributed files
- * for which the master file is written in an XML format compliant with
- * the MED 3.2 specification.
- * The reading and writing of the meshes and fields are apart :
- * the meshes must always be written/read before the fields. Reading/Writing fields
- * is optional and is done field after field. API for reading/writing fields
- * is written with a template so that MEDMEM::FIELD<int> and MEDMEM::FIELD<double>
- * can be conveniently handled.
-*/
-
-MESHCollectionMedXMLDriver::MESHCollectionMedXMLDriver(MESHCollection* collection):MESHCollectionDriver(collection)
-{
-}
-
-/*!reads a MED File XML Master File v>=2.3
- * and mounts the corresponding meshes in memory
- * the connect zones are created from the joints
- * 
- *\param filename XML file containing the list of MED v2.3 files
- * */
-
-int MESHCollectionMedXMLDriver::read(const char* filename, ParaDomainSelector* domainSelector)
-{
-
-  //distributed meshes //cvwat02
-  /*cvw 
-  vector<int*> cellglobal;
-  vector<int*> nodeglobal;
-  vector<int*> faceglobal;*/
-
-  int nbdomain;
-
-  _master_filename=filename;
-
-  // reading ascii master file
-  try{
-    // Setting up the XML tree corresponding to filename
-    xmlDocPtr master_doc=xmlParseFile(filename);
-
-    if (!master_doc)
-      throw INTERP_KERNEL::Exception(LOCALIZED("XML Master File does not exist or is not compliant with XML scheme"));
-
-    ////////////////////
-    //number of domains
-    ////////////////////
-    xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc);
-    xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//splitting/subdomain", xpathCtx);
-    if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0)
-      throw INTERP_KERNEL::Exception(LOCALIZED("XML Master File does not contain /MED/splitting/subdomain node"));
-
-    /* as subdomain has only one property which is "number"
-     * it suffices to take the content of its first child */
-    const char* mystring = (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content;
-    sscanf(mystring, "%d", &nbdomain);
-
-    //////////////////
-    //mesh name
-    //////////////////
-    xmlXPathFreeObject(xpathObj);
-    xpathObj = xmlXPathEvalExpression(BAD_CAST "//content/mesh", xpathCtx);
-    if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0)
-      throw INTERP_KERNEL::Exception(LOCALIZED("XML Master File does not contain /MED/content/mesh node"));
-    _collection->setName( (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content);
-
-    //cout << "nb domain " << nbdomain << endl;
-    MyGlobals::_fileNames.resize(nbdomain);
-    MyGlobals::_meshNames.resize(nbdomain);
-    (_collection->getMesh()).resize(nbdomain);
-    (_collection->getFaceMesh()).resize(nbdomain);
-    (_collection->getCellFamilyIds()).resize(nbdomain);
-    (_collection->getFaceFamilyIds()).resize(nbdomain);
-
-    /*cvw
-    cellglobal.resize(nbdomain);
-    nodeglobal.resize(nbdomain);
-    faceglobal.resize(nbdomain);
-    */
-
-    // retrieving the node which contains the file names
-    const char filechar[]="//files/subfile";
-    xmlXPathFreeObject(xpathObj);
-    xpathObj = xmlXPathEvalExpression(BAD_CAST filechar, xpathCtx);
-    if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0)
-      throw INTERP_KERNEL::Exception(LOCALIZED("XML Master File does not contain /MED/files/subfile nodes"));
-    int nbfiles = xpathObj->nodesetval ->nodeNr;
-    
-    for (int i=0; i<nbfiles;i++)
-    {
-      //reading information about the domain
-      string host;
-      /*cvw
-      cellglobal[i]=0;
-      faceglobal[i]=0;
-      nodeglobal[i]=0;
-      */
-
-      ////////////////////////////
-      //reading file names 
-      ////////////////////////////
-      std::ostringstream name_search_string;
-      name_search_string<<"//files/subfile[@id=\""<<i+1<<"\"]/name";
-      //cout <<name_search_string.str()<<endl;
-      xmlXPathObjectPtr xpathObjfilename =
-        xmlXPathEvalExpression(BAD_CAST name_search_string.str().c_str(),xpathCtx);
-      if (xpathObjfilename->nodesetval ==0)
-        throw INTERP_KERNEL::Exception(LOCALIZED("Error retrieving a file name from subfile of XML Master File"));
-      MyGlobals::_fileNames[i]=(const char*)xpathObjfilename->nodesetval->nodeTab[0]->children->content;
-
-      ////////////////////////////////
-      //reading the local mesh names
-      ////////////////////////////////
-      ostringstream mesh_search_string;
-      mesh_search_string<<"//mapping/mesh/chunk[@subdomain=\""<<i+1<<"\"]/name";
-
-      xmlXPathObjectPtr xpathMeshObj = xmlXPathEvalExpression(BAD_CAST mesh_search_string.str().c_str(),xpathCtx);
-      if (xpathMeshObj->nodesetval ==0)
-        throw INTERP_KERNEL::Exception(LOCALIZED("Error retrieving mesh name from chunk of XML Master File"));
-      MyGlobals::_meshNames[i]=(const char*)xpathMeshObj->nodesetval->nodeTab[0]->children->content;
-
-      if ( !domainSelector || domainSelector->isMyDomain(i))
-        readSubdomain(i);  //cvwat03
-        //cvw readSubdomain(cellglobal, faceglobal, nodeglobal, i);  //cvwat03
-      xmlXPathFreeObject(xpathObjfilename);
-      xmlXPathFreeObject(xpathMeshObj);
-    }//loop on domains
-
-    // LIBXML cleanup
-    xmlXPathFreeObject(xpathObj); 
-    xmlXPathFreeContext(xpathCtx); 
-    xmlFreeDoc(master_doc); 
-
-  }//of try
-  catch(...)
-  {
-    throw INTERP_KERNEL::Exception(LOCALIZED("I/O error reading parallel MED file"));
-  }
-
-
-  ParallelTopology* aPT = new ParallelTopology(_collection->getMesh());
-  //creation of topology from mesh and connect zones
-  if ( _collection->isParallelMode() )
-  {
-    //to know nb of cells on each proc to compute global cell ids from locally global
-    domainSelector->gatherNbOf(_collection->getMesh());
-  }
-  /*cvw
-  ParallelTopology* aPT = new ParallelTopology
-    ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
-  */
-  _collection->setTopology(aPT);
-  _collection->setDomainNames(_collection->getName());
-  /*cvw
-  for (int i=0; i<nbdomain; i++)
-  {
-    if (cellglobal[i]!=0) delete[] cellglobal[i];
-    if (nodeglobal[i]!=0) delete[] nodeglobal[i];
-    if (faceglobal[i]!=0) delete[] faceglobal[i];
-  }*/
-  
-  return 0;
-}
-
-
-/*! writes the collection of meshes in a 
- * MED v2.3 XML file
- * with the connect zones being written as joints
- * \param filename name of the XML file containing the meshes description
- */
-void MESHCollectionMedXMLDriver::write(const char* filename, ParaDomainSelector* domainSelector)
-{
-  xmlDocPtr master_doc = 0;
-  xmlNodePtr root_node = 0, node, node2;
-  //  xmlDTDPtr dtd = 0;
-
-  char buff[256];
-
-  //Creating the XML document
-
-  master_doc = xmlNewDoc(BAD_CAST "1.0");
-  root_node = xmlNewNode(0, BAD_CAST "root");
-  xmlDocSetRootElement(master_doc,root_node);
-
-  //Creating child nodes
-
-  // Version tag
-  node = xmlNewChild(root_node, 0, BAD_CAST "version",0);
-  xmlNewProp(node, BAD_CAST "maj", BAD_CAST "2");
-  xmlNewProp(node, BAD_CAST "min", BAD_CAST "3");
-  xmlNewProp(node, BAD_CAST "ver", BAD_CAST "1");
-
-  //Description tag
-
-  time_t present;
-  time( &present);
-  struct tm *time_asc = localtime(&present);
-  char date[6];
-  sprintf(date,"%02d%02d%02d",time_asc->tm_year
-          ,time_asc->tm_mon+1
-          ,time_asc->tm_mday);
-
-  node = xmlNewChild(root_node,0, BAD_CAST "description",0);
-
-  xmlNewProp(node, BAD_CAST "what", BAD_CAST _collection->getDescription().c_str());
-  xmlNewProp(node, BAD_CAST "when", BAD_CAST date);
-
-  //Content tag
-  node =xmlNewChild(root_node,0, BAD_CAST "content",0);
-  node2 = xmlNewChild(node, 0, BAD_CAST "mesh",0);
-  xmlNewProp(node2, BAD_CAST "name", BAD_CAST _collection->getName().c_str());
-
-  //Splitting tag
-  node=xmlNewChild(root_node,0,BAD_CAST "splitting",0);
-  node2=xmlNewChild(node,0,BAD_CAST "subdomain",0);
-  sprintf(buff, "%d", _collection->getMesh().size());
-  xmlNewProp(node2, BAD_CAST "number", BAD_CAST buff);
-  node2=xmlNewChild(node,0,BAD_CAST "global_numbering",0);
-  xmlNewProp(node2, BAD_CAST "present", BAD_CAST "yes");
-
-  //Files tag
-  xmlNodePtr file_node=xmlNewChild(root_node,0,BAD_CAST "files",0);
-
-  //Mapping tag
-  node = xmlNewChild(root_node,0,BAD_CAST "mapping",0);
-  xmlNodePtr mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0);
-  xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST _collection->getName().c_str());
-
-  int nbdomains= _collection->getMesh().size();
-  //vector<string> filenames;
-  //filenames.resize(nbdomains);
-
-  //loop on the domains
-  string finalMeshName=extractFromDescription(MyGlobals::_generalInformations[0], "finalMeshName=");
-  for (int idomain=nbdomains-1; idomain>=0;idomain--)
-  {
-    string distfilename;
-    ostringstream suffix;
-    suffix<<filename<<idomain+1<<".med";
-    distfilename=suffix.str();
-    //filenames[idomain]=distfilename;
-
-    if ( !domainSelector || domainSelector->isMyDomain( idomain ) )
-    {
-      if ( (_collection->getMesh())[idomain]->getNumberOfCells()==0 ) continue; //empty domain
-      if (MyGlobals::_verbose>1)
-        cout<<"proc "<<domainSelector->rank()<<" : writeMedFile "<<distfilename
-            << " "<<(_collection->getMesh())[idomain]->getNumberOfCells()<<" cells"
-            << " "<<(_collection->getFaceMesh())[idomain]->getNumberOfCells()<<" faces"
-            << " "<<(_collection->getMesh())[idomain]->getNumberOfNodes()<<" nodes"<<endl;
-      writeMedFile(idomain,distfilename);
-    }
-              
-    if (domainSelector->rank()==0)
-    {
-      //updating the ascii description file
-      node = xmlNewChild(file_node, 0, BAD_CAST "subfile",0);
-      sprintf (buff,"%d",idomain+1);
-      xmlNewProp(node, BAD_CAST "id", BAD_CAST buff);
-      xmlNewChild(node,0,BAD_CAST "name",BAD_CAST distfilename.c_str());
-      xmlNewChild(node,0,BAD_CAST "machine",BAD_CAST "localhost");
-      
-      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());
-    }
-  }
-  
-  //create the ascii description file
-  if (domainSelector->rank()==0)
-  {
-    string myfile(filename);
-    myfile.append(".xml");
-    _master_filename=myfile;
-    if ( !domainSelector || domainSelector->rank() == 0 )
-      xmlSaveFormatFileEnc(myfile.c_str(), master_doc, "UTF-8", 1);
-    //xmlFreeDoc(master_doc);
-    //xmlCleanupParser();
-  }
-  xmlFreeDoc(master_doc);
-  xmlCleanupParser();
-}
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionMedXMLDriver.hxx
deleted file mode 100644 (file)
index 8a946b6..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef MESHCOLLECTIONMEDXMLDRIVER_HXX_
-#define MESHCOLLECTIONMEDXMLDRIVER_HXX_
-
-#include "MEDPARTITIONER_MESHCollectionDriver.hxx"
-
-namespace MEDPARTITIONER
-{
-  class MESHCollection;
-
-  class MESHCollectionMedXMLDriver:public MESHCollectionDriver
-  {
-  public:
-
-    MESHCollectionMedXMLDriver(MESHCollection*);
-    virtual ~MESHCollectionMedXMLDriver(){}
-
-
-    int read(const char*, ParaDomainSelector* sel=0);
-
-    void write(const char*, ParaDomainSelector* sel=0);
-
-//     void readFields(vector <MEDMEM::FIELD<int> *>& filenames, char* fieldname,
-//                     int itnumber, int ordernumber)
-//     {
-//       _readFields(filenames,fieldname,itnumber,ordernumber);
-//     }
-//     void readFields(vector <MEDMEM::FIELD<double> *>& filenames, char* fieldname,
-//                     int itnumber, int ordernumber)
-//     {
-//       _readFields(filenames,fieldname,itnumber,ordernumber);
-//     }
-
-//     void writeFields(vector <MEDMEM::FIELD<double> *>& filenames, char* fieldname)
-//     {
-//       _writeFields( filenames, fieldname);
-//     }
-//     void writeFields(vector <MEDMEM::FIELD<int> *>& filenames, char* fieldname)
-//     {
-//       _writeFields( filenames, fieldname);
-//     }
-
-
-
-  private :
-
- //    template <class T> void _readFields(vector <MEDMEM::FIELD<T> *>& filenames, char* fieldname,
-//                                         int itnumber, int ordernumber);
-
-//     template <class T>
-//     void _writeFields(vector <MEDMEM::FIELD<T> *>& filenames, char* fieldname);
-
-    std::string _master_filename;
-  };
-
-}
-
-
-#endif /*MESHCOLLECTIONDRIVER_HXX_*/
diff --git a/src/MEDPartitioner/MEDPARTITIONER_METISGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_METISGraph.cxx
deleted file mode 100644 (file)
index 84731f4..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#ifdef ENABLE_PARMETIS
-#include <parmetis.h>
-#endif
-extern "C" {
-#include <metis.h>
-}
-#include "MEDPARTITIONER_METISGraph.hxx"
-#include "MEDPARTITIONER_ParaDomainSelector.hxx"
-#include "MEDPARTITIONER_utils.hxx"
-#include "InterpKernelException.hxx"
-
-#include <iostream>
-
-using namespace MEDPARTITIONER;
-
-METISGraph::METISGraph():Graph()
-{
-}
-
-METISGraph::METISGraph(MEDPARTITIONER::MEDSKYLINEARRAY* graph, int* edgeweight)
-  :Graph(graph,edgeweight)
-{
-}
-
-METISGraph::~METISGraph()
-{
-}
-
-void METISGraph::partGraph(int ndomain, //cvwat10
-                           const std::string& options_string,
-                           ParaDomainSelector* parallelizer)
-{
-  using std::vector;
-  vector<int> ran,vx,va; //for randomize
-  
-  if (MyGlobals::_verbose>10) cout<<"proc "<<MyGlobals::_rank<<" : METISGraph::partGraph"<<endl;
-  
-  // number of graph vertices
-  int n=_graph->getNumberOf();
-  //graph
-  int * xadj=const_cast<int*>(_graph->getIndex());
-  int * adjncy=const_cast<int*>(_graph->getValue());
-  //constraints
-  int * vwgt=_cellweight;
-  int * adjwgt=_edgeweight;
-  int wgtflag=(_edgeweight!=0)?1:0+(_cellweight!=0)?2:0;
-  //base 0 or 1
-  int base=0;
-  //ndomain
-  int nparts=ndomain;
-  //options
-  /*
-  (0=default_option,option,random_seed) see defs.h
-  #define PMV3_OPTION_DBGLVL   1
-  #define PMV3_OPTION_SEED     2
-  #define PMV3_OPTION_IPART    3
-  #define PMV3_OPTION_PSR              3
-  seems no changes int options[4]={1,0,33,0}; //test for a random seed of 33
-  */
-  int options[4]={0,0,0,0};
-  // output parameters
-  int edgecut;
-  int* partition=new int[n];
-
-  //if (MyGlobals::_verbose>10) cout<<"proc "<<MyGlobals::_rank<<" : METISGraph::partGraph n="<<n<<endl;
-  if (nparts >1)
-  {
-    if ( parallelizer )
-    {
-#ifdef ENABLE_PARMETIS
-      // distribution of vertices of the graph among the processors
-      if (MyGlobals::_verbose>100) 
-        cout<<"proc "<<MyGlobals::_rank
-            <<" : METISGraph::partGraph ParMETIS_PartKway"<<endl;
-      int * vtxdist=parallelizer->getProcVtxdist();
-      MPI_Comm comm=MPI_COMM_WORLD;
-      try
-      {
-        if (MyGlobals::_verbose>200) 
-        {
-          cout<<"proc "<<MyGlobals::_rank<<" : vtxdist :";
-          for (int i=0; i<MyGlobals::_world_size+1; ++i) cout<<vtxdist[i]<<" ";
-          cout<<endl;
-          
-          int lgxadj=vtxdist[MyGlobals::_rank+1]-vtxdist[MyGlobals::_rank];
-          //cout<<"lgxadj "<<lgxadj<<" "<<n<<endl;
-          
-          if (lgxadj>0)
-          {
-            cout<<"\nproc "<<MyGlobals::_rank<<" : lgxadj "<<lgxadj<<" lgadj "<<xadj[lgxadj+1]<<endl;
-            for (int i=0; i<10; ++i) cout<<xadj[i]<<" ";
-            cout<<"... "<<xadj[lgxadj]<<endl;
-            for (int i=0; i<15; ++i) cout<<adjncy[i]<<" ";
-            int ll=xadj[lgxadj]-1;
-            cout<<"... ["<<ll<<"] "<<adjncy[ll-1]<<" "<<adjncy[ll]<<endl;
-            /*for (int i=0; i<=ll; ++i) {
-              if (adjncy[i]<0) cout<<"***cvw00 error: adjncy[i]<0 "<<i<<endl;
-            }*/
-            int imaxx=0;
-            //for (int ilgxadj=0; ilgxadj<lgxadj; ilgxadj++)
-            for (int ilgxadj=0; ilgxadj<lgxadj; ilgxadj++)
-            {
-              int ilg=xadj[ilgxadj+1]-xadj[ilgxadj];
-              /*if (ilg<0) cout<<"***cvw01 error: ilg<0 in xadj "<<ilgxadj<<endl;
-              if (MyGlobals::_is0verbose>1000) 
-              {
-                cout<<"\n -cell "<<ilgxadj<<" "<<ilg<<" :";
-                for (int i=0; i<ilg; i++) cout<<" "<<adjncy[xadj[ilgxadj]+i];
-              }*/
-              if (ilg>imaxx) imaxx=ilg;
-            }
-            cout<<"\nproc "<<MyGlobals::_rank
-                <<" : on "<<lgxadj<<" cells, max neighbourg number (...for one cell) is "<<imaxx<<endl;
-          }
-          
-        }
-        if ((MyGlobals::_randomize!=0 || MyGlobals::_atomize!=0) && MyGlobals::_world_size==1)
-        {
-          //randomize initially was for test on ParMETIS error (sometimes)
-          //due to : seems no changes int options[4]={1,0,33,0}; //test for a random seed of 33
-          //it was keeped
-          ran=createRandomSize(n);
-          randomizeAdj(&xadj[0],&adjncy[0],ran,vx,va);
-          ParMETIS_PartKway( //cvwat11
-              vtxdist, &vx[0], &va[0], vwgt, 
-              adjwgt, &wgtflag, &base, &nparts, options, 
-              &edgecut, partition, &comm );
-        }
-        else
-        {
-          //MPI_Barrier(MPI_COMM_WORLD);
-          //cout<<"proc "<<MyGlobals::_rank<<" : barrier ParMETIS_PartKway done"<<endl;
-          ParMETIS_PartKway( //cvwat11
-              vtxdist, xadj, adjncy, vwgt, 
-              adjwgt, &wgtflag, &base, &nparts, options, 
-              &edgecut, partition, &comm );
-        }
-
-/*doc from parmetis.h
-       void __cdecl ParMETIS_PartKway(
-             idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, 
-                  idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, int *options, 
-             int *edgecut, idxtype *part, MPI_Comm *comm);
-
-       void __cdecl ParMETIS_V3_PartKway(
-             idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, 
-                  idxtype *adjwgt, int *wgtflag, int *numflag, int *ncon, int *nparts, 
-                  float *tpwgts, float *ubvec, int *options, int *edgecut, idxtype *part, 
-                  MPI_Comm *comm);
-*/
-
-      }
-      catch(...)
-      {
-        //helas ParMETIS "Error! Key -2 not found!" not catched...
-        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in ParMETIS_PartKway"));
-      }
-      if (n<8 && nparts==3)
-      {
-        for (int i=0; i<n; i++) partition[i]=i%3;
-      }
-#else
-      throw INTERP_KERNEL::Exception(LOCALIZED("ParMETIS is not available. Check your products, please."));
-#endif
-    //throw INTERP_KERNEL::Exception(LOCALIZED("ParMETIS is not available. Check your products, please."));
-    }
-    else
-    {
-      if (MyGlobals::_verbose>10) 
-        cout<<"proc "<<MyGlobals::_rank
-            <<" : METISGraph::partGraph METIS_PartGraph Recursive or Kway"<<endl;
-      if (options_string != "k")
-        METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag,
-                                 &base, &nparts, options, &edgecut, partition);
-      else
-        METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag,
-                            &base, &nparts, options, &edgecut, partition);
-    }
-  }
-  else
-  {
-    for (int i=0; i<n; i++) partition[i]=0;
-  }
-  
-  vector<int> index(n+1);
-  vector<int> value(n);
-  index[0]=0;
-  if (ran.size()>0 && MyGlobals::_atomize==0) //there is randomize
-  {
-    if (MyGlobals::_is0verbose>100) cout<<"randomize"<<endl;
-    for (int i=0; i<n; i++)
-    {
-      index[i+1]=index[i]+1;
-      value[ran[i]]=partition[i];
-    }
-  }
-  else
-  {
-    for (int i=0; i<n; i++)
-    {
-      index[i+1]=index[i]+1;
-      value[i]=partition[i];
-    }
-  }
-  delete[]partition;
-
-  //creating a skylinearray with no copy of the index and partition array
-  // the fifth argument true specifies that only the pointers are passed 
-  //to the object
-  
-  _partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
-}
-
diff --git a/src/MEDPartitioner/MEDPARTITIONER_METISGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_METISGraph.hxx
deleted file mode 100644 (file)
index 387e695..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef METISGRAPH_HXX_
-#define METISGRAPH_HXX_
-
-#include "MEDPARTITIONER_Graph.hxx"
-#include <string>
-
-namespace MEDPARTITIONER {
-  class MEDSKYLINEARRAY;
-  class MEDPARTITIONER_EXPORT METISGraph:public Graph
-  {
-  public:
-    METISGraph();
-    METISGraph(MEDPARTITIONER::MEDSKYLINEARRAY*, int* edgeweight=0);
-    virtual ~METISGraph();
-    void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0);
-    //private:
-    //  const MEDMEM::MEDSKYLINEARRAY* m_graph;
-  };
-}
-#endif /*METISGRAPH_HXX_*/
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx
new file mode 100644 (file)
index 0000000..5a09f79
--- /dev/null
@@ -0,0 +1,1764 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_MeshCollection.hxx"
+#include "MEDPARTITIONER_MeshCollectionDriver.hxx"
+#include "MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx"
+#include "MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx"
+#include "MEDPARTITIONER_ParallelTopology.hxx"
+#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_JointFinder.hxx"
+#include "MEDPARTITIONER_Graph.hxx"
+#include "MEDPARTITIONER_UserGraph.hxx"
+#include "MEDPARTITIONER_Utils.hxx" 
+
+#include "MEDLoader.hxx"
+#include "MEDCouplingMemArray.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingNormalizedUnstructuredMesh.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "PointLocator3DIntersectorP0P0.hxx"
+#include "BBTree.txx"
+
+#ifdef HAVE_MPI2
+#include <mpi.h>
+#endif
+
+#ifdef ENABLE_METIS
+#include "MEDPARTITIONER_MetisGraph.hxx"
+#endif
+#ifdef ENABLE_SCOTCH
+#include "MEDPARTITIONER_ScotchGraph.hxx"
+#endif
+
+#include <vector>
+#include <string>
+#include <limits>
+#include <set>
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDPARTITIONER;
+
+MeshCollection::MeshCollection()
+  : _topology(0),
+    _owns_topology(false),
+    _driver(0),
+    _domain_selector( 0 ),
+    _i_non_empty_mesh(-1),
+    _driver_type(MEDPARTITIONER::MedXml),
+    _subdomain_boundary_creates(false),
+    _family_splitting(false),
+    _create_empty_groups(false),
+    _joint_finder(0)
+{
+  cout<<"coucou"<<endl;
+}
+
+/*!constructor creating a new mesh collection (mesh series + topology)
+ *from an old collection and a new topology
+ * 
+ * On output, the constructor has built the meshes corresponding to the new mesh collection.
+ * The new topology has been updated so that face and node mappings are included.
+ * The families have been cast to their projections in the new topology.
+ * 
+ * \param initial_collection collection from which the data (coordinates, connectivity) are taken
+ * \param topology topology containing the cell mappings
+ */
+
+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( 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),
+    _joint_finder(0)
+{
+  std::vector<std::vector<std::vector<int> > > new2oldIds(initialCollection.getTopology()->nbDomain());
+  if (MyGlobals::_Verbose>10) std::cout<<"proc "<<MyGlobals::_Rank<<" : castCellMeshes"<<std::endl;
+  castCellMeshes(initialCollection, new2oldIds);
+
+  //defining the name for the collection and the underlying meshes
+  setName(initialCollection.getName());
+
+  /////////////////
+  //treating faces
+  /////////////////
+
+  if (MyGlobals::_Is0verbose) std::cout<<"treating faces"<<std::endl;
+  NodeMapping nodeMapping;
+  //nodeMapping contains the mapping between old nodes and new nodes
+  // (iolddomain,ioldnode)->(inewdomain,inewnode)
+  createNodeMapping(initialCollection, nodeMapping);
+  //cvw std::cout<<"castMeshes"<<std::endl;
+  std::vector<std::vector<std::vector<int> > > new2oldFaceIds;
+  castFaceMeshes(initialCollection, nodeMapping, new2oldFaceIds);
+
+  ////////////////////
+  //treating families
+  ////////////////////
+
+  if (MyGlobals::_Is0verbose) 
+    if (isParallelMode()) std::cout<<"ParallelMode on "<<topology->nbDomain()<<" Domains"<<std::endl;
+    else std::cout<<"NOT ParallelMode on "<<topology->nbDomain()<<" Domains"<<std::endl;
+    
+  if (MyGlobals::_Is0verbose>10) std::cout<<"treating cell and face families"<<std::endl;
+  
+  castIntField2(initialCollection.getMesh(),
+                this->getMesh(),
+                initialCollection.getCellFamilyIds(),
+                "cellFamily");
+  castIntField2(initialCollection.getFaceMesh(), 
+                this->getFaceMesh(),
+                initialCollection.getFaceFamilyIds(),
+                "faceFamily");
+
+  //////////////////
+  //treating groups
+  //////////////////
+  if (MyGlobals::_Is0verbose) std::cout<<"treating groups"<<std::endl;
+  _familyInfo=initialCollection.getFamilyInfo();
+  _groupInfo=initialCollection.getGroupInfo();
+  
+  //////////////////
+  //treating fields
+  //////////////////
+  if (MyGlobals::_Is0verbose) std::cout<<"treating fields"<<std::endl;
+  //cvwat08
+  castAllFields(initialCollection,"cellFieldDouble");
+  //castAllFields(initialCollection,"faceFieldsIds");
+}
+
+/*!
+  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
+*/
+
+void MeshCollection::castCellMeshes(
+                                    MeshCollection& initialCollection,
+                                    std::vector<std::vector<std::vector<int> > >& new2oldIds)
+{
+  if (_topology==0) throw INTERP_KERNEL::Exception(LOCALIZED("Topology has not been defined on call to castCellMeshes"));
+  
+  int nbNewDomain=_topology->nbDomain();
+  int nbOldDomain=initialCollection.getTopology()->nbDomain();
+  
+  _mesh.resize(nbNewDomain);
+  int rank=MyGlobals::_Rank;
+  //if (MyGlobals::_Verbose>10) std::cout<<"proc "<<rank<<" : castCellMeshes splitting"<<std::endl;
+  //splitting the initial domains into smaller bits
+  std::vector<std::vector<ParaMEDMEM::MEDCouplingUMesh*> > splitMeshes;
+  splitMeshes.resize(nbNewDomain);
+  for (int inew=0; inew<nbNewDomain; inew++)
+    {
+      splitMeshes[inew].resize(nbOldDomain, (ParaMEDMEM::MEDCouplingUMesh*)0);
+      /*std::fill( &(splitMeshes[inew][0]), 
+        &(splitMeshes[inew][0])+splitMeshes[inew].size(), 
+        (ParaMEDMEM::MEDCouplingUMesh*)0 );*/
+    }
+  
+  for (int iold=0; iold<nbOldDomain; iold++)
+    {
+      if (!isParallelMode() || initialCollection._domain_selector->isMyDomain(iold))
+        {
+          int size=(initialCollection._mesh)[iold]->getNumberOfCells();
+          std::vector<int> globalids(size);
+          initialCollection.getTopology()->getCellList(iold, &globalids[0]);
+          std::vector<int> ilocalnew(size); //local
+          std::vector<int> ipnew(size);     //idomain old
+          //cvw work locally
+          _topology->convertGlobalCellList(&globalids[0],size,&ilocalnew[0],&ipnew[0]);
+      
+          new2oldIds[iold].resize(nbNewDomain);
+          for (int i=0; i<ilocalnew.size(); i++)
+            {
+              new2oldIds[iold][ipnew[i]].push_back(i);
+            }
+          for (int inew=0; inew<nbNewDomain; inew++)
+            {
+              splitMeshes[inew][iold]=(ParaMEDMEM::MEDCouplingUMesh*)
+                (initialCollection.getMesh())[iold]->buildPartOfMySelf(&new2oldIds[iold][inew][0],
+                                                                       &new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),
+                                                                       true);
+              if (MyGlobals::_Verbose>400)
+                std::cout<<"proc "<<rank<<" : a splitMesh iold inew NbCells "<<iold<<" "<<inew<<" "
+                         <<splitMeshes[inew][iold]->getNumberOfCells()<<std::endl;
+            }
+        }
+    }
+
+  if (isParallelMode())
+    {
+      //if (MyGlobals::_Verbose>300) std::cout<<"proc "<<rank<<" : castCellMeshes send/receive"<<std::endl;
+      for (int iold=0; iold<nbOldDomain; iold++)
+        for(int inew=0; inew<nbNewDomain; inew++)
+          {
+            if (initialCollection._domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)) continue;
+
+            if(initialCollection._domain_selector->isMyDomain(iold))
+              _domain_selector->sendMesh(*(splitMeshes[inew][iold]),_domain_selector->getProcessorID(inew));
+
+            if (_domain_selector->isMyDomain(inew))
+              _domain_selector->recvMesh(splitMeshes[inew][iold],_domain_selector->getProcessorID(iold));
+
+          }
+    }
+  
+  //fusing the split meshes
+  if (MyGlobals::_Verbose>200) std::cout<<"proc "<<rank<<" : castCellMeshes fusing"<<std::endl;
+  for (int inew=0; inew<nbNewDomain ;inew++)
+    {
+      vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
+    
+      for (int i=0; i< splitMeshes[inew].size();i++)
+        if (splitMeshes[inew][i]!=0) 
+          if (splitMeshes[inew][i]->getNumberOfCells()>0)
+            meshes.push_back(splitMeshes[inew][i]);
+
+      if (!isParallelMode()||_domain_selector->isMyDomain(inew))
+        {
+          if (meshes.size()==0) 
+            {
+              _mesh[inew]=CreateEmptyMEDCouplingUMesh();
+              //throw INTERP_KERNEL::Exception(LOCALIZED("castCellMeshes fusing : no meshes"));
+              cout<<"WARNING : castCellMeshes fusing : no meshes try another number of processors"<<endl;
+            }
+          else
+            {
+              _mesh[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(meshes);
+              bool areNodesMerged;
+              int nbNodesMerged;
+              ParaMEDMEM::DataArrayInt* array=_mesh[inew]->mergeNodes(1e-12,areNodesMerged,nbNodesMerged);
+              array->decrRef(); // array is not used in this case
+              _mesh[inew]->zipCoords();
+            }
+        }
+      for (int i=0; i< splitMeshes[inew].size(); i++)
+        if (splitMeshes[inew][i]!=0) splitMeshes[inew][i]->decrRef();
+    }  
+  if (MyGlobals::_Verbose>300) std::cout<<"proc "<<rank<<" : castCellMeshes end fusing"<<std::endl;
+}
+
+/*!
+  \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, NodeMapping& nodeMapping)
+{
+  using std::vector;
+  using std::make_pair;
+  //  NodeMapping reverseNodeMapping;
+  for (int iold=0; iold<initialCollection.getTopology()->nbDomain();iold++)
+    {
+
+      double* bbox;
+      BBTree<3>* tree; 
+      if (!isParallelMode() || (_domain_selector->isMyDomain(iold)))
+        {
+          //      std::map<pair<double,pair<double, double> >, int > nodeClassifier;
+          int nvertices=initialCollection.getMesh(iold)->getNumberOfNodes();
+          bbox=new double[nvertices*6];
+          ParaMEDMEM::DataArrayDouble* coords = initialCollection.getMesh(iold)->getCoords();
+          double* coordsPtr=coords->getPointer();
+
+          for (int i=0; i<nvertices*3;i++)
+            {
+              bbox[i*2]=coordsPtr[i]-1e-6;
+              bbox[i*2+1]=coordsPtr[i]+1e-6;
+            }
+          tree=new BBTree<3>(bbox,0,0,nvertices,1e-9);
+        }
+
+      for (int inew=0; inew<_topology->nbDomain(); inew++) //cvwat12
+        {
+          //sending meshes for parallel computation
+          if (isParallelMode() && _domain_selector->isMyDomain(inew) && !_domain_selector->isMyDomain(iold))  
+            _domain_selector->sendMesh(*(getMesh(inew)), _domain_selector->getProcessorID(iold));
+          else if (isParallelMode() && !_domain_selector->isMyDomain(inew)&& _domain_selector->isMyDomain(iold))
+            {
+              ParaMEDMEM::MEDCouplingUMesh* mesh;
+              _domain_selector->recvMesh(mesh, _domain_selector->getProcessorID(inew));
+              ParaMEDMEM::DataArrayDouble* coords = mesh->getCoords();
+              for (int inode=0; inode<mesh->getNumberOfNodes();inode++)
+                {
+                  double* coordsPtr=coords->getPointer()+inode*3;
+                  vector<int> elems;
+                  tree->getElementsAroundPoint(coordsPtr,elems);
+                  if (elems.size()==0) continue;
+                  nodeMapping.insert(make_pair(make_pair(iold,elems[0]),make_pair(inew,inode)));
+                }
+              mesh->decrRef();
+            }
+          else if (!isParallelMode() || (_domain_selector->isMyDomain(inew) && _domain_selector->isMyDomain(iold)))
+            {
+              ParaMEDMEM::DataArrayDouble* coords = getMesh(inew)->getCoords();
+              for (int inode=0; inode<_mesh[inew]->getNumberOfNodes();inode++)
+                {
+                  double* coordsPtr=coords->getPointer()+inode*3;
+                  vector<int> elems;
+                  tree->getElementsAroundPoint(coordsPtr,elems);
+                  if (elems.size()==0) continue;
+                  nodeMapping.insert(make_pair(make_pair(iold,elems[0]),make_pair(inew,inode)));
+                }
+            }
+        }
+      if (!isParallelMode() || (_domain_selector->isMyDomain(iold)))
+        {
+          delete tree;
+          delete[] bbox;
+        }
+    } 
+
+}
+
+//getNodeIds(meshCell, meshFace, nodeIds)
+//inodeCell=nodeIds[inodeFace]
+//(put the biggest mesh in One)
+//if no corresponding node then inodeCell = -1
+void getNodeIds(ParaMEDMEM::MEDCouplingUMesh& meshOne, ParaMEDMEM::MEDCouplingUMesh& meshTwo, vector<int>& nodeIds)
+{
+  using std::vector;
+  if (!&meshOne || !&meshTwo) return;  //empty or not existing
+  double* bbox;
+  BBTree<3>* tree;
+  int nv1=meshOne.getNumberOfNodes();
+  bbox=new double[nv1*6];
+  ParaMEDMEM::DataArrayDouble* coords=meshOne.getCoords();
+  double* coordsPtr=coords->getPointer();
+  for (int i=0; i<nv1*3; i++)
+    {
+      bbox[i*2]=coordsPtr[i]-1e-6;
+      bbox[i*2+1]=coordsPtr[i]+1e-6;
+    }
+  tree=new BBTree<3>(bbox,0,0,nv1,1e-9);
+  
+  int nv2=meshTwo.getNumberOfNodes();
+  nodeIds.resize(nv2,-1);
+  coords=meshTwo.getCoords();
+  for (int inode=0; inode<nv2; inode++)
+    {
+      double* coordsPtr=coords->getPointer()+inode*3;
+      vector<int> elems;
+      tree->getElementsAroundPoint(coordsPtr,elems);
+      if (elems.size()==0) continue;
+      nodeIds[inode]=elems[0];
+    }
+  delete tree;
+  delete[] bbox;
+}
+
+/*!
+  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::castFaceMeshes(MeshCollection& initialCollection,
+                                    const std::multimap<std::pair<int,int>, std::pair<int,int> >& nodeMapping,
+                                    std::vector<std::vector<std::vector<int> > >& new2oldIds)
+{
+
+  //splitMeshes structure will contain the partition of 
+  //the old faces on the new ones
+  //splitMeshes[4][2] contains the faces from old domain 2
+  //that have to be added to domain 4
+  
+  using std::vector;
+  using std::map;
+  using std::multimap;
+  using std::pair;
+  using std::make_pair;
+  
+  vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom=initialCollection.getFaceMesh();
+  vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo=this->getFaceMesh();
+  
+  vector< vector<ParaMEDMEM::MEDCouplingUMesh*> > splitMeshes;
+  int newSize=_topology->nbDomain();
+  int fromSize=meshesCastFrom.size();
+  
+  splitMeshes.resize(newSize);
+  for (int inew=0;inew<newSize;inew++) splitMeshes[inew].resize(fromSize);
+  new2oldIds.resize(fromSize);
+  for (int iold=0;iold<fromSize;iold++) new2oldIds[iold].resize(newSize);
+  
+  //init null pointer for empty meshes
+  for (int inew=0;inew<newSize;inew++)
+    {
+      for (int iold=0;iold<fromSize;iold++)
+        {
+          splitMeshes[inew][iold]=0; //null for empty meshes
+          new2oldIds[iold][inew].clear();
+        }
+    }
+
+  //loop over the old domains to analyse the faces and decide 
+  //on which new domain they belong
+  
+  for (int iold=0; iold<fromSize;iold++)
+    {
+      if (isParallelMode() && !_domain_selector->isMyDomain(iold)) continue;
+      if (meshesCastFrom[iold] != 0)
+        {
+          for (int ielem=0; ielem<meshesCastFrom[iold]->getNumberOfCells(); ielem++)
+            {
+              vector<int> nodes;
+              meshesCastFrom[iold]->getNodeIdsOfCell(ielem,nodes);
+          
+              map <int,int> faces;
+
+              //analysis of element ielem
+              //counters are set for the element
+              //for each source node, the mapping is interrogated and the domain counters 
+              //are incremented for each target node
+              //the face is considered as going to target domains if the counter of the domain 
+              //is equal to the number of nodes
+              for (int inode=0; inode<nodes.size(); inode++)
+                {
+                  typedef multimap<pair<int,int>,pair<int,int> >::const_iterator MI;
+                  int mynode=nodes[inode];
+
+                  pair <MI,MI> myRange = nodeMapping.equal_range(make_pair(iold,mynode));
+                  for (MI iter=myRange.first; iter!=myRange.second; iter++)
+                    {
+                      int inew=iter->second.first;
+                      if (faces.find(inew)==faces.end())
+                        faces[inew]=1;
+                      else
+                        faces[inew]++;
+                    }
+                }
+          
+              for (map<int,int>::iterator iter=faces.begin(); iter!=faces.end(); iter++)
+                {
+                  if (iter->second==nodes.size())
+                    //cvw eligible but may be have to be face of a cell of this->getMesh()[inew]?
+                    //it is not sure here...
+                    //done before writeMedfile on option?... see filterFaceOnCell()
+                    new2oldIds[iold][iter->first].push_back(ielem);
+                }
+            }
+      
+          //creating the splitMeshes from the face ids
+          for (int inew=0;inew<_topology->nbDomain();inew++)
+            {
+              if (meshesCastFrom[iold]->getNumberOfCells() > 0) //cvw
+                {
+                  splitMeshes[inew][iold]=
+                    (ParaMEDMEM::MEDCouplingUMesh*) 
+                    ( meshesCastFrom[iold]->buildPartOfMySelf(&new2oldIds[iold][inew][0],
+                                                              &new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),
+                                                              true) 
+                      );
+                  splitMeshes[inew][iold]->zipCoords();
+                }
+              else
+                {
+                  //std::cout<<"one empty mesh from "<<iold<<std::endl; //cvw
+                  splitMeshes[inew][iold]=CreateEmptyMEDCouplingUMesh();
+                }
+            }
+        }
+      else
+        {
+          std::cout<<"proc "<<MyGlobals::_Rank<<" : castFaceMeshes empty mesh from iodDomain "<<iold<<std::endl;
+        }
+    }
+  
+  // send/receive stuff
+  if (isParallelMode())
+    {
+      ParaMEDMEM::MEDCouplingUMesh *empty=CreateEmptyMEDCouplingUMesh();
+      for (int iold=0; iold<fromSize; iold++)
+        for (int inew=0; inew<newSize; inew++)
+          {
+            /*std::cout<<"iold inew "<<iold<<" "<<inew<<" "<<
+              _domain_selector->isMyDomain(iold)<<" "<<
+              _domain_selector->isMyDomain(inew)<<std::endl;*/
+            if (_domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew))
+              if (splitMeshes[inew][iold] != 0) {
+                //cvw std::cout<<"send NOT empty mesh "<<splitMeshes[inew][iold]->getName()<<" "<<inew<<"<-"<<iold<<std::endl;
+                _domain_selector->sendMesh(*(splitMeshes[inew][iold]), _domain_selector->getProcessorID(inew));
+              }
+              else {
+                //std::cout<<"send empty mesh "<<inew<<"<-"<<iold<<std::endl;
+                _domain_selector->sendMesh(*(empty), _domain_selector->getProcessorID(inew));
+              }
+            if (!_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew))
+              _domain_selector->recvMesh(splitMeshes[inew][iold], _domain_selector->getProcessorID(iold));
+          }
+      empty->decrRef();
+    }
+  
+  //recollecting the bits of splitMeshes to fuse them into one
+  if (MyGlobals::_Verbose>300) std::cout<<"proc "<<MyGlobals::_Rank<<" : fuse splitMeshes"<<std::endl;
+  meshesCastTo.resize(newSize);
+  for (int inew=0; inew < newSize; inew++)
+    {
+      vector<const ParaMEDMEM::MEDCouplingUMesh*> myMeshes;
+      for (int iold=0; iold<fromSize; iold++)
+        {
+          ParaMEDMEM::MEDCouplingUMesh *umesh=splitMeshes[inew][iold];
+          if (umesh!=0)
+            if (umesh->getNumberOfCells()>0) 
+              {
+                myMeshes.push_back(umesh);
+              }
+          //else {
+          //  std::cout<<"one empty mesh "<<inew<<" "<<iold<<std::endl;
+          //}
+        }
+      
+      if (myMeshes.size()>0)
+        {
+          meshesCastTo[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(myMeshes);
+        }
+      else
+        {
+          //std::cout<<"one empty meshes to merge "<<inew<<std::endl;
+          //ParaMEDMEM::MEDCouplingUMesh *empty=ParaMEDMEM::MEDCouplingUMesh::New(); //empty one
+          //empty->setName("emptyMesh");
+          //empty->setMeshDimension(3);
+          //empty->allocateCells(0);
+          ParaMEDMEM::MEDCouplingUMesh *empty=CreateEmptyMEDCouplingUMesh();
+          meshesCastTo[inew]=empty;
+        }
+      //      meshesCastTo[inew]->zipCoords();
+      for (int iold=0; iold<fromSize; iold++)
+        if (splitMeshes[inew][iold]!=0) splitMeshes[inew][iold]->decrRef();
+    }
+  //if (MyGlobals::_Verbose>1) std::cout<<"proc "<<MyGlobals::_Rank<<" : end fuse"<<std::endl;
+}
+
+void MeshCollection::remapIntField(const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
+                                   const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
+                                   const int* fromArray,
+                                   int* toArray)
+{
+  using std::vector;
+  if (sourceMesh.getNumberOfCells()<=0) return; //empty mesh could exist
+  //cvw std::cout<<"remapIntField "<<sourceMesh.getNumberOfCells()<<" "<<targetMesh.getNumberOfCells()<<std::endl;
+  ParaMEDMEM::DataArrayDouble* sourceCoords=sourceMesh.getBarycenterAndOwner();
+  ParaMEDMEM::DataArrayDouble* targetCoords=targetMesh.getBarycenterAndOwner();
+   
+  ParaMEDMEM::MEDCouplingUMesh* tmpMesh=ParaMEDMEM::MEDCouplingUMesh::New();
+  tmpMesh->setCoords(sourceCoords);
+  vector<int> c;
+  vector<int> cI;
+  tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetMesh.getNumberOfCells(),1e-10,c,cI);
+  if (cI.size()!= targetMesh.getNumberOfCells()+1) 
+    throw INTERP_KERNEL::Exception(LOCALIZED("Error in source/target projection"));
+  for (int itargetnode=0; itargetnode<targetMesh.getNumberOfCells();itargetnode++)    
+    {
+      if (cI[itargetnode]==cI[itargetnode+1]) continue;
+      int isourcenode=c[cI[itargetnode]];
+      toArray[itargetnode]=fromArray[isourcenode];
+    } 
+  sourceCoords->decrRef();
+  targetCoords->decrRef();
+  tmpMesh->decrRef();
+}
+
+void MeshCollection::castIntField2(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,
+                                   std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo,
+                                   std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom,
+                                   std::string nameArrayTo)
+{
+  using std::vector;
+  
+  int ioldMax=meshesCastFrom.size();
+  int inewMax=meshesCastTo.size();
+  // send-recv operations
+  for (int inew=0; inew<inewMax; inew++)
+    {
+      for (int iold=0; iold<ioldMax; iold++)
+        {
+          //sending arrays for distant domains
+          if (isParallelMode() && _domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew))
+            {
+              //send mesh
+              _domain_selector->sendMesh(*meshesCastFrom[iold],_domain_selector->getProcessorID(inew));
+              //send vector
+              int size=arrayFrom[iold]->getNumberOfTuples(); //cvw may be -1!
+              vector<int>sendIds;
+              if (MyGlobals::_Verbose>400) std::cout<<"proc "<<_domain_selector->rank()<<" : castIntField SendIntVec size "<<size<<std::endl;
+              if (size>0) //no empty
+                {
+                  sendIds.resize(size);
+                  std::copy(arrayFrom[iold]->getPointer(),arrayFrom[iold]->getPointer()+size,&sendIds[0]);
+                }
+              else //empty
+                {
+                  size=0;
+                  sendIds.resize(size);
+                }
+              //std::cout<<"proc "<<_domain_selector->rank()<<" : castIntField SendIntVec "<<size<<std::endl;
+              SendIntVec(sendIds, _domain_selector->getProcessorID(inew));
+            }
+          //receiving arrays from distant domains
+          if (isParallelMode() && !_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew))
+            {
+              //receive mesh
+              vector<int> recvIds;
+              ParaMEDMEM::MEDCouplingUMesh* recvMesh;
+              _domain_selector->recvMesh(recvMesh,_domain_selector->getProcessorID(iold));
+              //receive vector
+              if (MyGlobals::_Verbose>400) std::cout<<"proc "<<_domain_selector->rank()<<" : castIntField recIntVec "<<std::endl;
+              RecvIntVec(recvIds, _domain_selector->getProcessorID(iold));
+              remapIntField2(inew,iold,*recvMesh,*meshesCastTo[inew],&recvIds[0],nameArrayTo);
+              recvMesh->decrRef(); //cww is it correct?
+            }
+        }
+    }
+  
+  //local contributions and aggregation
+  for (int inew=0; inew<inewMax; inew++)    
+    {
+      for (int iold=0; iold<ioldMax; iold++)
+        if (!isParallelMode() || ( _domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)))
+          {
+            remapIntField2(inew,iold,*meshesCastFrom[iold],*meshesCastTo[inew],arrayFrom[iold]->getConstPointer(),nameArrayTo);
+          }
+    }
+}
+
+void MeshCollection::remapIntField2(int inew,int iold,
+                                    const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
+                                    const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
+                                    const int* fromArray,
+                                    string nameArrayTo)
+//here we store ccI for next use in future call of castAllFields and remapDoubleField2
+{
+  //cout<<"remapIntField2 "<<Cle2ToStr(nameArrayTo,inew,iold)<<endl;
+  if (sourceMesh.getNumberOfCells()<=0) return; //empty mesh could exist
+  //cvw std::cout<<"remapIntField "<<sourceMesh.getNumberOfCells()<<" "<<targetMesh.getNumberOfCells()<<std::endl;
+  ParaMEDMEM::DataArrayDouble* sourceCoords=sourceMesh.getBarycenterAndOwner();
+  ParaMEDMEM::DataArrayDouble* targetCoords=targetMesh.getBarycenterAndOwner();
+   
+  ParaMEDMEM::MEDCouplingUMesh* tmpMesh=ParaMEDMEM::MEDCouplingUMesh::New();
+  tmpMesh->setCoords(sourceCoords);
+  vector<int> c;
+  vector<int> cI;
+  vector<int> ccI; //memorize intersection target<-source(inew,iold)
+  string str,cle;
+  str=nameArrayTo+"_toArray";
+  cle=Cle1ToStr(str,inew);
+  int* toArray;
+  int targetSize=targetMesh.getNumberOfCells();
+  //first time iold : create and initiate 
+  if (_mapDataArrayInt.find(cle)==_mapDataArrayInt.end())
+    {
+      if (MyGlobals::_Is0verbose>100) cout<<"create "<<cle<<" size "<<targetSize<<endl;
+      ParaMEDMEM::DataArrayInt* p=DataArrayInt::New();
+      p->alloc(targetSize,1);
+      p->fillWithZero();
+      toArray=p->getPointer();
+      _mapDataArrayInt[cle]=p;
+    }
+  else //other times iold: refind and complete
+    {
+      toArray=_mapDataArrayInt.find(cle)->second->getPointer();
+    }
+  tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetSize,1e-10,c,cI);
+  if (cI.size()!=targetSize+1) 
+    throw INTERP_KERNEL::Exception(LOCALIZED("Error in source/target projection"));
+  for (int itargetnode=0; itargetnode<targetSize; itargetnode++)    
+    {
+      if (cI[itargetnode]==cI[itargetnode+1]) continue;
+      int isourcenode=c[cI[itargetnode]];
+      toArray[itargetnode]=fromArray[isourcenode];
+      //memorize intersection 
+      ccI.push_back(itargetnode); //next we'll do toArray[ccI[i]]=fromArray[ccI[i+1]]
+      ccI.push_back(isourcenode);
+    }
+  //ccI.push_back(sourceMesh.getNumberOfCells()); //additionnal information at end??
+  
+  //memories intersection for future same job on fields (if no existing cle=no intersection)
+  str=Cle2ToStr(nameArrayTo+"_ccI",inew,iold);
+  if (MyGlobals::_Verbose>700) cout<<"proc "<<MyGlobals::_Rank<<" : map memorize '"<<str<<"'\n";
+  _mapDataArrayInt[str]=CreateDataArrayIntFromVector(ccI, 2);
+  sourceCoords->decrRef();
+  targetCoords->decrRef();
+  tmpMesh->decrRef();
+}
+
+void MeshCollection::castAllFields(MeshCollection& initialCollection, string nameArrayTo) //cvwat08
+{
+  using std::vector;
+  if (nameArrayTo!="cellFieldDouble") 
+    throw INTERP_KERNEL::Exception(LOCALIZED("Error castAllField only on cellFieldDouble"));
+
+  string nameTo="typeData=6"; //resume the type of field casted 
+  // send-recv operations
+  int ioldMax=initialCollection.getMesh().size();
+  int inewMax=this->getMesh().size();
+  int iFieldMax=initialCollection.getFieldDescriptions().size();
+  if (MyGlobals::_Verbose>10) cout<<"castAllFields with:\n"<<ReprVectorOfString(initialCollection.getFieldDescriptions())<<endl;
+  //std::vector<std::string> initialCollection.getFieldDescriptions()
+  //getFieldDescriptions() is a string description of field coherent and tested and set BEFORE.
+  //see collection.prepareFieldDescriptions()
+  for (int ifield=0; ifield<iFieldMax; ifield++)
+    {
+      string descriptionField=initialCollection.getFieldDescriptions()[ifield];
+      if (descriptionField.find(nameTo)==string::npos) continue; //only nameTo accepted in Fields name description
+      for (int inew=0; inew<inewMax; inew++)
+        {
+          for (int iold=0; iold<ioldMax; iold++)
+            {
+              //sending arrays for distant domains
+              if (isParallelMode() && _domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew))
+                {
+                  int target=_domain_selector->getProcessorID(inew);
+                  ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); //cvwat14
+                  //getField look for and read it if not done, and assume decrRef() in ~MeshCollection;
+                  if (MyGlobals::_Verbose>10) 
+                    std::cout<<"proc "<<_domain_selector->rank()<<" : castAllFields sendDouble"<<std::endl;
+                  SendDataArrayDouble(field, target);
+                }
+              //receiving arrays from distant domains
+              if (isParallelMode() && !_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew))
+                {
+                  int source=_domain_selector->getProcessorID(iold);
+                  //receive vector
+                  if (MyGlobals::_Verbose>10) 
+                    std::cout<<"proc "<<_domain_selector->rank()<<" : castAllFields recvDouble"<<std::endl;
+                  ParaMEDMEM::DataArrayDouble* field=RecvDataArrayDouble(source);
+                  remapDoubleField3(inew,iold,field,nameArrayTo,descriptionField);
+                }
+            }
+        }
+  
+      //local contributions and aggregation
+      for (int inew=0; inew<inewMax; inew++)
+        {
+          for (int iold=0; iold<ioldMax; iold++)
+            if (!isParallelMode() || ( _domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)))
+              {
+                ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); //cvwat14
+                remapDoubleField3(inew,iold,field,nameArrayTo,descriptionField);
+              }
+        }
+    }
+}
+
+void MeshCollection::remapDoubleField3(int inew, int iold, 
+                                       ParaMEDMEM::DataArrayDouble* fromArray,
+                                       string nameArrayTo,
+                                       string descriptionField)
+//here we use 'cellFamily_ccI inew iold' set in remapIntField2
+{
+  using std::vector;
+  if (nameArrayTo!="cellFieldDouble") 
+    throw INTERP_KERNEL::Exception(LOCALIZED("Error remapDoubleField3 only on cellFieldDouble"));
+  string cle=Cle2ToStr("cellFamily_ccI",inew,iold);
+  
+  map<string,ParaMEDMEM::DataArrayInt*>::iterator it1;
+  it1=_mapDataArrayInt.find(cle);
+  if (it1==_mapDataArrayInt.end())
+    {
+      cerr<<"proc "<<MyGlobals::_Rank<<" : remapDoubleField3 cle '"<<cle<<"' not found"<<endl;
+      cerr<<" trying remap of field double on cells : "<<descriptionField<<endl;
+      return;
+    }
+  //create ccI in remapIntField2
+  ParaMEDMEM::DataArrayInt* ccI=it1->second;
+  if (MyGlobals::_Verbose>300) cout<<"proc "<<MyGlobals::_Rank<<" : remapDoubleField3 "<<cle<<" size "<<ccI->getNbOfElems()<<endl;
+  //cout<<descriptionField<<endl;
+  
+  int nbcell=this->getMesh()[inew]->getNumberOfCells(); //number of cell of mesh
+  int nbcomp=fromArray->getNumberOfComponents();
+  int nbPtGauss=StrToInt(ExtractFromDescription(descriptionField, "nbPtGauss="));
+  
+  //int nbk=fromArray->getNumberOfTuples();
+  
+  //cle=reprGenericDescription(descriptionField)+" "+IntToStr(inew);
+  string tag="inewFieldDouble="+IntToStr(inew);
+  cle=descriptionField+SerializeFromString(tag);
+  //cout<<"descriptionField in remapDoubleField3 : "<<descriptionField<<endl;
+  int fromArrayNbOfElem=fromArray->getNbOfElems();
+  int fromArrayNbOfComp=fromArray->getNumberOfComponents();
+  int fromArrayNbOfCell=fromArrayNbOfElem/fromArrayNbOfComp/nbPtGauss;
+  
+  if (MyGlobals::_Verbose>1000)
+    {
+      cout<<"proc "<<MyGlobals::_Rank<<" nbcell "<<nbcell<<" nbcomp "<<nbcomp<<" nbPtGauss "<<nbPtGauss<<
+        " fromArray nbOfElems "<<fromArrayNbOfElem<<
+        " nbTuples "<<fromArray->getNumberOfTuples()<<
+        " nbcells "<<fromArrayNbOfCell<<
+        " nbComponents "<<fromArray->getNumberOfComponents()<<endl;
+    }
+
+  ParaMEDMEM::DataArrayDouble* field=0;
+  map<string,ParaMEDMEM::DataArrayDouble*>::iterator it2;
+  it2=_mapDataArrayDouble.find(cle);
+  if (it2==_mapDataArrayDouble.end())
+    {
+      if (MyGlobals::_Verbose>300) cout<<"proc "<<MyGlobals::_Rank<<" : remapDoubleField3 cle '"<<cle<<"' not found and create it"<<endl;
+      field=DataArrayDouble::New();
+      _mapDataArrayDouble[cle]=field;
+      field->alloc(nbcell*nbPtGauss,nbcomp);
+      field->fillWithZero();
+    }
+  else
+    {
+      field=it2->second;
+      if (field->getNumberOfTuples()!=nbcell*nbPtGauss || field->getNumberOfComponents()!=nbcomp)
+        {
+          cerr<<"proc "<<MyGlobals::_Rank<<" : remapDoubleField3 pb of size "<<
+            " trying remap of field double on cells : \n"<<descriptionField<<endl;
+          return;
+        }
+    }
+  //cout<<"proc "<<MyGlobals::_Rank<<" : remapDoubleField3 "<<cle<<" size "<<ccI->getNbOfElems()<<endl;
+  
+  if (nbPtGauss==1)
+    {
+      field->setPartOfValuesAdv(fromArray,ccI);
+    }
+  else
+    {
+      //replaced by setPartOfValuesAdv if nbPtGauss==1
+      int iMax=ccI->getNbOfElems();
+      int* pccI=ccI->getPointer();
+      double* pField=field->getPointer();
+      double* pFrom=fromArray->getPointer();
+      int itarget, isource, delta=nbPtGauss*nbcomp;
+      for (int i=0; i<iMax; i=i+2)  //cell
+        {
+          itarget=pccI[i];
+          isource=pccI[i+1];
+          if ((itarget<0) || (itarget>=nbcell) || (isource<0) || (isource>=fromArrayNbOfCell))
+            throw INTERP_KERNEL::Exception(LOCALIZED("Error field override"));
+          int ita=itarget*delta;
+          int iso=isource*delta;
+          for (int k=0; k<delta; k++) pField[ita+k]=pFrom[iso+k]; //components and gausspoints
+        }
+    }
+}
+
+/*! constructing the MESH collection from a distributed file
+ *
+ * \param filename name of the master file containing the list of all the MED files
+ */
+MeshCollection::MeshCollection(const std::string& filename)
+  : _topology(0),
+    _owns_topology(true),
+    _driver(0),
+    _domain_selector( 0 ),
+    _i_non_empty_mesh(-1),
+    _driver_type(MEDPARTITIONER::Undefined),
+    _subdomain_boundary_creates(false),
+    _family_splitting(false),
+    _create_empty_groups(false),
+    _joint_finder(0)
+{
+  // char filenamechar[256];
+  // strcpy(filenamechar,filename.c_str());
+  try
+    {
+      _driver=new MeshCollectionMedXmlDriver(this);
+      _driver->read (filename.c_str());
+      _driver_type = MedXml;
+    }
+  catch(...) 
+    {  // Handle all exceptions
+      if ( _driver ) delete _driver; _driver=0;
+      try
+        {
+          _driver=new MeshCollectionMedAsciiDriver(this);
+          _driver->read (filename.c_str());
+          _driver_type=MedAscii;
+        }
+      catch(...)
+        {
+          if ( _driver ) delete _driver; _driver=0;
+          throw INTERP_KERNEL::Exception(LOCALIZED("file does not comply with any recognized format"));
+        }
+    }
+  for ( int idomain = 0; idomain < _mesh.size(); ++idomain )
+    if ( _mesh[idomain] && _mesh[idomain]->getNumberOfNodes() > 0 )
+      _i_non_empty_mesh = idomain;
+}
+
+/*! Constructing the MESH collection from selected domains of a distributed file
+ * 
+ * \param filename  - name of the master file containing the list of all the MED files
+ * \param domainSelector - selector of domains to load
+ */
+MeshCollection::MeshCollection(const std::string& filename, ParaDomainSelector& domainSelector) //cvwat01
+  : _topology(0),
+    _owns_topology(true),
+    _driver(0),
+    //cvw _domain_selector( domainSelector.nbProcs() > 1 ? & domainSelector : 0 ),
+    _domain_selector( &domainSelector ),
+    _i_non_empty_mesh(-1),
+    _driver_type(MEDPARTITIONER::Undefined),
+    _subdomain_boundary_creates(false),
+    _family_splitting(false),
+    _create_empty_groups(false),
+    _joint_finder(0)
+{
+  std::string myfile=filename;
+  std::size_t found=myfile.find(".xml");
+  if (found!=std::string::npos) //file .xml
+    {
+      try
+        {
+          _driver=new MeshCollectionMedXmlDriver(this); //cvwat02
+          _driver->read ( (char*)filename.c_str(), _domain_selector );
+          _driver_type = MedXml;
+        }
+      catch(...)
+        {  // Handle all exceptions
+          if ( _driver ) delete _driver; _driver=0;
+          throw INTERP_KERNEL::Exception(LOCALIZED("file .xml does not comply with any recognized format"));
+        }
+    }
+  else 
+    {
+      found=myfile.find(".med");
+      if (found!=std::string::npos) //file .med single
+        {
+          //make a temporary file .xml and retry MedXmlDriver
+          std::string xml="\
+<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n \
+<root>\n \
+  <version maj=\"2\" min=\"3\" ver=\"1\"/>\n \
+  <description what=\"\" when=\"\"/>\n \
+  <content>\n \
+    <mesh name=\"$meshName\"/>\n \
+  </content>\n \
+  <splitting>\n \
+    <subdomain number=\"1\"/>\n \
+    <global_numbering present=\"no\"/>\n \
+  </splitting>\n \
+  <files>\n \
+    <subfile id=\"1\">\n \
+      <name>$fileName</name>\n \
+      <machine>localhost</machine>\n \
+    </subfile>\n \
+  </files>\n \
+  <mapping>\n \
+    <mesh name=\"$meshName\">\n \
+      <chunk subdomain=\"1\">\n \
+        <name>$meshName</name>\n \
+      </chunk>\n \
+    </mesh>\n \
+  </mapping>\n \
+</root>\n";
+          std::vector<std::string> meshNames=MEDLoader::GetMeshNames(myfile.c_str());
+          xml.replace(xml.find("$fileName"),9,myfile);
+          xml.replace(xml.find("$meshName"),9,meshNames[0]);
+          xml.replace(xml.find("$meshName"),9,meshNames[0]);
+          xml.replace(xml.find("$meshName"),9,meshNames[0]);
+          //std::cout<<xml<<std::endl;
+          std::string nameFileXml=myfile;
+          nameFileXml.replace(nameFileXml.find(".med"),4,".xml");
+          nameFileXml="medpartitioner_"+nameFileXml;
+          if (_domain_selector->rank()==0) //only on to write it
+            {
+              std::ofstream f(nameFileXml.c_str());
+              f<<xml;
+              f.close();
+            }
+#ifdef HAVE_MPI2
+          MPI_Barrier(MPI_COMM_WORLD); //wait for creation of nameFileXml
+#endif
+          try
+            {
+              _driver=new MeshCollectionMedXmlDriver(this);
+              _driver->read ( (char*)nameFileXml.c_str(), _domain_selector );
+              _driver_type = MedXml;
+            }
+          catch(...)
+            {  // Handle all exceptions
+              if ( _driver ) delete _driver; _driver=0;
+              throw INTERP_KERNEL::Exception(LOCALIZED("file medpartitioner_xxx.xml does not comply with any recognized format"));
+            }
+        }
+      else //no extension
+        {
+          try
+            {
+              _driver=new MeshCollectionMedAsciiDriver(this);
+              _driver->read ( (char*)filename.c_str(), _domain_selector );
+              _driver_type=MedAscii;
+            }
+          catch(...)
+            {
+              if ( _driver ) delete _driver; _driver=0;
+              throw INTERP_KERNEL::Exception(LOCALIZED("file name with no extension does not comply with any recognized format"));
+            }
+        }
+    }
+  
+  /*done in MeshCollectionMedXmlDriver read
+    if ( isParallelMode() )
+    // to know nb of cells on each proc to compute global cell ids from locally global
+    _domain_selector->gatherNbOf( getMesh() );*/
+
+  // find non-empty domain mesh
+  for ( int idomain = 0; idomain < _mesh.size(); ++idomain )
+    if ( _mesh[idomain] && _mesh[idomain]->getNumberOfNodes() > 0 )
+      _i_non_empty_mesh = idomain;
+  
+  try
+    {
+      //check for all proc/file compatibility of _fieldDescriptions
+      //*MyGlobals::_File_Names=AllgathervVectorOfString(*MyGlobals::_File_Names);
+      _fieldDescriptions=AllgathervVectorOfString(MyGlobals::_Field_Descriptions); //cvwat07
+    }
+  catch(INTERP_KERNEL::Exception& e)
+    {
+      cerr<<"proc "<<MyGlobals::_Rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
+      throw INTERP_KERNEL::Exception(LOCALIZED("Something wrong verifying coherency of files med ands fields"));
+    }
+  
+  try
+    {
+      //check for all proc/file compatibility of _familyInfo //cvwat05
+      vector<string> v2=AllgathervVectorOfString(VectorizeFromMapOfStringInt(_familyInfo));
+      _familyInfo=DevectorizeToMapOfStringInt(v2);
+    }
+  catch(INTERP_KERNEL::Exception& e)
+    {
+      cerr<<"proc "<<MyGlobals::_Rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
+      throw INTERP_KERNEL::Exception(LOCALIZED("Something wrong merging all familyInfo"));
+    }
+
+  try
+    {
+      //check for all proc/file compatibility of _groupInfo
+      vector<string> v2=AllgathervVectorOfString(
+                                                 VectorizeFromMapOfStringVectorOfString(_groupInfo));
+      _groupInfo=DeleteDuplicatesInMapOfStringVectorOfString(
+                                                             DevectorizeToMapOfStringVectorOfString(v2));
+    }
+  catch(INTERP_KERNEL::Exception& e)
+    {
+      cerr<<"proc "<<MyGlobals::_Rank<<" : INTERP_KERNEL_Exception : "<<e.what()<<endl;
+      throw INTERP_KERNEL::Exception(LOCALIZED("Something wrong merging all groupInfo"));
+    }
+
+  
+  //std::vector< std::string > _meshes=MEDLoader::GetMeshNames(filename);
+  //std::vector< std::string > _fields=MEDLoader::GetAllFieldNamesOnMesh(filename,meshname[0]);
+  //cout<<"number of fields "<<_fields.size()<<endl;
+  
+}
+
+/*! constructing the MESH collection from a sequential MED-file
+ * 
+ * \param filename MED file
+ * \param meshname name of the mesh that is to be read
+ */
+MeshCollection::MeshCollection(const std::string& filename, const std::string& meshname)
+  : _name(meshname),
+    _topology(0),
+    _owns_topology(true),
+    _driver(0),
+    _domain_selector( 0 ),
+    _i_non_empty_mesh(-1),
+    _driver_type(MEDPARTITIONER::MedXml),
+    _subdomain_boundary_creates(false),
+    _family_splitting(false),
+    _create_empty_groups(false),
+    _joint_finder(0)
+{
+  try // avoid memory leak in case of inexistent filename
+    {
+      retrieveDriver()->readSeq (filename.c_str(),meshname.c_str());
+    }
+  catch (...)
+    {
+      if ( _driver ) delete _driver; _driver=0;
+      throw INTERP_KERNEL::Exception(LOCALIZED("problem reading .med files"));
+    }
+  if ( _mesh[0] && _mesh[0]->getNumberOfNodes() > 0 )
+    _i_non_empty_mesh = 0;
+}
+
+MeshCollection::~MeshCollection()
+{
+  for (int i=0; i<_mesh.size();i++)
+    if (_mesh[i]!=0) _mesh[i]->decrRef(); 
+  
+  for (int i=0; i<_cellFamilyIds.size();i++)
+    if (_cellFamilyIds[i]!=0) _cellFamilyIds[i]->decrRef();
+  
+  for (int i=0; i<_faceMesh.size();i++)
+    if (_faceMesh[i]!=0) _faceMesh[i]->decrRef();
+  
+  for (int i=0; i<_faceFamilyIds.size();i++)
+    if (_faceFamilyIds[i]!=0) _faceFamilyIds[i]->decrRef();
+  
+  for (map<string, ParaMEDMEM::DataArrayInt*>::iterator it=_mapDataArrayInt.begin() ; it!=_mapDataArrayInt.end(); it++ )
+    if ((*it).second!=0) (*it).second->decrRef();
+  
+  for (map<string, ParaMEDMEM::DataArrayDouble*>::iterator it=_mapDataArrayDouble.begin() ; it!=_mapDataArrayDouble.end(); it++ )
+    if ((*it).second!=0) (*it).second->decrRef();
+  
+  if (_driver !=0) {delete _driver; _driver=0;}
+  if (_topology!=0 && _owns_topology) {delete _topology; _topology=0;}
+  
+  if (_joint_finder!=0) {delete _joint_finder; _joint_finder=0;}
+}
+
+/*! constructing the MESH collection from a file
+ * 
+ * The method creates as many MED-files as there are domains in the 
+ * collection. It also creates a master file that lists all the MED files.
+ * The MED files created in ths manner contain joints that describe the 
+ * connectivity between subdomains.
+ * 
+ * \param filename name of the master file that will contain the list of the MED files
+ * 
+ */
+void MeshCollection::write(const std::string& filename)
+{
+  //building the connect zones necessary for writing joints
+  //   if (_topology->nbDomain()>1)
+  //     buildConnectZones();
+  //suppresses link with driver so that it can be changed for writing
+  if (_driver!=0) delete _driver;
+  _driver=0;
+
+  //char filenamechar[256];
+  //  strcpy(filenamechar,filename.c_str());
+  retrieveDriver()->write (filename.c_str(), _domain_selector);
+}
+
+/*! creates or gets the link to the collection driver
+ */
+MeshCollectionDriver* MeshCollection::retrieveDriver()
+{
+  if (_driver==0)
+    {
+      switch(_driver_type)
+        {
+        case MedXml:
+          _driver=new MeshCollectionMedXmlDriver(this);
+          break;
+        case MedAscii:
+          _driver=new MeshCollectionMedAsciiDriver(this);
+          break;
+        default:
+          throw INTERP_KERNEL::Exception(LOCALIZED("Unrecognized driver"));
+        }
+    }
+  return _driver;
+}
+
+
+/*! gets an existing driver
+ * 
+ */
+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();
+}
+
+std::vector<ParaMEDMEM::MEDCouplingUMesh*>& MeshCollection::getMesh() {
+  return _mesh;
+}
+
+std::vector<ParaMEDMEM::MEDCouplingUMesh*>& MeshCollection::getFaceMesh() {
+  return _faceMesh;
+}
+
+ParaMEDMEM::MEDCouplingUMesh* MeshCollection::getMesh(int idomain) const {
+  return _mesh[idomain];
+}
+
+ParaMEDMEM::MEDCouplingUMesh* MeshCollection::getFaceMesh(int idomain) {
+  return _faceMesh[idomain];
+}
+
+std::vector<MEDPARTITIONER::ConnectZone*>& MeshCollection::getCZ() {
+  return _connect_zones;
+}
+
+Topology* MeshCollection::getTopology() const {
+  return _topology;
+}
+
+void MeshCollection::setTopology(Topology* topo) {
+  if (_topology!=0)
+    {
+      throw INTERP_KERNEL::Exception(LOCALIZED("topology is already set"));
+    }
+  else
+    _topology = topo;
+}
+
+/*! Method creating the cell graph
+ * 
+ * \param array returns the pointer to the structure that contains the graph 
+ * \param edgeweight returns the pointer to the table that contains the edgeweights
+ *        (only used if indivisible regions are required)
+ */
+void MeshCollection::buildCellGraph(MEDPARTITIONER::SkyLineArray* & array, int *& edgeweights ) //cvwat09
+{
+  using std::multimap;
+  using std::vector;
+  using std::make_pair;
+  using std::pair;
+  
+  multimap< int, int > node2cell;
+  multimap< int, int > cell2cell;
+  multimap< int, int > cell2node;
+
+  vector<vector<multimap<int,int> > > commonDistantNodes;
+  int nbdomain=_topology->nbDomain();
+  if (isParallelMode())
+    {
+      _joint_finder=new JointFinder(*this);
+      _joint_finder->findCommonDistantNodes();
+      commonDistantNodes=_joint_finder->getDistantNodeCell();
+    }
+
+  if (MyGlobals::_Verbose>500) _joint_finder->print();
+  
+  //looking for reverse nodal connectivity i global numbering
+  for (int idomain=0; idomain<nbdomain; idomain++)
+    {
+      if (isParallelMode() && !_domain_selector->isMyDomain(idomain)) continue;
+    
+      /*obsolete
+        int offsetCell=0, offsetNode=0;
+        if (isParallelMode())
+        {
+        offsetCell=_domain_selector->getDomainCellShift(idomain);
+        offsetNode=_domain_selector->getDomainNodeShift(idomain);
+        }*/
+    
+      ParaMEDMEM::DataArrayInt* index=ParaMEDMEM::DataArrayInt::New();
+      ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New();
+      int nbNodes=_mesh[idomain]->getNumberOfNodes();
+      //cout<<"proc "<<MyGlobals::_Rank<<" idomain "<<idomain<<" nbNodes "<<nbNodes<<" offsetCell "<<offsetCell<<" offsetNode "<<offsetNode<<endl;
+      _mesh[idomain]->getReverseNodalConnectivity(revConn,index);
+      //problem saturation over 1 000 000 nodes for 1 proc
+      if (MyGlobals::_Verbose>100) cout<<"proc "<<MyGlobals::_Rank<<" getReverseNodalConnectivity done on "<<nbNodes<<" nodes"<<endl;
+      int* index_ptr=index->getPointer();
+      int* revConnPtr=revConn->getPointer();
+      //if (MyGlobals::_Verbose>100) cout<<"proc "<<MyGlobals::_Rank<<" create node2cell on local nodes with global numerotation idomain|inode|icell\n";
+      for (int i=0; i<nbNodes; i++)
+        {
+          for (int icell=index_ptr[i]; icell<index_ptr[i+1]; icell++)
+            {
+              /*cvw local
+                node2cell.insert(make_pair(i, revConnPtr[icell]));
+                cout<<" "<<idomain<<"|"<<i<<"|"<<revConnPtr[icell];
+                cell2node.insert(make_pair(revConnPtr[icell], i));
+              */
+              int globalNode=_topology->convertNodeToGlobal(idomain,i);
+              int globalCell=_topology->convertCellToGlobal(idomain,revConnPtr[icell]);
+              node2cell.insert(make_pair(globalNode, globalCell));
+              //cvw cout<<" "<<idomain<<"|"<<i<<"#"<< globalNode<<"|"<<revConnPtr[icell]<<"#"<<globalCell;
+              cell2node.insert(make_pair(globalCell, globalNode));
+            }
+        }
+      revConn->decrRef();
+      index->decrRef();
+      //vector<vector<multimap<int,int> > > dNC=getDistantNodeCell()
+      for (int iother=0; iother<nbdomain; iother++)
+        {
+          std::multimap<int,int>::iterator it;
+          int isource=idomain;
+          int itarget=iother;
+          for (it=_joint_finder->_distant_node_cell[isource][itarget].begin(); 
+               it!=_joint_finder->_distant_node_cell[isource][itarget].end(); it++)
+            {
+              int globalNode=_topology->convertNodeToGlobal(idomain,(*it).first);
+              int globalCell=(*it).second;
+              node2cell.insert(make_pair(globalNode, globalCell));
+              //cout<<"processor "<<MyGlobals::_Rank<<" : isource "<<isource<<" itarget "<<itarget<<
+              //      " "<<(*it).first<<"~"<<globalNode<<"~"<<globalCell<<endl;
+              cell2node.insert(make_pair(globalCell, globalNode));
+            }
+        }
+    }  //endfor idomain
+
+  //creating graph arcs (cell to cell relations)
+  //arcs are stored in terms of (index,value) notation
+  // 0 3 5 6 6
+  // 1 2 3 2 3 3 
+  // means 6 arcs (0,1), (0,2), (0,3), (1,2), (1,3), (2,3)
+  // in present version arcs are not doubled but reflexive (1,1) arcs are present for each cell
+  //warning here one node have less than or equal effective number of cell with it
+  //but cell could have more than effective nodes
+  //because other equals nodes in other domain (with other global inode)
+  if (MyGlobals::_Verbose>100) cout<<"proc "<<MyGlobals::_Rank<<" creating graph arcs on nbNodes "<<_topology->nbNodes()<<endl;
+  for (int inode=0; inode<_topology->nbNodes(); inode++)  //on all nodes
+    {
+      typedef multimap<int,int>::const_iterator MI;
+      pair <MI,MI> myRange=node2cell.equal_range(inode);
+      for (MI cell1=myRange.first; cell1!=myRange.second; cell1++)  //on cells with inode
+        {
+          pair <MI,MI> myNodes1=cell2node.equal_range(cell1->second);  //nodes of one cell
+          for (MI cell2=myRange.first; cell2!=myRange.second; cell2++)  //on one of these cell
+            {
+              if (cell1->second!=cell2->second)  //in cells of my domain
+                {
+                  pair <MI,MI> myNodes2=cell2node.equal_range(cell2->second); //on nodes of this cell
+                  int nbcn=0; //number of common nodes between cells: at least 3 for cells
+                  for (MI it1=myNodes1.first; it1!=myNodes1.second; ++it1)
+                    {
+                      for (MI it2=myNodes2.first; it2!=myNodes2.second; ++it2)
+                        {
+                          if ((*it1).second==(*it2).second)
+                            {
+                              nbcn=nbcn+1 ; break;
+                            }
+                        }
+                    }
+                  if (nbcn>=3)  //cvw TODO if 2d cells set at 2
+                    cell2cell.insert(make_pair(cell1->second,cell2->second));
+                  //note here there is some global numerotation of cell which come from other domain (not mydomain)
+                  //cout<<" "<<MyGlobals::_Rank<<"!"<<cell1->second<<"!"<<cell2->second; //cvw
+                }
+            }
+        }
+    }
+  
+  if (MyGlobals::_Verbose>100) cout<<"proc "<<MyGlobals::_Rank<<" create skylinearray"<<endl;
+  //filling up index and value to create skylinearray structure
+  vector <int> index,value;
+  index.push_back(0);
+  int idep=0;
+  
+  for (int idomain=0; idomain<nbdomain; idomain++)
+    {
+      if (isParallelMode() && !_domain_selector->isMyDomain(idomain)) continue;
+      int nbCells=_mesh[idomain]->getNumberOfCells();
+      for (int icell=0; icell<nbCells; icell++)
+        {
+          int size=0;
+          int globalCell=_topology->convertCellToGlobal(idomain,icell);
+          multimap<int,int>::iterator it;
+          pair<multimap<int,int>::iterator,multimap<int,int>::iterator> ret;
+          ret=cell2cell.equal_range(globalCell);
+          //cout<<" "<<MyGlobals::_Rank<<"$"<<icell<<"$"<<globalCell;
+          for (it=ret.first; it!=ret.second; ++it)
+            {
+              //cout<<" "<<MyGlobals::_Rank<<"$"<<icell<<"$"<<globalCell<<"$"<<(*it).second<<endl;
+              int ival=(*it).second; //no adding one existing yet
+              for (int i=idep ; i<idep+size ; i++)
+                {
+                  if (value[i]==ival)
+                    {
+                      ival= -1; break;
+                    }
+                }
+              if (ival!= -1)
+                {
+                  value.push_back(ival);
+                  //cout<<"|"<<ival;
+                  size++;
+                }
+            }
+          //cout<<" ";
+          idep=index[index.size()-1]+size;
+          index.push_back(idep);
+        }
+    }
+  
+  array=new MEDPARTITIONER::SkyLineArray(index,value);
+
+  if (MyGlobals::_Verbose>100)
+    {
+      std::cout<<"\nproc "<<_domain_selector->rank()<<" : end MeshCollection::buildCellGraph "<<
+        index.size()-1<<" "<<value.size()<<std::endl;
+      if (index.size()>1)
+        {
+          for (int i=0; i<10; ++i) cout<<index[i]<<" ";
+          cout<<"... "<<index[index.size()-1]<<endl;
+          for (int i=0; i<15; ++i) cout<<value[i]<<" ";
+          int ll=index[index.size()-1]-1;
+          cout<<"... ("<<ll<<") "<<value[ll-1]<<" "<<value[ll]<<endl;
+        }
+    }
+  
+}
+
+
+/*! Creates the partition corresponding to the cell graph and the partition number
+ * 
+ * \param nbdomain number of subdomains for the newly created graph
+ * 
+ * returns a topology based on the new graph
+ */
+Topology* MeshCollection::createPartition(int nbdomain, //cvwat06
+                                          Graph::splitter_type split, 
+                                          const std::string& options_string,
+                                          int* user_edge_weights,
+                                          int* user_vertices_weights)
+{
+  using std::cout;
+  using std::endl;
+  
+  if (MyGlobals::_Verbose>10) cout<<"proc "<<MyGlobals::_Rank<<" : MeshCollection::createPartition : Building cell graph"<<endl;
+  
+  if (nbdomain <1) throw INTERP_KERNEL::Exception(LOCALIZED("Number of subdomains must be > 0"));
+  MEDPARTITIONER::SkyLineArray* array=0;
+  int* edgeweights=0;
+
+  //cout<<"Building cell graph... ";
+  //   if ( _domain_selector )
+  //     buildCellGraphParallel(array,edgeweights);
+  //   else
+  buildCellGraph(array,edgeweights); //cvwat09
+  //MPI_Barrier(MPI_COMM_WORLD);
+  //cout<<"proc "<<MyGlobals::_Rank<<" :end barrier CellGraph done"<<endl;
+  Graph* cellGraph;
+  switch (split)
+    {
+    case Graph::METIS:
+#ifdef ENABLE_METIS
+      if (MyGlobals::_Verbose>10) cout<<"METISGraph"<<endl;
+      cellGraph=(Graph*)(new METISGraph(array,edgeweights));
+#else
+      throw INTERP_KERNEL::Exception(LOCALIZED("METIS Graph is not available. Check your products, please."));
+#endif
+      break;
+    case Graph::SCOTCH:
+#ifdef ENABLE_SCOTCH
+      if (MyGlobals::_Verbose>10) cout<<"SCOTCHGraph"<<endl;
+      cellGraph=(Graph*)(new SCOTCHGraph(array,edgeweights));
+#else
+      throw INTERP_KERNEL::Exception(LOCALIZED("SCOTCH Graph is not available. Check your products, please."));
+#endif
+      break;
+    }
+
+  //!user-defined weights
+  if (user_edge_weights!=0) 
+    cellGraph->setEdgesWeights(user_edge_weights);
+  if (user_vertices_weights!=0)
+    cellGraph->setVerticesWeights(user_vertices_weights);
+
+  if (MyGlobals::_Is0verbose>10) cout<<"partitioning graph on "<<nbdomain<<" domains"<<endl;
+  cellGraph->partGraph(nbdomain, options_string, _domain_selector);  //cvwat10
+
+  if (MyGlobals::_Is0verbose>10) cout<<"building new topology"<<endl;
+  //cellGraph is a shared pointer 
+  Topology* topology=new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension());
+
+  //cleaning
+  if (edgeweights!=0) delete[] edgeweights;
+  // if (array!=0) delete array;
+  delete cellGraph;
+  if (MyGlobals::_Verbose>11) cout<<"proc "<<MyGlobals::_Rank<<" : end MeshCollection::createPartition"<<endl;
+  return topology;
+}
+
+/*! Creates a topology for a partition specified by the user
+ * 
+ * \param table user-specified partition (for each cell contains the domain number from 0 to n-1)
+ * 
+ * returns a topology based on the new partition
+ */
+Topology* MeshCollection::createPartition(const int* partition)
+{
+  using std::set;
+  
+  MEDPARTITIONER::SkyLineArray* array=0;
+  int* edgeweights=0;
+
+  buildCellGraph(array,edgeweights);
+  Graph* cellGraph;
+  set<int> domains;
+  for (int i=0; i<_topology->nbCells(); i++)
+    {
+      domains.insert(partition[i]);
+    }
+  int nbdomain=domains.size();
+  
+  cellGraph=(Graph*)(new UserGraph(array, partition, _topology->nbCells()));
+  
+  //cellGraph is a shared pointer 
+  Topology* topology = new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension());
+  
+  //  if (array!=0) delete array;
+  delete cellGraph;
+  return topology;
+}
+
+void MeshCollection::setDomainNames(const std::string& name)
+{
+  for (int i=0; i<_topology->nbDomain(); i++)
+    {
+      std::ostringstream oss;
+      oss<<name<<"_"<<i;
+      if (!isParallelMode() || _domain_selector->isMyDomain(i))
+        _mesh[i]->setName(oss.str().c_str());
+    }
+}
+
+ParaMEDMEM::DataArrayDouble* MeshCollection::getField(std::string descriptionField, int iold)
+//getField look for and read it if not done, and assume decrRef() in ~MeshCollection;
+//something like MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
+{
+  int rank=MyGlobals::_Rank;
+  string tag="ioldFieldDouble="+IntToStr(iold);
+  string descriptionIold=descriptionField+SerializeFromString(tag);
+  if (_mapDataArrayDouble.find(descriptionIold)!=_mapDataArrayDouble.end())
+    {
+      if (MyGlobals::_Verbose>300) cout<<"proc "<<rank<<" : YET READ getField : "<<descriptionIold<<endl;
+      DataArrayDouble* res=_mapDataArrayDouble[descriptionIold];
+      //cout<<res->reprZip()<<endl;
+      return res;
+    }
+  if (MyGlobals::_Verbose>200) cout<<"proc "<<rank<<" : TO BE READ getField : "<<descriptionIold<<endl;
+  string description, fileName, meshName, fieldName;
+  int idomain, typeField, DT, IT, entity;
+  idomain=iold;
+  fileName=MyGlobals::_File_Names[iold];
+  if (MyGlobals::_Verbose>10) 
+    cout<<"proc "<<MyGlobals::_Rank<<" : in "<<fileName<<" "<<iold<<" "<<descriptionIold<<endl;
+  //cout<<"\n\n"<<"ON_CELLS "<<ON_CELLS<<" ON_NODES "<<ON_NODES<<" ON_GAUSS_PT "<<ON_GAUSS_PT<<" ON_GAUSS_NE "<<ON_GAUSS_NE<<endl;;
+  //typeField ON_CELLS 0 ON_NODES 1 ON_GAUSS_PT 2 ON_GAUSS_NE 3;
+  //FieldDescriptionToData(descriptionField, &idomain, &fileName, &meshName, &fieldName, &typeField, &DT, &IT);
+  FieldShortDescriptionToData(descriptionIold, fieldName, typeField, entity, DT, IT);
+  meshName=MyGlobals::_Mesh_Names[iold];
+  
+  //MEDCouplingFieldDouble* f2=MEDLoader::ReadFieldCell(
+  //         fileName.c_str(), meshName.c_str(), meshDimRelToMax, fieldName.c_str(), DT, IT);
+  MEDCouplingFieldDouble* f2=MEDLoader::ReadField((ParaMEDMEM::TypeOfField) typeField,
+                                                  fileName.c_str(), meshName.c_str(), 0, fieldName.c_str(), DT, IT);
+  
+  DataArrayDouble* res=f2->getArray();
+  //to know names of components
+  vector <string> browse=BrowseFieldDouble(f2);
+  //done yet 
+  //double time=f2->getTime(IT,DT);
+  //browse.push_back("time="+DoubleToStr(time));
+  string localFieldInformation=descriptionIold+SerializeFromVectorOfString(browse);
+  if (MyGlobals::_Verbose>10) cout<<"proc "<<MyGlobals::_Rank<<" : localFieldInformation : "<<localFieldInformation<<endl;
+  MyGlobals::_General_Informations.push_back(localFieldInformation);
+  res->incrRef();  //free field, keep res
+  f2->decrRef();
+  _mapDataArrayDouble[descriptionIold]=res; 
+  
+  //duplicate it! because f2->decRef!!
+  //DataArrayDouble* res=f2->getArray()->deepCpy();
+  //f2->decrRef();
+  //cout<<res->reprZip()<<endl;
+  //have to put it in map for next needs.. decRef later...~MeshCollection
+  return res;
+}
+
+void MeshCollection::prepareFieldDescriptions()
+//to have unique valid fields names/pointers/descriptions for partitionning
+//filter _fieldDescriptions to be in all procs compliant and equal
+{
+  int nbfiles=MyGlobals::_File_Names.size(); //nb domains
+  vector<string> r2;
+  //from allgatherv then vector(procs) of serialised vector(fields) of vector(description) data
+  for (int i=0; i<_fieldDescriptions.size(); i++)
+    {
+      vector<string> r1=DeserializeToVectorOfString(_fieldDescriptions[i]);
+      for (int i=0; i<r1.size(); i++) r2.push_back(r1[i]);
+    }
+  //here vector(procs*fields) of serialised vector(description) data
+  _fieldDescriptions=r2;
+  int nbfields=_fieldDescriptions.size(); //on all domains
+  if ((nbfields%nbfiles)!=0)
+    {
+      if (MyGlobals::_Rank==0)
+        {
+          cerr<<"\nERROR : incoherent number of fields references in all files .med\n"<<endl
+              <<"fileMedNames :"<<endl
+              <<ReprVectorOfString(MyGlobals::_File_Names)
+              <<"fieldDescriptions :"<<endl
+              <<ReprVectorOfString(MyGlobals::_Field_Descriptions); //cvwat07
+        }
+      throw INTERP_KERNEL::Exception(LOCALIZED("incoherent number of fields references in all files .med\n"));
+    }
+  _fieldDescriptions.resize(nbfields/nbfiles);
+  for (int i=0; i<_fieldDescriptions.size(); i++)
+    {
+      string str=_fieldDescriptions[i];
+      str=EraseTagSerialized(str,"idomain=");
+      str=EraseTagSerialized(str,"fileName=");
+      _fieldDescriptions[i]=str;
+    }
+}
+
+//returns true if inodes of a face are in inodes of a cell
+bool isFaceOncell(vector< int >& inodesFace,vector< int >&  inodesCell)
+{
+  int ires=0;
+  int nbok=inodesFace.size();
+  for (int i=0; i<nbok; i++)
+    {
+      int ii=inodesFace[i];
+      if (ii<0) cout<<"isFaceOncell problem inodeface<0"<<endl;
+      for (int j=0; j<inodesCell.size(); j++)
+        {
+          if (ii==inodesCell[j])
+            {
+              ires=ires+1; break; //inode of face found
+            }
+        }
+      if (ires<i+1) break; //inode of face not found do not continue...
+    }
+  return (ires==nbok);
+}
+
+void MeshCollection::filterFaceOnCell()
+{
+  //meshesCells=_mesh;
+  //meshesFaces=_faceMesh;
+  for (int inew=0; inew<_topology->nbDomain(); inew++)
+    {
+      if (isParallelMode() && _domain_selector->isMyDomain(inew))
+        {
+          if (MyGlobals::_Verbose>200) 
+            std::cout<<"proc "<<MyGlobals::_Rank<<" : filterFaceOnCell on inewDomain "<<inew<<
+              " nbOfFaces "<<_faceMesh[inew]->getNumberOfCells()<<endl;
+          ParaMEDMEM::MEDCouplingUMesh* mcel=_mesh[inew];
+          ParaMEDMEM::MEDCouplingUMesh* mfac=_faceMesh[inew];
+      
+          //to have cellnode=f(facenode)... inodeCell=nodeIds[inodeFace]
+          vector<int> nodeIds;
+          //cout<<"proc "<<MyGlobals::_Rank<<" : nodeIds beg "<<inew<<" "<<mcel<<" "<<mfac<<endl;
+          getNodeIds(*mcel, *mfac, nodeIds);
+          if (nodeIds.size()==0) continue;  //one empty mesh nothing to do
+      
+          DataArrayInt *revNodalCel=DataArrayInt::New();
+          DataArrayInt *revNodalIndxCel=DataArrayInt::New();
+          mcel->getReverseNodalConnectivity(revNodalCel,revNodalIndxCel);
+          int *revC=revNodalCel->getPointer();
+          int *revIndxC=revNodalIndxCel->getPointer();
+      
+          vector< int > faceOnCell;
+          vector< int > faceNotOnCell;
+          int nbface=mfac->getNumberOfCells();
+          for (int iface=0; iface<nbface; iface++)
+            {
+              bool ok;
+              vector< int > inodesFace;
+              mfac->getNodeIdsOfCell(iface, inodesFace);
+              int nbnodFace=inodesFace.size();
+              //set inodesFace in mcel
+              for (int i=0; i<nbnodFace; i++) inodesFace[i]=nodeIds[inodesFace[i]];
+              int inod=inodesFace[0];
+              if (inod<0) cout<<"filterFaceOnCell problem 1"<<endl;
+              int nbcell=revIndxC[inod+1]-revIndxC[inod];
+              for (int j=0; j<nbcell; j++) //look for each cell with inod
+                {
+                  int icel=revC[revIndxC[inod]+j];
+                  vector< int > inodesCell;
+                  mcel->getNodeIdsOfCell(icel, inodesCell);
+                  ok=isFaceOncell(inodesFace, inodesCell);
+                  if (ok) break;
+                }
+              if (ok)
+                {
+                  faceOnCell.push_back(iface);
+                  //if (MyGlobals::_Is0verbose) cout<<"face on cell "<<iface<<" "<<faceOnCell.size()-1<<endl;
+                }
+              else
+                {
+                  faceNotOnCell.push_back(iface);
+                  if (MyGlobals::_Is0verbose) cout<<"face NOT on cell "<<iface<<" "<<faceOnCell.size()-1<<endl;
+                }
+            }
+      
+          revNodalCel->decrRef();
+          revNodalIndxCel->decrRef();
+      
+          string cle;
+          cle=Cle1ToStr("filterFaceOnCell",inew);
+          _mapDataArrayInt[cle]=CreateDataArrayIntFromVector(faceOnCell);
+          cle=Cle1ToStr("filterNotFaceOnCell",inew);
+          _mapDataArrayInt[cle]=CreateDataArrayIntFromVector(faceNotOnCell);
+      
+          /*ParaMEDMEM::DataArrayInt* index=ParaMEDMEM::DataArrayInt::New();
+            ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New();
+            _mesh[idomain]->getReverseNodalConnectivity(revConn,index);
+            int* index_ptr=index->getPointer();*/
+      
+          /*if (MyGlobals::_Is0verbose)
+            {
+            cout<<"proc "<<MyGlobals::_Rank<<" : nodeIds end "<<inew<<" "<<nodeIds.size()<<endl;
+            for (int i=0; i<nodeIds.size(); i++) cout<<" "<<nodeIds[i];
+            cout<<endl;
+            }*/
+
+        }
+    }
+}
+
+/*
+void MeshCollection::buildBoundaryOnCellMeshes()
+//no used... yet
+{
+  //cout<<"buildBoundaryOnCellMeshes"<<endl;
+  //meshesCells=_mesh;
+  //meshesFaces=_faceMesh;
+  for (int inew=0; inew<_topology->nbDomain(); inew++)
+  {
+    if (isParallelMode() && _domain_selector->isMyDomain(inew))
+    {
+      if (MyGlobals::_Verbose>1) std::cout<<"proc "<<MyGlobals::_Rank<<" : filterFaceOnCell on "<<inew<<" "<<_faceMesh[inew]->getNumberOfCells()<<endl;
+      ParaMEDMEM::MEDCouplingUMesh* mcel=_mesh[inew];
+      //ParaMEDMEM::MEDCouplingUMesh& mfac=_faceMesh[inew];
+      
+      DataArrayInt *desc=DataArrayInt::New();
+      DataArrayInt *descIndx=DataArrayInt::New();
+      DataArrayInt *revDesc=DataArrayInt::New();
+      DataArrayInt *revDescIndx=DataArrayInt::New();
+      //
+      MEDCouplingUMesh *meshDM1=mcel->buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx);
+      revDesc->decrRef();
+      desc->decrRef();
+      descIndx->decrRef();
+      int nbOfCells=meshDM1->getNumberOfCells();
+      const int *revDescIndxC=revDescIndx->getConstPointer();
+      std::vector<int> boundaryCells;
+      for(int i=0; i<nbOfCells; i++)
+        if(revDescIndxC[i+1]-revDescIndxC[i]==1)
+          boundaryCells.push_back(i);
+      revDescIndx->decrRef();
+      bool keepCoords=true;
+      MEDCouplingUMesh *ret=(MEDCouplingUMesh *)meshDM1->buildPartOfMySelf(&boundaryCells[0],&boundaryCells[0]+boundaryCells.size(),keepCoords);
+      meshDM1->decrRef();
+      //don't know what to do with result yet..
+      //_faceMesh[inew]->decrRef();
+      //_faceMesh[inew]=ret;
+    }
+  }
+}
+*/
+
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx
new file mode 100644 (file)
index 0000000..569c045
--- /dev/null
@@ -0,0 +1,229 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_MESHCOLLECTION_HXX__
+#define __MEDPARTITIONER_MESHCOLLECTION_HXX__
+
+#include "MEDPARTITIONER.hxx"
+#include "MEDPARTITIONER_Graph.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+
+#include <vector>
+#include <map>
+#include <string>
+
+namespace ParaMEDMEM
+{
+  class MEDCouplingUMesh;
+  class DataArrayInt;
+}
+
+namespace MEDPARTITIONER
+{
+  class Topology;
+  class MeshCollectionDriver;
+  class ParaDomainSelector;
+  class SkyLineArray;
+  class ConnectZone;
+  class JointFinder;
+  
+  typedef enum{MedAscii, MedXml, Undefined} DriverType;
+  typedef std::multimap<std::pair<int,int>, std::pair<int,int> > NodeMapping ;
+  typedef std::vector<std::pair<int,int> >  NodeList;
+  
+  class MEDPARTITIONER_EXPORT MeshCollection
+  {
+  public:
+    MeshCollection();
+    //Constructing from an existing mesh and a new topology
+    MeshCollection(MeshCollection&, Topology*, bool family_splitting=false, bool create_empty_groups=false);
+    //Constructing the mesh collection from a file
+    MeshCollection(const std::string& filename);
+    //Constructing the mesh collection from a file
+    MeshCollection(const std::string& filename, ParaDomainSelector& domainSelector);
+    //Constructing the mesh collection from a file
+    MeshCollection(const std::string& filename, const std::string& meshname);
+    ~MeshCollection();
+    bool isParallelMode() const { return _domain_selector; }
+    
+    //writing to a distributed file
+    void write(const std::string& filename);
+    
+    //getting the driver
+    MeshCollectionDriver* retrieveDriver();
+    MeshCollectionDriver* getDriver() const;
+    void setDriverType(MEDPARTITIONER::DriverType type) {_driver_type=type;}
+
+    //creation of the cell graph
+    void buildCellGraph(MEDPARTITIONER::SkyLineArray* & array,int *& edgeweights );
+    //creation and partition of the associated graph
+    Topology* createPartition(int nbdomain, Graph::splitter_type type = Graph::METIS,
+                              const std::string& ="", int* edgeweights=0, int* verticesweights=0);
+
+    //creation of a user specified partition
+    Topology* createPartition(const int* partition);
+
+    //getting mesh dimension
+    int getMeshDimension() const ;
+    //getting a reference to mesh vector
+    std::vector<ParaMEDMEM::MEDCouplingUMesh*>& getMesh();
+    std::vector<ParaMEDMEM::MEDCouplingUMesh*>& getFaceMesh();
+    std::vector<std::vector<ParaMEDMEM::MEDCouplingUMesh*> >& getGroupMeshes();
+
+    ParaMEDMEM::MEDCouplingUMesh* getMesh(int idomain) const;
+    ParaMEDMEM::MEDCouplingUMesh* getFaceMesh(int idomain);
+    std::vector<ParaMEDMEM::MEDCouplingUMesh*>& getGroupMeshes(int idomain);
+
+    std::vector<ParaMEDMEM::DataArrayInt*>& getCellFamilyIds() {return _cellFamilyIds;}
+    std::vector<ParaMEDMEM::DataArrayInt*>& getFaceFamilyIds() {return _faceFamilyIds;}
+    
+    std::map<std::string, ParaMEDMEM::DataArrayInt*>& getMapDataArrayInt() {return _mapDataArrayInt;}
+    std::map<std::string, ParaMEDMEM::DataArrayDouble*>& getMapDataArrayDouble() {return _mapDataArrayDouble;}
+
+    std::map<std::string,int>& getFamilyInfo() {return _familyInfo;}
+    std::map<std::string, std::vector<std::string> >& getGroupInfo() {return _groupInfo;}
+
+    ParaMEDMEM::DataArrayDouble* getField(std::string descriptionField, int iold);
+    std::vector<std::string>&  getFieldDescriptions() {return _fieldDescriptions;}
+    void prepareFieldDescriptions();
+    void filterFaceOnCell();
+     
+    //getting a reference to connect zones vector
+    std::vector<MEDPARTITIONER::ConnectZone*>& getCZ();
+
+    //getting a pointer to topology
+    Topology* getTopology() const ;
+    ParaDomainSelector* getParaDomainSelector() const{return _domain_selector;}
+    //setting 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 setDomainNames(const std::string& name);
+
+    //getting/setting the description of the global mesh
+    std::string getDescription() const {return _description;}
+    void setDescription(const std::string& name) { _description=name;}
+
+    //creates the node mapping between an old collection and the present one
+    void createNodeMapping(MeshCollection& initialCollection, 
+                           std::multimap<std::pair<int,int>,std::pair<int,int> >& nodeMapping);
+    
+    void castCellMeshes(MeshCollection& initialCollection, 
+                        std::vector<std::vector<std::vector<int> > >& new2oldIds);
+    
+    //creates faces on the new collection
+    void castFaceMeshes(MeshCollection& initialCollection,
+                        const std::multimap<std::pair<int,int>, std::pair<int,int> >& nodeMapping,
+                        std::vector<std::vector<std::vector<int> > >& new2oldIds);
+
+  private:
+    void castIntField2(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,
+                       std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo,
+                       std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom,
+                       std::string nameArrayTo);
+
+    void castAllFields(MeshCollection& initialCollection,
+                       std::string nameArrayTo);
+
+    void findCommonDistantNodes(std::vector<std::vector<std::multimap<int,int> > >& commonDistantNodes);
+
+    void remapIntField(const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
+                       const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
+                       const int* fromArray,
+                       int* toArray);
+    
+    void remapIntField2(int inew, int iold, 
+                        const ParaMEDMEM::MEDCouplingUMesh& sourceMesh,
+                        const ParaMEDMEM::MEDCouplingUMesh& targetMesh,
+                        const int* fromArray,
+                        std::string nameArrayTo);
+
+    void remapDoubleField3(int inew, int iold,
+                           ParaMEDMEM::DataArrayDouble* fromArray,
+                           std::string nameArrayTo,
+                           std::string descriptionField);
+
+    //link to mesh_collection topology
+    Topology* _topology;
+    
+    //control over topology
+    bool _owns_topology;
+    
+    //Driver for read/write operations
+    MeshCollectionDriver* _driver;
+    
+    //Parallelizer - mark of parallel execution mode
+    ParaDomainSelector* _domain_selector;
+    
+    //links to meshes
+    std::vector<ParaMEDMEM::MEDCouplingUMesh*> _mesh;
+    std::vector<ParaMEDMEM::MEDCouplingUMesh*> _faceMesh;
+    
+    //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;
+    
+    //DataArrayInt* storages
+    std::map<std::string, ParaMEDMEM::DataArrayInt*> _mapDataArrayInt;
+    //DataArrayDouble* storages
+    std::map<std::string, ParaMEDMEM::DataArrayDouble*> _mapDataArrayDouble;
+    
+    //fields to be partitioned
+    std::vector<std::string> _fieldDescriptions;
+    
+    //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;
+
+    //name of global mesh
+    std::string _name;
+
+    //description of global mesh
+    std::string _description;
+
+    //specifies the driver associated to the collection
+    DriverType _driver_type;
+
+    //flag specifying that the splitter should create boundary constituent entity
+    //so that they are written in joints
+    bool _subdomain_boundary_creates;
+
+    //flag specifying that families must be preserved by the splitting
+    bool _family_splitting;
+
+    //flag specifying that groups must be created on all domains, even if they are empty
+    bool _create_empty_groups;
+
+    JointFinder* _joint_finder;
+  };
+}
+#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx
new file mode 100644 (file)
index 0000000..e82ed72
--- /dev/null
@@ -0,0 +1,467 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_ParallelTopology.hxx"
+#include "MEDPARTITIONER_MeshCollectionDriver.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
+#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "MEDLoader.hxx"
+#include "MEDFileMesh.hxx"
+
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
+#include <iostream>
+#include <fstream>
+
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <sys/time.h>
+
+extern "C" {
+#include "med.h"
+}
+
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDPARTITIONER;
+
+MeshCollectionDriver::MeshCollectionDriver(MeshCollection* collection):_collection(collection)
+{
+}
+
+/*!reads a unique MED File v>=2.1
+ * and mounts the corresponding mesh in memory
+ *\param filename binary file
+ *\param meshname mesh name in the MED file
+ * */
+int MeshCollectionDriver::readSeq(const char* filename, const char* meshname)
+{
+  cout<<"readSeq"<<endl;
+  MyGlobals::_File_Names.resize(1);
+  MyGlobals::_File_Names[0]=string(filename);
+
+  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(filename,meshname);
+  //puts the only mesh in the mesh vector
+  (_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
+  (_collection->getFamilyInfo())=mfm->getFamilyInfo();
+  (_collection->getGroupInfo())=mfm->getGroupInfo();
+
+  (_collection->getCZ()).clear();
+  
+  ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()));
+  _collection->setTopology(aPT);
+  _collection->setName(meshname);
+  _collection->setDomainNames(meshname);
+  return 0;
+}
+
+
+//================================================================================
+/*!
+ * \brief Return mesh dimension from distributed med file had being read
+ */
+//================================================================================
+
+void MeshCollectionDriver::readSubdomain(vector<int*>& cellglobal, //cvwat03
+                                         vector<int*>& faceglobal,
+                                         vector<int*>& nodeglobal, int idomain)
+{
+  string meshname=MyGlobals::_Mesh_Names[idomain];
+  string file=MyGlobals::_File_Names[idomain];
+  //cout << "Reading "<<meshname<<" in "<<file<<endl; //cvw
+
+  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file.c_str(),meshname.c_str());
+  vector<int> nonEmpty=mfm->getNonEmptyLevels();
+  
+  try 
+    { 
+      (_collection->getMesh())[idomain]=mfm->getLevel0Mesh(false); 
+      //reading families groups
+      ParaMEDMEM::DataArrayInt* cellIds(mfm->getFamilyFieldAtLevel(0)->deepCpy());
+      (_collection->getCellFamilyIds())[idomain]=cellIds;
+    }
+  catch(...)
+    { 
+      (_collection->getMesh())[idomain]=CreateEmptyMEDCouplingUMesh(); // or 0 if you want tests;
+      ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
+      empty->alloc(0,1);
+      (_collection->getCellFamilyIds())[idomain]=empty;
+      cout<<"\nNO Level0Mesh (Cells)\n";
+    }
+  try 
+    { 
+      if (nonEmpty.size()>1 && nonEmpty[1]==-1)
+        {
+          (_collection->getFaceMesh())[idomain]=mfm->getLevelM1Mesh(false);
+          //reading families groups
+          ParaMEDMEM::DataArrayInt* faceIds(mfm->getFamilyFieldAtLevel(-1)->deepCpy());
+          (_collection->getFaceFamilyIds())[idomain]=faceIds;
+        }
+      else
+        {
+          throw "no faces";
+        }
+    }
+  catch(...)
+    {
+      (_collection->getFaceMesh())[idomain]=CreateEmptyMEDCouplingUMesh(); // or 0 if you want test;
+      ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
+      (_collection->getFaceFamilyIds())[idomain]=empty;
+      if (MyGlobals::_Verbose>10) cout<<"proc "<<MyGlobals::_Rank<<" : NO LevelM1Mesh (Faces)\n";
+    }
+  
+  //reading groups
+  _collection->getFamilyInfo()=mfm->getFamilyInfo();
+  _collection->getGroupInfo()=mfm->getGroupInfo();
+
+  mfm->decrRef();
+  
+  vector<string> localInformation;
+  string str;
+  localInformation.push_back(str+"ioldDomain="+IntToStr(idomain));
+  localInformation.push_back(str+"meshName="+meshname);
+  MyGlobals::_General_Informations.push_back(SerializeFromVectorOfString(localInformation));
+  vector<string> localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); //cvwat07
+  if (localFields.size()>0) 
+    MyGlobals::_Field_Descriptions.push_back(SerializeFromVectorOfString(localFields));
+}
+
+
+void MeshCollectionDriver::readSubdomain(int idomain)
+{
+  string meshname=MyGlobals::_Mesh_Names[idomain];
+  string file=MyGlobals::_File_Names[idomain];
+  //cout << "Reading "<<meshname<<" in "<<file<<endl; //cvw
+
+  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file.c_str(),meshname.c_str());
+  vector<int> nonEmpty=mfm->getNonEmptyLevels();
+  
+  try 
+    { 
+      (_collection->getMesh())[idomain]=mfm->getLevel0Mesh(false); 
+      //reading families groups
+      ParaMEDMEM::DataArrayInt* cellIds(mfm->getFamilyFieldAtLevel(0)->deepCpy());
+      (_collection->getCellFamilyIds())[idomain]=cellIds;
+    }
+  catch(...)
+    { 
+      (_collection->getMesh())[idomain]=CreateEmptyMEDCouplingUMesh(); // or 0 if you want tests;
+      ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
+      empty->alloc(0,1);
+      (_collection->getCellFamilyIds())[idomain]=empty;
+      cout<<"\nNO Level0Mesh (Cells)\n";
+    }
+  try 
+    { 
+      if (nonEmpty.size()>1 && nonEmpty[1]==-1)
+        {
+          (_collection->getFaceMesh())[idomain]=mfm->getLevelM1Mesh(false);
+          //reading families groups
+          ParaMEDMEM::DataArrayInt* faceIds(mfm->getFamilyFieldAtLevel(-1)->deepCpy());
+          (_collection->getFaceFamilyIds())[idomain]=faceIds;
+        }
+      else
+        {
+          throw "no faces";
+        }
+    }
+  catch(...)
+    {
+      (_collection->getFaceMesh())[idomain]=CreateEmptyMEDCouplingUMesh(); // or 0 if you want test;
+      ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New();
+      (_collection->getFaceFamilyIds())[idomain]=empty;
+      if (MyGlobals::_Verbose>10) cout<<"proc "<<MyGlobals::_Rank<<" : NO LevelM1Mesh (Faces)\n";
+    }
+  
+  //reading groups
+  _collection->getFamilyInfo()=mfm->getFamilyInfo();
+  _collection->getGroupInfo()=mfm->getGroupInfo();
+
+  mfm->decrRef();
+  
+  vector<string> localInformation;
+  string str;
+  localInformation.push_back(str+"ioldDomain="+IntToStr(idomain));
+  localInformation.push_back(str+"meshName="+meshname);
+  MyGlobals::_General_Informations.push_back(SerializeFromVectorOfString(localInformation));
+  vector<string> localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); //cvwat07
+  if (localFields.size()>0) 
+    MyGlobals::_Field_Descriptions.push_back(SerializeFromVectorOfString(localFields));
+}
+
+
+void MeshCollectionDriver::writeMedFile(int idomain, const string& distfilename)
+{
+  vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
+  ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain);
+  ParaMEDMEM::MEDCouplingUMesh* faceMesh=_collection->getFaceMesh(idomain);
+  ParaMEDMEM::MEDCouplingUMesh* faceMeshFilter=0;
+  
+  string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName=");
+  string cleFilter=Cle1ToStr("filterFaceOnCell",idomain);
+  DataArrayInt* filter=0;
+  if (_collection->getMapDataArrayInt().find(cleFilter)!=_collection->getMapDataArrayInt().end())
+    {
+      filter=_collection->getMapDataArrayInt().find(cleFilter)->second;
+      int* index=filter->getPointer();
+      faceMeshFilter=(MEDCouplingUMesh *) faceMesh->buildPartOfMySelf(index,index+filter->getNbOfElems(),true);
+      faceMesh=faceMeshFilter;
+    }
+  cellMesh->setName(finalMeshName.c_str());
+  meshes.push_back(cellMesh);
+  //cellMesh->zipCoords();
+  //faceMesh->zipCoords();
+  
+  faceMesh->checkCoherency();
+  if (faceMesh->getNumberOfCells()>0)
+    {
+      faceMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10);
+      meshes.push_back(faceMesh);
+    }
+  
+  /*do not work
+    ParaMEDMEM::MEDFileUMesh* mfm2=ParaMEDMEM::MEDFileUMesh::New();
+    MEDFileUMesh* mfm2 = static_cast<MEDFileUMesh*>(cellMesh->getMeshes()->getMeshAtPos(0));
+    MEDFileUMesh* mfm2 = ParaMEDMEM::MEDFileUMesh::New(cellMesh);
+    string fname="FUM_"+distfilename;
+    mfm2->setMeshAtLevel(0, cellMesh );
+    mfm2->setMeshAtLevel(-1, faceMesh );
+    mfm2->write(fname.c_str(),0);
+    mfm2->decrRef();
+  */
+  
+  ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0;
+  //ParaMEDMEM::MEDCouplingUMesh* boundaryMesh1=0;
+  //ParaMEDMEM::MEDCouplingUMesh* finalboundaryMesh=0;
+  if (MyGlobals::_Creates_Boundary_Faces>0)
+    {
+      //try to write Boundary meshes
+      bool keepCoords=false; //TODO or true
+      boundaryMesh=(MEDCouplingUMesh *) cellMesh->buildBoundaryMesh(keepCoords);
+      boundaryMesh->setName("boundaryMesh");
+      //cout<<"boundaryMesh "<<boundaryMesh->getNumberOfCells()<<endl;
+      //do not work if faceMesh present yet //The mesh dimension of meshes must be different each other!
+      //boundaryMesh->checkCoherency();
+      //boundaryMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10);
+      //meshes.push_back(boundaryMesh);
+      //string boundary="boundary_"+distfilename;
+    
+      /*try to find joint do no work
+        int rang=MyGlobals::_Rank;
+        if (rang==1) (_collection->getParaDomainSelector())->sendMesh(*(boundaryMesh),0);
+        if (rang==0) 
+        {
+        (_collection->getParaDomainSelector())->recvMesh(boundaryMesh1,1);
+        //vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
+        //vector<DataArrayInt* > corr;
+        //meshes.push_back(boundaryMesh);
+        //meshes.push_back(boundaryMesh1);
+        //need share the same coords
+        //boundaryMesh1->tryToShareSameCoordsPermute(*boundaryMesh, 1e-10);
+        //finalboundaryMesh=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,2, corr);
+        //boundaryMesh=finalboundaryMesh;
+      
+        boundaryMesh->zipCoords();
+        boundaryMesh1->zipCoords();
+        finalboundaryMesh=MEDCouplingUMesh::MergeUMeshes(boundaryMesh,boundaryMesh1);
+        DataArrayInt* commonNodes=0;
+        commonNodes=finalboundaryMesh->zipCoordsTraducer();
+        boundaryMesh=finalboundaryMesh;
+        cout<<"zipcoords"<<commonNodes->repr()<<endl;
+        }
+      */
+    }
+  
+  MEDLoader::WriteUMeshes(distfilename.c_str(), meshes, true);
+  if (faceMeshFilter!=0) faceMeshFilter->decrRef();
+  
+  
+  if (boundaryMesh!=0)
+    {
+      //doing that testMesh becomes second mesh sorted by alphabetical order of name
+      MEDLoader::WriteUMesh(distfilename.c_str(), boundaryMesh, false);
+      boundaryMesh->decrRef();
+    }
+
+  //cout<<"familyInfo :\n"<<ReprMapOfStringInt(_collection->getFamilyInfo())<<endl;
+  //cout<<"groupInfo :\n"<<ReprMapOfStringVectorOfString(_collection->getGroupInfo())<<endl;
+  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename.c_str(), _collection->getMesh(idomain)->getName());
+        
+  /*example of adding new family
+    (_collection->getFamilyInfo())["FaceNotOnCell"]=-500;
+    vector<string> FaceNotOnCell;
+    FaceNotOnCell.push_back("FaceNotOnCell");
+    (_collection->getGroupInfo())["FaceNotOnCell"]=FaceNotOnCell;
+  */
+  
+  mfm->setFamilyInfo(_collection->getFamilyInfo());
+  mfm->setGroupInfo(_collection->getGroupInfo());
+  
+  //without filter mfm->setFamilyFieldArr(-1,(_collection->getFaceFamilyIds())[idomain]);
+  
+  string cle=Cle1ToStr("faceFamily_toArray",idomain);
+  if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end())
+    {
+      DataArrayInt* fam=_collection->getMapDataArrayInt().find(cle)->second;
+      DataArrayInt* famFilter=0;
+      if (filter!=0)
+        {
+          int* index=filter->getPointer();
+          int nbTuples=filter->getNbOfElems();
+          //not the good one...buildPartOfMySelf do not exist for DataArray 
+          //Filter=fam->renumberAndReduce(index, filter->getNbOfElems());
+          famFilter=DataArrayInt::New();
+          famFilter->alloc(nbTuples,1);
+          int* pfamFilter=famFilter->getPointer();
+          int* pfam=fam->getPointer();
+          for (int i=0; i<nbTuples; i++) pfamFilter[i]=pfam[index[i]];
+          fam=famFilter;
+          mfm->setFamilyFieldArr(-1,fam);
+          famFilter->decrRef();
+        }
+      //cout<<"proc "<<MyGlobals::_Rank<<"cvw111 "<<nbTuples<<endl;
+      //mfm->setFamilyFieldArr(-1,fam);
+      //if (famFilter!=0) famFilter->decrRef();
+    }
+  
+  /*example visualisation of filter
+    if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end())
+    {
+    DataArrayInt* fam=_collection->getMapDataArrayInt().find(cle)->second;
+    string cle2=Cle1ToStr("filterNotFaceOnCell",idomain);
+    if (_collection->getMapDataArrayInt().find(cle2)!=_collection->getMapDataArrayInt().end())
+    {
+    DataArrayInt* filter=_collection->getMapDataArrayInt().find(cle2)->second;
+    int* index=filter->getPointer();
+    int* pfam=fam->getPointer();
+    for (int i=0; i<filter->getNbOfElems(); i++) pfam[index[i]]=-500;
+    }
+    mfm->setFamilyFieldArr(-1,fam);
+    //mfm->setFamilyFieldArr(-1,_collection->getMapDataArrayInt().find(cle)->second);
+    }
+  */
+  
+  cle=Cle1ToStr("cellFamily_toArray",idomain);
+  if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end())
+    mfm->setFamilyFieldArr(0,_collection->getMapDataArrayInt().find(cle)->second);
+  
+  mfm->write(distfilename.c_str(),0);
+  cle="/inewFieldDouble="+IntToStr(idomain)+"/";
+    
+  map<string,ParaMEDMEM::DataArrayDouble*>::iterator it;
+  int nbfFieldFound=0;
+  for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++)
+    {
+      string desc=(*it).first;
+      size_t found=desc.find(cle);
+      if (found==string::npos) continue;
+      if (MyGlobals::_Verbose>20) cout<<"proc "<<MyGlobals::_Rank<<" : write field "<<desc<<endl;
+      string meshName, fieldName;
+      int typeField, DT, IT, entity;
+      FieldShortDescriptionToData(desc, fieldName, typeField, entity, DT, IT);
+      double time=StrToDouble(ExtractFromDescription(desc, "time="));
+      int typeData=StrToInt(ExtractFromDescription(desc, "typeData="));
+      //int nbPtGauss=StrToInt(ExtractFromDescription(desc, "nbPtGauss="));
+      string entityName=ExtractFromDescription(desc, "entityName=");
+      MEDCouplingFieldDouble* field=0;
+      if (typeData!=6)
+        {
+          cout<<"WARNING : writeMedFile : typeData "<<typeData<<" not implemented for fields\n";
+          continue;
+        }
+      if (entityName=="MED_CELL")
+        {
+          //there is a field of idomain to write
+          field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME);
+        }
+      if (entityName=="MED_NODE_ELEMENT")
+        {
+          //there is a field of idomain to write
+          field=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME);
+        }
+      if (!field)
+        {
+          cout<<"WARNING : writeMedFile : entityName "<<entityName<<" not implemented for fields\n";
+          continue;
+        }
+      nbfFieldFound++;
+      field->setName(fieldName.c_str());
+      field->setMesh(mfm->getLevel0Mesh(false));
+      DataArrayDouble* da=(*it).second;
+    
+      //get information for components etc..
+      vector<string> r1;
+      r1=SelectTagsInVectorOfString(MyGlobals::_General_Informations,"fieldName="+fieldName);
+      r1=SelectTagsInVectorOfString(r1,"typeField="+IntToStr(typeField));
+      r1=SelectTagsInVectorOfString(r1,"DT="+IntToStr(DT));
+      r1=SelectTagsInVectorOfString(r1,"IT="+IntToStr(IT));
+      //not saved in file? field->setDescription(ExtractFromDescription(r1[0], "fieldDescription=").c_str());
+      int nbc=StrToInt(ExtractFromDescription(r1[0], "nbComponents="));
+      //double time=StrToDouble(ExtractFromDescription(r1[0], "time="));
+      if (nbc==da->getNumberOfComponents())
+        {
+          for (int i=0; i<nbc; i++) 
+            da->setInfoOnComponent(i,ExtractFromDescription(r1[0], "componentInfo"+IntToStr(i)+"=").c_str());
+        }
+      else
+        {
+          cerr<<"Problem On field "<<fieldName<<" : number of components unexpected "<<da->getNumberOfComponents()<<endl;
+        }
+    
+      field->setArray(da);
+      field->setTime(time,DT,IT);
+      field->checkCoherency();
+      try
+        {
+          MEDLoader::WriteField(distfilename.c_str(),field,false);
+          //if entityName=="MED_NODE_ELEMENT"
+          //AN INTERP_KERNEL::EXCEPTION HAS BEEN THROWN : Not implemented other profile fitting from already written mesh for fields than on NODES and on CELLS.**********
+          //modification MEDLoader.cxx done
+        }
+      catch(INTERP_KERNEL::Exception& e)
+        {
+          //cout trying rewrite all data, only one field defined
+          string tmp,newName=distfilename;
+          tmp+="_"+fieldName+"_"+IntToStr(nbfFieldFound)+".med";
+          newName.replace(newName.find(".med"),4,tmp);
+          cout<<"WARNING : writeMedFile : new file name with only one field :"<<newName<<endl;
+          MEDLoader::WriteField(newName.c_str(),field,true);
+        }
+      //cout<<"proc "<<MyGlobals::_Rank<<" : write field "<<cle<<" done"<<endl;
+    }
+  mfm->decrRef();
+}
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx
new file mode 100644 (file)
index 0000000..5ff5184
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_MESHCOLLECTIONDRIVER_HXX__
+#define __MEDPARTITIONER_MESHCOLLECTIONDRIVER_HXX__
+
+#include "MEDPARTITIONER.hxx"
+
+#include <vector>
+#include <string>
+
+namespace MEDPARTITIONER
+{
+  class MeshCollection;
+  class ParaDomainSelector;
+
+  class MEDPARTITIONER_EXPORT MeshCollectionDriver
+  {
+  public:
+    MeshCollectionDriver(MeshCollection*);
+    virtual ~MeshCollectionDriver()
+    {
+    }
+    virtual int read(const char*, ParaDomainSelector* sel=0) = 0;
+    int readSeq(const char*,const char*);
+    virtual void write(const char*, ParaDomainSelector* sel=0) = 0;
+
+  protected:
+    void readSubdomain(std::vector<int*>& cellglobal,
+                       std::vector<int*>& faceglobal,
+                       std::vector<int*>& nodeglobal, int idomain);
+    void readSubdomain(int idomain);
+    void writeMedFile(int idomain, const std::string& distfilename);
+
+    MeshCollection* _collection;
+  };
+}
+#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx
new file mode 100644 (file)
index 0000000..5a60695
--- /dev/null
@@ -0,0 +1,177 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_ParallelTopology.hxx"
+#include "MEDPARTITIONER_MeshCollectionDriver.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
+#include "MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx"
+#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+#include "MEDLoader.hxx"
+
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
+#include <iostream>
+#include <fstream>
+
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <sys/time.h>
+
+using namespace MEDPARTITIONER;
+using namespace std;
+
+MeshCollectionMedAsciiDriver::MeshCollectionMedAsciiDriver(MeshCollection* collection):MeshCollectionDriver(collection)
+{
+}
+
+/*!reads a MED File v>=2.3
+ * and mounts the corresponding meshes in memory
+ * the connect zones are created from the joints
+ * 
+ *\param filename ascii file containing the list of MED v2.3 files
+ * */
+
+int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* domainSelector)
+{
+  //distributed meshes
+  vector<int*> cellglobal;
+  vector<int*> nodeglobal;
+  vector<int*> faceglobal;
+  int nbdomain;
+
+  //reading ascii master file
+  try
+    {
+      ifstream asciiinput(filename);
+      if (!asciiinput) throw INTERP_KERNEL::Exception(LOCALIZED("Master ASCII File does not exist"));
+      char charbuffer[512];
+      asciiinput.getline(charbuffer,512);
+
+      while (charbuffer[0]=='#')
+        {
+          asciiinput.getline(charbuffer,512);
+        }
+
+      //reading number of domains
+      nbdomain=atoi(charbuffer);
+      //cout << "nb domain "<<nbdomain<<endl;
+      //    asciiinput>>nbdomain;
+      MyGlobals::_File_Names.resize(nbdomain);
+      MyGlobals::_Mesh_Names.resize(nbdomain);
+      (_collection->getMesh()).resize(nbdomain);
+      cellglobal.resize(nbdomain);
+      nodeglobal.resize(nbdomain);
+      faceglobal.resize(nbdomain);
+
+      if (nbdomain == 0) throw INTERP_KERNEL::Exception(LOCALIZED("Empty ASCII master file"));
+      for (int i=0; i<nbdomain;i++)
+        {
+          //reading information about the domain
+          string mesh;
+          int idomain;
+          string host;
+          cellglobal[i]=0;
+          faceglobal[i]=0;
+          nodeglobal[i]=0;
+
+          asciiinput >> mesh >> idomain >> MyGlobals::_Mesh_Names[i] >> host >> MyGlobals::_File_Names[i];
+
+          //Setting the name of the global mesh (which should be is the same for all the subdomains)
+          if (i==0)
+            _collection->setName(mesh);
+
+          if (idomain!=i+1)
+            {
+              throw INTERP_KERNEL::Exception(LOCALIZED("domain must be written from 1 to N in ASCII file descriptor"));
+            }
+          if ( !domainSelector || domainSelector->isMyDomain(i))
+            readSubdomain(cellglobal,faceglobal,nodeglobal, i);
+
+        } //loop on domains
+    } //of try
+  catch(...)
+    {
+      throw INTERP_KERNEL::Exception(LOCALIZED("I/O error reading parallel MED file"));
+    }
+
+  //creation of topology from mesh and connect zones
+  ParallelTopology* aPT = new ParallelTopology
+    ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
+  _collection->setTopology(aPT);
+
+  for (int i=0; i<nbdomain; i++)
+    {
+      if (cellglobal[i]!=0) delete[] cellglobal[i];
+      if (nodeglobal[i]!=0) delete[] nodeglobal[i];
+      if (faceglobal[i]!=0) delete[] faceglobal[i];
+    }
+  return 0;
+}
+
+
+/*! writes the collection of meshes in a MED v2.3 file
+ * with the connect zones being written as joints
+ * \param filename name of the ascii file containing the meshes description
+ */
+void MeshCollectionMedAsciiDriver::write(const char* filename, ParaDomainSelector* domainSelector)
+{
+  int nbdomains=_collection->getMesh().size();
+  vector<string> filenames;
+  filenames.resize(nbdomains);
+
+  //loop on the domains
+  for (int idomain=0; idomain<nbdomains; idomain++)
+    {
+      string distfilename;
+      ostringstream suffix;
+      suffix<<filename<<idomain+1<<".med";
+      distfilename=suffix.str();
+      filenames[idomain]=distfilename;
+
+      if ( !domainSelector || domainSelector->isMyDomain( idomain ) )
+        {
+          if ( !_collection->getMesh()[idomain]->getNumberOfCells()==0 ) continue;//empty domain
+          MEDLoader::WriteUMesh(distfilename.c_str(),(_collection->getMesh())[idomain],true);
+          //writeSubdomain(idomain, nbdomains, distfilename.c_str(), domainSelector);
+        }
+    }
+
+  //write master file
+  if ( !domainSelector || domainSelector->rank() == 0 )
+    {
+      ofstream file(filename);
+      file << "#MED Fichier V 2.3"<<" "<<endl;
+      file << "#"<<" "<<endl;
+      file << _collection->getMesh().size()<<" "<<endl;
+
+      for (int idomain=0; idomain<nbdomains; idomain++)
+        file << _collection->getName() <<" "<< idomain+1 << " "
+             << (_collection->getMesh())[idomain]->getName() << " localhost "
+             << filenames[idomain] << " "<<endl;
+    }
+
+}
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx
new file mode 100644 (file)
index 0000000..af53bbe
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_MESHCOLLECTIONMEDASCIIDRIVER_HXX__
+#define __MEDPARTITIONER_MESHCOLLECTIONMEDASCIIDRIVER_HXX__
+
+#include "MEDPARTITIONER_MeshCollectionDriver.hxx"
+
+namespace MEDPARTITIONER
+{
+  class MeshCollection;
+  class MeshCollectionMedAsciiDriver : public MeshCollectionDriver
+  {
+  public:
+    MeshCollectionMedAsciiDriver(MeshCollection*);
+    virtual ~MeshCollectionMedAsciiDriver()
+    {
+    }
+    int read(const char*, ParaDomainSelector* sel=0);
+    void write(const char*, ParaDomainSelector* sel=0);
+  private :
+    std::string _master_filename;
+  };
+}
+#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx
new file mode 100644 (file)
index 0000000..d8b75af
--- /dev/null
@@ -0,0 +1,284 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_ParallelTopology.hxx"
+#include "MEDPARTITIONER_MeshCollectionDriver.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
+#include "MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx"
+#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+
+#include "MEDCouplingUMesh.hxx"
+#include "MEDLoader.hxx"
+#include "MEDFileMesh.hxx"
+
+#include <vector>
+#include <string>
+#include <map>
+#include <set>
+#include <cstring>
+#include <iostream>
+#include <fstream>
+#include <sstream>
+
+#include <libxml/tree.h>
+#include <libxml/parser.h>
+#include <libxml/xpath.h>
+#include <libxml/xpathInternals.h>
+
+#include <sys/time.h>
+
+using namespace MEDPARTITIONER;
+using namespace std;
+
+/*!\class MeshCollectionMedXmlDriver
+ *
+ *\brief Driver for MED 3.2 files having Xml master files
+ *
+ * Driver for reading and writing distributed files
+ * for which the master file is written in an Xml format compliant with
+ * the MED 3.2 specification.
+ * The reading and writing of the meshes and fields are apart :
+ * the meshes must always be written/read before the fields. Reading/Writing fields
+ * is optional and is done field after field. API for reading/writing fields
+ * is written with a template so that FIELD<int> and FIELD<double>
+ * can be conveniently handled.
+ */
+
+MeshCollectionMedXmlDriver::MeshCollectionMedXmlDriver(MeshCollection* collection):MeshCollectionDriver(collection)
+{
+}
+
+/*!reads a MED File Xml Master File v>=2.3
+ * and mounts the corresponding meshes in memory
+ * the connect zones are created from the joints
+ * 
+ *\param filename Xml file containing the list of MED v2.3 files
+ * */
+
+int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* domainSelector)
+{
+  //distributed meshes
+  int nbdomain;
+  _master_filename=filename;
+
+  //reading ascii master file
+  try
+    {
+      //Setting up the Xml tree corresponding to filename
+      xmlDocPtr master_doc=xmlParseFile(filename);
+
+      if (!master_doc)
+        throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not exist or is not compliant with Xml scheme"));
+
+      //number of domains
+      xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc);
+      xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//splitting/subdomain", xpathCtx);
+      if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0)
+        throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not contain /MED/splitting/subdomain node"));
+
+      //as subdomain has only one property which is "number"
+      //it suffices to take the content of its first child 
+      const char* mystring = (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content;
+      sscanf(mystring, "%d", &nbdomain);
+
+      //mesh name
+      xmlXPathFreeObject(xpathObj);
+      xpathObj = xmlXPathEvalExpression(BAD_CAST "//content/mesh", xpathCtx);
+      if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0)
+        throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not contain /MED/content/mesh node"));
+      _collection->setName( (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content);
+
+      //cout << "nb domain " << nbdomain << endl;
+      MyGlobals::_File_Names.resize(nbdomain);
+      MyGlobals::_Mesh_Names.resize(nbdomain);
+      (_collection->getMesh()).resize(nbdomain);
+      (_collection->getFaceMesh()).resize(nbdomain);
+      (_collection->getCellFamilyIds()).resize(nbdomain);
+      (_collection->getFaceFamilyIds()).resize(nbdomain);
+
+      //retrieving the node which contains the file names
+      const char filechar[]="//files/subfile";
+      xmlXPathFreeObject(xpathObj);
+      xpathObj = xmlXPathEvalExpression(BAD_CAST filechar, xpathCtx);
+      if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0)
+        throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not contain /MED/files/subfile nodes"));
+      int nbfiles = xpathObj->nodesetval ->nodeNr;
+    
+      for (int i=0; i<nbfiles;i++)
+        {
+          //reading information about the domain
+          string host;
+          //reading file names 
+          std::ostringstream name_search_string;
+          name_search_string<<"//files/subfile[@id=\""<<i+1<<"\"]/name";
+          xmlXPathObjectPtr xpathObjfilename =
+            xmlXPathEvalExpression(BAD_CAST name_search_string.str().c_str(),xpathCtx);
+          if (xpathObjfilename->nodesetval ==0)
+            throw INTERP_KERNEL::Exception(LOCALIZED("Error retrieving a file name from subfile of Xml Master File"));
+          MyGlobals::_File_Names[i]=(const char*)xpathObjfilename->nodesetval->nodeTab[0]->children->content;
+
+          //reading the local mesh names
+          ostringstream mesh_search_string;
+          mesh_search_string<<"//mapping/mesh/chunk[@subdomain=\""<<i+1<<"\"]/name";
+
+          xmlXPathObjectPtr xpathMeshObj = xmlXPathEvalExpression(BAD_CAST mesh_search_string.str().c_str(),xpathCtx);
+          if (xpathMeshObj->nodesetval ==0)
+            throw INTERP_KERNEL::Exception(LOCALIZED("Error retrieving mesh name from chunk of Xml Master File"));
+          MyGlobals::_Mesh_Names[i]=(const char*)xpathMeshObj->nodesetval->nodeTab[0]->children->content;
+
+          if ( !domainSelector || domainSelector->isMyDomain(i))
+            readSubdomain(i);  //cvwat03
+          xmlXPathFreeObject(xpathObjfilename);
+          xmlXPathFreeObject(xpathMeshObj);
+        } //loop on domains
+
+      //LIBXML cleanup
+      xmlXPathFreeObject(xpathObj); 
+      xmlXPathFreeContext(xpathCtx); 
+      xmlFreeDoc(master_doc); 
+
+    } //of try
+  catch(...)
+    {
+      throw INTERP_KERNEL::Exception(LOCALIZED("I/O error reading parallel MED file"));
+    }
+
+
+  ParallelTopology* aPT = new ParallelTopology(_collection->getMesh());
+  //creation of topology from mesh and connect zones
+  if ( _collection->isParallelMode() )
+    {
+      //to know nb of cells on each proc to compute global cell ids from locally global
+      domainSelector->gatherNbOf(_collection->getMesh());
+    }
+  _collection->setTopology(aPT);
+  _collection->setDomainNames(_collection->getName());
+  return 0;
+}
+
+
+/*! writes the collection of meshes in a 
+ * MED v2.3 Xml file
+ * with the connect zones being written as joints
+ * \param filename name of the Xml file containing the meshes description
+ */
+void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* domainSelector)
+{
+  xmlDocPtr master_doc = 0;
+  xmlNodePtr root_node = 0, node, node2;
+  char buff[256];
+
+  //Creating the Xml document
+  master_doc = xmlNewDoc(BAD_CAST "1.0");
+  root_node = xmlNewNode(0, BAD_CAST "root");
+  xmlDocSetRootElement(master_doc,root_node);
+
+  //Creating child nodes
+  // Version tag
+  node = xmlNewChild(root_node, 0, BAD_CAST "version",0);
+  xmlNewProp(node, BAD_CAST "maj", BAD_CAST "2");
+  xmlNewProp(node, BAD_CAST "min", BAD_CAST "3");
+  xmlNewProp(node, BAD_CAST "ver", BAD_CAST "1");
+
+  //Description tag
+  time_t present;
+  time( &present);
+  struct tm *time_asc = localtime(&present);
+  char date[6];
+  sprintf(date,"%02d%02d%02d",time_asc->tm_year
+          ,time_asc->tm_mon+1
+          ,time_asc->tm_mday);
+
+  node = xmlNewChild(root_node,0, BAD_CAST "description",0);
+
+  xmlNewProp(node, BAD_CAST "what", BAD_CAST _collection->getDescription().c_str());
+  xmlNewProp(node, BAD_CAST "when", BAD_CAST date);
+
+  //Content tag
+  node =xmlNewChild(root_node,0, BAD_CAST "content",0);
+  node2 = xmlNewChild(node, 0, BAD_CAST "mesh",0);
+  xmlNewProp(node2, BAD_CAST "name", BAD_CAST _collection->getName().c_str());
+
+  //Splitting tag
+  node=xmlNewChild(root_node,0,BAD_CAST "splitting",0);
+  node2=xmlNewChild(node,0,BAD_CAST "subdomain",0);
+  sprintf(buff, "%d", _collection->getMesh().size());
+  xmlNewProp(node2, BAD_CAST "number", BAD_CAST buff);
+  node2=xmlNewChild(node,0,BAD_CAST "global_numbering",0);
+  xmlNewProp(node2, BAD_CAST "present", BAD_CAST "yes");
+
+  //Files tag
+  xmlNodePtr file_node=xmlNewChild(root_node,0,BAD_CAST "files",0);
+
+  //Mapping tag
+  node = xmlNewChild(root_node,0,BAD_CAST "mapping",0);
+  xmlNodePtr mesh_node = xmlNewChild(node, 0, BAD_CAST "mesh",0);
+  xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST _collection->getName().c_str());
+
+  int nbdomains= _collection->getMesh().size();
+
+  //loop on the domains
+  string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName=");
+  for (int idomain=nbdomains-1; idomain>=0;idomain--)
+    {
+      string distfilename;
+      ostringstream suffix;
+      suffix<<filename<<idomain+1<<".med";
+      distfilename=suffix.str();
+
+      if ( !domainSelector || domainSelector->isMyDomain( idomain ) )
+        {
+          if ( (_collection->getMesh())[idomain]->getNumberOfCells()==0 ) continue; //empty domain
+          if (MyGlobals::_Verbose>1)
+            cout<<"proc "<<domainSelector->rank()<<" : writeMedFile "<<distfilename
+                << " "<<(_collection->getMesh())[idomain]->getNumberOfCells()<<" cells"
+                << " "<<(_collection->getFaceMesh())[idomain]->getNumberOfCells()<<" faces"
+                << " "<<(_collection->getMesh())[idomain]->getNumberOfNodes()<<" nodes"<<endl;
+          writeMedFile(idomain,distfilename);
+        }
+
+      if (domainSelector->rank()==0)
+        {
+          //updating the ascii description file
+          node = xmlNewChild(file_node, 0, BAD_CAST "subfile",0);
+          sprintf (buff,"%d",idomain+1);
+          xmlNewProp(node, BAD_CAST "id", BAD_CAST buff);
+          xmlNewChild(node,0,BAD_CAST "name",BAD_CAST distfilename.c_str());
+          xmlNewChild(node,0,BAD_CAST "machine",BAD_CAST "localhost");
+
+          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());
+        }
+    }
+  
+  //create the ascii description file
+  if (domainSelector->rank()==0)
+    {
+      string myfile(filename);
+      myfile.append(".xml");
+      _master_filename=myfile;
+      if ( !domainSelector || domainSelector->rank() == 0 )
+        xmlSaveFormatFileEnc(myfile.c_str(), master_doc, "UTF-8", 1);
+    }
+  xmlFreeDoc(master_doc);
+  xmlCleanupParser();
+}
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx
new file mode 100644 (file)
index 0000000..61b4c90
--- /dev/null
@@ -0,0 +1,41 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_MESHCOLLECTIONMEDXMLDRIVER_HXX__
+#define __MEDPARTITIONER_MESHCOLLECTIONMEDXMLDRIVER_HXX__
+
+#include "MEDPARTITIONER_MeshCollectionDriver.hxx"
+
+namespace MEDPARTITIONER
+{
+  class MeshCollection;
+  class MeshCollectionMedXmlDriver : public MeshCollectionDriver
+  {
+  public:
+    MeshCollectionMedXmlDriver(MeshCollection*);
+    virtual ~MeshCollectionMedXmlDriver()
+    {
+    }
+    int read(const char*, ParaDomainSelector* sel=0);
+    void write(const char*, ParaDomainSelector* sel=0);
+  private :
+    std::string _master_filename;
+  };
+}
+#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx
new file mode 100644 (file)
index 0000000..401f9ed
--- /dev/null
@@ -0,0 +1,236 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_MetisGraph.hxx"
+#include "MEDPARTITIONER_ParaDomainSelector.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
+
+#include "InterpKernelException.hxx"
+
+#include <iostream>
+
+#ifdef ENABLE_PARMETIS
+#include <parmetis.h>
+#endif
+extern "C" {
+#include <metis.h>
+}
+
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDPARTITIONER;
+
+METISGraph::METISGraph():Graph()
+{
+}
+
+METISGraph::METISGraph(MEDPARTITIONER::SkyLineArray* graph, int* edgeweight)
+  :Graph(graph,edgeweight)
+{
+}
+
+METISGraph::~METISGraph()
+{
+}
+
+void METISGraph::partGraph(int ndomain,
+                           const std::string& options_string,
+                           ParaDomainSelector* parallelizer)
+{
+  using std::vector;
+  vector<int> ran,vx,va; //for randomize
+  
+  if (MyGlobals::_Verbose>10) cout<<"proc "<<MyGlobals::_Rank<<" : METISGraph::partGraph"<<endl;
+  
+  // number of graph vertices
+  int n=_graph->getNumberOf();
+  //graph
+  int * xadj=const_cast<int*>(_graph->getIndex());
+  int * adjncy=const_cast<int*>(_graph->getValue());
+  //constraints
+  int * vwgt=_cellweight;
+  int * adjwgt=_edgeweight;
+  int wgtflag=(_edgeweight!=0)?1:0+(_cellweight!=0)?2:0;
+  //base 0 or 1
+  int base=0;
+  //ndomain
+  int nparts=ndomain;
+  //options
+  /*
+    (0=default_option,option,random_seed) see defs.h
+    #define PMV3_OPTION_DBGLVL 1
+    #define PMV3_OPTION_SEED 2
+    #define PMV3_OPTION_IPART 3
+    #define PMV3_OPTION_PSR 3
+    seems no changes int options[4]={1,0,33,0}; //test for a random seed of 33
+  */
+  int options[4]={0,0,0,0};
+  // output parameters
+  int edgecut;
+  int* partition=new int[n];
+
+  //if (MyGlobals::_Verbose>10) cout<<"proc "<<MyGlobals::_Rank<<" : METISGraph::partGraph n="<<n<<endl;
+  if (nparts >1)
+    {
+      if ( parallelizer )
+        {
+#ifdef ENABLE_PARMETIS
+          // distribution of vertices of the graph among the processors
+          if (MyGlobals::_Verbose>100) 
+            cout<<"proc "<<MyGlobals::_Rank
+                <<" : METISGraph::partGraph ParMETIS_PartKway"<<endl;
+          int * vtxdist=parallelizer->getProcVtxdist();
+          MPI_Comm comm=MPI_COMM_WORLD;
+          try
+            {
+              if (MyGlobals::_Verbose>200) 
+                {
+                  cout<<"proc "<<MyGlobals::_Rank<<" : vtxdist :";
+                  for (int i=0; i<MyGlobals::_World_Size+1; ++i) cout<<vtxdist[i]<<" ";
+                  cout<<endl;
+          
+                  int lgxadj=vtxdist[MyGlobals::_Rank+1]-vtxdist[MyGlobals::_Rank];
+                  //cout<<"lgxadj "<<lgxadj<<" "<<n<<endl;
+          
+                  if (lgxadj>0)
+                    {
+                      cout<<"\nproc "<<MyGlobals::_Rank<<" : lgxadj "<<lgxadj<<" lgadj "<<xadj[lgxadj+1]<<endl;
+                      for (int i=0; i<10; ++i) cout<<xadj[i]<<" ";
+                      cout<<"... "<<xadj[lgxadj]<<endl;
+                      for (int i=0; i<15; ++i) cout<<adjncy[i]<<" ";
+                      int ll=xadj[lgxadj]-1;
+                      cout<<"... ["<<ll<<"] "<<adjncy[ll-1]<<" "<<adjncy[ll]<<endl;
+                      /*for (int i=0; i<=ll; ++i) {
+                        if (adjncy[i]<0) cout<<"***cvw00 error: adjncy[i]<0 "<<i<<endl;
+                        }*/
+                      int imaxx=0;
+                      //for (int ilgxadj=0; ilgxadj<lgxadj; ilgxadj++)
+                      for (int ilgxadj=0; ilgxadj<lgxadj; ilgxadj++)
+                        {
+                          int ilg=xadj[ilgxadj+1]-xadj[ilgxadj];
+                          /*if (ilg<0) cout<<"***cvw01 error: ilg<0 in xadj "<<ilgxadj<<endl;
+                            if (MyGlobals::_Is0verbose>1000) 
+                            {
+                            cout<<"\n -cell "<<ilgxadj<<" "<<ilg<<" :";
+                            for (int i=0; i<ilg; i++) cout<<" "<<adjncy[xadj[ilgxadj]+i];
+                            }*/
+                          if (ilg>imaxx) imaxx=ilg;
+                        }
+                      cout<<"\nproc "<<MyGlobals::_Rank
+                          <<" : on "<<lgxadj<<" cells, max neighbourg number (...for one cell) is "<<imaxx<<endl;
+                    }
+          
+                }
+              if ((MyGlobals::_Randomize!=0 || MyGlobals::_Atomize!=0) && MyGlobals::_World_Size==1)
+                {
+                  //randomize initially was for test on ParMETIS error (sometimes)
+                  //due to : seems no changes int options[4]={1,0,33,0}; //test for a random seed of 33
+                  //it was keeped
+                  ran=CreateRandomSize(n);
+                  RandomizeAdj(&xadj[0],&adjncy[0],ran,vx,va);
+                  ParMETIS_PartKway( //cvwat11
+                                    vtxdist, &vx[0], &va[0], vwgt, 
+                                    adjwgt, &wgtflag, &base, &nparts, options, 
+                                    &edgecut, partition, &comm );
+                }
+              else
+                {
+                  //MPI_Barrier(MPI_COMM_WORLD);
+                  //cout<<"proc "<<MyGlobals::_Rank<<" : barrier ParMETIS_PartKway done"<<endl;
+                  ParMETIS_PartKway( //cvwat11
+                                    vtxdist, xadj, adjncy, vwgt, 
+                                    adjwgt, &wgtflag, &base, &nparts, options, 
+                                    &edgecut, partition, &comm );
+                }
+
+              /*doc from parmetis.h
+                void __cdecl ParMETIS_PartKway(
+                idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, 
+                idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, int *options, 
+                int *edgecut, idxtype *part, MPI_Comm *comm);
+
+                void __cdecl ParMETIS_V3_PartKway(
+                idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt, 
+                idxtype *adjwgt, int *wgtflag, int *numflag, int *ncon, int *nparts, 
+                float *tpwgts, float *ubvec, int *options, int *edgecut, idxtype *part, 
+                MPI_Comm *comm);
+              */
+
+            }
+          catch(...)
+            {
+              //shit ParMETIS "Error! Key -2 not found!" not catched...
+              throw INTERP_KERNEL::Exception(LOCALIZED("Problem in ParMETIS_PartKway"));
+            }
+          if (n<8 && nparts==3)
+            {
+              for (int i=0; i<n; i++) partition[i]=i%3;
+            }
+#else
+          throw INTERP_KERNEL::Exception(LOCALIZED("ParMETIS is not available. Check your products, please."));
+#endif
+          //throw INTERP_KERNEL::Exception(LOCALIZED("ParMETIS is not available. Check your products, please."));
+        }
+      else
+        {
+          if (MyGlobals::_Verbose>10) 
+            cout<<"proc "<<MyGlobals::_Rank
+                <<" : METISGraph::partGraph METIS_PartGraph Recursive or Kway"<<endl;
+          if (options_string != "k")
+            METIS_PartGraphRecursive(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag,
+                                     &base, &nparts, options, &edgecut, partition);
+          else
+            METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag,
+                                &base, &nparts, options, &edgecut, partition);
+        }
+    }
+  else
+    {
+      for (int i=0; i<n; i++) partition[i]=0;
+    }
+  
+  vector<int> index(n+1);
+  vector<int> value(n);
+  index[0]=0;
+  if (ran.size()>0 && MyGlobals::_Atomize==0) //there is randomize
+    {
+      if (MyGlobals::_Is0verbose>100) cout<<"randomize"<<endl;
+      for (int i=0; i<n; i++)
+        {
+          index[i+1]=index[i]+1;
+          value[ran[i]]=partition[i];
+        }
+    }
+  else
+    {
+      for (int i=0; i<n; i++)
+        {
+          index[i+1]=index[i]+1;
+          value[i]=partition[i];
+        }
+    }
+  delete[]partition;
+
+  //creating a skylinearray with no copy of the index and partition array
+  //the fifth argument true specifies that only the pointers are passed 
+  //to the object
+  
+  _partition = new MEDPARTITIONER::SkyLineArray(index,value);
+}
+
diff --git a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.hxx
new file mode 100644 (file)
index 0000000..f4329c5
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_METISGRAPH_HXX__
+#define __MEDPARTITIONER_METISGRAPH_HXX__
+
+#include "MEDPARTITIONER_Graph.hxx"
+
+#include <string>
+
+namespace MEDPARTITIONER {
+  class SkyLineArray;
+  class MEDPARTITIONER_EXPORT METISGraph : public Graph
+  {
+  public:
+    METISGraph();
+    METISGraph(MEDPARTITIONER::SkyLineArray*, int* edgeweight=0);
+    virtual ~METISGraph();
+    void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0);
+  };
+}
+#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_SCOTCHGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_SCOTCHGraph.cxx
deleted file mode 100644 (file)
index eba5ef4..0000000
+++ /dev/null
@@ -1,105 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#include <cstdio>
-extern "C" {
-#define restrict
-#include "scotch.h"
-}
-#include "MEDPARTITIONER_Graph.hxx"
-#include "MEDPARTITIONER_SCOTCHGraph.hxx"
-
-using namespace MEDPARTITIONER;
-  
-SCOTCHGraph::SCOTCHGraph():Graph()
-{
-}
-
-SCOTCHGraph::SCOTCHGraph(MEDPARTITIONER::MEDSKYLINEARRAY* graph, int* edgeweight):Graph(graph,edgeweight)
-{
-}
-
-SCOTCHGraph::~SCOTCHGraph()
-{
-}
-
-void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* sel)
-{
-  // number of graph vertices
-  int n = _graph->getNumberOf();
-
-  //graph
-  int * xadj=const_cast<int*>(_graph->getIndex());
-  int * adjncy = const_cast<int*>(_graph->getValue());
-
-  //ndomain
-  int nparts = ndomain;
-
-  // output parameters
-  int* partition = new int[n+1];
-
-  SCOTCH_Graph scotch_graph;
-
-  SCOTCH_graphInit(&scotch_graph);
-
-
-  SCOTCH_graphBuild(&scotch_graph,
-                    1, //premier indice 1
-                    n, // nb of graph nodes
-                    xadj,
-                    0,
-                    _cellweight, //graph vertices loads
-                    0,
-                    xadj[n], // number of edges
-                    adjncy,
-                    _edgeweight);
-
-  SCOTCH_Strat scotch_strategy;           
-  SCOTCH_stratInit(&scotch_strategy);
-
-  //!user-defined options for the strategy
-  if (options_string!="")
-    SCOTCH_stratGraphMap(&scotch_strategy,options_string.c_str());
-
-
-  if (nparts>1)           
-    SCOTCH_graphPart(&scotch_graph,nparts,&scotch_strategy,partition);
-  else
-    // partition for 1 subdomain
-    for (int i=0; i<n+1; i++)
-      partition[i]=0;
-
-  SCOTCH_stratExit(&scotch_strategy);
-  SCOTCH_graphExit(&scotch_graph);
-
-    std::vector<int> index(n+1);
-  std::vector<int> value(n);
-  index[0]=0;
-  for (int i=0; i<n; i++)
-  {
-    index[i+1]=index[i]+1;
-    value[i]=partition[i];
-  }
-
-  //creating a skylinearray with no copy of the index and partition array
-  // the fifth argument true specifies that only the pointers are passed 
-  //to the object
-  
-  _partition = new MEDPARTITIONER::MEDSKYLINEARRAY(index,value);
-
-}
diff --git a/src/MEDPartitioner/MEDPARTITIONER_SCOTCHGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_SCOTCHGraph.hxx
deleted file mode 100644 (file)
index 01dab7f..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef MEDPARTITIONER_SCOTCHGRAPH_HXX_
-#define MEDPARTITIONER_SCOTCHGRAPH_HXX_
-
-#include "MEDPARTITIONER.hxx"
-#include <string>
-
-namespace MEDPARTITIONER {
-  class MEDSKYLINEARRAY;
-  class MEDPARTITIONER_EXPORT SCOTCHGraph:public Graph
-  {
-  public:
-    SCOTCHGraph();
-    SCOTCHGraph(MEDPARTITIONER::MEDSKYLINEARRAY*, int* edgeweight=0);
-    virtual ~SCOTCHGraph();
-    void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0);
-  };
-}
-#endif /*SCOTCHGRAPH_HXX_*/
diff --git a/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.cxx
new file mode 100644 (file)
index 0000000..be737ce
--- /dev/null
@@ -0,0 +1,108 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_Graph.hxx"
+#include "MEDPARTITIONER_ScotchGraph.hxx"
+
+#include <cstdio>
+
+extern "C" {
+#define restrict
+#include "scotch.h"
+}
+
+using namespace MEDPARTITIONER;
+  
+SCOTCHGraph::SCOTCHGraph():Graph()
+{
+}
+
+SCOTCHGraph::SCOTCHGraph(MEDPARTITIONER::SkyLineArray* graph, int* edgeweight):Graph(graph,edgeweight)
+{
+}
+
+SCOTCHGraph::~SCOTCHGraph()
+{
+}
+
+void SCOTCHGraph::partGraph(int ndomain, const std::string& options_string, ParaDomainSelector* sel)
+{
+  // number of graph vertices
+  int n = _graph->getNumberOf();
+
+  //graph
+  int * xadj=const_cast<int*>(_graph->getIndex());
+  int * adjncy = const_cast<int*>(_graph->getValue());
+
+  //ndomain
+  int nparts = ndomain;
+
+  // output parameters
+  int* partition = new int[n+1];
+
+  SCOTCH_Graph scotch_graph;
+
+  SCOTCH_graphInit(&scotch_graph);
+
+
+  SCOTCH_graphBuild(&scotch_graph,
+                    1, //premier indice 1
+                    n, // nb of graph nodes
+                    xadj,
+                    0,
+                    _cellweight, //graph vertices loads
+                    0,
+                    xadj[n], // number of edges
+                    adjncy,
+                    _edgeweight);
+
+  SCOTCH_Strat scotch_strategy;           
+  SCOTCH_stratInit(&scotch_strategy);
+
+  //!user-defined options for the strategy
+  if (options_string!="")
+    SCOTCH_stratGraphMap(&scotch_strategy,options_string.c_str());
+
+
+  if (nparts>1)           
+    SCOTCH_graphPart(&scotch_graph,nparts,&scotch_strategy,partition);
+  else
+    // partition for 1 subdomain
+    for (int i=0; i<n+1; i++)
+      partition[i]=0;
+
+  SCOTCH_stratExit(&scotch_strategy);
+  SCOTCH_graphExit(&scotch_graph);
+
+  std::vector<int> index(n+1);
+  std::vector<int> value(n);
+  index[0]=0;
+  for (int i=0; i<n; i++)
+    {
+      index[i+1]=index[i]+1;
+      value[i]=partition[i];
+    }
+
+  //creating a skylinearray with no copy of the index and partition array
+  // the fifth argument true specifies that only the pointers are passed 
+  //to the object
+  
+  _partition = new MEDPARTITIONER::SkyLineArray(index,value);
+
+}
diff --git a/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx b/src/MEDPartitioner/MEDPARTITIONER_ScotchGraph.hxx
new file mode 100644 (file)
index 0000000..8df0329
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_SCOTCHGRAPH_HXX__
+#define __MEDPARTITIONER_SCOTCHGRAPH_HXX__
+
+#include "MEDPARTITIONER.hxx"
+
+#include <string>
+
+namespace MEDPARTITIONER {
+  class SkyLineArray;
+  class MEDPARTITIONER_EXPORT SCOTCHGraph : public Graph
+  {
+  public:
+    SCOTCHGraph();
+    SCOTCHGraph(MEDPARTITIONER::SkyLineArray*, int* edgeweight=0);
+    virtual ~SCOTCHGraph();
+    void partGraph(int ndomain, const std::string& options_string="", ParaDomainSelector* sel=0);
+  };
+}
+#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx b/src/MEDPartitioner/MEDPARTITIONER_Utils.cxx
new file mode 100644 (file)
index 0000000..4cc67f3
--- /dev/null
@@ -0,0 +1,1618 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "MEDPARTITIONER_Utils.hxx"
+
+#include "MEDLoader.hxx"
+#include "MEDLoaderBase.hxx"
+#include "MEDFileUtilities.hxx"
+#include "CellModel.hxx"
+#include "MEDCouplingUMesh.hxx"
+#include "MEDCouplingFieldDouble.hxx"
+#include "InterpKernelException.hxx"
+#include "MEDCouplingAutoRefCountObjectPtr.hxx"
+#include "InterpKernelAutoPtr.hxx"
+
+#include <fstream>
+#include <iostream>
+#include <iomanip>
+#include <sstream>
+#include <string>
+
+#ifdef HAVE_MPI2
+#include <mpi.h>
+#endif
+
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDPARTITIONER;
+
+int MEDPARTITIONER::MyGlobals::_Verbose=0;
+int MEDPARTITIONER::MyGlobals::_Is0verbose=0;
+int MEDPARTITIONER::MyGlobals::_Rank=(-1);
+int MEDPARTITIONER::MyGlobals::_World_Size=(-1);
+int MEDPARTITIONER::MyGlobals::_Randomize=0;
+int MEDPARTITIONER::MyGlobals::_Atomize=0;
+int MEDPARTITIONER::MyGlobals::_Creates_Boundary_Faces=0;
+vector<string> MEDPARTITIONER::MyGlobals::_File_Names;
+vector<string> MEDPARTITIONER::MyGlobals::_Mesh_Names;
+vector<string> MEDPARTITIONER::MyGlobals::_Field_Descriptions;
+vector<string> MEDPARTITIONER::MyGlobals::_General_Informations;
+
+std::string MEDPARTITIONER::Trim(const std::string& s,const std::string& drop)
+{
+  string r=s;
+  r.erase(r.find_last_not_of(drop)+1);
+  return r.erase(0,r.find_first_not_of(drop));
+}
+
+std::string MEDPARTITIONER::IntToStr(const int i)
+{
+  ostringstream oss;
+  oss<<i;
+  return oss.str();
+}
+
+std::string MEDPARTITIONER::DoubleToStr(const double i)
+{
+  ostringstream oss;
+  oss<<i;
+  return oss.str();
+}
+
+int MEDPARTITIONER::StrToInt(const std::string& s)
+{
+  int res;
+  istringstream iss(s);
+  iss>>res;
+  return res;
+}
+
+double MEDPARTITIONER::StrToDouble(const std::string& s)
+{
+  double res;
+  istringstream iss(s);
+  iss>>res;
+  return res;
+}
+
+bool MEDPARTITIONER::TestArg(const char *arg, const char *argExpected, string& argValue)
+{
+  argValue="";
+  int i;
+  for (i=0; i<strlen(arg); i++)
+    {
+      if (arg[i]=='=') break;
+      if (arg[i]!=argExpected[i]) return false;
+    }
+  for (int j=i+1; j<strlen(arg); j++) argValue+=arg[j];
+  //cout<<"found at "<<i<<" "<<argValue<<endl;
+  return true;
+}
+
+std::vector<int> MEDPARTITIONER::CreateRandomSize(const int size)
+{
+  vector<int> res(size);
+  for (int i=0; i<size; i++) res[i]=i;
+  //cvw TODO or not? srand( (unsigned)time( NULL ) );
+  srand( MyGlobals::_Randomize );
+  for (int i=0; i<size; i++)
+    {
+      int ii=rand()%size;
+      int tmp=res[ii];
+      res[ii]=res[i];
+      res[i]=tmp;
+    }
+  //cout<<"CreateRandomSize "<<size<<endl;
+  if (size<50) { for (int i=0; i<size; i++) cout<<res[i]<<" "; cout<<endl; }
+  return res;
+}
+
+void MEDPARTITIONER::RandomizeAdj(int* xadj, int* adjncy, std::vector<int>& ran, vector<int>& vx, vector<int>& va)
+//randomize a xadj and adjncy, renumbering vertices belong rand.
+//work only on one processor!!!!
+{
+  if (MyGlobals::_World_Size>1)
+    {
+      cerr<<"MEDPARTITIONER::RandomizeAdj only works on one proc!"<<endl;
+      return;
+    }
+  int size=ran.size();
+  vector<int> invran(size);
+  for (int i=0; i<size; i++) invran[ran[i]]=i;
+  vx.resize(size+1);
+  int lga=xadj[size];
+  va.resize(lga);
+  int jj=0;
+  vx[0]=0;
+  for (int i=0; i<size; i++)
+    {
+      int ir=ran[i];
+      int ii=xadj[ir];
+      int lgj=xadj[ir+1]-ii;
+      for (int j=0; j<lgj; j++)
+        {
+          //va[jj]=adjncy[ii]; //for first debug only
+          va[jj]=invran[adjncy[ii]];
+          jj=jj+1;
+          ii=ii+1;
+        }
+      vx[i+1]=jj;
+    }
+}
+
+void MEDPARTITIONER::TestRandomize()
+{
+  //int xadj[6]={0,2,5,9,12,13}; //for first debug only
+  //int adjncy[13]={1,4,0,2,4,1,3,4,2,4,4,3,4};
+  int xadj[6]={0,2,5,9,12,13};
+  int adjncy[13]={0,0,1,1,1,2,2,2,2,3,3,3,4};
+  cout<<"TestRandomize"<<endl;
+  for (int i=0; i<6; i++) cout<<xadj[i]<<" "; cout<<endl;
+  for (int i=0; i<13; i++) cout<<adjncy[i]<<" "; cout<<endl;
+  int size=5;
+  vector<int> r=CreateRandomSize(size);
+  vector<int> vx,va;
+  RandomizeAdj(&xadj[0],&adjncy[0],r,vx,va);
+  for (int i=0; i<vx.size(); i++) cout<<vx[i]<<" "; cout<<endl;
+  for (int i=0; i<va.size(); i++) cout<<va[i]<<" "; cout<<endl;
+}
+
+std::string MEDPARTITIONER::ReprVectorOfString(const std::vector<string>& vec)
+{
+  if (vec.size()==0) return string(" NONE\n");
+  ostringstream oss;
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) 
+    oss<<" -> '"<<*i<<"'"<<endl;
+  return oss.str();
+}
+
+std::string MEDPARTITIONER::ReprVectorOfString(const std::vector<std::string>& vec, const std::string separator)
+{
+  if (vec.size()==0) return string(" NONE\n");
+  ostringstream oss;
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) 
+    oss<<separator<<*i;
+  return oss.str();
+}
+
+std::string MEDPARTITIONER::ReprMapOfStringInt(const std::map<std::string,int>& mymap)
+{
+  if (mymap.size()==0) return string(" NONE\n");
+  ostringstream oss;
+  for (map<string,int>::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) 
+    oss<<" -> ["<<(*i).first<<"]="<<(*i).second<<endl;
+  return oss.str();
+}
+
+std::string MEDPARTITIONER::ReprMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap)
+{
+  if (mymap.size()==0) return string(" NONE\n");
+  ostringstream oss;
+  for (map< string,vector<string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) 
+    oss<<" -> ["<<(*i).first<<"]="<<endl<<ReprVectorOfString((*i).second)<<endl;
+  return oss.str();
+}
+
+std::string MEDPARTITIONER::ReprFieldDescriptions(const std::vector<std::string>& vec, const std::string separator)
+{
+  if (vec.size()==0) return string(" NONE\n");
+  ostringstream oss;
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
+    {
+      oss<<" ->"; 
+      oss<<ReprVectorOfString(DeserializeToVectorOfString(*i), separator)<<endl;
+    }
+  return oss.str();
+}
+
+std::string MEDPARTITIONER::SerializeFromString(const std::string& s)
+//a string "hello" gives a string "    5/hello/"
+//serialized_FromVectorOfString_string+SerializeFromString("toto") is
+//equivalent to vector<string>.push_back("toto") on serialized_FromVectorOfString_string
+{
+  ostringstream oss;
+  oss<<setw(5)<<s.size()<<"/"<<s<<"/";
+  return oss.str();
+}
+
+std::string MEDPARTITIONER::SerializeFromVectorOfString(const std::vector<std::string>& vec)
+//a vector of string gives a string
+{
+  ostringstream oss;
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
+    oss<<setw(5)<<(*i).size()<<"/"<<*i<<"/";
+  //string res(oss.str());
+  return oss.str();
+}
+
+std::vector<std::string> MEDPARTITIONER::DeserializeToVectorOfString(const std::string& str)
+//a string gives a vector of string
+{
+  //vector<string> res=new vector<string>;
+  vector<string> res;
+  size_t pos=0;
+  size_t posmax=str.size();
+  if (posmax==0) return res;  //empty vector
+  size_t length;
+  while (pos < posmax-6)  //setw(5)+" "
+    {
+      istringstream iss(str.substr(pos,5));
+      iss>>length;
+      //cout<<"length "<<length<<endl;
+      if ((str[pos+5]!='/') || (str[pos+6+length]!='/'))
+        {
+          cerr<<"Error on string '"<<str<<"'"<<endl;;
+          throw INTERP_KERNEL::Exception(LOCALIZED("Error on string"));
+        }
+      res.push_back(str.substr(pos+6,length));
+      pos=pos+6+length+1;
+    }
+  return res;
+}
+
+std::string MEDPARTITIONER::EraseTagSerialized(const std::string& fromStr, const std::string& tag)
+{
+  vector<string> vec=DeserializeToVectorOfString(fromStr);
+  vector<string> res;
+  for (int i=0; i<vec.size(); i++)
+    {
+      if (vec[i].find(tag)==string::npos) res.push_back(vec[i]);
+    }
+  return MEDPARTITIONER::SerializeFromVectorOfString(res);
+}
+
+std::vector<std::string> MEDPARTITIONER::VectorizeFromMapOfStringInt(const std::map<std::string,int>& mymap)
+//elements first and second of map give one elements in result vector of string
+//converting formatted the int second as firsts characters ending at first slash
+{
+  vector<string> res;
+  for (map<string,int>::const_iterator i=mymap.begin(); i!=mymap.end(); ++i)
+    {
+      ostringstream oss;
+      oss<<(*i).second<<"/"<<(*i).first;
+      res.push_back(oss.str());
+    }
+  return res;
+}
+
+std::map<std::string,int> MEDPARTITIONER::DevectorizeToMapOfStringInt(const std::vector<std::string>& vec)
+//if existing identicals (first,second) in vector no problem, else Exception
+{
+  map<string,int> res;
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
+    {
+      size_t pos=0;
+      size_t posmax=(*i).size();
+      size_t found=(*i).find('/'); //first slash
+      if ((found==string::npos) || (found<1))
+        throw INTERP_KERNEL::Exception(LOCALIZED("Error aIntNumber/anyString is expected"));
+      int second;
+      istringstream iss((*i).substr(pos,found));
+      iss>>second;
+      string first=(*i).substr(pos+found+1,posmax-found);
+      map<string,int>::iterator it=res.find(first);
+      if (it!=res.end())
+        if ((*it).second!=second)
+          throw INTERP_KERNEL::Exception(LOCALIZED("Error not the same map value"));
+      res[first]=second;
+    }
+  return res;
+}
+
+std::vector<std::string> MEDPARTITIONER::VectorizeFromMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap)
+//elements first and second of map give one elements in result vector of string
+//adding key map and length of second vector as first string in each serialized vector
+//one serialized vector per key map
+{
+  vector<string> res;
+  for (map< string,vector<string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i)
+    {
+      vector<string> vs=(*i).second;  //a vector of string;
+      ostringstream oss;
+      oss<<"Keymap/"<<(*i).first<<"/"<<(*i).second.size();
+      vs.insert(vs.begin(), oss.str());
+      res.push_back(SerializeFromVectorOfString(vs));
+    }
+  return res;
+}
+
+std::map< std::string,std::vector<std::string> > MEDPARTITIONER::DevectorizeToMapOfStringVectorOfString(const std::vector<std::string>& vec)
+//if existing identicals keymap in vector no problem
+//duplicates in second vector
+{
+  map< string,vector<string> > res;
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
+    {
+      vector<string> vs=DeserializeToVectorOfString(*i);
+    
+      string enTete=vs[0];
+      size_t posmax=enTete.size();
+      size_t foundKey=enTete.find("Keymap/");
+      size_t foundSizeVector=enTete.find_last_of('/');
+      if ((foundKey==string::npos) || (foundKey!=0) || ((foundKey+7)>=foundSizeVector))
+        throw INTERP_KERNEL::Exception(LOCALIZED("Error Keymap/anyString/aIntNumber is expected"));
+      int sizeVector;
+      istringstream iss(enTete.substr(foundSizeVector+1,posmax-foundSizeVector));
+      iss>>sizeVector;
+      string keymap=enTete.substr(foundKey+7,foundSizeVector-foundKey-7);
+      //cout<<keymap<<" : sizeVector="<<enTete.substr(foundSizeVector+1,posmax-foundSizeVector)<<endl;
+      for (int i=1; i<=sizeVector; i++)
+        res[keymap].push_back(vs[i]); //add unconditionnaly,so merge duplicates in second vector
+    }
+  return res;
+}
+
+std::vector<std::string> MEDPARTITIONER::SelectTagsInVectorOfString(const std::vector<std::string>& vec, const std::string tag)
+{
+  vector<string> res;
+  if (vec.size()==0) return res;
+  //shit for unique and unique_copy for the duplicate CONSECUTIVE elements
+  //I do not want to sort
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
+    {
+      if ((*i).find(tag)!=string::npos) res.push_back(*i);
+    }
+  return res;
+}
+
+std::vector<std::string> MEDPARTITIONER::DeleteDuplicatesInVectorOfString(const std::vector<std::string>& vec)
+{
+  vector<string> res;
+  if (vec.size()==0) return res;
+  //shit for unique and unique_copy for the duplicate CONSECUTIVE elements
+  //I do not want to sort
+  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
+    {
+      bool found=false;
+      for (vector<string>::const_iterator j=res.begin(); j!=res.end(); ++j)
+        {
+          if ((*i).compare(*j)==0)
+            {
+              found=true;
+              break;
+            }
+        }
+      if (!found) res.push_back(*i);
+    }
+  return res;
+}
+
+std::map< std::string,std::vector<std::string> > MEDPARTITIONER::DeleteDuplicatesInMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap)
+{
+  map< string,vector<string> > res;
+  for (map< string,vector<string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i)
+    res[(*i).first]=DeleteDuplicatesInVectorOfString((*i).second);
+  return res;
+}
+
+/*
+  void MEDPARTITIONER::SendVectorOfString(const std::vector<std::string>& vec, const int target)
+  //non conseille, interblocages, utiliser sendAndReceive
+  {
+  throw INTERP_KERNEL::Exception(LOCALIZED("use SendAndReceiveVectorOfString please."));
+  string str=SerializeFromVectorOfString(vec);
+  int tag=111000;
+  int size=str.length();
+  MPI_Send( &size, 1, MPI_INT, target, tag, MPI_COMM_WORLD );
+  MPI_Send( (void*)str.data(), str.length(), MPI_CHAR, target, tag+100, MPI_COMM_WORLD );
+  cout<<"proc "<<MyGlobals::_Rank<<" : send to "<<target<<" '"<<str<<"'"<<endl;
+  }
+*/
+
+/*
+  std::vector<std::string> MEDPARTITIONER::RecvVectorOfString(const int source)
+  //non conseille, interblocages, utiliser sendAndReceive
+  {
+  throw INTERP_KERNEL::Exception(LOCALIZED("use SendAndReceiveVectorOfString please."));
+  int recSize=0;
+  int tag=111000;
+  MPI_Status status;
+  MPI_Recv(&recSize, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+  string recData(recSize,'x');
+  MPI_Recv((void*)recData.data(), recSize, MPI_CHAR, 1, tag+100, MPI_COMM_WORLD, &status);
+  //cout<<"proc "<<MyGlobals::_Rank<<" : receive from "<<source<<" '"<<recData<<"'"<<endl;
+  return DeserializeToVectorOfString(recData);
+  }
+*/
+
+std::vector<std::string> MEDPARTITIONER::SendAndReceiveVectorOfString(const std::vector<std::string>& vec, const int source, const int target)
+//not optimized but suffisant
+//return empty vector if i am not target
+{
+  int rank=MyGlobals::_Rank;
+  
+  /*for test
+    ostringstream oss;
+    oss<<"sendAndReceive from "<<setw(3)<<source<<" to "<<setw(3)<<target<<"-";
+    string str(oss.str());
+   */
+
+  MPI_Status status;
+  int tag = 111001;
+  if (rank == source)
+    {
+      string str=SerializeFromVectorOfString(vec);
+      int size=str.length();
+      MPI_Send( &size, 1, MPI_INT, target, tag, MPI_COMM_WORLD );
+      //cout<<"proc "<<source<<" : send "<<size<<endl;
+      MPI_Send( (void*)str.data(), str.length(), MPI_CHAR, target, tag+100, MPI_COMM_WORLD );
+      //cout<<"proc "<<source<<" : send    '"<<str<<"'"<<endl;
+    }
+  
+  int recSize=0;
+  if (rank == target)
+    {
+      MPI_Recv(&recSize, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+      //cout<<"proc "<<target<<" : receive "<<recSize<<endl;
+      string recData(recSize,'x');
+      MPI_Recv((void*)recData.data(), recSize, MPI_CHAR, source, tag+100, MPI_COMM_WORLD, &status);
+      //cout<<"proc "<<target<<" : receive '"<<recData<<"'"<<endl;
+      return DeserializeToVectorOfString(recData); //not empty one for target proc
+    }
+  vector<string> res;
+  return res; //empty one for other proc
+}
+
+std::vector<std::string> MEDPARTITIONER::AllgathervVectorOfString(const std::vector<std::string>& vec)
+//strings NO need all same size!!!!
+{
+  int world_size=MyGlobals::_World_Size;
+  string str=SerializeFromVectorOfString(vec);
+  
+  /*for test
+    int rank=MyGlobals::_Rank;
+    ostringstream oss;
+    oss<<"allgatherv from "<<setw(3)<<rank<<" to all"<<"-";
+    string str(oss.str());*/
+  
+  vector<int> indexes(world_size);
+  int size=str.length();
+  MPI_Allgather(&size, 1, MPI_INT, 
+                &indexes[0], 1, MPI_INT, MPI_COMM_WORLD);
+  
+  /*{
+    ostringstream oss;
+    for (int i=0; i<world_size; i++) oss<<" "<<indexes[i];
+    cout<<"proc "<<rank<<" : receive '"<<oss.str()<<"'"<<endl;
+    }*/
+  
+  //calcul of displacement
+  vector< int > disp(1,0);
+  for (int i=0; i<world_size; i++) disp.push_back( disp.back() + indexes[i] );
+  
+  string recData(disp.back(),'x');
+  MPI_Allgatherv((void*)str.data(), str.length(), MPI_CHAR,
+                 (void*)recData.data(), &indexes[0], &disp[0], MPI_CHAR,
+                 MPI_COMM_WORLD);
+  
+  //really extraordinary verbose for debug
+  vector<string> deserial=DeserializeToVectorOfString(recData);
+  if (MyGlobals::_Verbose>1000) 
+    {
+      cout<<"proc "<<MyGlobals::_Rank<<" : receive '"<<recData<<"'"<<endl;
+      cout<<"deserialize is : a vector of size "<<deserial.size()<<endl;
+      cout<<ReprVectorOfString(deserial)<<endl;
+    }
+  return deserial;
+}
+
+//void MEDPARTITIONER::sendRecvVectorOfString(const std::vector<string>& vec, const int source, const int target)
+//TODO
+
+std::string MEDPARTITIONER::Cle1ToStr(const std::string& s, const int inew)
+{
+  ostringstream oss;
+  oss<<s<<" "<<inew;
+  return oss.str();
+}
+
+void MEDPARTITIONER::Cle1ToData(const std::string& cle, std::string& s, int& inew)
+{
+  size_t posmax=cle.size();
+  size_t found=cle.find(' ');
+  if ((found==string::npos) || (found<1))
+    throw INTERP_KERNEL::Exception(LOCALIZED("Error 'aStringWithoutWhitespace aInt' is expected"));
+  s=cle.substr(0,found);
+  istringstream iss(cle.substr(found,posmax-found));
+  iss>>inew;
+}
+
+std::string MEDPARTITIONER::Cle2ToStr(const std::string& s, const int inew, const int iold)
+{
+  ostringstream oss;
+  oss<<s<<" "<<inew<<" "<<iold;
+  return oss.str();
+}
+
+void MEDPARTITIONER::Cle2ToData(const std::string& cle, std::string& s, int& inew, int& iold)
+{
+  size_t posmax=cle.size();
+  size_t found=cle.find(' ');
+  if ((found==string::npos) || (found<1))
+    throw INTERP_KERNEL::Exception(LOCALIZED("Error 'aStringWithoutWhitespace aInt aInt' is expected"));
+  s=cle.substr(0,found);
+  istringstream iss(cle.substr(found,posmax-found));
+  iss>>inew>>iold;
+}
+
+std::string MEDPARTITIONER::ExtractFromDescription(const std::string& description,const std::string& tag)
+{
+  size_t found=description.find(tag);
+  if ((found==string::npos) || (found<1))
+    {
+      cerr<<"ERROR : not found '"<<tag<<"' in '"<<description<<"'\n";
+      throw INTERP_KERNEL::Exception(LOCALIZED("Error"));
+    }
+  size_t beg=found;
+  size_t end=beg;
+  if (description[found-1]!='/')
+    {
+      //find without '/'... and pray looking for first whitespace
+      //something like 'idomain=0 fileName=tmp.med meshName=...'
+      end=description.size();
+      beg+=tag.length();
+      string res=description.substr(beg,end-beg);
+      found=res.find(' ');
+      if (found==string::npos) found=res.length();
+      res=res.substr(0,found);
+      //cout<<"find without '/' !"<<tag<<"!"<<res<<"!"<<endl;
+      return res;
+    }
+  size_t lg=StrToInt(description.substr(found-6,found));
+  beg+=tag.length();
+  //cout<<"find with '/' !"<<tag<<"!"<<description.substr(beg,lg-tag.length())<<"!"<<lg<<endl;
+  return description.substr(beg,lg-tag.length());
+}
+
+void MEDPARTITIONER::FieldDescriptionToData(const std::string& description, 
+                                            int& idomain, std::string& fileName, std::string& meshName, std::string& fieldName, int& typeField, int& DT, int& IT)
+{
+  idomain=StrToInt(ExtractFromDescription(description,"idomain="));
+  fileName=ExtractFromDescription(description,"fileName=");
+  meshName=ExtractFromDescription(description,"meshName=");
+  fieldName=ExtractFromDescription(description,"fieldName=");
+  typeField=StrToInt(ExtractFromDescription(description,"typeField="));
+  DT=StrToInt(ExtractFromDescription(description,"DT="));
+  IT=StrToInt(ExtractFromDescription(description,"IT="));
+  cout<<"idomain="<<idomain<<" fileName="<<fileName<<" meshName="<<meshName<<" fieldName="<<fieldName<<endl;
+}
+
+void MEDPARTITIONER::FieldShortDescriptionToData(const std::string& description, 
+                                                 std::string& fieldName, int& typeField, int& entity, int& DT, int& IT)
+{
+  //*meshName=ExtractFromDescription(description,"meshName=");
+  fieldName=ExtractFromDescription(description,"fieldName=");
+  typeField=StrToInt(ExtractFromDescription(description,"typeField="));
+  entity=StrToInt(ExtractFromDescription(description,"entity="));
+  DT=StrToInt(ExtractFromDescription(description,"DT="));
+  IT=StrToInt(ExtractFromDescription(description,"IT="));
+  //cout<<" meshName="<<*meshName<<" fieldName="<<*fieldName<<endl;
+}
+
+ParaMEDMEM::DataArrayInt* MEDPARTITIONER::CreateDataArrayIntFromVector(const std::vector<int>& v)
+{
+  ParaMEDMEM::DataArrayInt* p=DataArrayInt::New();
+  p->alloc(v.size(),1);
+  std::copy(v.begin(),v.end(),p->getPointer());
+  return p;
+}
+
+ParaMEDMEM::DataArrayInt* MEDPARTITIONER::CreateDataArrayIntFromVector(const std::vector<int>& v,const int nbComponents)
+{
+  ParaMEDMEM::DataArrayInt* p=DataArrayInt::New();
+  if (v.size()%nbComponents!=0)
+    throw INTERP_KERNEL::Exception(LOCALIZED("Problem size modulo nbComponents != 0"));
+  p->alloc(v.size()/nbComponents,nbComponents);
+  std::copy(v.begin(),v.end(),p->getPointer());
+  return p;
+}
+
+ParaMEDMEM::DataArrayDouble* MEDPARTITIONER::CreateDataArrayDoubleFromVector(const std::vector<double>& v)
+{
+  ParaMEDMEM::DataArrayDouble* p=DataArrayDouble::New();
+  p->alloc(v.size(),1);
+  std::copy(v.begin(),v.end(),p->getPointer());
+  return p;
+}
+
+std::vector<std::string> MEDPARTITIONER::BrowseFieldDouble(const MEDCouplingFieldDouble* fd)
+//quick almost human readable information on a field double
+
+/*
+  example done by fd->simpleRepr() :
+  FieldDouble with name : "VectorFieldOnCells"
+  Description of field is : ""
+  FieldDouble space discretization is : P0
+  FieldDouble time discretization is : One time label. Time is defined by iteration=0 order=1 and time=2.
+  Time unit is : ""
+  FieldDouble nature of field is : NoNature
+  FieldDouble default array has 3 components and 30000 tuples.
+  FieldDouble default array has following info on components : "vx" "vy" "vz"
+  Mesh support information :
+  __________________________
+  Unstructured mesh with name : "testMesh"
+  Description of mesh : ""
+  Time attached to the mesh [unit] : 0 []
+  Iteration : -1 Order : -1
+  Mesh dimension : 3
+  Space dimension : 3
+  Info attached on space dimension : "" "" ""
+  Number of nodes : 33201
+  Number of cells : 30000
+  Cell types present : NORM_HEXA8
+*/
+
+{
+  vector<string> res;
+  //res.push_back("fieldName="); res.back()+=fd->getName();
+  //not saved in file? res.push_back("fieldDescription="); res.back()+=fd->getDescription();
+  //ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n";
+  //ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n";
+  //ret << "FieldDouble nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n";
+  if (fd->getArray())
+    {
+      int nb=fd->getArray()->getNumberOfComponents();
+      res.push_back("nbComponents="); res.back()+=IntToStr(nb);
+      //ret << "FieldDouble default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
+      //ret << "FieldDouble default array has following info on components : ";
+      for (int i=0; i<nb; i++)
+        {
+          //ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
+          res.push_back("componentInfo");
+          res.back()+=IntToStr(i)+"="+fd->getArray()->getInfoOnComponent(i);
+        }
+    }
+  else
+    {
+      res.push_back("nbComponents=0");  //unknown
+    }
+  return res;
+}
+
+std::vector<std::string> MEDPARTITIONER::BrowseAllFields(const std::string& myfile)
+//quick almost human readable information on all fields in a .med file
+{
+  vector<string> res;
+  vector<string> meshNames=MEDLoader::GetMeshNames(myfile.c_str());
+  
+  for (int i=0; i<meshNames.size(); i++)
+    {
+      vector<string> fieldNames=
+        MEDLoader::GetAllFieldNamesOnMesh(myfile.c_str(),meshNames[i].c_str());
+      for (int j = 0; j < fieldNames.size(); j++)
+        {
+          vector< ParaMEDMEM::TypeOfField > typeFields=
+            MEDLoader::GetTypesOfField(myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
+          for (int k = 0; k < typeFields.size(); k++)
+            {
+              vector< pair< int, int > > its=
+                MEDLoader::GetFieldIterations(typeFields[k], myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
+              if (MyGlobals::_Is0verbose>100) cout<<"fieldName "<<fieldNames[j].c_str()<<" typeField "<<typeFields[k]<<" its.size() "<<its.size()<<endl;
+              for (int m = 0; m < its.size(); m++)
+                {
+                  vector<string> resi;
+                  resi.push_back("fileName="); resi.back()+=myfile;
+                  resi.push_back("meshName="); resi.back()+=meshNames[i];
+                  resi.push_back("fieldName="); resi.back()+=fieldNames[j];
+                  resi.push_back("typeField="); resi.back()+=IntToStr((int)typeFields[k]);
+                  resi.push_back("DT="); resi.back()+=IntToStr((int)its[m].first);
+                  resi.push_back("IT="); resi.back()+=IntToStr((int)its[m].second);
+                  res.push_back(SerializeFromVectorOfString(resi));
+                }
+            }
+        }
+    }
+  return res;
+}
+
+std::vector<std::string> MEDPARTITIONER::GetInfosOfField(const char *fileName, const char *meshName, const int idomain)
+{
+  const int lggeom=10;
+  const med_geometry_type GEOMTYPE[lggeom]={ //MED_N_CELL_FIXED_GEO] = { 
+    //MED_POINT1,
+    //MED_SEG2,
+    //MED_SEG3,
+    //MED_SEG4,
+    //MED_TRIA3,
+    //MED_QUAD4,
+    //MED_TRIA6,
+    //MED_TRIA7,
+    //MED_QUAD8,
+    //MED_QUAD9,
+    MED_TETRA4,
+    MED_PYRA5,
+    MED_PENTA6,
+    MED_HEXA8,
+    MED_OCTA12,
+    MED_TETRA10,
+    MED_PYRA13,
+    MED_PENTA15,
+    MED_HEXA20,
+    MED_HEXA27,
+    //MED_POLYGON,
+    //MED_POLYHEDRON 
+  };
+
+  const char * const GEOMTYPENAME[lggeom]={
+    //"MED_POINT1",
+    //"MED_SEG2",
+    //"MED_SEG3",
+    //"MED_SEG4",
+    //"MED_TRIA3",
+    //"MED_QUAD4",
+    //"MED_TRIA6",
+    //"MED_TRIA7",
+    //"MED_QUAD8",
+    //"MED_QUAD9",
+    "MED_TETRA4",
+    "MED_PYRA5",
+    "MED_PENTA6",
+    "MED_HEXA8",
+    "MED_OCTA12",
+    "MED_TETRA10",
+    "MED_PYRA13",
+    "MED_PENTA15",
+    "MED_HEXA20",
+    "MED_HEXA27",
+    //"MED_POLYGONE",
+    //"MED_POLYEDRE",
+  };
+
+
+  const int lgentity=3;
+  const med_entity_type ENTITYTYPE[lgentity]={ //MED_N_ENTITY_TYPES+2]={
+    //MED_UNDEF_ENTITY_TYPE,
+    MED_CELL,
+    //MED_DESCENDING_FACE,
+    //MED_DESCENDING_EDGE,
+    MED_NODE,
+    MED_NODE_ELEMENT,
+    //MED_STRUCT_ELEMENT,
+    //MED_UNDEF_ENTITY_TYPE
+  };
+
+  const char * const ENTITYTYPENAME[lgentity]={ //MED_N_ENTITY_TYPES+2]={
+    //"MED_UNDEF_ENTITY_TYPE",
+    "MED_CELL",
+    //"MED_FACE",
+    //"MED_ARETE",
+    "MED_NODE",
+    "MED_NODE_ELEMENT",
+    //"MED_STRUCT_ELEMENT",
+    //"MED_UNDEF_ENTITY_TYPE"
+  };
+  
+  vector<string> res;
+  med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
+  med_int nbFields=MEDnField(fid);
+  if (MyGlobals::_Verbose>20) cout<<"on filename "<<fileName<<" nbOfField "<<nbFields<<endl;
+  //
+  med_field_type typcha;
+  med_int numdt=0,numo=0;
+  med_float dt=0.0;
+  char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+  char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
+  med_bool localmesh;
+  //
+  for(int i=1; i<=nbFields; i++)
+    {
+      med_int ncomp=MEDfieldnComponent(fid,i);
+      INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
+      INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
+      INTERP_KERNEL::AutoPtr<char> dt_unit=new char[MED_LNAME_SIZE+1];
+      med_int nbPdt;
+      MEDfieldInfo(fid,i,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt);
+      string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
+      string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1);
+      for (int k=1; k<=nbPdt; k++)
+        {
+          MEDfieldComputingStepInfo(fid,nomcha,k,&numdt,&numo,&dt);
+          if (MyGlobals::_Verbose>20) 
+            cout<<"on filename "<<fileName<<" field "<<i<<" fieldName "<<curFieldName<<" meshName "<<curMeshName<<
+              " typ "<<typcha<<" nbComponent "<<ncomp<<" nbPdt "<<nbPdt<<" noPdt "<<k<<
+              " ndt "<<numdt<<" nor "<<numo<<" dt "<<dt<<endl;
+          for (int ie=0; ie<lgentity; ie++)
+            {
+              for (int j=0; j<lggeom; j++)
+                {
+                  int profilesize=0,nbi=0;
+                  med_entity_type enttype=ENTITYTYPE[ie];
+                  //enttype=MED_NODE;enttype=MED_CELL;enttype=MED_NODE_ELEMENT;
+                  char pflname[MED_NAME_SIZE+1]="";
+                  char locname[MED_NAME_SIZE+1]="";
+                  med_int nbofprofile=MEDfieldnProfile(fid,nomcha,numdt,numo,enttype,GEOMTYPE[j],pflname,locname);
+
+                  /*
+                    med_proto.h firefox file:///export/home/.../med-3.0.3/doc/html.dox/index.html
+                    MEDfieldnValueWithProfileByName(const med_idt fid, const char * const fieldname,const med_int numdt,const med_int numit,
+                    const med_entity_type entitype, const med_geometry_type geotype, const char * const profilename,
+                    const med_storage_mode storagemode,med_int * const profilesize,
+                    char * const localizationname, med_int * const nbofintegrationpoint);
+
+                    MEDfieldnValueWithProfile(const med_idt fid, const char * const fieldname,const med_int numdt,const med_int numit,
+                    const med_entity_type entitype, const med_geometry_type geotype,
+                    const int profileit,
+                    const med_storage_mode storagemode,char * const profilename ,med_int * const profilesize,
+                    char * const localizationname, med_int * const nbofintegrationpoint);
+                  */
+                  int profileit=1;
+                  if (enttype==MED_NODE)
+                    {
+                      med_geometry_type mygeomtype=MED_UNDEF_ENTITY_TYPE;
+                      med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit,
+                                                                MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi);
+                      if (nbOfVal>0)
+                        {
+                          if (MyGlobals::_Verbose>20)
+                            cout<<"on filename "<<fileName<<" entity "<<enttype<<" nbOfVal with "<<
+                              nbofprofile<<" profile(s) for geomType (AUCUN) nbOfVal "<<
+                              nbOfVal<<" profilName '"<<pflname<<"' profileSize "<<profilesize<<" nbPtGauss "<<nbi<<endl;
+                          vector<string> resi;
+                          resi.push_back("idomain="); resi.back()+=IntToStr(idomain);
+                          resi.push_back("fileName="); resi.back()+=fileName;
+                          resi.push_back("meshName="); resi.back()+=curMeshName;
+                          resi.push_back("fieldName="); resi.back()+=curFieldName;
+                          resi.push_back("typeField="); resi.back()+=IntToStr((int)ON_NODES);
+                          resi.push_back("typeData="); resi.back()+=IntToStr((int)typcha);  //6 for double?
+                          resi.push_back("nbComponent="); resi.back()+=IntToStr((int)ncomp);
+                          resi.push_back("DT="); resi.back()+=IntToStr((int)numdt);
+                          resi.push_back("IT="); resi.back()+=IntToStr((int)numo);
+                          resi.push_back("time="); resi.back()+=DoubleToStr(dt);
+                          resi.push_back("entity="); resi.back()+=IntToStr((int)enttype);
+                          resi.push_back("entityName="); resi.back()+=ENTITYTYPENAME[ie];
+                          resi.push_back("nbOfVal="); resi.back()+=IntToStr((int)nbOfVal);
+                          resi.push_back("profilName="); resi.back()+=pflname;
+                          resi.push_back("profileSize="); resi.back()+=IntToStr((int)profilesize);
+                          resi.push_back("nbPtGauss="); resi.back()+=IntToStr((int)nbi);
+                          res.push_back(SerializeFromVectorOfString(resi));
+                        }
+                      break; //on nodes no need to scute all geomtype
+                    }
+                  else
+                    {
+                      med_geometry_type mygeomtype=GEOMTYPE[j];
+                      med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit,
+                                                                MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi);
+                      if (nbOfVal>0)
+                        {
+                          if (MyGlobals::_Verbose>20)
+                            cout<<"on filename "<<fileName<<" entity "<<enttype<<" nbOfVal with "<<
+                              nbofprofile<<" profile(s) for geomType "<<
+                              GEOMTYPE[j]<<" "<<GEOMTYPENAME[j]<<" nbOfVal "<<
+                              nbOfVal<<" profilName '"<<pflname<<"' profileSize "<<profilesize<<" nbPtGauss "<<nbi<<endl;
+                          int typeField=(-1); //unknown
+                          if (enttype==MED_CELL) typeField=ON_CELLS;
+                          if (enttype==MED_NODE_ELEMENT) typeField=ON_GAUSS_NE;
+                          //if (enttype==??) typeField=ON_GAUSS_PT;
+                          vector<string> resi;
+                          resi.push_back("idomain="); resi.back()+=IntToStr(idomain);
+                          resi.push_back("fileName="); resi.back()+=fileName;
+                          resi.push_back("meshName="); resi.back()+=curMeshName;
+                          resi.push_back("fieldName="); resi.back()+=curFieldName;
+                          resi.push_back("typeField="); resi.back()+=IntToStr((int)typeField);
+                          resi.push_back("typeData="); resi.back()+=IntToStr((int)typcha);  //6 for double?
+                          resi.push_back("nbComponent="); resi.back()+=IntToStr((int)ncomp);
+                          resi.push_back("DT="); resi.back()+=IntToStr((int)numdt);
+                          resi.push_back("IT="); resi.back()+=IntToStr((int)numo);
+                          resi.push_back("time="); resi.back()+=DoubleToStr(dt);
+                          resi.push_back("entity="); resi.back()+=IntToStr((int)enttype);
+                          resi.push_back("entityName="); resi.back()+=ENTITYTYPENAME[ie];
+                          resi.push_back("geomType="); resi.back()+=IntToStr((int)GEOMTYPE[j]);
+                          resi.push_back("geomTypeName="); resi.back()+=GEOMTYPENAME[j];
+                          resi.push_back("nbOfVal="); resi.back()+=IntToStr((int)nbOfVal);
+                          resi.push_back("profilName="); resi.back()+=pflname;
+                          resi.push_back("profileSize="); resi.back()+=IntToStr((int)profilesize);
+                          resi.push_back("nbPtGauss="); resi.back()+=IntToStr((int)nbi);
+                          if (typeField==(-1))
+                            {
+                              cout<<"WARNING : unknown typeField for entity type "<<enttype<<endl<<
+                                SerializeFromVectorOfString(resi)<<endl;
+                              continue;  //do not register push_back
+                            }
+                          res.push_back(SerializeFromVectorOfString(resi));
+                        }
+                    }
+                }
+            }
+        }
+    }
+  delete [] maa_ass;
+  delete [] nomcha;
+  MEDfileClose(fid);
+  if (MyGlobals::_Verbose>10) cout<<"detected fields:\n"<<ReprVectorOfString(res)<<endl;
+  return res;
+}
+
+std::vector<std::string> MEDPARTITIONER::BrowseAllFieldsOnMesh(const std::string& myfile, const std::string& mymesh, const int idomain)
+//quick almost human readable information on all fields on a mesh in a .med file
+{
+  vector<string> res=GetInfosOfField(myfile.c_str(),mymesh.c_str(),idomain);
+  return res;
+  
+  /*obsolete do no work on GetTypesOfField ON_GAUSS_NE
+    vector<string> res;
+    vector<string> meshNames;
+    meshNames.push_back(mymesh);
+  
+    for (int i=0; i<meshNames.size(); i++)
+    {
+    vector<string> fieldNames=
+    MEDLoader::GetAllFieldNamesOnMesh(myfile.c_str(),meshNames[i].c_str());
+    for (int j=0; j<fieldNames.size(); j++)
+    {
+    vector< ParaMEDMEM::TypeOfField > typeFields=
+    MEDLoader::GetTypesOfField(myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
+    //if (MyGlobals::_Is0verbose>100) cout<<"fieldName "<<fieldNames[j].c_str()<<"typeField.size "<<typeFields.size()<<endl;
+    if (typeFields.size()==0) {
+    cerr<<"problem : fieldNames "<<fieldNames[j]<<" without GetTypesOfField ! Type of field specified not managed"<<endl;
+    //typeFields.push_back(ON_GAUSS_NE);
+    }
+    for (int k=0; k<typeFields.size(); k++)
+    {
+    vector< pair< int, int > > its;
+    its=MEDLoader::GetFieldIterations(typeFields[k], myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
+    //if (typeFields[k]==ON_GAUSS_NE) its.push_back(make_pair(5,6));
+    if (MyGlobals::_Is0verbose>100) cout<<"fieldName "<<fieldNames[j].c_str()<<" typeField "<<typeFields[k]<<" its.size() "<<its.size()<<endl;
+    for (int m = 0; m < its.size(); m++)
+    {
+    vector<string> resi;
+    resi.push_back("idomain="); resi.back()+=IntToStr(idomain);
+    resi.push_back("fileName="); resi.back()+=myfile;
+    resi.push_back("meshName="); resi.back()+=meshNames[i];
+    resi.push_back("fieldName="); resi.back()+=fieldNames[j];
+    resi.push_back("typeField="); resi.back()+=IntToStr((int)typeFields[k]);
+    resi.push_back("DT="); resi.back()+=IntToStr((int)its[m].first);
+    resi.push_back("IT="); resi.back()+=IntToStr((int)its[m].second);
+    //cout<<"BrowseAllFieldsOnMesh add "<<resi.size()<<endl;
+    res.push_back(SerializeFromVectorOfString(resi));
+    }
+    }
+    }
+    }
+    return res;
+  */
+}
+
+/*!
+  Sends content of \a vec to processor \a target. To be used with \a RecvDoubleVec method.
+  \param vec vector to be sent
+  \param target processor id of the target
+*/
+void MEDPARTITIONER::SendDoubleVec(const std::vector<double>& vec, const int target)
+{
+  int tag = 111002;
+  int size=vec.size();
+  if (MyGlobals::_Verbose>1000) 
+    cout<<"proc "<<MyGlobals::_Rank<<" : --> SendDoubleVec "<<size<<endl;
+#ifdef HAVE_MPI2
+  MPI_Send(&size, 1, MPI_INT, target, tag, MPI_COMM_WORLD);
+  MPI_Send(const_cast<double*>(&vec[0]), size, MPI_DOUBLE, target, tag+100, MPI_COMM_WORLD);
+#endif
+}
+
+/*! Receives messages from proc \a source to fill vector<int> vec.
+  To be used with \a SendDoubleVec method.
+
+  \param vec vector that is filled
+  \param source processor id of the incoming messages
+*/
+std::vector<double>* MEDPARTITIONER::RecvDoubleVec(const int source)
+{
+  int tag = 111002;
+  int size;
+#ifdef HAVE_MPI2
+  MPI_Status status;  
+  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+  if (MyGlobals::_Verbose>1000) 
+    cout<<"proc "<<MyGlobals::_Rank<<" : <-- RecvDoubleVec "<<size<<endl;;
+  vector<double>* vec=new vector<double>;
+  vec->resize(size);
+  MPI_Recv(&vec[0], size, MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status);
+#endif
+  return vec;
+}
+
+void MEDPARTITIONER::RecvDoubleVec(std::vector<double>& vec, const int source)
+{
+  int tag = 111002;
+  int size;
+#ifdef HAVE_MPI2
+  MPI_Status status;  
+  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+  if (MyGlobals::_Verbose>1000)
+    cout<<"proc "<<MyGlobals::_Rank<<" : <-- RecvDoubleVec "<<size<<endl;;
+  vec.resize(size);
+  MPI_Recv(&vec[0], size, MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status);
+#endif
+}
+/*!
+  Sends content of \a vec to processor \a target. To be used with \a RecvIntVec method.
+  \param vec vector to be sent
+  \param target processor id of the target
+*/
+void MEDPARTITIONER::SendIntVec(const std::vector<int>& vec, const int target)
+{
+  int tag = 111003;
+  int size=vec.size();
+  if (MyGlobals::_Verbose>1000)
+    cout<<"proc "<<MyGlobals::_Rank<<" : --> SendIntVec "<<size<<endl; //cvw 
+#ifdef HAVE_MPI2
+  MPI_Send(&size, 1, MPI_INT, target, tag, MPI_COMM_WORLD);
+  MPI_Send(const_cast<int*>(&vec[0]), size,MPI_INT, target, tag+100, MPI_COMM_WORLD);
+#endif
+}
+
+/*! Receives messages from proc \a source to fill vector<int> vec.
+  To be used with \a SendIntVec method.
+  \param vec vector that is filled
+  \param source processor id of the incoming messages
+*/
+std::vector<int>* MEDPARTITIONER::RecvIntVec(const int source)
+{
+  int tag = 111003;
+  int size;
+#ifdef HAVE_MPI2
+  MPI_Status status;  
+  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+  if (MyGlobals::_Verbose>1000) 
+    cout<<"proc "<<MyGlobals::_Rank<<" : <-- RecvIntVec "<<size<<endl; //cvw 
+  vector<int>* vec=new vector<int>;
+  vec->resize(size);
+  MPI_Recv(&vec[0], size, MPI_INT, source, tag+100, MPI_COMM_WORLD, &status);
+#endif
+  return vec;
+}
+
+void MEDPARTITIONER::RecvIntVec(std::vector<int>& vec, const int source)
+{
+  int tag = 111003;
+  int size;
+#ifdef HAVE_MPI2
+  MPI_Status status;  
+  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+  if (MyGlobals::_Verbose>1000)
+    cout<<"proc "<<MyGlobals::_Rank<<" : <-- RecvIntVec "<<size<<endl; //cvw 
+  vec.resize(size);
+  MPI_Recv(&vec[0], size, MPI_INT, source, tag+100, MPI_COMM_WORLD,&status);
+#endif
+}
+
+/*!
+  Sends content of \a dataArrayInt to processor \a target. 
+  To be used with \a RecvDataArrayInt method.
+  \param da dataArray to be sent
+  \param target processor id of the target
+*/
+void MEDPARTITIONER::SendDataArrayInt(const ParaMEDMEM::DataArrayInt* da, const int target)
+{
+  if (da==0) throw INTERP_KERNEL::Exception(LOCALIZED("Problem send DataArrayInt* NULL"));
+  int tag = 111004;
+  int size[3];
+  size[0]=da->getNbOfElems();
+  size[1]=da->getNumberOfTuples();
+  size[2]=da->getNumberOfComponents();
+  if (MyGlobals::_Verbose>1000) 
+    cout<<"proc "<<MyGlobals::_Rank<<" : --> SendDataArrayInt "<<size[0]<<endl; //cvw 
+#ifdef HAVE_MPI2
+  MPI_Send(&size, 3, MPI_INT, target, tag, MPI_COMM_WORLD);
+  const int * p=da->getConstPointer();
+  MPI_Send(const_cast<int*>(&p[0]), size[0] ,MPI_INT, target, tag+100, MPI_COMM_WORLD);
+#endif
+}
+
+/*! Receives messages from proc \a source to fill dataArrayInt da.
+  To be used with \a SendIntVec method.
+  \param da dataArrayInt that is filled
+  \param source processor id of the incoming messages
+*/
+ParaMEDMEM::DataArrayInt* MEDPARTITIONER::RecvDataArrayInt(const int source)
+{
+  int tag = 111004;
+  int size[3];
+#ifdef HAVE_MPI2
+  MPI_Status status;
+  MPI_Recv(size, 3, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+  if (MyGlobals::_Verbose>1000)
+    cout<<"proc "<<MyGlobals::_Rank<<" : <-- RecvDataArrayInt "<<size[0]<<endl; //cvw 
+  if (size[0]!=(size[1]*size[2]))
+    throw INTERP_KERNEL::Exception(LOCALIZED("Problem in RecvDataArrayInt incoherent sizes"));
+  ParaMEDMEM::DataArrayInt* da=ParaMEDMEM::DataArrayInt::New();
+  da->alloc(size[1],size[2]);
+  int * p=da->getPointer();
+  MPI_Recv(const_cast<int*>(&p[0]), size[0], MPI_INT, source, tag+100, MPI_COMM_WORLD, &status);
+#endif
+  return da;
+}
+
+/*!
+  Sends content of \a dataArrayInt to processor \a target. 
+  To be used with \a RecvDataArrayDouble method.
+  \param da dataArray to be sent
+  \param target processor id of the target
+*/
+void MEDPARTITIONER::SendDataArrayDouble(const ParaMEDMEM::DataArrayDouble* da, const int target)
+{
+  if (da==0) throw INTERP_KERNEL::Exception(LOCALIZED("Problem send DataArrayDouble* NULL"));
+  int tag = 111005;
+  int size[3];
+  size[0]=da->getNbOfElems();
+  size[1]=da->getNumberOfTuples();
+  size[2]=da->getNumberOfComponents();
+  if (MyGlobals::_Verbose>1000) 
+    cout<<"proc "<<MyGlobals::_Rank<<" : --> SendDataArrayDouble "<<size[0]<<endl; //cvw 
+#ifdef HAVE_MPI2
+  MPI_Send(&size, 3, MPI_INT, target, tag, MPI_COMM_WORLD);
+  const double * p=da->getConstPointer();
+  MPI_Send(const_cast<double*>(&p[0]), size[0] ,MPI_DOUBLE, target, tag+100, MPI_COMM_WORLD);
+#endif
+}
+
+/*! Receives messages from proc \a source to fill dataArrayDouble da.
+  To be used with \a SendDoubleVec method.
+  \param da dataArrayDouble that is filled
+  \param source processor id of the incoming messages
+*/
+ParaMEDMEM::DataArrayDouble* MEDPARTITIONER::RecvDataArrayDouble(const int source)
+{
+  int tag = 111005;
+  int size[3];
+#ifdef HAVE_MPI2
+  MPI_Status status;
+  MPI_Recv(size, 3, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
+  if (MyGlobals::_Verbose>1000)
+    cout<<"proc "<<MyGlobals::_Rank<<" : <-- RecvDataArrayDouble "<<size[0]<<endl; //cvw 
+  if (size[0]!=(size[1]*size[2]))
+    throw INTERP_KERNEL::Exception(LOCALIZED("Problem in RecvDataArrayDouble incoherent sizes"));
+  ParaMEDMEM::DataArrayDouble* da=ParaMEDMEM::DataArrayDouble::New();
+  da->alloc(size[1],size[2]);
+  double * p=da->getPointer();
+  MPI_Recv(const_cast<double*>(&p[0]), size[0], MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status);
+#endif
+  return da;
+}
+
+ParaMEDMEM::MEDCouplingUMesh* MEDPARTITIONER::CreateEmptyMEDCouplingUMesh()
+//create empty MEDCouplingUMesh* dim 3
+{
+  ParaMEDMEM::MEDCouplingUMesh* umesh=ParaMEDMEM::MEDCouplingUMesh::New();
+  umesh->setMeshDimension(3);
+  umesh->allocateCells(0);
+  umesh->finishInsertingCells();
+  ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
+  myCoords->alloc(0,3);
+  umesh->setCoords(myCoords);
+  umesh->setName("EMPTY");
+  myCoords->decrRef();
+  umesh->checkCoherency();
+  return umesh;
+}
+
+void MEDPARTITIONER::TestVectorOfStringMpi()
+{
+  int rank=MyGlobals::_Rank;
+  int world_size=MyGlobals::_World_Size;
+  vector<string> myVector;
+  ostringstream oss;
+  oss<<"hello from "<<setw(5)<<rank<<" "<<string(rank+1,'n')<<
+    " next is an empty one";
+  myVector.push_back(oss.str());
+  myVector.push_back("");
+  myVector.push_back("next is an singleton");
+  myVector.push_back("1");
+  
+  if (rank==0)
+    {
+      /*
+        string s0=SerializeFromVectorOfString(myVector);
+        cout<<"s0 is : a string '"<<s0<<"'"<<endl;
+        vector<string> v0=DeserializeToVectorOfString(s0);
+        cout<<"v0 is : a vector of size "<<v0.size()<<endl;
+        cout<<ReprVectorOfString(v0)<<endl;
+      */
+      string s0=SerializeFromVectorOfString(myVector);
+      vector<string> res=DeserializeToVectorOfString(s0);
+      if (res.size()!=myVector.size()) 
+        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)serialise VectorOfString incoherent sizes"));
+      for (int i=0; i<myVector.size(); i++)
+        if (res[i]!=myVector[i])
+          throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)serialise VectorOfString incoherent elements"));
+    }
+
+  for (int i=0; i<world_size; i++)
+    {
+      for (int j=0; j<world_size; j++)
+        {
+          vector<string> res=SendAndReceiveVectorOfString(myVector, i, j);
+          if ((rank==j) && MyGlobals::_Verbose>20)
+            cout<<"proc "<<rank<<" : receive \n"<<ReprVectorOfString(res)<<endl;
+          if (rank==j)
+            {
+              if (res.size()!=myVector.size()) 
+                throw INTERP_KERNEL::Exception(LOCALIZED("Problem in SendAndReceiveVectorOfString incoherent sizes"));
+              for (int i=1; i<myVector.size(); i++) //first is different
+                if (res[i]!=myVector[i])
+                  throw INTERP_KERNEL::Exception(LOCALIZED("Problem in SendAndReceiveVectorOfString incoherent elements"));
+            }
+          else 
+            {
+              if (res.size()!=0) 
+                throw INTERP_KERNEL::Exception(LOCALIZED("Problem in SendAndReceiveVectorOfString size have to be 0"));
+            }
+        }
+    }
+  vector<string> res=AllgathervVectorOfString(myVector);
+  //sometimes for test
+  res=AllgathervVectorOfString(myVector);
+  res=AllgathervVectorOfString(myVector);
+  if (rank==0 && MyGlobals::_Verbose>20)
+    cout<<"proc "<<rank<<" : receive \n"<<ReprVectorOfString(res)<<endl;
+  if (res.size()!=myVector.size()*world_size) 
+    throw INTERP_KERNEL::Exception(LOCALIZED("Problem in AllgathervVectorOfString incoherent sizes"));
+  int jj=(-1);
+  for (int j=0; j<world_size; j++)
+    {
+      for (int i=0; i<myVector.size(); i++)
+        {
+          jj=jj+1;
+          if (i==0) continue; //first is different
+          if (res[jj]!=myVector[i])
+            throw INTERP_KERNEL::Exception(LOCALIZED("Problem in AllgathervVectorOfString incoherent elements"));
+        }
+    }
+  if (MyGlobals::_Verbose) cout<<"proc "<<rank<<" : OK TestVectorOfStringMpi END"<< endl;
+}
+
+void MEDPARTITIONER::TestMapOfStringIntMpi()
+{
+  int rank=MyGlobals::_Rank;
+  //int world_size=MyGlobals::_World_Size;
+  map<string,int> myMap;
+  myMap["one"]=1;
+  myMap["two"]=22;  //a bug
+  myMap["three"]=3;
+  myMap["two"]=2; //last speaking override
+  
+  if (rank==0)
+    {
+      vector<string> v2=VectorizeFromMapOfStringInt(myMap);
+      /*
+        cout<<"v2 is : a vector of size "<<v2.size()<<endl;
+        cout<<ReprVectorOfString(v2)<<endl;
+      */
+      map<string,int> m3=DevectorizeToMapOfStringInt(v2);
+      if (ReprMapOfStringInt(m3)!=ReprMapOfStringInt(myMap))
+        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)vectorize MapOfStringInt"));
+    }
+    
+  vector<string> v2=AllgathervVectorOfString(VectorizeFromMapOfStringInt(myMap));
+  if (rank==0 && MyGlobals::_Verbose>20)
+    {
+      cout<<"v2 is : a vector of size "<<v2.size()<<endl;
+      cout<<ReprVectorOfString(v2)<<endl;
+      map<string,int> m2=DevectorizeToMapOfStringInt(v2);
+      cout<<"m2 is : a map of size "<<m2.size()<<endl;
+      cout<<ReprMapOfStringInt(m2)<<endl;
+    }
+  if (MyGlobals::_Verbose) cout<<"proc "<<rank<<" : OK TestMapOfStringIntMpi END"<< endl;
+}
+
+void MEDPARTITIONER::TestMapOfStringVectorOfStringMpi()
+{
+  int rank=MyGlobals::_Rank;
+  //int world_size=MyGlobals::_World_Size;
+  vector<string> myVector;
+  ostringstream oss;
+  oss<<"hello from "<<setw(5)<<MyGlobals::_Rank<<" "<<string(rank+1,'n')<<
+    " next is an empty one";
+  myVector.push_back(oss.str());
+  myVector.push_back("");
+  myVector.push_back("next is an singleton");
+  myVector.push_back("1");
+  
+  if (rank==0)
+    {
+      map< string,vector<string> > m2;
+      m2["first key"]=myVector;
+      m2["second key"]=myVector;
+      vector<string> v2=VectorizeFromMapOfStringVectorOfString(m2);
+      map< string,vector<string> > m3=DevectorizeToMapOfStringVectorOfString(v2);
+      if (rank==0 && MyGlobals::_Verbose>20)
+        cout<<"m2 is : a MapOfStringVectorOfString of size "<<m2.size()<<endl;
+      cout<<ReprMapOfStringVectorOfString(m2)<<endl;
+      cout<<"v2 is : a vector of size "<<v2.size()<<endl;
+      cout<<ReprVectorOfString(v2)<<endl;
+      cout<<"m3 is : a map of size "<<m3.size()<<endl;
+      cout<<ReprMapOfStringVectorOfString(m3)<<endl;
+      if (ReprMapOfStringVectorOfString(m3)!=ReprMapOfStringVectorOfString(m2))
+        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)vectorize MapOfStringVectorOfString"));
+    }
+    
+  map< string,vector<string> > m4;
+  m4["1rst key"]=myVector;
+  m4["2snd key"]=myVector;
+  vector<string> v4=AllgathervVectorOfString(VectorizeFromMapOfStringVectorOfString(m4));
+  if (rank==0 && MyGlobals::_Verbose>20)
+    {
+      map< string,vector<string> > m5=DevectorizeToMapOfStringVectorOfString(v4);
+      map< string,vector<string> > m6=DeleteDuplicatesInMapOfStringVectorOfString(m5);
+      cout<<"m5 is : a map of size "<<m5.size()<<endl;
+      cout<<ReprMapOfStringVectorOfString(m5)<<endl;
+      cout<<"m6 is : a map from m5 with deleteDuplicates of size "<<m6.size()<<endl;
+      cout<<ReprMapOfStringVectorOfString(m6)<<endl;
+    }
+  if (MyGlobals::_Verbose) cout<<"proc "<<rank<<" : OK TestMapOfStringVectorOfStringMpi END"<< endl;
+}
+
+void MEDPARTITIONER::TestDataArrayMpi()
+{
+  int rank=MyGlobals::_Rank;
+  //int
+  {
+    ParaMEDMEM::DataArrayInt* send=ParaMEDMEM::DataArrayInt::New();
+    ParaMEDMEM::DataArrayInt* recv=0;
+    int nbOfTuples=5;
+    int numberOfComponents=3;
+    send->alloc(nbOfTuples,numberOfComponents);
+    vector<int> vals;
+    for (int j=0; j<nbOfTuples; j++)
+      for (int i=0; i<numberOfComponents; i++) vals.push_back((j+1)*10+i+1);
+    std::copy(vals.begin(),vals.end(),send->getPointer());
+    if (rank==0) SendDataArrayInt(send, 1);
+    if (rank==1) recv=RecvDataArrayInt(0);
+    if (rank==1 && MyGlobals::_Verbose>20)
+      {
+        cout<<send->repr()<<endl;
+        cout<<recv->repr()<<endl;
+      }
+    if (rank==1)
+      {
+        if (send->repr()!=recv->repr())
+          throw INTERP_KERNEL::Exception(LOCALIZED("Problem in send&recv DataArrayInt"));
+      }
+    send->decrRef();
+    if (rank==1) recv->decrRef();
+  }
+  //double
+  {
+    ParaMEDMEM::DataArrayDouble* send=ParaMEDMEM::DataArrayDouble::New();
+    ParaMEDMEM::DataArrayDouble* recv=0;
+    int nbOfTuples=5;
+    int numberOfComponents=3;
+    send->alloc(nbOfTuples,numberOfComponents);
+    vector<double> vals;
+    for (int j=0; j<nbOfTuples; j++)
+      for (int i=0; i<numberOfComponents; i++) vals.push_back(double(j+1)+double(i+1)/10);
+    std::copy(vals.begin(),vals.end(),send->getPointer());
+    if (rank==0) SendDataArrayDouble(send, 1);
+    if (rank==1) recv=RecvDataArrayDouble(0);
+    if (rank==1 && MyGlobals::_Verbose>20)
+      {
+        cout<<send->repr()<<endl;
+        cout<<recv->repr()<<endl;
+      }
+    if (rank==1)
+      {
+        if (send->repr()!=recv->repr())
+          throw INTERP_KERNEL::Exception(LOCALIZED("Problem in send&recv DataArrayDouble"));
+      }
+    send->decrRef();
+    if (rank==1) recv->decrRef();
+  }
+  
+  if (MyGlobals::_Verbose) cout<<"proc "<<rank<<" : OK TestDataArrayMpi END"<< endl;
+}
+
+void MEDPARTITIONER::TestPersistantMpi0To1(int taille, int nb)
+{
+  double temps_debut=MPI_Wtime();
+  int rang=MyGlobals::_Rank;
+  vector<int> x, y;
+  int tag=111111;
+  MPI_Request requete0, requete1;
+  MPI_Status statut;
+  int ok=0;
+  string res;
+  if (rang==0)
+    {
+      x.resize(taille);
+      MPI_Ssend_init(&x[0], taille, MPI_INT, 1, tag, MPI_COMM_WORLD , &requete0);
+      for(int k=0; k<nb; k++)
+        {
+          for (int i=0; i<taille; ++i) x[i]=k;
+          //Envoi d’un gros message --> cela peut prendre du temps
+          MPI_Start(&requete0);
+          //Traitement sequentiel independant de "x"
+          //...
+          MPI_Wait(&requete0, &statut);
+          //Traitement sequentiel impliquant une modification de "x" en memoire
+          //x=...
+        }
+      MPI_Request_free(&requete0);
+    }
+  else if (rang == 1)
+    {
+      y.resize(taille);
+      MPI_Recv_init(&y[0], taille,  MPI_INT, 0, tag, MPI_COMM_WORLD , &requete1);
+      for(int k=0; k<nb; k++)
+        {
+          //Pre-traitement sequentiel
+          //...
+          for (int i=0; i<taille; ++i) y[i]=(-1);
+          //Reception du gros message --> cela peut prendre du temps
+          MPI_Start(&requete1);
+          //Traitement sequentiel independant de "y"
+          //...
+          MPI_Wait(&requete1, &statut);
+          //Traitement sequentiel dependant de "y"
+          //...=f(y)
+          int nb=0;
+          for (int i=0; i<taille; ++i)
+            if (y[i]==k) nb++;
+          if (nb==taille) ok++;
+          if (MyGlobals::_Verbose>9)
+            {
+              res="0K"; if (nb!=taille) res="KO";
+              cout<<res<<k<<" ";
+            }
+        }
+      res="0K"; if (ok!=nb) res="MAUVAIS";
+      if (MyGlobals::_Verbose>1) 
+        cout<<"resultat "<<res<<" time(sec) "<<MPI_Wtime()-temps_debut<<endl;
+      MPI_Request_free(&requete1);
+    }
+  //temps_fin=(MPI_WTIME()-temps_debut);
+}
+
+void MEDPARTITIONER::TestPersistantMpiRing(int taille, int nb)
+{
+  double temps_debut=MPI_Wtime();
+  int befo, next, rang, wsize, tagbefo, tagnext;
+  rang=MyGlobals::_Rank;
+  wsize=MyGlobals::_World_Size;
+  befo=rang-1; if (befo<0) befo=wsize-1;
+  next=rang+1; if (next>=wsize) next=0;
+  vector<int> x, y;
+  tagbefo=111111+befo;
+  tagnext=111111+rang;
+  MPI_Request requete0, requete1;
+  MPI_Status statut1, statut2;
+  int ok=0;
+  string res;
+  //cout<<"ini|"<<rang<<'|'<<befo<<'|'<<next<<' ';
+  {
+    x.resize(taille);
+    y.resize(taille);
+    MPI_Ssend_init(&x[0], taille, MPI_INT, next, tagnext, MPI_COMM_WORLD , &requete0);
+    MPI_Recv_init(&y[0], taille,  MPI_INT, befo, tagbefo, MPI_COMM_WORLD , &requete1);
+    //cout<<"isr|"<<rang<<'|'<<requete0<<'|'<<requete1<<' ';
+    for(int k=0; k<nb; k++)
+      {
+        for (int i=0; i<taille; ++i) x[i]=k+rang;
+        //Envoi d’un gros message --> cela peut prendre du temps
+        MPI_Start(&requete0);
+        //Reception du gros message --> cela peut prendre du temps
+        for (int i=0; i<taille; ++i) y[i]=(-1);
+        MPI_Start(&requete1);
+        //Traitement sequentiel independant de "x"
+        //...
+        //Traitement sequentiel independant de "y"
+        //...
+        //cout<<"dsr|"<<rang<<' ';
+        MPI_Wait(&requete1, &statut1);
+        //Traitement sequentiel dependant de "y"
+        //...=f(y)
+        int nb=0;
+        for (int i=0; i<taille; ++i)
+          if (y[i]==k+befo) nb++;
+        if (nb==taille) ok++;
+        if (MyGlobals::_Verbose>9)
+          {
+            res="0K"+IntToStr(rang); if (nb!=taille) res="KO"+IntToStr(rang);
+            cout<<res<<k<<" ";
+          }
+        MPI_Wait(&requete0, &statut2);
+        //Traitement sequentiel impliquant une modification de "x" en memoire
+        //x=...
+      }
+    res="0K"; if (ok!=nb) res="MAUVAIS";
+    temps_debut=MPI_Wtime()-temps_debut;
+    MPI_Request_free(&requete1);
+    MPI_Request_free(&requete0);
+  }
+  //temps_fin=(MPI_WTIME()-temps_debut);
+  if (MyGlobals::_Verbose>1) 
+    cout<<"resultat proc "<<rang<<" "<<res<<" time(sec) "<<temps_debut<<endl;
+}
+void MEDPARTITIONER::TestPersistantMpiRingOnCommSplit(int taille, int nb)
+{
+  double temps_debut=MPI_Wtime();
+  int rang=MyGlobals::_Rank;
+  MPI_Comm newcomm;
+  int couleur=1;
+  int rangMax=4;
+  if (rang>=rangMax) couleur=MPI_UNDEFINED;
+  cout<<"coul|"<<rang<<'|'<<couleur<<' ';
+  //MPI_Comm_dup (MPI_COMM_WORLD, &newcomm) ;
+  MPI_Comm_split(MPI_COMM_WORLD, couleur, rang, &newcomm);
+  
+  int befo, next, wsize, tagbefo, tagnext;
+  wsize=rangMax;
+  if (wsize>MyGlobals::_World_Size) wsize=MyGlobals::_World_Size;
+  befo=rang-1; if (befo<0) befo=wsize-1;
+  next=rang+1; if (next>=wsize) next=0;
+  vector<int> x, y;
+  tagbefo=111111+befo;
+  tagnext=111111+rang;
+  MPI_Request requete0, requete1;
+  MPI_Status statut1, statut2;
+  int ok=0;
+  string res;
+  
+  //cout<<"ini|"<<rang<<'|'<<befo<<'|'<<next<<' ';
+  if (couleur==1)
+    {
+      x.resize(taille);
+      y.resize(taille);
+      MPI_Ssend_init(&x[0], taille, MPI_INT, next, tagnext, newcomm , &requete0);
+      MPI_Recv_init(&y[0], taille,  MPI_INT, befo, tagbefo, newcomm , &requete1);
+      //cout<<"isr|"<<rang<<'|'<<requete0<<'|'<<requete1<<' ';
+      for(int k=0; k<nb; k++)
+        {
+          for (int i=0; i<taille; ++i) x[i]=k+rang;
+          //Envoi d’un gros message --> cela peut prendre du temps
+          MPI_Start(&requete0);
+          //Reception du gros message --> cela peut prendre du temps
+          for (int i=0; i<taille; ++i) y[i]=(-1);
+          MPI_Start(&requete1);
+          //Traitement sequentiel independant de "x"
+          //...
+          //Traitement sequentiel independant de "y"
+          //...
+          //cout<<"dsr|"<<rang<<' ';
+          MPI_Wait(&requete1, &statut1);
+          //Traitement sequentiel dependant de "y"
+          //...=f(y)
+          int nb=0;
+          for (int i=0; i<taille; ++i)
+            if (y[i]==k+befo) nb++;
+          if (nb==taille) ok++;
+          if (MyGlobals::_Verbose>9)
+            {
+              res="0K"+IntToStr(rang); if (nb!=taille) res="KO"+IntToStr(rang);
+              cout<<res<<k<<" ";
+            }
+          MPI_Wait(&requete0, &statut2);
+          //Traitement sequentiel impliquant une modification de "x" en memoire
+          //x=...
+        }
+      res="0K"; if (ok!=nb) res="MAUVAIS";
+      temps_debut=MPI_Wtime()-temps_debut;
+      MPI_Request_free(&requete1);
+      MPI_Request_free(&requete0);
+    }
+  //MPI_Barrier(MPI_COMM_WORLD);
+  cout<<"barrier|"<<rang<<"|"<<newcomm<<" ";
+  if (couleur==1) MPI_Comm_free(&newcomm);
+  //temps_fin=(MPI_WTIME()-temps_debut);
+  if (MyGlobals::_Verbose>1) 
+    cout<<"resultat proc "<<rang<<" "<<res<<" time(sec) "<<temps_debut<<endl;
+}
+
+
diff --git a/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx b/src/MEDPartitioner/MEDPARTITIONER_Utils.hxx
new file mode 100644 (file)
index 0000000..4dd7068
--- /dev/null
@@ -0,0 +1,141 @@
+// Copyright (C) 2007-2011  CEA/DEN, EDF R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __MEDPARTITIONER_UTILS_HXX__
+#define __MEDPARTITIONER_UTILS_HXX__
+
+#include "MEDCouplingUMesh.hxx"
+
+#include <string>
+#include <vector>
+#include <map>
+
+#ifdef LOCALIZED
+#undef LOCALIZED
+#endif
+
+#if defined(_DEBUG_) || defined(_DEBUG)
+//only for  debug # define LOCALIZED(message) #message , __FILE__ , __FUNCTION__ , __LINE__
+# define LOCALIZED(message) #message , __FUNCTION__ , __LINE__
+#else
+# define LOCALIZED(message) #message
+#endif
+
+namespace MEDPARTITIONER
+{
+  std::string Trim(const std::string& s,const std::string& drop);
+  std::string IntToStr(const int i);
+  std::string DoubleToStr(const double i);
+  int StrToInt(const std::string& s);
+  double StrToDouble(const std::string& s);
+  bool TestArg(const char *arg, const char *argExpected, std::string& argValue);
+  std::vector<int> CreateRandomSize(const int size);
+  void RandomizeAdj(int* xadj, int* adjncy, std::vector<int>& ran, std::vector<int>& vx, std::vector<int>& va);
+  void TestRandomize();
+  
+  std::string ReprVectorOfString(const std::vector<std::string>& vec);
+  std::string ReprVectorOfString(const std::vector<std::string>& vec, const std::string separator);
+  std::string ReprMapOfStringInt(const std::map<std::string,int>& mymap);
+  std::string ReprMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap);
+  std::string ReprFieldDescriptions(const std::vector<std::string>& vec,const  std::string separator);
+  
+  std::string SerializeFromString(const std::string& s);
+  std::string SerializeFromVectorOfString(const std::vector<std::string>& vec);
+  std::vector<std::string> DeserializeToVectorOfString(const std::string& str);
+  std::string EraseTagSerialized(const std::string& fromStr, const std::string& tag);
+  
+  std::vector<std::string> VectorizeFromMapOfStringInt(const std::map<std::string,int>& mymap);
+  std::map<std::string,int> DevectorizeToMapOfStringInt(const std::vector<std::string>& vec);
+  
+  std::vector<std::string> VectorizeFromMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap);
+  std::map< std::string,std::vector<std::string> > DevectorizeToMapOfStringVectorOfString(const std::vector<std::string>& vec);
+  
+  std::vector<std::string> SelectTagsInVectorOfString(const std::vector<std::string>& vec, const std::string tag);
+  std::vector<std::string> DeleteDuplicatesInVectorOfString(const std::vector<std::string>& vec);
+  std::map< std::string,std::vector<std::string> > DeleteDuplicatesInMapOfStringVectorOfString(const std::map< std::string,std::vector<std::string> >& mymap);
+  
+  std::string Cle1ToStr(const std::string& s, const int inew);
+  void Cle1ToData(const std::string& cle, std::string& s, int& inew);
+  
+  std::string Cle2ToStr(const std::string& s,const int inew,const int iold);
+  void Cle2ToData(const std::string& cle, std::string& s, int& inew, int& iold);
+  
+  std::string ExtractFromDescription(const std::string& description,const  std::string& tag);
+  void FieldDescriptionToData(const std::string& description,
+                              int& idomain, std::string& fileName, std::string& meshName, std::string& fieldName,
+                              int& typeField, int& DT, int& IT);
+  void FieldShortDescriptionToData(const std::string& description,
+                                   std::string& fieldName, int& typeField, int& entity, int& DT, int& IT);
+  
+  ParaMEDMEM::DataArrayInt* CreateDataArrayIntFromVector(const std::vector<int>& v);
+  ParaMEDMEM::DataArrayInt* CreateDataArrayIntFromVector(const std::vector<int>& v, const int nbComponents);
+  ParaMEDMEM::DataArrayDouble* CreateDataArrayDoubleFromVector(const std::vector<double>& v);
+
+  //non conseille, interblocages, utiliser sendAndReceive
+  //void SendVectorOfString(const std::vector<std::string>& vec, const int target);
+  //std::vector<std::string> RecvVectorOfString(const int source);
+  //TODO void sendRecvVectorOfString(const std::vector<std::string>& vec, const int source, const int target);
+  std::vector<std::string> SendAndReceiveVectorOfString(const std::vector<std::string>& vec, const int source, const int target);
+  std::vector<std::string> AllgathervVectorOfString(const std::vector<std::string>& vec);
+  
+  std::vector<std::string> BrowseFieldDouble(const ParaMEDMEM::MEDCouplingFieldDouble* fd);
+  std::vector<std::string> BrowseAllFields(const std::string& myfile);
+  std::vector<std::string> BrowseAllFieldsOnMesh(const std::string& myfile, const std::string& mymesh, const int idomain);
+  std::vector<std::string> GetInfosOfField(const char *fileName, const char *meshName, const int idomain );
+
+  void SendDoubleVec(const std::vector<double>& vec, const int target);
+  std::vector<double>* RecvDoubleVec(const int source);
+  void RecvDoubleVec(std::vector<double>& vec, const int source);
+    
+  void SendIntVec(const std::vector<int>& vec, const int target);
+  std::vector<int>* RecvIntVec(int source);
+  void RecvIntVec(std::vector<int>& vec, const int source);
+  
+  void SendDataArrayInt(const ParaMEDMEM::DataArrayInt* da, const int target);
+  ParaMEDMEM::DataArrayInt* RecvDataArrayInt(const int source);
+  void SendDataArrayDouble(const ParaMEDMEM::DataArrayDouble* da, const int target);
+  ParaMEDMEM::DataArrayDouble* RecvDataArrayDouble(const int source);
+  
+  ParaMEDMEM::MEDCouplingUMesh* CreateEmptyMEDCouplingUMesh();
+  
+  void TestVectorOfStringMpi();
+  void TestMapOfStringIntMpi();
+  void TestMapOfStringVectorOfStringMpi();
+  void TestDataArrayMpi();
+  void TestPersistantMpi0To1(int taille, int nb);
+  void TestPersistantMpiRing(int taille, int nb);
+  void TestPersistantMpiRingOnCommSplit(int taille, int nb);
+
+  class MyGlobals
+  {
+  public : static int _Verbose;  //0 to 1000 over 200 is debug
+  public : static int _Rank;
+  public : static int _World_Size;
+  public : static int _Randomize;
+  public : static int _Atomize;
+  public : static int _Creates_Boundary_Faces;
+  public : static int _Is0verbose; //trace cout if rank 0 and verbose
+  public : static std::vector<std::string> _File_Names;    //on [iold]
+  public : static std::vector<std::string> _Mesh_Names;    //on [iold]
+  public : static std::vector<std::string> _Field_Descriptions;
+    //used for descriptions of components of fields for example...
+  public : static std::vector<std::string> _General_Informations;
+  };
+}
+#endif
diff --git a/src/MEDPartitioner/MEDPARTITIONER_utils.cxx b/src/MEDPartitioner/MEDPARTITIONER_utils.cxx
deleted file mode 100644 (file)
index 19843ca..0000000
+++ /dev/null
@@ -1,1627 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-
-#include "MEDLoader.hxx"
-#include "MEDLoaderBase.hxx"
-#include "MEDFileUtilities.hxx"
-#include "CellModel.hxx"
-#include "MEDCouplingUMesh.hxx"
-#include "MEDCouplingFieldDouble.hxx"
-#include "MEDPARTITIONER_utils.hxx"
-#include "InterpKernelException.hxx"
-#include "MEDCouplingAutoRefCountObjectPtr.hxx"
-#include "InterpKernelAutoPtr.hxx"
-
-#ifdef HAVE_MPI2
-#include <mpi.h>
-#endif
-
-#include <fstream>
-#include <iostream>
-#include <iomanip>
-#include <sstream>
-#include <string>
-
-using namespace std;
-using namespace MEDPARTITIONER;
-
-int MEDPARTITIONER::MyGlobals::_verbose=0;
-int MEDPARTITIONER::MyGlobals::_is0verbose=0;
-int MEDPARTITIONER::MyGlobals::_rank=-1;
-int MEDPARTITIONER::MyGlobals::_world_size=-1;
-int MEDPARTITIONER::MyGlobals::_randomize=0;
-int MEDPARTITIONER::MyGlobals::_atomize=0;
-int MEDPARTITIONER::MyGlobals::_creates_boundary_faces=0;
-vector<string> MEDPARTITIONER::MyGlobals::_fileNames;
-vector<string> MEDPARTITIONER::MyGlobals::_meshNames;
-vector<string> MEDPARTITIONER::MyGlobals::_fieldDescriptions;
-vector<string> MEDPARTITIONER::MyGlobals::_generalInformations;
-
-string MEDPARTITIONER::trim(string& s, const string& drop)
-{
-  string r=s.erase(s.find_last_not_of(drop)+1);
-  return r.erase(0,r.find_first_not_of(drop));
-}
-
-string MEDPARTITIONER::intToStr(int i)
-{
-  ostringstream oss;
-  oss<<i;
-  return oss.str();
-}
-
-int MEDPARTITIONER::strToInt(string s)
-{
-  int res;
-  istringstream iss(s);
-  iss>>res;
-  return res;
-}
-
-string MEDPARTITIONER::doubleToStr(double i)
-{
-  ostringstream oss;
-  oss<<i;
-  return oss.str();
-}
-
-double MEDPARTITIONER::strToDouble(string s)
-{
-  double res;
-  istringstream iss(s);
-  iss>>res;
-  return res;
-}
-
-bool MEDPARTITIONER::testArg(const char *arg, const char *argExpected, string& argValue)
-{
-  argValue="";
-  int i;
-  for (i=0; i<strlen(arg); i++)
-  {
-    if (arg[i]=='=') break;
-    if (arg[i]!=argExpected[i]) return false;
-  }
-  for (int j=i+1; j<strlen(arg); j++) argValue+=arg[j];
-  //cout<<"found at "<<i<<" "<<argValue<<endl;
-  return true;
-}
-
-vector<int> MEDPARTITIONER::createRandomSize(int size)
-{
-  vector<int> res(size);
-  for (int i=0; i<size; i++) res[i]=i;
-  //cvw TODO srand( (unsigned)time( NULL ) );
-  srand( MyGlobals::_randomize );
-  for (int i=0; i<size; i++)
-  {
-    int ii=rand()%size;
-    int tmp=res[ii];
-    res[ii]=res[i];
-    res[i]=tmp;
-  }
-  //cout<<"createRandomSize "<<size<<endl;
-  if (size<50) { for (int i=0; i<size; i++) cout<<res[i]<<" "; cout<<endl; }
-  return res;
-}
-
-void MEDPARTITIONER::randomizeAdj(int* xadj, int* adjncy, vector<int>& ran, vector<int>& vx, vector<int>& va)
-//randomize a xadj and adjncy, renumbering vertices belong rand.
-//work only on one processor!!!!
-{
-  if (MyGlobals::_world_size>1)
-  {
-    cerr<<"randomizeAdj only on one proc!"<<endl;
-    return;
-  }
-  int size=ran.size();
-  vector<int> invran(size);
-  for (int i=0; i<size; i++) invran[ran[i]]=i;
-  vx.resize(size+1);
-  int lga=xadj[size];
-  va.resize(lga);
-  int jj=0;
-  vx[0]=0;
-  for (int i=0; i<size; i++)
-  {
-    int ir=ran[i];
-    int ii=xadj[ir];
-    int lgj=xadj[ir+1]-ii;
-    for (int j=0; j<lgj; j++)
-    {
-      //va[jj]=adjncy[ii]; //for first debug only
-      va[jj]=invran[adjncy[ii]];
-      jj=jj+1;
-      ii=ii+1;
-    }
-    vx[i+1]=jj;
-  }
-}
-
-void MEDPARTITIONER::testRandomize()
-{
-  //int xadj[6]={0,2,5,9,12,13}; //for first debug only
-  //int adjncy[13]={1,4,0,2,4,1,3,4,2,4,4,3,4};
-  int xadj[6]={0,2,5,9,12,13};
-  int adjncy[13]={0,0,1,1,1,2,2,2,2,3,3,3,4};
-  cout<<"testRandomize"<<endl;
-  for (int i=0; i<6; i++) cout<<xadj[i]<<" "; cout<<endl;
-  for (int i=0; i<13; i++) cout<<adjncy[i]<<" "; cout<<endl;
-  int size=5;
-  vector<int> r=createRandomSize(size);
-  vector<int> vx,va;
-  randomizeAdj(&xadj[0],&adjncy[0],r,vx,va);
-  for (int i=0; i<vx.size(); i++) cout<<vx[i]<<" "; cout<<endl;
-  for (int i=0; i<va.size(); i++) cout<<va[i]<<" "; cout<<endl;
-}
-
-string MEDPARTITIONER::reprVectorOfString(const vector<string>& vec)
-{
-  if (vec.size()==0) return string(" NONE\n");
-  ostringstream oss;
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) 
-    oss<<" -> '"<<*i<<"'"<<endl;
-  return oss.str();
-}
-
-string MEDPARTITIONER::reprVectorOfString(const vector<string>& vec, string sep)
-{
-  if (vec.size()==0) return string(" NONE\n");
-  ostringstream oss;
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i) 
-    oss<<sep<<*i;
-  return oss.str();
-}
-
-string MEDPARTITIONER::reprMapOfStringInt(const map<string,int>& mymap)
-{
-  if (mymap.size()==0) return string(" NONE\n");
-  ostringstream oss;
-  for (map<string,int>::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) 
-    oss<<" -> ["<<(*i).first<<"]="<<(*i).second<<endl;
-  return oss.str();
-}
-
-string MEDPARTITIONER::reprMapOfStringVectorOfString(const map< string,vector<string> >& mymap)
-{
-  if (mymap.size()==0) return string(" NONE\n");
-  ostringstream oss;
-  for (map< string,vector<string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) 
-    oss<<" -> ["<<(*i).first<<"]="<<endl<<reprVectorOfString((*i).second)<<endl;
-  return oss.str();
-}
-
-string MEDPARTITIONER::reprFieldDescriptions(const vector<string>& vec, string sep)
-{
-  if (vec.size()==0) return string(" NONE\n");
-  ostringstream oss;
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
-  {
-    oss<<" ->"; 
-    oss<<reprVectorOfString(deserializeToVectorOfString(*i), sep)<<endl;
-    /*vector<string> vec2=deserializeToVectorOfString(*i);
-    for (vector<string>::const_iterator j=vec2.begin(); j!=vec2.end(); ++j)
-      oss<<reprVectorOfString(deserializeToVectorOfString(*j), sep)<<endl;*/
-  }
-  return oss.str();
-}
-
-string MEDPARTITIONER::serializeFromString(const string& s)
-//a string "hello" gives a string "    5/hello/"
-//serialized_FromVectorOfString_string+serializeFromString("toto") is
-//equivalent to vector<string>.push_back("toto") on serialized_FromVectorOfString_string
-{
-  ostringstream oss;
-  oss<<setw(5)<<s.size()<<"/"<<s<<"/";
-  return oss.str();
-}
-
-string MEDPARTITIONER::serializeFromVectorOfString(const vector<string>& vec)
-//a vector of string gives a string
-{
-  ostringstream oss;
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
-    oss<<setw(5)<<(*i).size()<<"/"<<*i<<"/";
-  //string res(oss.str());
-  return oss.str();
-}
-
-vector<string> MEDPARTITIONER::deserializeToVectorOfString(const string& str)
-//a string gives a vector of string
-{
-  //vector<string> res=new vector<string>;
-  vector<string> res;
-  size_t pos=0;
-  size_t posmax=str.size();
-  if (posmax==0) return res;  //empty vector
-  size_t length;
-  while (pos < posmax-6)  //setw(5)+" "
-  {
-    istringstream iss(str.substr(pos,5));
-    iss>>length;
-    //cout<<"length "<<length<<endl;
-    if ((str[pos+5]!='/') || (str[pos+6+length]!='/'))
-    {
-      cerr<<"Error on string '"<<str<<"'"<<endl;;
-      throw INTERP_KERNEL::Exception(LOCALIZED("Error on string"));
-    }
-    res.push_back(str.substr(pos+6,length));
-    pos=pos+6+length+1;
-  }
-  return res;
-}
-
-string MEDPARTITIONER::eraseTagSerialized(string fromStr, string tag)
-{
-  vector<string> vec=deserializeToVectorOfString(fromStr);
-  vector<string> res;
-  for (int i=0; i<vec.size(); i++)
-  {
-    if (vec[i].find(tag)==string::npos) res.push_back(vec[i]);
-  }
-  return MEDPARTITIONER::serializeFromVectorOfString(res);
-}
-
-vector<string> MEDPARTITIONER::vectorizeFromMapOfStringInt(const map<string,int>& mymap)
-//elements first and second of map give one elements in result vector of string
-//converting formatted the int second as firsts characters ending at first slash
-{
-  vector<string> res;
-  for (map<string,int>::const_iterator i=mymap.begin(); i!=mymap.end(); ++i)
-  {
-    ostringstream oss;
-    oss<<(*i).second<<"/"<<(*i).first;
-    res.push_back(oss.str());
-  }
-  return res;
-}
-
-map<string,int> MEDPARTITIONER::devectorizeToMapOfStringInt(const vector<string>& vec)
-//if existing identicals (first,second) in vector no problem, else Exception
-{
-  map<string,int> res;
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
-  {
-    size_t pos=0;
-    size_t posmax=(*i).size();
-    size_t found=(*i).find('/'); //first slash
-    if ((found==string::npos) || (found<1))
-      throw INTERP_KERNEL::Exception(LOCALIZED("Error aIntNumber/anyString is expected"));
-    int second;
-    istringstream iss((*i).substr(pos,found));
-    iss>>second;
-    string first=(*i).substr(pos+found+1,posmax-found);
-    map<string,int>::iterator it=res.find(first);
-    if (it!=res.end())
-      if ((*it).second!=second)
-        throw INTERP_KERNEL::Exception(LOCALIZED("Error not the same map value"));
-    res[first]=second;
-  }
-  return res;
-}
-
-vector<string> MEDPARTITIONER::vectorizeFromMapOfStringVectorOfString(const map< string,vector<string> >& mymap)
-//elements first and second of map give one elements in result vector of string
-//adding key map and length of second vector as first string in each serialized vector
-//one serialized vector per key map
-{
-  vector<string> res;
-  for (map< string,vector<string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i)
-  {
-    vector<string> vs=(*i).second;  //a vector of string;
-    ostringstream oss;
-    oss<<"Keymap/"<<(*i).first<<"/"<<(*i).second.size();
-    vs.insert(vs.begin(), oss.str());
-    res.push_back(serializeFromVectorOfString(vs));
-  }
-  return res;
-}
-
-map< string,vector<string> > MEDPARTITIONER::devectorizeToMapOfStringVectorOfString(const vector<string>& vec)
-//if existing identicals keymap in vector no problem
-//duplicates in second vector
-{
-  map< string,vector<string> > res;
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
-  {
-    vector<string> vs=deserializeToVectorOfString(*i);
-    
-    string enTete=vs[0];
-    size_t posmax=enTete.size();
-    size_t foundKey=enTete.find("Keymap/");
-    size_t foundSizeVector=enTete.find_last_of('/');
-    if ((foundKey==string::npos) || (foundKey!=0) || ((foundKey+7)>=foundSizeVector))
-      throw INTERP_KERNEL::Exception(LOCALIZED("Error Keymap/anyString/aIntNumber is expected"));
-    int sizeVector;
-    istringstream iss(enTete.substr(foundSizeVector+1,posmax-foundSizeVector));
-    iss>>sizeVector;
-    string keymap=enTete.substr(foundKey+7,foundSizeVector-foundKey-7);
-    //cout<<keymap<<" : sizeVector="<<enTete.substr(foundSizeVector+1,posmax-foundSizeVector)<<endl;
-    for (int i=1; i<=sizeVector; i++)
-      res[keymap].push_back(vs[i]); //add unconditionnaly,so merge duplicates in second vector
-  }
-  return res;
-}
-
-vector<string> MEDPARTITIONER::selectTagsInVectorOfString(const vector<string>& vec, string tag)
-{
-  vector<string> res;
-  if (vec.size()==0) return res;
-  //shit for unique and unique_copy for the duplicate CONSECUTIVE elements
-  //I do not want to sort
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
-  {
-    if ((*i).find(tag)!=string::npos) res.push_back(*i);
-  }
-  return res;
-}
-
-vector<string> MEDPARTITIONER::deleteDuplicatesInVectorOfString(const vector<string>& vec)
-{
-  vector<string> res;
-  if (vec.size()==0) return res;
-  //shit for unique and unique_copy for the duplicate CONSECUTIVE elements
-  //I do not want to sort
-  for (vector<string>::const_iterator i=vec.begin(); i!=vec.end(); ++i)
-  {
-    bool found=false;
-    for (vector<string>::const_iterator j=res.begin(); j!=res.end(); ++j)
-    {
-      if ((*i).compare(*j)==0)
-      {
-        found=true;
-        break;
-      }
-    }
-    if (!found) res.push_back(*i);
-  }
-  return res;
-}
-
-map< string,vector<string> > MEDPARTITIONER::deleteDuplicatesInMapOfStringVectorOfString(const map< string,vector<string> >& mymap)
-{
-  map< string,vector<string> > res;
-  for (map< string,vector<string> >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i)
-    res[(*i).first]=deleteDuplicatesInVectorOfString((*i).second);
-  return res;
-}
-
-void MEDPARTITIONER::sendVectorOfString(const vector<string>& vec, const int target)
-//non conseille, interblocages, utiliser sendAndReceive
-{
-  throw INTERP_KERNEL::Exception(LOCALIZED("use sendAndReceiveVectorOfString please."));
-  string str=serializeFromVectorOfString(vec);
-  int tag=111000;
-  int size=str.length();
-  MPI_Send( &size, 1, MPI_INT, target, tag, MPI_COMM_WORLD );
-  MPI_Send( (void*)str.data(), str.length(), MPI_CHAR, target, tag+100, MPI_COMM_WORLD );
-  cout<<"proc "<<MyGlobals::_rank<<" : send to "<<target<<" '"<<str<<"'"<<endl;
-}
-
-vector<string> MEDPARTITIONER::recvVectorOfString(const int source)
-//non conseille, interblocages, utiliser sendAndReceive
-{
-  throw INTERP_KERNEL::Exception(LOCALIZED("use sendAndReceiveVectorOfString please."));
-  int recSize=0;
-  int tag=111000;
-  MPI_Status status;
-  MPI_Recv(&recSize, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-  string recData(recSize,'x');
-  MPI_Recv((void*)recData.data(), recSize, MPI_CHAR, 1, tag+100, MPI_COMM_WORLD, &status);
-  //cout<<"proc "<<MyGlobals::_rank<<" : receive from "<<source<<" '"<<recData<<"'"<<endl;
-  return deserializeToVectorOfString(recData);
-}
-
-vector<string> MEDPARTITIONER::sendAndReceiveVectorOfString(const vector<string>& vec, const int source, const int target)
-//not optimized but suffisant
-//return empty vector if i am not target
-{
-  int rank=MyGlobals::_rank;
-  
-  /*for test
-  ostringstream oss;
-  oss<<"sendAndReceive from "<<setw(3)<<source<<" to "<<setw(3)<<target<<"-";
-  string str(oss.str());*/
-
-  MPI_Status status;
-  int tag = 111001;
-  if (rank == source)
-  {
-    string str=serializeFromVectorOfString(vec);
-    int size=str.length();
-    MPI_Send( &size, 1, MPI_INT, target, tag, MPI_COMM_WORLD );
-    //cout<<"proc "<<source<<" : send "<<size<<endl;
-    MPI_Send( (void*)str.data(), str.length(), MPI_CHAR, target, tag+100, MPI_COMM_WORLD );
-    //cout<<"proc "<<source<<" : send    '"<<str<<"'"<<endl;
-  }
-  
-  int recSize=0;
-  if (rank == target)
-  {
-    MPI_Recv(&recSize, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-    //cout<<"proc "<<target<<" : receive "<<recSize<<endl;
-    string recData(recSize,'x');
-    MPI_Recv((void*)recData.data(), recSize, MPI_CHAR, source, tag+100, MPI_COMM_WORLD, &status);
-    //cout<<"proc "<<target<<" : receive '"<<recData<<"'"<<endl;
-    return deserializeToVectorOfString(recData); //not empty one for target proc
-  }
-  vector<string> res;
-  return res; //empty one for other proc
-}
-
-vector<string> MEDPARTITIONER::allgathervVectorOfString(const vector<std::string>& vec)
-//strings NO need all same size!!!!
-{
-  int world_size=MyGlobals::_world_size;
-  string str=serializeFromVectorOfString(vec);
-  
-  /*for test
-  int rank=MyGlobals::_rank;
-  ostringstream oss;
-  oss<<"allgatherv from "<<setw(3)<<rank<<" to all"<<"-";
-  string str(oss.str());*/
-  
-  vector<int> indexes(world_size);
-  int size=str.length();
-  MPI_Allgather(&size, 1, MPI_INT, 
-                &indexes[0], 1, MPI_INT, MPI_COMM_WORLD);
-  
-  /*{
-    ostringstream oss;
-    for (int i=0; i<world_size; i++) oss<<" "<<indexes[i];
-    cout<<"proc "<<rank<<" : receive '"<<oss.str()<<"'"<<endl;
-  }*/
-  
-  //calcul of displacement
-  vector< int > disp(1,0);
-  for (int i=0; i<world_size; i++) disp.push_back( disp.back() + indexes[i] );
-  
-  string recData(disp.back(),'x');
-  MPI_Allgatherv((void*)str.data(), str.length(), MPI_CHAR,
-                 (void*)recData.data(), &indexes[0], &disp[0], MPI_CHAR,
-                 MPI_COMM_WORLD);
-  
-  //really extraordinary verbose for debug
-  vector<string> deserial=deserializeToVectorOfString(recData);
-  if (MyGlobals::_verbose>1000) 
-  {
-    cout<<"proc "<<MyGlobals::_rank<<" : receive '"<<recData<<"'"<<endl;
-    cout<<"deserialize is : a vector of size "<<deserial.size()<<endl;
-    cout<<reprVectorOfString(deserial)<<endl;
-  }
-  return deserial;
-}
-
-//void MEDPARTITIONER::sendrecvVectorOfString(const vector<string>& vec, const int source, const int target)
-//TODO
-
-string MEDPARTITIONER::cle1ToStr(string s, int inew)
-{
-  ostringstream oss;
-  oss<<s<<" "<<inew;
-  return oss.str();
-}
-
-void MEDPARTITIONER::cle1ToData(string cle, string& s, int& inew)
-{
-  size_t posmax=cle.size();
-  size_t found=cle.find(' ');
-  if ((found==string::npos) || (found<1))
-      throw INTERP_KERNEL::Exception(LOCALIZED("Error 'aStringWithoutWhitespace aInt' is expected"));
-  s=cle.substr(0,found);
-  istringstream iss(cle.substr(found,posmax-found));
-  iss>>inew;
-}
-
-string MEDPARTITIONER::cle2ToStr(string s, int inew, int iold)
-{
-  ostringstream oss;
-  oss<<s<<" "<<inew<<" "<<iold;
-  return oss.str();
-}
-
-void MEDPARTITIONER::cle2ToData(string cle, string& s, int& inew, int& iold)
-{
-  size_t posmax=cle.size();
-  size_t found=cle.find(' ');
-  if ((found==string::npos) || (found<1))
-      throw INTERP_KERNEL::Exception(LOCALIZED("Error 'aStringWithoutWhitespace aInt aInt' is expected"));
-  s=cle.substr(0,found);
-  istringstream iss(cle.substr(found,posmax-found));
-  iss>>inew>>iold;
-}
-
-string MEDPARTITIONER::extractFromDescription(string description,string tag)
-{
-  size_t found=description.find(tag);
-  if ((found==string::npos) || (found<1))
-  {
-    cerr<<"ERROR : not found '"<<tag<<"' in '"<<description<<"'\n";
-    throw INTERP_KERNEL::Exception(LOCALIZED("Error"));
-  }
-  size_t beg=found;
-  size_t end=beg;
-  if (description[found-1]!='/')
-  {
-    //find without '/'... and pray looking for first whitespace
-    //something like 'idomain=0 fileName=tmp.med meshName=...'
-    end=description.size();
-    beg+=tag.length();
-    string res=description.substr(beg,end-beg);
-    found=res.find(' ');
-    if (found==string::npos) found=res.length();
-    res=res.substr(0,found);
-    //cout<<"find without '/' !"<<tag<<"!"<<res<<"!"<<endl;
-    return res;
-  }
-  size_t lg=strToInt(description.substr(found-6,found));
-  beg+=tag.length();
-  //cout<<"find with '/' !"<<tag<<"!"<<description.substr(beg,lg-tag.length())<<"!"<<lg<<endl;
-  return description.substr(beg,lg-tag.length());
-}
-
-void MEDPARTITIONER::fieldDescriptionToData(string description, 
-    int& idomain, string& fileName, string& meshName, string& fieldName, int& typeField, int& DT, int& IT)
-{
-  idomain=strToInt(extractFromDescription(description,"idomain="));
-  fileName=extractFromDescription(description,"fileName=");
-  meshName=extractFromDescription(description,"meshName=");
-  fieldName=extractFromDescription(description,"fieldName=");
-  typeField=strToInt(extractFromDescription(description,"typeField="));
-  DT=strToInt(extractFromDescription(description,"DT="));
-  IT=strToInt(extractFromDescription(description,"IT="));
-  cout<<"idomain="<<idomain<<" fileName="<<fileName<<" meshName="<<meshName<<" fieldName="<<fieldName<<endl;
-}
-
-void MEDPARTITIONER::fieldShortDescriptionToData(string description, 
-    string& fieldName, int& typeField, int& entity, int& DT, int& IT)
-{
-  //*meshName=extractFromDescription(description,"meshName=");
-  fieldName=extractFromDescription(description,"fieldName=");
-  typeField=strToInt(extractFromDescription(description,"typeField="));
-  entity=strToInt(extractFromDescription(description,"entity="));
-  DT=strToInt(extractFromDescription(description,"DT="));
-  IT=strToInt(extractFromDescription(description,"IT="));
-  //cout<<" meshName="<<*meshName<<" fieldName="<<*fieldName<<endl;
-}
-
-ParaMEDMEM::DataArrayInt* MEDPARTITIONER::createDataArrayIntFromVector(vector<int>& v)
-{
-  ParaMEDMEM::DataArrayInt* p=DataArrayInt::New();
-  p->alloc(v.size(),1);
-  std::copy(v.begin(),v.end(),p->getPointer());
-  return p;
-}
-
-ParaMEDMEM::DataArrayInt* MEDPARTITIONER::createDataArrayIntFromVector(vector<int>& v, int nbComponents)
-{
-  ParaMEDMEM::DataArrayInt* p=DataArrayInt::New();
-  if (v.size()%nbComponents!=0)
-    throw INTERP_KERNEL::Exception(LOCALIZED("Problem size modulo nbComponents != 0"));
-  p->alloc(v.size()/nbComponents,nbComponents);
-  std::copy(v.begin(),v.end(),p->getPointer());
-  return p;
-}
-
-ParaMEDMEM::DataArrayDouble* MEDPARTITIONER::createDataArrayDoubleFromVector(vector<double>& v)
-{
-  ParaMEDMEM::DataArrayDouble* p=DataArrayDouble::New();
-  p->alloc(v.size(),1);
-  std::copy(v.begin(),v.end(),p->getPointer());
-  return p;
-}
-
-vector<string> MEDPARTITIONER::browseFieldDouble(const MEDCouplingFieldDouble* fd)
-//quick almost human readable information on a field double
-/* example done by fd->simpleRepr() :
-FieldDouble with name : "VectorFieldOnCells"
-Description of field is : ""
-FieldDouble space discretization is : P0
-FieldDouble time discretization is : One time label. Time is defined by iteration=0 order=1 and time=2.
-Time unit is : ""
-FieldDouble nature of field is : NoNature
-FieldDouble default array has 3 components and 30000 tuples.
-FieldDouble default array has following info on components : "vx" "vy" "vz"
-Mesh support information :
-__________________________
-Unstructured mesh with name : "testMesh"
-Description of mesh : ""
-Time attached to the mesh [unit] : 0 []
-Iteration : -1 Order : -1
-Mesh dimension : 3
-Space dimension : 3
-Info attached on space dimension : "" "" ""
-Number of nodes : 33201
-Number of cells : 30000
-Cell types present : NORM_HEXA8
-*/
-{
-  vector<string> res;
-  //res.push_back("fieldName="); res.back()+=fd->getName();
-  //not saved in file? res.push_back("fieldDescription="); res.back()+=fd->getDescription();
-  //ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n";
-  //ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n";
-  //ret << "FieldDouble nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n";
-  if (fd->getArray())
-  {
-    int nb=fd->getArray()->getNumberOfComponents();
-    res.push_back("nbComponents="); res.back()+=intToStr(nb);
-    //ret << "FieldDouble default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n";
-    //ret << "FieldDouble default array has following info on components : ";
-    for (int i=0; i<nb; i++)
-    {
-      //ret << "\"" << getArray()->getInfoOnComponent(i) << "\" ";
-      res.push_back("componentInfo");
-      res.back()+=intToStr(i)+"="+fd->getArray()->getInfoOnComponent(i);
-    }
-  }
-  else
-  {
-    res.push_back("nbComponents=0");  //unknown
-  }
-  return res;
-}
-
-vector<string> MEDPARTITIONER::browseAllFields(const string& myfile)
-//quick almost human readable information on all fields in a .med file
-{
-  vector<string> res;
-  vector<string> meshNames=MEDLoader::GetMeshNames(myfile.c_str());
-  
-  for (int i=0; i<meshNames.size(); i++)
-  {
-    vector<string> fieldNames=
-      MEDLoader::GetAllFieldNamesOnMesh(myfile.c_str(),meshNames[i].c_str());
-    for (int j = 0; j < fieldNames.size(); j++)
-    {
-      vector< ParaMEDMEM::TypeOfField > typeFields=
-        MEDLoader::GetTypesOfField(myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
-      for (int k = 0; k < typeFields.size(); k++)
-      {
-        vector< pair< int, int > > its=
-          MEDLoader::GetFieldIterations(typeFields[k], myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
-        if (MyGlobals::_is0verbose>100) cout<<"fieldName "<<fieldNames[j].c_str()<<" typeField "<<typeFields[k]<<" its.size() "<<its.size()<<endl;
-        for (int m = 0; m < its.size(); m++)
-        {
-          vector<string> resi;
-          resi.push_back("fileName="); resi.back()+=myfile;
-          resi.push_back("meshName="); resi.back()+=meshNames[i];
-          resi.push_back("fieldName="); resi.back()+=fieldNames[j];
-          resi.push_back("typeField="); resi.back()+=intToStr((int)typeFields[k]);
-          resi.push_back("DT="); resi.back()+=intToStr((int)its[m].first);
-          resi.push_back("IT="); resi.back()+=intToStr((int)its[m].second);
-          res.push_back(serializeFromVectorOfString(resi));
-        }
-      }
-    }
-  }
-  return res;
-}
-
-/*
-vector<string> MEDPARTITIONER::browseAllFieldsOnMesh(const string& myfile, const string& mymesh, int idomain)
-//quick almost human readable information on all fields on a mesh in a .med file using MEDFILEBROWSER
-{
-  vector<string> res;
-  vector<string> meshNames;
-  meshNames.push_back(mymesh);
-  MEDMEM::MEDFILEBROWSER myMed(myfile);
-  for (int i=0; i<meshNames.size(); i++)
-  {
-    
-  }
-  return res;
-}*/
-
-vector<string> MEDPARTITIONER::GetInfosOfField(const char *fileName, const char *meshName, int idomain)
-{
-const int lggeom=10;
-const med_geometry_type GEOMTYPE[lggeom]={ //MED_N_CELL_FIXED_GEO] = { 
-  //MED_POINT1,
-  //MED_SEG2,
-  //MED_SEG3,
-  //MED_SEG4,
-  //MED_TRIA3,
-  //MED_QUAD4,
-  //MED_TRIA6,
-  //MED_TRIA7,
-  //MED_QUAD8,
-  //MED_QUAD9,
-  MED_TETRA4,
-  MED_PYRA5,
-  MED_PENTA6,
-  MED_HEXA8,
-  MED_OCTA12,
-  MED_TETRA10,
-  MED_PYRA13,
-  MED_PENTA15,
-  MED_HEXA20,
-  MED_HEXA27,
-  //MED_POLYGON,
-  //MED_POLYHEDRON 
-};
-
-const char * const GEOMTYPENAME[lggeom]={
-  //"MED_POINT1",
-  //"MED_SEG2",
-  //"MED_SEG3",
-  //"MED_SEG4",
-  //"MED_TRIA3",
-  //"MED_QUAD4",
-  //"MED_TRIA6",
-  //"MED_TRIA7",
-  //"MED_QUAD8",
-  //"MED_QUAD9",
-  "MED_TETRA4",
-  "MED_PYRA5",
-  "MED_PENTA6",
-  "MED_HEXA8",
-  "MED_OCTA12",
-  "MED_TETRA10",
-  "MED_PYRA13",
-  "MED_PENTA15",
-  "MED_HEXA20",
-  "MED_HEXA27",
-  //"MED_POLYGONE",
-  //"MED_POLYEDRE",
-};
-
-
-const int lgentity=3;
-const med_entity_type ENTITYTYPE[lgentity]={ //MED_N_ENTITY_TYPES+2]={
-  //MED_UNDEF_ENTITY_TYPE,
-  MED_CELL,
-  //MED_DESCENDING_FACE,
-  //MED_DESCENDING_EDGE,
-  MED_NODE,
-  MED_NODE_ELEMENT,
-  //MED_STRUCT_ELEMENT,
-  //MED_UNDEF_ENTITY_TYPE
-};
-
-const char * const ENTITYTYPENAME[lgentity]={ //MED_N_ENTITY_TYPES+2]={
-  //"MED_UNDEF_ENTITY_TYPE",
-  "MED_CELL",
-  //"MED_FACE",
-  //"MED_ARETE",
-  "MED_NODE",
-  "MED_NODE_ELEMENT",
-  //"MED_STRUCT_ELEMENT",
-  //"MED_UNDEF_ENTITY_TYPE"
-};
-  
-  vector<string> res;
-  med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY);
-  med_int nbFields=MEDnField(fid);
-  if (MyGlobals::_verbose>20) cout<<"on filename "<<fileName<<" nbOfField "<<nbFields<<endl;
-  //
-  med_field_type typcha;
-  med_int numdt=0,numo=0;
-  med_float dt=0.0;
-  char *maa_ass=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
-  char *nomcha=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
-  med_bool localmesh;
-  //
-  for(int i=1; i<=nbFields; i++)
-  {
-    med_int ncomp=MEDfieldnComponent(fid,i);
-    INTERP_KERNEL::AutoPtr<char> comp=new char[ncomp*MED_SNAME_SIZE+1];
-    INTERP_KERNEL::AutoPtr<char> unit=new char[ncomp*MED_SNAME_SIZE+1];
-    INTERP_KERNEL::AutoPtr<char> dt_unit=new char[MED_LNAME_SIZE+1];
-    med_int nbPdt;
-    MEDfieldInfo(fid,i,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt);
-    std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1);
-    std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1);
-    for (int k=1; k<=nbPdt; k++)
-    {
-      MEDfieldComputingStepInfo(fid,nomcha,k,&numdt,&numo,&dt);
-      if (MyGlobals::_verbose>20) 
-        cout<<"on filename "<<fileName<<" field "<<i<<" fieldName "<<curFieldName<<" meshName "<<curMeshName<<
-                  " typ "<<typcha<<" nbComponent "<<ncomp<<" nbPdt "<<nbPdt<<" noPdt "<<k<<
-                  " ndt "<<numdt<<" nor "<<numo<<" dt "<<dt<<endl;
-      for (int ie=0; ie<lgentity; ie++)
-      {
-        for (int j=0; j<lggeom; j++)
-        {
-          int profilesize=0,nbi=0;
-          med_entity_type enttype=ENTITYTYPE[ie];
-          //enttype=MED_NODE;enttype=MED_CELL;enttype=MED_NODE_ELEMENT;
-          char pflname[MED_NAME_SIZE+1]="";
-          char locname[MED_NAME_SIZE+1]="";
-          med_int nbofprofile=MEDfieldnProfile(fid,nomcha,numdt,numo,enttype,GEOMTYPE[j],pflname,locname);
-
-/*
-med_proto.h firefox file:///export/home/.../med-3.0.3/doc/html.dox/index.html
-MEDfieldnValueWithProfileByName(const med_idt fid, const char * const fieldname,const med_int numdt,const med_int numit,
-  const med_entity_type entitype, const med_geometry_type geotype, const char * const profilename,
-  const med_storage_mode storagemode,med_int * const profilesize,
-  char * const localizationname, med_int * const nbofintegrationpoint);
-
-MEDfieldnValueWithProfile(const med_idt fid, const char * const fieldname,const med_int numdt,const med_int numit,
-  const med_entity_type entitype, const med_geometry_type geotype,
-  const int profileit,
-  const med_storage_mode storagemode,char * const profilename ,med_int * const profilesize,
-  char * const localizationname, med_int * const nbofintegrationpoint);
-*/
-          int profileit=1;
-          if (enttype==MED_NODE)
-          {
-            med_geometry_type mygeomtype=MED_UNDEF_ENTITY_TYPE;
-            med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit,
-                                                      MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi);
-            if (nbOfVal>0)
-            {
-              if (MyGlobals::_verbose>20)
-                cout<<"on filename "<<fileName<<" entity "<<enttype<<" nbOfVal with "<<
-                      nbofprofile<<" profile(s) for geomType (AUCUN) nbOfVal "<<
-                      nbOfVal<<" profilName '"<<pflname<<"' profileSize "<<profilesize<<" nbPtGauss "<<nbi<<endl;
-              vector<string> resi;
-              resi.push_back("idomain="); resi.back()+=intToStr(idomain);
-              resi.push_back("fileName="); resi.back()+=fileName;
-              resi.push_back("meshName="); resi.back()+=curMeshName;
-              resi.push_back("fieldName="); resi.back()+=curFieldName;
-              resi.push_back("typeField="); resi.back()+=intToStr((int)ON_NODES);
-              resi.push_back("typeData="); resi.back()+=intToStr((int)typcha);  //6 for double?
-              resi.push_back("nbComponent="); resi.back()+=intToStr((int)ncomp);
-              resi.push_back("DT="); resi.back()+=intToStr((int)numdt);
-              resi.push_back("IT="); resi.back()+=intToStr((int)numo);
-              resi.push_back("time="); resi.back()+=doubleToStr(dt);
-              resi.push_back("entity="); resi.back()+=intToStr((int)enttype);
-              resi.push_back("entityName="); resi.back()+=ENTITYTYPENAME[ie];
-              resi.push_back("nbOfVal="); resi.back()+=intToStr((int)nbOfVal);
-              resi.push_back("profilName="); resi.back()+=pflname;
-              resi.push_back("profileSize="); resi.back()+=intToStr((int)profilesize);
-              resi.push_back("nbPtGauss="); resi.back()+=intToStr((int)nbi);
-              res.push_back(serializeFromVectorOfString(resi));
-            }
-            break; //on nodes no need to scute all geomtype
-          }
-          else
-          {
-            med_geometry_type mygeomtype=GEOMTYPE[j];
-            med_int nbOfVal=MEDfieldnValueWithProfile(fid,nomcha,numdt,numo,enttype,mygeomtype,profileit,
-                                                      MED_COMPACT_PFLMODE,pflname,&profilesize,locname,&nbi);
-            if (nbOfVal>0)
-            {
-              if (MyGlobals::_verbose>20)
-                cout<<"on filename "<<fileName<<" entity "<<enttype<<" nbOfVal with "<<
-                      nbofprofile<<" profile(s) for geomType "<<
-                      GEOMTYPE[j]<<" "<<GEOMTYPENAME[j]<<" nbOfVal "<<
-                      nbOfVal<<" profilName '"<<pflname<<"' profileSize "<<profilesize<<" nbPtGauss "<<nbi<<endl;
-              int typeField=-1; //unknown
-              if (enttype==MED_CELL) typeField=ON_CELLS;
-              if (enttype==MED_NODE_ELEMENT) typeField=ON_GAUSS_NE;
-              //if (enttype==??) typeField=ON_GAUSS_PT;
-              vector<string> resi;
-              resi.push_back("idomain="); resi.back()+=intToStr(idomain);
-              resi.push_back("fileName="); resi.back()+=fileName;
-              resi.push_back("meshName="); resi.back()+=curMeshName;
-              resi.push_back("fieldName="); resi.back()+=curFieldName;
-              resi.push_back("typeField="); resi.back()+=intToStr((int)typeField);
-              resi.push_back("typeData="); resi.back()+=intToStr((int)typcha);  //6 for double?
-              resi.push_back("nbComponent="); resi.back()+=intToStr((int)ncomp);
-              resi.push_back("DT="); resi.back()+=intToStr((int)numdt);
-              resi.push_back("IT="); resi.back()+=intToStr((int)numo);
-              resi.push_back("time="); resi.back()+=doubleToStr(dt);
-              resi.push_back("entity="); resi.back()+=intToStr((int)enttype);
-              resi.push_back("entityName="); resi.back()+=ENTITYTYPENAME[ie];
-              resi.push_back("geomType="); resi.back()+=intToStr((int)GEOMTYPE[j]);
-              resi.push_back("geomTypeName="); resi.back()+=GEOMTYPENAME[j];
-              resi.push_back("nbOfVal="); resi.back()+=intToStr((int)nbOfVal);
-              resi.push_back("profilName="); resi.back()+=pflname;
-              resi.push_back("profileSize="); resi.back()+=intToStr((int)profilesize);
-              resi.push_back("nbPtGauss="); resi.back()+=intToStr((int)nbi);
-              if (typeField==-1)
-              {
-                cout<<"WARNING : unknown typeField for entity type "<<enttype<<endl<<
-                      serializeFromVectorOfString(resi)<<endl;
-                continue;  //do not register push_back
-              }
-              res.push_back(serializeFromVectorOfString(resi));
-            }
-          }
-        }
-      }
-    }
-  }
-  delete [] maa_ass;
-  delete [] nomcha;
-  MEDfileClose(fid);
-  if (MyGlobals::_verbose>10) cout<<"detected fields:\n"<<reprVectorOfString(res)<<endl;
-  return res;
-}
-
-vector<string> MEDPARTITIONER::browseAllFieldsOnMesh(const string& myfile, const string& mymesh, int idomain)
-//quick almost human readable information on all fields on a mesh in a .med file
-{
-  vector<string> res=GetInfosOfField(myfile.c_str(),mymesh.c_str(),idomain);
-  return res;
-  
-  /*obsolete do no work on GetTypesOfField ON_GAUSS_NE
-  vector<string> res;
-  vector<string> meshNames;
-  meshNames.push_back(mymesh);
-  
-  for (int i=0; i<meshNames.size(); i++)
-  {
-    vector<string> fieldNames=
-      MEDLoader::GetAllFieldNamesOnMesh(myfile.c_str(),meshNames[i].c_str());
-    for (int j=0; j<fieldNames.size(); j++)
-    {
-      vector< ParaMEDMEM::TypeOfField > typeFields=
-        MEDLoader::GetTypesOfField(myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
-      //if (MyGlobals::_is0verbose>100) cout<<"fieldName "<<fieldNames[j].c_str()<<"typeField.size "<<typeFields.size()<<endl;
-      if (typeFields.size()==0) {
-        cerr<<"problem : fieldNames "<<fieldNames[j]<<" without GetTypesOfField ! Type of field specified not managed"<<endl;
-        //typeFields.push_back(ON_GAUSS_NE);
-      }
-      for (int k=0; k<typeFields.size(); k++)
-      {
-        vector< pair< int, int > > its;
-        its=MEDLoader::GetFieldIterations(typeFields[k], myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str());
-        //if (typeFields[k]==ON_GAUSS_NE) its.push_back(make_pair(5,6));
-        if (MyGlobals::_is0verbose>100) cout<<"fieldName "<<fieldNames[j].c_str()<<" typeField "<<typeFields[k]<<" its.size() "<<its.size()<<endl;
-        for (int m = 0; m < its.size(); m++)
-        {
-          vector<string> resi;
-          resi.push_back("idomain="); resi.back()+=intToStr(idomain);
-          resi.push_back("fileName="); resi.back()+=myfile;
-          resi.push_back("meshName="); resi.back()+=meshNames[i];
-          resi.push_back("fieldName="); resi.back()+=fieldNames[j];
-          resi.push_back("typeField="); resi.back()+=intToStr((int)typeFields[k]);
-          resi.push_back("DT="); resi.back()+=intToStr((int)its[m].first);
-          resi.push_back("IT="); resi.back()+=intToStr((int)its[m].second);
-          //cout<<"browseAllFieldsOnMesh add "<<resi.size()<<endl;
-          res.push_back(serializeFromVectorOfString(resi));
-        }
-      }
-    }
-  }
-  return res;
-  */
-}
-
-/*!
-Sends content of \a vec to processor \a target. To be used with \a recvDoubleVec method.
-\param vec vector to be sent
-\param target processor id of the target
-*/
-void MEDPARTITIONER::sendDoubleVec(const std::vector<double>& vec, int target)
-{
-  int tag = 111002;
-  int size=vec.size();
-  if (MyGlobals::_verbose>1000) 
-    cout<<"proc "<<MyGlobals::_rank<<" : --> sendDoubleVec "<<size<<endl;
-#ifdef HAVE_MPI2
-  MPI_Send(&size, 1, MPI_INT, target, tag, MPI_COMM_WORLD);
-  MPI_Send(const_cast<double*>(&vec[0]), size, MPI_DOUBLE, target, tag+100, MPI_COMM_WORLD);
-#endif
-}
-
-/*! Receives messages from proc \a source to fill vector<int> vec.
-To be used with \a sendDoubleVec method.
-
-\param vec vector that is filled
-\param source processor id of the incoming messages
- */
-std::vector<double>* MEDPARTITIONER::recvDoubleVec(int source)
-{
-  int tag = 111002;
-  int size;
-#ifdef HAVE_MPI2
-  MPI_Status status;  
-  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-  if (MyGlobals::_verbose>1000) 
-    cout<<"proc "<<MyGlobals::_rank<<" : <-- recvDoubleVec "<<size<<endl;;
-  std::vector<double>* vec=new std::vector<double>;
-  vec->resize(size);
-  MPI_Recv(&vec[0], size, MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status);
-#endif
-  return vec;
-}
-
-void MEDPARTITIONER::recvDoubleVec(std::vector<double>& vec, int source)
-{
-  int tag = 111002;
-  int size;
-#ifdef HAVE_MPI2
-  MPI_Status status;  
-  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-  if (MyGlobals::_verbose>1000)
-    cout<<"proc "<<MyGlobals::_rank<<" : <-- recvDoubleVec "<<size<<endl;;
-  vec.resize(size);
-  MPI_Recv(&vec[0], size, MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status);
-#endif
-}
-/*!
-Sends content of \a vec to processor \a target. To be used with \a recvIntVec method.
-\param vec vector to be sent
-\param target processor id of the target
-*/
-void MEDPARTITIONER::sendIntVec(const std::vector<int>& vec, int target)
-{
-  int tag = 111003;
-  int size=vec.size();
-  if (MyGlobals::_verbose>1000)
-    cout<<"proc "<<MyGlobals::_rank<<" : --> sendIntVec "<<size<<endl; //cvw 
-#ifdef HAVE_MPI2
-  MPI_Send(&size, 1, MPI_INT, target, tag, MPI_COMM_WORLD);
-  MPI_Send(const_cast<int*>(&vec[0]), size,MPI_INT, target, tag+100, MPI_COMM_WORLD);
-#endif
-}
-
-/*! Receives messages from proc \a source to fill vector<int> vec.
-To be used with \a sendIntVec method.
-\param vec vector that is filled
-\param source processor id of the incoming messages
- */
-std::vector<int>* MEDPARTITIONER::recvIntVec(int source)
-{
-  int tag = 111003;
-  int size;
-#ifdef HAVE_MPI2
-  MPI_Status status;  
-  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-  if (MyGlobals::_verbose>1000) 
-    cout<<"proc "<<MyGlobals::_rank<<" : <-- recvIntVec "<<size<<endl; //cvw 
-  std::vector<int>* vec=new std::vector<int>;
-  vec->resize(size);
-  MPI_Recv(&vec[0], size, MPI_INT, source, tag+100, MPI_COMM_WORLD, &status);
-#endif
-  return vec;
-}
-
-void MEDPARTITIONER::recvIntVec(std::vector<int>& vec, int source)
-{
-  int tag = 111003;
-  int size;
-#ifdef HAVE_MPI2
-  MPI_Status status;  
-  MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-  if (MyGlobals::_verbose>1000)
-    cout<<"proc "<<MyGlobals::_rank<<" : <-- recvIntVec "<<size<<endl; //cvw 
-  vec.resize(size);
-  MPI_Recv(&vec[0], size, MPI_INT, source, tag+100, MPI_COMM_WORLD,&status);
-#endif
-}
-
-/*!
-Sends content of \a dataArrayInt to processor \a target. 
-To be used with \a recvDataArrayInt method.
-\param da dataArray to be sent
-\param target processor id of the target
-*/
-void MEDPARTITIONER::sendDataArrayInt(ParaMEDMEM::DataArrayInt* da, int target)
-{
-  if (da==0) throw INTERP_KERNEL::Exception(LOCALIZED("Problem send DataArrayInt* NULL"));
-  int tag = 111004;
-  int size[3];
-  size[0]=da->getNbOfElems();
-  size[1]=da->getNumberOfTuples();
-  size[2]=da->getNumberOfComponents();
-  if (MyGlobals::_verbose>1000) 
-    cout<<"proc "<<MyGlobals::_rank<<" : --> sendDataArrayInt "<<size[0]<<endl; //cvw 
-#ifdef HAVE_MPI2
-  MPI_Send(&size, 3, MPI_INT, target, tag, MPI_COMM_WORLD);
-  const int * p=da->getPointer();
-  MPI_Send(const_cast<int*>(&p[0]), size[0] ,MPI_INT, target, tag+100, MPI_COMM_WORLD);
-#endif
-}
-
-/*! Receives messages from proc \a source to fill dataArrayInt da.
-To be used with \a sendIntVec method.
-\param da dataArrayInt that is filled
-\param source processor id of the incoming messages
- */
-ParaMEDMEM::DataArrayInt* MEDPARTITIONER::recvDataArrayInt(int source)
-//std::vector<int>& vec, int source)const
-{
-  int tag = 111004;
-  int size[3];
-#ifdef HAVE_MPI2
-  MPI_Status status;
-  MPI_Recv(size, 3, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-  if (MyGlobals::_verbose>1000)
-    cout<<"proc "<<MyGlobals::_rank<<" : <-- recvDataArrayInt "<<size[0]<<endl; //cvw 
-  if (size[0]!=(size[1]*size[2]))
-    throw INTERP_KERNEL::Exception(LOCALIZED("Problem in recvDataArrayInt incoherent sizes"));
-  ParaMEDMEM::DataArrayInt* da=ParaMEDMEM::DataArrayInt::New();
-  da->alloc(size[1],size[2]);
-  int * p=da->getPointer();
-  MPI_Recv(const_cast<int*>(&p[0]), size[0], MPI_INT, source, tag+100, MPI_COMM_WORLD, &status);
-#endif
-  return da;
-}
-
-/*!
-Sends content of \a dataArrayInt to processor \a target. 
-To be used with \a recvDataArrayDouble method.
-\param da dataArray to be sent
-\param target processor id of the target
-*/
-void MEDPARTITIONER::sendDataArrayDouble(ParaMEDMEM::DataArrayDouble* da, int target)
-{
-  if (da==0) throw INTERP_KERNEL::Exception(LOCALIZED("Problem send DataArrayDouble* NULL"));
-  int tag = 111005;
-  int size[3];
-  size[0]=da->getNbOfElems();
-  size[1]=da->getNumberOfTuples();
-  size[2]=da->getNumberOfComponents();
-  if (MyGlobals::_verbose>1000) 
-    cout<<"proc "<<MyGlobals::_rank<<" : --> sendDataArrayDouble "<<size[0]<<endl; //cvw 
-#ifdef HAVE_MPI2
-  MPI_Send(&size, 3, MPI_INT, target, tag, MPI_COMM_WORLD);
-  double * p=da->getPointer();
-  MPI_Send(const_cast<double*>(&p[0]), size[0] ,MPI_DOUBLE, target, tag+100, MPI_COMM_WORLD);
-#endif
-}
-
-/*! Receives messages from proc \a source to fill dataArrayDouble da.
-To be used with \a sendDoubleVec method.
-\param da dataArrayDouble that is filled
-\param source processor id of the incoming messages
- */
-ParaMEDMEM::DataArrayDouble* MEDPARTITIONER::recvDataArrayDouble(int source)
-//std::vector<int>& vec, int source)const
-{
-  int tag = 111005;
-  int size[3];
-#ifdef HAVE_MPI2
-  MPI_Status status;
-  MPI_Recv(size, 3, MPI_INT, source, tag, MPI_COMM_WORLD, &status);
-  if (MyGlobals::_verbose>1000)
-    cout<<"proc "<<MyGlobals::_rank<<" : <-- recvDataArrayDouble "<<size[0]<<endl; //cvw 
-  if (size[0]!=(size[1]*size[2]))
-    throw INTERP_KERNEL::Exception(LOCALIZED("Problem in recvDataArrayDouble incoherent sizes"));
-  ParaMEDMEM::DataArrayDouble* da=ParaMEDMEM::DataArrayDouble::New();
-  da->alloc(size[1],size[2]);
-  double * p=da->getPointer();
-  MPI_Recv(const_cast<double*>(&p[0]), size[0], MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status);
-#endif
-  return da;
-}
-
-ParaMEDMEM::MEDCouplingUMesh* MEDPARTITIONER::createEmptyMEDCouplingUMesh()
- //create empty MEDCouplingUMesh* dim 3
-{
-  ParaMEDMEM::MEDCouplingUMesh* umesh=ParaMEDMEM::MEDCouplingUMesh::New();
-  umesh->setMeshDimension(3);
-  umesh->allocateCells(0);
-  umesh->finishInsertingCells();
-  ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
-  myCoords->alloc(0,3);
-  umesh->setCoords(myCoords);
-  umesh->setName("EMPTY");
-  myCoords->decrRef();
-  umesh->checkCoherency();
-  return umesh;
-}
-
-void MEDPARTITIONER::testVectorOfStringMPI()
-{
-  int rank=MyGlobals::_rank;
-  int world_size=MyGlobals::_world_size;
-  vector<string> myVector;
-  ostringstream oss;
-  oss<<"hello from "<<setw(5)<<rank<<" "<<string(rank+1,'n')<<
-       " next is an empty one";
-  myVector.push_back(oss.str());
-  myVector.push_back("");
-  myVector.push_back("next is an singleton");
-  myVector.push_back("1");
-  
-  if (rank==0)
-  {
-    /*
-    string s0=serializeFromVectorOfString(myVector);
-    cout<<"s0 is : a string '"<<s0<<"'"<<endl;
-    vector<string> v0=deserializeToVectorOfString(s0);
-    cout<<"v0 is : a vector of size "<<v0.size()<<endl;
-    cout<<reprVectorOfString(v0)<<endl;
-    */
-    string s0=serializeFromVectorOfString(myVector);
-    vector<string> res=deserializeToVectorOfString(s0);
-    if (res.size()!=myVector.size()) 
-      throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)serialise VectorOfString incoherent sizes"));
-    for (int i=0; i<myVector.size(); i++)
-      if (res[i]!=myVector[i])
-        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)serialise VectorOfString incoherent elements"));
-  }
-
-  for (int i=0; i<world_size; i++)
-  {
-    for (int j=0; j<world_size; j++)
-    {
-      vector<string> res=sendAndReceiveVectorOfString(myVector, i, j);
-      if ((rank==j) && MyGlobals::_verbose>20)
-        cout<<"proc "<<rank<<" : receive \n"<<reprVectorOfString(res)<<endl;
-      if (rank==j)
-      {
-        if (res.size()!=myVector.size()) 
-          throw INTERP_KERNEL::Exception(LOCALIZED("Problem in sendAndReceiveVectorOfString incoherent sizes"));
-        for (int i=1; i<myVector.size(); i++) //first is different
-          if (res[i]!=myVector[i])
-            throw INTERP_KERNEL::Exception(LOCALIZED("Problem in sendAndReceiveVectorOfString incoherent elements"));
-      }
-      else 
-      {
-        if (res.size()!=0) 
-        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in sendAndReceiveVectorOfString size have to be 0"));
-      }
-    }
-  }
-  vector<string> res=allgathervVectorOfString(myVector);
-  //sometimes for test
-  res=allgathervVectorOfString(myVector);
-  res=allgathervVectorOfString(myVector);
-  if (rank==0 && MyGlobals::_verbose>20)
-    cout<<"proc "<<rank<<" : receive \n"<<reprVectorOfString(res)<<endl;
-  if (res.size()!=myVector.size()*world_size) 
-    throw INTERP_KERNEL::Exception(LOCALIZED("Problem in allgathervVectorOfString incoherent sizes"));
-  int jj=-1;
-  for (int j=0; j<world_size; j++)
-  {
-    for (int i=0; i<myVector.size(); i++)
-    {
-      jj=jj+1;
-      if (i==0) continue; //first is different
-      if (res[jj]!=myVector[i])
-        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in allgathervVectorOfString incoherent elements"));
-    }
-  }
-  if (MyGlobals::_verbose) cout<<"proc "<<rank<<" : OK testVectorOfStringMPI END"<< endl;
-}
-
-void MEDPARTITIONER::testMapOfStringIntMPI()
-{
-  int rank=MyGlobals::_rank;
-  //int world_size=MyGlobals::_world_size;
-  map<string,int> myMap;
-  myMap["one"]=1;
-  myMap["two"]=22;  //a bug
-  myMap["three"]=3;
-  myMap["two"]=2; //last speaking override
-  
-  if (rank==0)
-  {
-    vector<string> v2=vectorizeFromMapOfStringInt(myMap);
-    /*
-    cout<<"v2 is : a vector of size "<<v2.size()<<endl;
-    cout<<reprVectorOfString(v2)<<endl;
-    */
-    map<string,int> m3=devectorizeToMapOfStringInt(v2);
-    if (reprMapOfStringInt(m3)!=reprMapOfStringInt(myMap))
-      throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)vectorize MapOfStringInt"));
-  }
-    
-  vector<string> v2=allgathervVectorOfString(vectorizeFromMapOfStringInt(myMap));
-  if (rank==0 && MyGlobals::_verbose>20)
-  {
-    cout<<"v2 is : a vector of size "<<v2.size()<<endl;
-    cout<<reprVectorOfString(v2)<<endl;
-    map<string,int> m2=devectorizeToMapOfStringInt(v2);
-    cout<<"m2 is : a map of size "<<m2.size()<<endl;
-    cout<<reprMapOfStringInt(m2)<<endl;
-  }
-  if (MyGlobals::_verbose) cout<<"proc "<<rank<<" : OK testMapOfStringIntMPI END"<< endl;
-}
-
-void MEDPARTITIONER::testMapOfStringVectorOfStringMPI()
-{
-  int rank=MyGlobals::_rank;
-  //int world_size=MyGlobals::_world_size;
-  vector<string> myVector;
-  ostringstream oss;
-  oss<<"hello from "<<setw(5)<<MyGlobals::_rank<<" "<<string(rank+1,'n')<<
-       " next is an empty one";
-  myVector.push_back(oss.str());
-  myVector.push_back("");
-  myVector.push_back("next is an singleton");
-  myVector.push_back("1");
-  
-  if (rank==0)
-  {
-    map< string,vector<string> > m2;
-    m2["first key"]=myVector;
-    m2["second key"]=myVector;
-    vector<string> v2=vectorizeFromMapOfStringVectorOfString(m2);
-    map< string,vector<string> > m3=devectorizeToMapOfStringVectorOfString(v2);
-    if (rank==0 && MyGlobals::_verbose>20)
-      cout<<"m2 is : a MapOfStringVectorOfString of size "<<m2.size()<<endl;
-      cout<<reprMapOfStringVectorOfString(m2)<<endl;
-      cout<<"v2 is : a vector of size "<<v2.size()<<endl;
-      cout<<reprVectorOfString(v2)<<endl;
-      cout<<"m3 is : a map of size "<<m3.size()<<endl;
-      cout<<reprMapOfStringVectorOfString(m3)<<endl;
-    if (reprMapOfStringVectorOfString(m3)!=reprMapOfStringVectorOfString(m2))
-      throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)vectorize MapOfStringVectorOfString"));
-  }
-    
-  map< string,vector<string> > m4;
-  m4["1rst key"]=myVector;
-  m4["2snd key"]=myVector;
-  vector<string> v4=allgathervVectorOfString(vectorizeFromMapOfStringVectorOfString(m4));
-  if (rank==0 && MyGlobals::_verbose>20)
-  {
-    map< string,vector<string> > m5=devectorizeToMapOfStringVectorOfString(v4);
-    map< string,vector<string> > m6=deleteDuplicatesInMapOfStringVectorOfString(m5);
-    cout<<"m5 is : a map of size "<<m5.size()<<endl;
-    cout<<reprMapOfStringVectorOfString(m5)<<endl;
-    cout<<"m6 is : a map from m5 with deleteDuplicates of size "<<m6.size()<<endl;
-    cout<<reprMapOfStringVectorOfString(m6)<<endl;
-  }
-  if (MyGlobals::_verbose) cout<<"proc "<<rank<<" : OK testMapOfStringVectorOfStringMPI END"<< endl;
-}
-
-void MEDPARTITIONER::testDataArrayMPI()
-{
-  int rank=MyGlobals::_rank;
-  //int
-  {
-    ParaMEDMEM::DataArrayInt* send=ParaMEDMEM::DataArrayInt::New();
-    ParaMEDMEM::DataArrayInt* recv=0;
-    int nbOfTuples=5;
-    int numberOfComponents=3;
-    send->alloc(nbOfTuples,numberOfComponents);
-    vector<int> vals;
-    for (int j=0; j<nbOfTuples; j++)
-      for (int i=0; i<numberOfComponents; i++) vals.push_back((j+1)*10+i+1);
-    std::copy(vals.begin(),vals.end(),send->getPointer());
-    if (rank==0) sendDataArrayInt(send, 1);
-    if (rank==1) recv=recvDataArrayInt(0);
-    if (rank==1 && MyGlobals::_verbose>20)
-    {
-      cout<<send->repr()<<endl;
-      cout<<recv->repr()<<endl;
-    }
-    if (rank==1)
-    {
-      if (send->repr()!=recv->repr())
-        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in send&recv DataArrayInt"));
-    }
-    send->decrRef();
-    if (rank==1) recv->decrRef();
-  }
-  //double
-  {
-    ParaMEDMEM::DataArrayDouble* send=ParaMEDMEM::DataArrayDouble::New();
-    ParaMEDMEM::DataArrayDouble* recv=0;
-    int nbOfTuples=5;
-    int numberOfComponents=3;
-    send->alloc(nbOfTuples,numberOfComponents);
-    vector<double> vals;
-    for (int j=0; j<nbOfTuples; j++)
-      for (int i=0; i<numberOfComponents; i++) vals.push_back(double(j+1)+double(i+1)/10);
-    std::copy(vals.begin(),vals.end(),send->getPointer());
-    if (rank==0) sendDataArrayDouble(send, 1);
-    if (rank==1) recv=recvDataArrayDouble(0);
-    if (rank==1 && MyGlobals::_verbose>20)
-    {
-      cout<<send->repr()<<endl;
-      cout<<recv->repr()<<endl;
-    }
-    if (rank==1)
-    {
-      if (send->repr()!=recv->repr())
-        throw INTERP_KERNEL::Exception(LOCALIZED("Problem in send&recv DataArrayDouble"));
-    }
-    send->decrRef();
-    if (rank==1) recv->decrRef();
-  }
-  
-  if (MyGlobals::_verbose) cout<<"proc "<<rank<<" : OK testDataArrayMPI END"<< endl;
- }
-
-void MEDPARTITIONER::testPersistantMpi0To1(int taille, int nb)
-{
-  double temps_debut=MPI_Wtime();
-  int rang=MyGlobals::_rank;
-  vector<int> x, y;
-  int tag=111111;
-  MPI_Request requete0, requete1;
-  MPI_Status statut;
-  int ok=0;
-  string res;
-  if (rang==0)
-  {
-    x.resize(taille);
-    MPI_Ssend_init(&x[0], taille, MPI_INT, 1, tag, MPI_COMM_WORLD , &requete0);
-    for(int k=0; k<nb; k++)
-    {
-      for (int i=0; i<taille; ++i) x[i]=k;
-      //Envoi d’un gros message --> cela peut prendre du temps
-      MPI_Start(&requete0);
-      //Traitement sequentiel independant de "x"
-      //...
-      MPI_Wait(&requete0, &statut);
-      //Traitement sequentiel impliquant une modification de "x" en memoire
-      //x=...
-    }
-    MPI_Request_free(&requete0);
-  }
-  else if (rang == 1)
-  {
-    y.resize(taille);
-    MPI_Recv_init(&y[0], taille,  MPI_INT, 0, tag, MPI_COMM_WORLD , &requete1);
-    for(int k=0; k<nb; k++)
-    {
-      //Pre-traitement sequentiel
-      //...
-      for (int i=0; i<taille; ++i) y[i]=-1;
-      //Reception du gros message --> cela peut prendre du temps
-      MPI_Start(&requete1);
-      //Traitement sequentiel independant de "y"
-      //...
-      MPI_Wait(&requete1, &statut);
-      //Traitement sequentiel dependant de "y"
-      //...=f(y)
-      int nb=0;
-      for (int i=0; i<taille; ++i)
-        if (y[i]==k) nb++;
-      if (nb==taille) ok++;
-      if (MyGlobals::_verbose>9)
-      {
-        res="0K"; if (nb!=taille) res="KO";
-        cout<<res<<k<<" ";
-      }
-    }
-    res="0K"; if (ok!=nb) res="MAUVAIS";
-    if (MyGlobals::_verbose>1) 
-      cout<<"resultat "<<res<<" time(sec) "<<MPI_Wtime()-temps_debut<<endl;
-    MPI_Request_free(&requete1);
-  }
-  //temps_fin=(MPI_WTIME()-temps_debut);
-}
-
-void MEDPARTITIONER::testPersistantMpiRing(int taille, int nb)
-{
-  double temps_debut=MPI_Wtime();
-  int befo, next, rang, wsize, tagbefo, tagnext;
-  rang=MyGlobals::_rank;
-  wsize=MyGlobals::_world_size;
-  befo=rang-1; if (befo<0) befo=wsize-1;
-  next=rang+1; if (next>=wsize) next=0;
-  vector<int> x, y;
-  tagbefo=111111+befo;
-  tagnext=111111+rang;
-  MPI_Request requete0, requete1;
-  MPI_Status statut1, statut2;
-  int ok=0;
-  string res;
-  //cout<<"ini|"<<rang<<'|'<<befo<<'|'<<next<<' ';
-  {
-    x.resize(taille);
-    y.resize(taille);
-    MPI_Ssend_init(&x[0], taille, MPI_INT, next, tagnext, MPI_COMM_WORLD , &requete0);
-    MPI_Recv_init(&y[0], taille,  MPI_INT, befo, tagbefo, MPI_COMM_WORLD , &requete1);
-    //cout<<"isr|"<<rang<<'|'<<requete0<<'|'<<requete1<<' ';
-    for(int k=0; k<nb; k++)
-    {
-      for (int i=0; i<taille; ++i) x[i]=k+rang;
-      //Envoi d’un gros message --> cela peut prendre du temps
-      MPI_Start(&requete0);
-      //Reception du gros message --> cela peut prendre du temps
-      for (int i=0; i<taille; ++i) y[i]=-1;
-      MPI_Start(&requete1);
-      //Traitement sequentiel independant de "x"
-      //...
-      //Traitement sequentiel independant de "y"
-      //...
-      //cout<<"dsr|"<<rang<<' ';
-      MPI_Wait(&requete1, &statut1);
-      //Traitement sequentiel dependant de "y"
-      //...=f(y)
-      int nb=0;
-      for (int i=0; i<taille; ++i)
-        if (y[i]==k+befo) nb++;
-      if (nb==taille) ok++;
-      if (MyGlobals::_verbose>9)
-      {
-        res="0K"+intToStr(rang); if (nb!=taille) res="KO"+intToStr(rang);
-        cout<<res<<k<<" ";
-      }
-      MPI_Wait(&requete0, &statut2);
-      //Traitement sequentiel impliquant une modification de "x" en memoire
-      //x=...
-    }
-    res="0K"; if (ok!=nb) res="MAUVAIS";
-    temps_debut=MPI_Wtime()-temps_debut;
-    MPI_Request_free(&requete1);
-    MPI_Request_free(&requete0);
-  }
-  //temps_fin=(MPI_WTIME()-temps_debut);
-  if (MyGlobals::_verbose>1) 
-    cout<<"resultat proc "<<rang<<" "<<res<<" time(sec) "<<temps_debut<<endl;
-}
-void MEDPARTITIONER::testPersistantMpiRingOnCommSplit(int taille, int nb)
-{
-  double temps_debut=MPI_Wtime();
-  int rang=MyGlobals::_rank;
-  MPI_Comm newcomm;
-  int couleur=1;
-  int rangMax=4;
-  if (rang>=rangMax) couleur=MPI_UNDEFINED;
-  cout<<"coul|"<<rang<<'|'<<couleur<<' ';
-  //MPI_Comm_dup (MPI_COMM_WORLD, &newcomm) ;
-  MPI_Comm_split(MPI_COMM_WORLD, couleur, rang, &newcomm);
-  
-  int befo, next, wsize, tagbefo, tagnext;
-  wsize=rangMax;
-  if (wsize>MyGlobals::_world_size) wsize=MyGlobals::_world_size;
-  befo=rang-1; if (befo<0) befo=wsize-1;
-  next=rang+1; if (next>=wsize) next=0;
-  vector<int> x, y;
-  tagbefo=111111+befo;
-  tagnext=111111+rang;
-  MPI_Request requete0, requete1;
-  MPI_Status statut1, statut2;
-  int ok=0;
-  string res;
-  
-  //cout<<"ini|"<<rang<<'|'<<befo<<'|'<<next<<' ';
-  if (couleur==1)
-  {
-    x.resize(taille);
-    y.resize(taille);
-    MPI_Ssend_init(&x[0], taille, MPI_INT, next, tagnext, newcomm , &requete0);
-    MPI_Recv_init(&y[0], taille,  MPI_INT, befo, tagbefo, newcomm , &requete1);
-    //cout<<"isr|"<<rang<<'|'<<requete0<<'|'<<requete1<<' ';
-    for(int k=0; k<nb; k++)
-    {
-      for (int i=0; i<taille; ++i) x[i]=k+rang;
-      //Envoi d’un gros message --> cela peut prendre du temps
-      MPI_Start(&requete0);
-      //Reception du gros message --> cela peut prendre du temps
-      for (int i=0; i<taille; ++i) y[i]=-1;
-      MPI_Start(&requete1);
-      //Traitement sequentiel independant de "x"
-      //...
-      //Traitement sequentiel independant de "y"
-      //...
-      //cout<<"dsr|"<<rang<<' ';
-      MPI_Wait(&requete1, &statut1);
-      //Traitement sequentiel dependant de "y"
-      //...=f(y)
-      int nb=0;
-      for (int i=0; i<taille; ++i)
-        if (y[i]==k+befo) nb++;
-      if (nb==taille) ok++;
-      if (MyGlobals::_verbose>9)
-      {
-        res="0K"+intToStr(rang); if (nb!=taille) res="KO"+intToStr(rang);
-        cout<<res<<k<<" ";
-      }
-      MPI_Wait(&requete0, &statut2);
-      //Traitement sequentiel impliquant une modification de "x" en memoire
-      //x=...
-    }
-    res="0K"; if (ok!=nb) res="MAUVAIS";
-    temps_debut=MPI_Wtime()-temps_debut;
-    MPI_Request_free(&requete1);
-    MPI_Request_free(&requete0);
-  }
-  //MPI_Barrier(MPI_COMM_WORLD);
-  cout<<"barrier|"<<rang<<"|"<<newcomm<<" ";
-  if (couleur==1) MPI_Comm_free(&newcomm);
-  //temps_fin=(MPI_WTIME()-temps_debut);
-  if (MyGlobals::_verbose>1) 
-    cout<<"resultat proc "<<rang<<" "<<res<<" time(sec) "<<temps_debut<<endl;
-}
-
-
diff --git a/src/MEDPartitioner/MEDPARTITIONER_utils.hxx b/src/MEDPartitioner/MEDPARTITIONER_utils.hxx
deleted file mode 100644 (file)
index 4c6fbea..0000000
+++ /dev/null
@@ -1,147 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-#ifndef MEDPARTITIONER_UTILS_HXX_
-#define MEDPARTITIONER_UTILS_HXX_
-#include "MEDCouplingUMesh.hxx"
-
-#include <string>
-#include <vector>
-#include <map>
-
-#ifdef LOCALIZED
-#undef LOCALIZED
-#endif
-
-#if defined(_DEBUG_) || defined(_DEBUG)
-//# define LOCALIZED(message) #message , __FILE__ , __FUNCTION__ , __LINE__
-# define LOCALIZED(message) #message , __FUNCTION__ , __LINE__
-#else
-# define LOCALIZED(message) #message
-#endif
-
-namespace MEDPARTITIONER
-{
-  using namespace std;
-  using namespace ParaMEDMEM;
-  
-  string trim(string& s,const string& drop);
-  string intToStr(int i);
-  string doubleToStr(double i);
-  int strToInt(string s);
-  double strToDouble(string s);
-  bool testArg(const char *arg, const char *argExpected, string& argValue);
-  vector<int> createRandomSize(int size);
-  void randomizeAdj(int* xadj, int* adjncy, vector<int>& ran, vector<int>& vx, vector<int>& va);
-  void testRandomize();
-  
-  string reprVectorOfString(const vector<string>& vec);
-  string reprVectorOfString(const vector<string>& vec, string sep);
-  string reprMapOfStringInt(const map<string,int>& mymap);
-  string reprMapOfStringVectorOfString(const map< string,vector<string> >& mymap);
-  string reprFieldDescriptions(const vector<string>& vec, string sep);
-  
-  string serializeFromString(const string& s);
-  string serializeFromVectorOfString(const vector<string>& vec);
-  vector<string> deserializeToVectorOfString(const string& str);
-  string eraseTagSerialized(string fromStr, string tag);
-  
-  vector<string> vectorizeFromMapOfStringInt(const map<string,int>& mymap);
-  map<string,int> devectorizeToMapOfStringInt(const vector<string>& vec);
-  
-  vector<string> vectorizeFromMapOfStringVectorOfString(const map< string,vector<string> >& mymap);
-  map< string,vector<string> > devectorizeToMapOfStringVectorOfString(const vector<string>& vec);
-  
-  vector<string> selectTagsInVectorOfString(const vector<string>& vec, string tag);
-  vector<string> deleteDuplicatesInVectorOfString(const vector<string>& vec);
-  map< string,vector<string> > deleteDuplicatesInMapOfStringVectorOfString(const map< string,vector<string> >& mymap);
-  
-  string cle1ToStr(string s, int inew);
-  void cle1ToData(string cle, string& s, int& inew);
-  
-  string cle2ToStr(string s, int inew, int iold);
-  void cle2ToData(string cle, string& s, int& inew, int& iold);
-  
-  string extractFromDescription(string description, string tag);
-  void fieldDescriptionToData(string description,
-    int& idomain, string& fileName, string& meshName, string& fieldName,
-    int& typeField, int& DT, int& IT);
-  void fieldShortDescriptionToData(string description,
-    string& fieldName, int& typeField, int& entity, int& DT, int& IT);
-  
-  ParaMEDMEM::DataArrayInt* createDataArrayIntFromVector(vector<int>& v);
-  ParaMEDMEM::DataArrayInt* createDataArrayIntFromVector(vector<int>& v, int nbComponents);
-  ParaMEDMEM::DataArrayDouble* createDataArrayDoubleFromVector(vector<double>& v);
-
-  void sendVectorOfString(const vector<string>& vec, const int target);
-  vector<string> recvVectorOfString(const int source);
-  //TODO void sendrecvVectorOfString(const vector<string>& vec, const int source, const int target);
-  vector<string> sendAndReceiveVectorOfString(const vector<string>& vec, const int source, const int target);
-  vector<string> allgathervVectorOfString(const vector<std::string>& vec);
-  
-  vector<string> browseFieldDouble(const MEDCouplingFieldDouble* fd);
-  vector<string> browseAllFields(const string& myfile);
-  vector<string> browseAllFieldsOnMesh(const string& myfile, const string& mymesh, int idomain);
-  vector<string> GetInfosOfField(const char *fileName, const char *meshName, int idomain );
-
-  void sendDoubleVec(const std::vector<double>& vec, int target);
-  std::vector<double>* recvDoubleVec(int source);
-  void recvDoubleVec(std::vector<double>& vec, int source);
-    
-  void sendIntVec(const std::vector<int>& vec, int target);
-  std::vector<int>* recvIntVec(int source);
-  void recvIntVec(std::vector<int>& vec, int source);
-  
-  void sendDataArrayInt(ParaMEDMEM::DataArrayInt* da, int target);
-  ParaMEDMEM::DataArrayInt* recvDataArrayInt(int source);
-  void sendDataArrayDouble(ParaMEDMEM::DataArrayDouble* da, int target);
-  ParaMEDMEM::DataArrayDouble* recvDataArrayDouble(int source);
-  
-  ParaMEDMEM::MEDCouplingUMesh* createEmptyMEDCouplingUMesh();
-  
-  void testVectorOfStringMPI();
-  void testMapOfStringIntMPI();
-  void testMapOfStringVectorOfStringMPI();
-  void testDataArrayMPI();
-  void testPersistantMpi0To1(int taille, int nb);
-  void testPersistantMpiRing(int taille, int nb);
-  void testPersistantMpiRingOnCommSplit(int taille, int nb);
-
-  class MyGlobals
-  {
-    public : static int _verbose;  //0 to 1000 over 200 is debug
-    public : static int _rank;
-    public : static int _world_size;
-    public : static int _randomize;
-    public : static int _atomize;
-    public : static int _creates_boundary_faces;
-    public : static int _is0verbose; //cout if rank 0 and verbose
-    public : static vector<string> _fileNames;    //on [iold]
-    public : static vector<string> _meshNames;    //on [iold]
-    public : static vector<string> _fieldDescriptions;
-    //used for descriptions of components of fields for example...
-    public : static vector<string> _generalInformations;
-    
-  };
-  
-  /*int MyGlobals::_verbose=0;
-  int MyGlobals::_is0verbose=0;
-  int MyGlobals::_rank=-1;
-  int MyGlobals::_world_size=-1;*/
-}
-#endif /*MEDPARTITIONER_UTILS_HXX_*/
index b7f36c18575e8c4222995317e0205e640be771c4..34256d2a81a4a07deb8c426824b4eff9efcc6527 100644 (file)
@@ -1,23 +1,22 @@
-#  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
+# Copyright (C) 2007-2011  CEA/DEN, EDF R&D
 #
-#  This library is free software; you can redistribute it and/or
-#  modify it under the terms of the GNU Lesser General Public
-#  License as published by the Free Software Foundation; either
-#  version 2.1 of the License.
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
 #
-#  This library is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-#  Lesser General Public License for more details.
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Lesser General Public License for more details.
 #
-#  You should have received a copy of the GNU Lesser General Public
-#  License along with this library; if not, write to the Free Software
-#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 #
-#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-#  MED : MED files in memory
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
+
 include $(top_srcdir)/adm_local/unix/make_common_starter.am
 
 # this directory must be recompiled before Test folder
@@ -29,35 +28,33 @@ endif
 lib_LTLIBRARIES= libmedpartitioner.la
 
 salomeinclude_HEADERS= \
-MEDPARTITIONER_MESHCollection.hxx \
-MEDPARTITIONER_MESHCollectionMedXMLDriver.H \
-MEDPARTITIONER_MESHCollectionMedAsciiDriver.H \
-MEDPARTITIONER_MESHCollectionDriver.hxx \
-MEDPARTITIONER_MESHCollectionMedXMLDriver.hxx \
-MEDPARTITIONER_MESHCollectionMedAsciiDriver.hxx \
+MEDPARTITIONER_MeshCollection.hxx \
+MEDPARTITIONER_MeshCollectionDriver.hxx \
+MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx \
+MEDPARTITIONER_MeshCollectionMedAsciiDriver.hxx \
 MEDPARTITIONER_ParallelTopology.hxx \
 MEDPARTITIONER_JointFinder.hxx \
 MEDPARTITIONER_Graph.hxx\
 MEDPARTITIONER_UserGraph.hxx\
-MEDPARTITIONER_utils.hxx \
+MEDPARTITIONER_Utils.hxx \
 MEDPARTITIONER.hxx \
 MEDPARTITIONER_ParaDomainSelector.hxx \
 MEDPARTITIONER_ConnectZone.hxx \
 MEDPARTITIONER_SkyLineArray.hxx
 
 if MED_ENABLE_METIS
-    salomeinclude_HEADERS+= MEDPARTITIONER_METISGraph.hxx
+    salomeinclude_HEADERS+= MEDPARTITIONER_MetisGraph.hxx
 endif
 if MED_ENABLE_SCOTCH
-    salomeinclude_HEADERS+= MEDPARTITIONER_SCOTCHGraph.hxx
+    salomeinclude_HEADERS+= MEDPARTITIONER_ScotchGraph.hxx
 endif
 
 dist_libmedpartitioner_la_SOURCES= \
-MEDPARTITIONER_utils.cxx \
-MEDPARTITIONER_MESHCollection.cxx \
-MEDPARTITIONER_MESHCollectionDriver.cxx \
-MEDPARTITIONER_MESHCollectionMedXMLDriver.cxx \
-MEDPARTITIONER_MESHCollectionMedAsciiDriver.cxx \
+MEDPARTITIONER_Utils.cxx \
+MEDPARTITIONER_MeshCollection.cxx \
+MEDPARTITIONER_MeshCollectionDriver.cxx \
+MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx \
+MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx \
 MEDPARTITIONER_ParallelTopology.cxx \
 MEDPARTITIONER_Graph.cxx\
 MEDPARTITIONER_UserGraph.cxx\
@@ -67,10 +64,10 @@ MEDPARTITIONER_SkyLineArray.cxx \
 MEDPARTITIONER_ConnectZone.cxx
 
 if MED_ENABLE_METIS
-    dist_libmedpartitioner_la_SOURCES+= MEDPARTITIONER_METISGraph.cxx
+    dist_libmedpartitioner_la_SOURCES+= MEDPARTITIONER_MetisGraph.cxx
 endif
 if MED_ENABLE_SCOTCH
-    dist_libmedpartitioner_la_SOURCES+= MEDPARTITIONER_SCOTCHGraph.cxx
+    dist_libmedpartitioner_la_SOURCES+= MEDPARTITIONER_ScotchGraph.cxx
 endif
 
 libmedpartitioner_la_CPPFLAGS= $(MPI_INCLUDES) $(MED3_INCLUDES) $(HDF5_INCLUDES) @CXXTMPDPTHFLAGS@ \
@@ -79,8 +76,6 @@ libmedpartitioner_la_CPPFLAGS= $(MPI_INCLUDES) $(MED3_INCLUDES) $(HDF5_INCLUDES)
   -I$(srcdir)/../MEDLoader -I$(srcdir)/../INTERP_KERNEL
 
 libmedpartitioner_la_LDFLAGS= 
-#libmedpartitioner_la_LDFLAGS= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) \
-#      ../MEDMEM/libmedmem.la ../MEDWrapper/V2_1/Core/libmed_V2_1.la
 
 if MED_ENABLE_PARMETIS
   libmedpartitioner_la_CPPFLAGS+= $(PARMETIS_CPPFLAGS)
@@ -99,31 +94,24 @@ if MED_ENABLE_KERNEL
   libmedpartitioner_la_LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace 
 endif
 
-#libmedpartitioner_la_LDFLAGS+= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) $(MPI_LIBS) \
-#      ../MEDMEM/libmedmem.la  ../INTERP_KERNEL/libinterpkernel.la ../MEDCoupling/libmedcoupling.la ../MEDLoader/libmedloader.la 
 libmedpartitioner_la_LDFLAGS+= $(MED2_LIBS) $(HDF5_LIBS) $(STDLIB) $(LIBXML_LIBS) $(MPI_LIBS) \
        ../INTERP_KERNEL/libinterpkernel.la ../MEDCoupling/libmedcoupling.la ../MEDLoader/libmedloader.la 
 
-# Executables targets
-bin_PROGRAMS= medpartitioner
-
-dist_medpartitioner_SOURCES= medpartitioner.cxx
-
 medpartitioner_CPPFLAGS= $(libmedpartitioner_la_CPPFLAGS)
 medpartitioner_LDADD= $(libmedpartitioner_la_LDFLAGS) -lm $(BOOST_LIBS) libmedpartitioner.la
+
 if MED_ENABLE_KERNEL
   medpartitioner_LDADD+= -lSALOMEBasics
 endif
 
+# Executables targets
 if MPI_IS_OK
-  bin_PROGRAMS+=medpartitioner_para
+  bin_PROGRAMSmedpartitioner_para
   dist_medpartitioner_para_SOURCES= medpartitioner_para.cxx
   medpartitioner_para_CPPFLAGS= $(medpartitioner_CPPFLAGS)
   medpartitioner_para_LDADD= $(medpartitioner_LDADD)
 endif
 
-OBSOLETE_FILES = \
-       MEDPARTITIONER_SequentialTopology.cxx \
-       test_HighLevelAPI.cxx
+OBSOLETE_FILES =
 
 EXTRA_DIST += $(OBSOLETE_FILES)
index 7b8bde6cc9666766682ce7711f367a15bf30ed82..4be16f9181066b39caad1ebbe16a90a93e4c5343 100644 (file)
@@ -17,7 +17,6 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-
 #include <sstream>
 #include <cmath>
 #include <list>
@@ -28,8 +27,6 @@
 //#include "MEDPARTITIONERTest.hxx"
 #include <cppunit/TestAssert.h>
 
-//#include "MEDMEM_STRING.hxx"
-
 #include "MEDPARTITIONERTest.hxx"
 
 #include "CellModel.hxx"
 #include "MEDCouplingMemArray.hxx"
 #include "MEDCouplingMultiFields.hxx"
 
-#include "MEDPARTITIONER_MESHCollection.hxx"
-//#include "MEDPARTITIONER_Topology.hxx"
+#include "MEDPARTITIONER_MeshCollection.hxx"
 #include "MEDPARTITIONER_ParallelTopology.hxx"
 #include "MEDPARTITIONER_ParaDomainSelector.hxx"
 
-#include "MEDPARTITIONER_utils.hxx"
+#include "MEDPARTITIONER_Utils.hxx"
 
 #ifdef HAVE_MPI2
 #include <mpi.h>
 #endif
 
 using namespace std;
-//using namespace MEDPARTITIONER;
 using namespace ParaMEDMEM;
 using namespace MEDPARTITIONER;
 
-/*string intToStr(int i)
-{
-  ostringstream oss;
-  oss<<i;
-  return oss.str();
-}*/
-
 void MEDPARTITIONERTest::setSize(int ni, int nj, int nk)
 {
   this->_ni=ni;  //nb of hexa9
   this->_nj=nj;
   this->_nk=nk;
   this->_ntot=_ni*_nj*_nk;
-  string ijk=intToStr(ni)+"x"+intToStr(nj)+"x"+intToStr(nk);
+  string ijk=IntToStr(ni)+"x"+IntToStr(nj)+"x"+IntToStr(nk);
   this->_fileName="tmp_testMesh_"+ijk+".med";
   this->_fileNameWithFaces="tmp_testMeshWithFaces_"+ijk+".med";
-  string ij=intToStr(ni)+"x"+intToStr(nj);
+  string ij=IntToStr(ni)+"x"+IntToStr(nj);
   this->_fileName2="tmp_testMesh_"+ij+".med";
   this->_meshName="testMesh";
 }
@@ -102,7 +90,7 @@ void MEDPARTITIONERTest::setbigSize()
 // ============================================================================
 void MEDPARTITIONERTest::setUp()
 {
-  this->_verbose=0;
+  this->_verbose=100;
 }
 
 // ============================================================================
@@ -120,46 +108,46 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildCUBE3DMesh()
   vector<int> conn;
   vector<double> coor;
   for (int k=0; k<=_nk; k++)
-  for (int j=0; j<=_nj; j++)
-  for (int i=0; i<=_ni; i++)
-  {
-    coor.push_back(i+.1);
-    coor.push_back(j+.2);
-    coor.push_back(k+.3);
-  }
+    for (int j=0; j<=_nj; j++)
+      for (int i=0; i<=_ni; i++)
+        {
+          coor.push_back(i+.1);
+          coor.push_back(j+.2);
+          coor.push_back(k+.3);
+        }
   int ii;
   for (int k=0; k<_nk; k++)
-  for (int j=0; j<_nj; j++)
-  for (int i=0; i<_ni; i++)
-  {
-    ii=i + j*(_ni+1) + k*(_ni+1)*(_nj+1);
-    conn.push_back(ii);
-    conn.push_back(ii+1);
-    ii=ii + _ni + 2 ;
-    conn.push_back(ii);
-    conn.push_back(ii-1);
+    for (int j=0; j<_nj; j++)
+      for (int i=0; i<_ni; i++)
+        {
+          ii=i + j*(_ni+1) + k*(_ni+1)*(_nj+1);
+          conn.push_back(ii);
+          conn.push_back(ii+1);
+          ii=ii + _ni + 2 ;
+          conn.push_back(ii);
+          conn.push_back(ii-1);
     
-    ii=i + j*(_ni+1) + (k+1)*(_ni+1)*(_nj+1);
-    conn.push_back(ii);
-    conn.push_back(ii+1);
-    ii=ii + _ni + 2 ;
-    conn.push_back(ii);
-    conn.push_back(ii-1);
-  }
+          ii=i + j*(_ni+1) + (k+1)*(_ni+1)*(_nj+1);
+          conn.push_back(ii);
+          conn.push_back(ii+1);
+          ii=ii + _ni + 2 ;
+          conn.push_back(ii);
+          conn.push_back(ii-1);
+        }
 
   if (false) //(_verbose)
-  {
-    cout<<"\nnb coor "<<(_ni+1)*(_nj+1)*(_nk+1)*3<<" "<<coor.size()<<endl;
-    for (int i=0; i<coor.size(); i++) cout<<coor[i]<<" ";
-    cout<<endl;
-    cout<<"\nnb conn "<<(_ni)*(_nj)*(_nk)*8<<" "<<conn.size()<<endl;
-    for (int i=0; i<conn.size(); i=i+8)
-    { 
-      for (int j=0; j<8; j++) cout<<conn[i+j]<<" ";
+    {
+      cout<<"\nnb coor "<<(_ni+1)*(_nj+1)*(_nk+1)*3<<" "<<coor.size()<<endl;
+      for (int i=0; i<coor.size(); i++) cout<<coor[i]<<" ";
+      cout<<endl;
+      cout<<"\nnb conn "<<(_ni)*(_nj)*(_nk)*8<<" "<<conn.size()<<endl;
+      for (int i=0; i<conn.size(); i=i+8)
+        { 
+          for (int j=0; j<8; j++) cout<<conn[i+j]<<" ";
+          cout<<endl;
+        }
       cout<<endl;
     }
-    cout<<endl;
-  }
   
   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
   mesh->setMeshDimension(3);
@@ -167,16 +155,16 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildCUBE3DMesh()
   int nbv=coor.size()/3; //nb of vertices
   mesh->allocateCells(nbc);
   for(int i=0; i<nbc; i++)
-  {
-    int onehexa[8];
-    std::copy(conn.begin()+i*8,conn.begin()+(i+1)*8,onehexa);
-    if (false) //(_verbose)
     {
-      for (int j=0; j<8; j++) cout<<onehexa[j]<<" ";
-      cout<<endl;
+      int onehexa[8];
+      std::copy(conn.begin()+i*8,conn.begin()+(i+1)*8,onehexa);
+      if (false) //(_verbose)
+        {
+          for (int j=0; j<8; j++) cout<<onehexa[j]<<" ";
+          cout<<endl;
+        }
+      mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,onehexa);
     }
-    mesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,onehexa);
-  }
   mesh->finishInsertingCells();
   DataArrayDouble *myCoords=DataArrayDouble::New();
   myCoords->alloc(nbv,3);
@@ -194,39 +182,39 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildCARRE3DMesh()
   vector<int> conn;
   vector<double> coor;
   for (int j=0; j<=_nj; j++)
-  for (int i=0; i<=_ni; i++)
-  {
-    int k=j;
-    coor.push_back(i+.1);
-    coor.push_back(j+.2);
-    coor.push_back(k+.3);
-  }
+    for (int i=0; i<=_ni; i++)
+      {
+        int k=j;
+        coor.push_back(i+.1);
+        coor.push_back(j+.2);
+        coor.push_back(k+.3);
+      }
   int ii;
   int k=0;
   for (int j=0; j<_nj; j++)
-  for (int i=0; i<_ni; i++)
-  {
-    ii=i + j*(_ni+1) + k*(_ni+1)*(_nj+1);
-    conn.push_back(ii);
-    conn.push_back(ii+1);
-    ii=ii + _ni + 2 ;
-    conn.push_back(ii);
-    conn.push_back(ii-1);
-   }
+    for (int i=0; i<_ni; i++)
+      {
+        ii=i + j*(_ni+1) + k*(_ni+1)*(_nj+1);
+        conn.push_back(ii);
+        conn.push_back(ii+1);
+        ii=ii + _ni + 2 ;
+        conn.push_back(ii);
+        conn.push_back(ii-1);
+      }
 
   if (false) //(_verbose)
-  {
-    cout<<"\nnb coor "<<(_ni+1)*(_nj+1)*3<<" "<<coor.size()<<endl;
-    for (int i=0; i<coor.size(); i++) cout<<coor[i]<<" ";
-    cout<<endl;
-    cout<<"\nnb conn "<<(_ni)*(_nj)*4<<" "<<conn.size()<<endl;
-    for (int i=0; i<conn.size(); i=i+4)
-    { 
-      for (int j=0; j<4; j++) cout<<conn[i+j]<<" ";
+    {
+      cout<<"\nnb coor "<<(_ni+1)*(_nj+1)*3<<" "<<coor.size()<<endl;
+      for (int i=0; i<coor.size(); i++) cout<<coor[i]<<" ";
+      cout<<endl;
+      cout<<"\nnb conn "<<(_ni)*(_nj)*4<<" "<<conn.size()<<endl;
+      for (int i=0; i<conn.size(); i=i+4)
+        { 
+          for (int j=0; j<4; j++) cout<<conn[i+j]<<" ";
+          cout<<endl;
+        }
       cout<<endl;
     }
-    cout<<endl;
-  }
   
   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
   mesh->setMeshDimension(2);
@@ -234,16 +222,16 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildCARRE3DMesh()
   int nbv=coor.size()/3; //nb of vertices
   mesh->allocateCells(nbc);
   for(int i=0; i<nbc; i++)
-  {
-    int onequa[4];
-    std::copy(conn.begin()+i*4,conn.begin()+(i+1)*4,onequa);
-    if (false) //(_verbose)
     {
-      for (int j=0; j<4; j++) cout<<onequa[j]<<" ";
-      cout<<endl;
+      int onequa[4];
+      std::copy(conn.begin()+i*4,conn.begin()+(i+1)*4,onequa);
+      if (false) //(_verbose)
+        {
+          for (int j=0; j<4; j++) cout<<onequa[j]<<" ";
+          cout<<endl;
+        }
+      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,onequa);
     }
-    mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,onequa);
-  }
   mesh->finishInsertingCells();
   DataArrayDouble *myCoords=DataArrayDouble::New();
   myCoords->alloc(nbv,3);
@@ -261,39 +249,39 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildFACE3DMesh()
   vector<int> conn;
   vector<double> coor;
   for (int j=0; j<=_nj; j++)
-  for (int i=0; i<=_ni; i++)
-  {
-    int k=0;
-    coor.push_back(i+.1);
-    coor.push_back(j+.2);
-    coor.push_back(k+.3);
-  }
+    for (int i=0; i<=_ni; i++)
+      {
+        int k=0;
+        coor.push_back(i+.1);
+        coor.push_back(j+.2);
+        coor.push_back(k+.3);
+      }
   int ii;
   int k=0;
   for (int j=0; j<_nj; j++)
-  for (int i=0; i<_ni; i++)
-  {
-    ii=i + j*(_ni+1) + k*(_ni+1)*(_nj+1);
-    conn.push_back(ii);
-    conn.push_back(ii+1);
-    ii=ii + _ni + 2 ;
-    conn.push_back(ii);
-    conn.push_back(ii-1);
-   }
+    for (int i=0; i<_ni; i++)
+      {
+        ii=i + j*(_ni+1) + k*(_ni+1)*(_nj+1);
+        conn.push_back(ii);
+        conn.push_back(ii+1);
+        ii=ii + _ni + 2 ;
+        conn.push_back(ii);
+        conn.push_back(ii-1);
+      }
 
   if (false) //(_verbose)
-  {
-    cout<<"\nnb coor "<<(_ni+1)*(_nj+1)*3<<" "<<coor.size()<<endl;
-    for (int i=0; i<coor.size(); i++) cout<<coor[i]<<" ";
-    cout<<endl;
-    cout<<"\nnb conn "<<(_ni)*(_nj)*4<<" "<<conn.size()<<endl;
-    for (int i=0; i<conn.size(); i=i+4)
-    { 
-      for (int j=0; j<4; j++) cout<<conn[i+j]<<" ";
+    {
+      cout<<"\nnb coor "<<(_ni+1)*(_nj+1)*3<<" "<<coor.size()<<endl;
+      for (int i=0; i<coor.size(); i++) cout<<coor[i]<<" ";
+      cout<<endl;
+      cout<<"\nnb conn "<<(_ni)*(_nj)*4<<" "<<conn.size()<<endl;
+      for (int i=0; i<conn.size(); i=i+4)
+        { 
+          for (int j=0; j<4; j++) cout<<conn[i+j]<<" ";
+          cout<<endl;
+        }
       cout<<endl;
     }
-    cout<<endl;
-  }
   
   MEDCouplingUMesh *mesh=MEDCouplingUMesh::New();
   mesh->setMeshDimension(2);
@@ -301,16 +289,16 @@ ParaMEDMEM::MEDCouplingUMesh * MEDPARTITIONERTest::buildFACE3DMesh()
   int nbv=coor.size()/3; //nb of vertices
   mesh->allocateCells(nbc);
   for(int i=0; i<nbc; i++)
-  {
-    int onequa[4];
-    std::copy(conn.begin()+i*4,conn.begin()+(i+1)*4,onequa);
-    if (false) //(_verbose)
     {
-      for (int j=0; j<4; j++) cout<<onequa[j]<<" ";
-      cout<<endl;
+      int onequa[4];
+      std::copy(conn.begin()+i*4,conn.begin()+(i+1)*4,onequa);
+      if (false) //(_verbose)
+        {
+          for (int j=0; j<4; j++) cout<<onequa[j]<<" ";
+          cout<<endl;
+        }
+      mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,onequa);
     }
-    mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,onequa);
-  }
   mesh->finishInsertingCells();
   DataArrayDouble *myCoords=DataArrayDouble::New();
   myCoords->alloc(nbv,3);
@@ -327,13 +315,13 @@ MEDCouplingFieldDouble * MEDPARTITIONERTest::buildVecFieldOnCells(string myfileN
   //int ni=2,nj=3,nk=5; //nb of hexa9
   vector<double> field;
   for (int k=0; k<_nk; k++)
-  for (int j=0; j<_nj; j++)
-  for (int i=0; i<_ni; i++)
-  {
-    field.push_back(i+.1);
-    field.push_back(j+.2);
-    field.push_back(k+.3);
-  }
+    for (int j=0; j<_nj; j++)
+      for (int i=0; i<_ni; i++)
+        {
+          field.push_back(i+.1);
+          field.push_back(j+.2);
+          field.push_back(k+.3);
+        }
   //cvwat
   MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(myfileName.c_str(),_meshName.c_str(),0);
   int nbOfCells=mesh->getNumberOfCells();
@@ -360,13 +348,13 @@ MEDCouplingFieldDouble * MEDPARTITIONERTest::buildVecFieldOnNodes()
   //int ni=2,nj=3,nk=5; //nb of hexa9
   vector<double> field;
   for (int k=0; k<=_nk; k++)
-  for (int j=0; j<=_nj; j++)
-  for (int i=0; i<=_ni; i++)
-  {
-    field.push_back(i+.1);
-    field.push_back(j+.2);
-    field.push_back(k+.3);
-  }
+    for (int j=0; j<=_nj; j++)
+      for (int i=0; i<=_ni; i++)
+        {
+          field.push_back(i+.1);
+          field.push_back(j+.2);
+          field.push_back(k+.3);
+        }
   
   MEDCouplingUMesh *mesh=MEDLoader::ReadUMeshFromFile(_fileName.c_str(),_meshName.c_str(),0);
   int nbOfNodes=mesh->getNumberOfNodes();
@@ -392,83 +380,83 @@ MEDCouplingFieldDouble * MEDPARTITIONERTest::buildVecFieldOnNodes()
 void MEDPARTITIONERTest::createTestMeshWithoutField()
 {
   {
-  MEDCouplingUMesh * mesh = buildCUBE3DMesh();
-  MEDLoader::WriteUMesh(_fileName.c_str(),mesh,true);
-  if (_verbose) cout<<endl<<_fileName<<" created"<<endl;
-  if (_ntot<1000000) //too long
-  {
-    MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileName.c_str(),mesh->getName(),0);
-    if (_verbose) cout<<_fileName<<" reread"<<endl;
-    CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12));
-    mesh_rw->decrRef();
-  }
-  mesh->decrRef();
+    MEDCouplingUMesh * mesh = buildCUBE3DMesh();
+    MEDLoader::WriteUMesh(_fileName.c_str(),mesh,true);
+    if (_verbose) cout<<endl<<_fileName<<" created"<<endl;
+    if (_ntot<1000000) //too long
+      {
+        MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileName.c_str(),mesh->getName(),0);
+        if (_verbose) cout<<_fileName<<" reread"<<endl;
+        CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12));
+        mesh_rw->decrRef();
+      }
+    mesh->decrRef();
   }
   
   {
-  vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
-  MEDCouplingUMesh * mesh1 = buildCUBE3DMesh();
-  MEDCouplingUMesh * mesh2 = buildFACE3DMesh();
-  mesh1->setName("testMesh");
-  mesh2->setName("theFaces");
-  mesh2->tryToShareSameCoordsPermute(*mesh1, 1e-9);
-  mesh2->checkCoherency();
-  mesh1->checkCoherency();
-  meshes.push_back(mesh1);
-  meshes.push_back(mesh2);
-  MEDLoader::WriteUMeshes(_fileNameWithFaces.c_str(), meshes, true);
+    vector<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
+    MEDCouplingUMesh * mesh1 = buildCUBE3DMesh();
+    MEDCouplingUMesh * mesh2 = buildFACE3DMesh();
+    mesh1->setName("testMesh");
+    mesh2->setName("theFaces");
+    mesh2->tryToShareSameCoordsPermute(*mesh1, 1e-9);
+    mesh2->checkCoherency();
+    mesh1->checkCoherency();
+    meshes.push_back(mesh1);
+    meshes.push_back(mesh2);
+    MEDLoader::WriteUMeshes(_fileNameWithFaces.c_str(), meshes, true);
   
-  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_fileNameWithFaces.c_str(), mesh1->getName());
-  DataArrayInt* FacesFam=DataArrayInt::New();
-  FacesFam->alloc(mfm->getSizeAtLevel(-1),1);
-  FacesFam->fillWithValue(-1);
-  DataArrayInt* CellsFam=DataArrayInt::New();
-  CellsFam->alloc(mfm->getSizeAtLevel(0),1);
-  CellsFam->fillWithValue(1);
-  mfm->setFamilyFieldArr(-1,FacesFam);
-  mfm->setFamilyFieldArr(0,CellsFam);
-  map<string,int> theFamilies;
-  theFamilies["FAMILLE_ZERO"]=0;
-  theFamilies["FamilyFaces"]=-1;
-  theFamilies["FamilyCells"]=1;
-  map<string, vector<string> > theGroups;
-  theGroups["GroupFaces"].push_back("FamilyFaces");
-  theGroups["GroupCells"].push_back("FamilyCells");
-  mfm->setFamilyInfo(theFamilies);
-  mfm->setGroupInfo(theGroups);
-  mfm->write(_fileNameWithFaces.c_str(),0);
-  FacesFam->decrRef();
-  CellsFam->decrRef();
+    ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_fileNameWithFaces.c_str(), mesh1->getName());
+    DataArrayInt* FacesFam=DataArrayInt::New();
+    FacesFam->alloc(mfm->getSizeAtLevel(-1),1);
+    FacesFam->fillWithValue(-1);
+    DataArrayInt* CellsFam=DataArrayInt::New();
+    CellsFam->alloc(mfm->getSizeAtLevel(0),1);
+    CellsFam->fillWithValue(1);
+    mfm->setFamilyFieldArr(-1,FacesFam);
+    mfm->setFamilyFieldArr(0,CellsFam);
+    map<string,int> theFamilies;
+    theFamilies["FAMILLE_ZERO"]=0;
+    theFamilies["FamilyFaces"]=-1;
+    theFamilies["FamilyCells"]=1;
+    map<string, vector<string> > theGroups;
+    theGroups["GroupFaces"].push_back("FamilyFaces");
+    theGroups["GroupCells"].push_back("FamilyCells");
+    mfm->setFamilyInfo(theFamilies);
+    mfm->setGroupInfo(theGroups);
+    mfm->write(_fileNameWithFaces.c_str(),0);
+    FacesFam->decrRef();
+    CellsFam->decrRef();
   
-  /*ce truc marche pas!
-  ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_fileNameWithFaces.c_str(), mesh1->getName());
-  vector<const ParaMEDMEM::MEDCouplingUMesh*> ms;
-  ms.push_back(mesh2);
-  mfm->setGroupsFromScratch(-1, ms);
-  mfm->write(_fileNameWithFaces.c_str(),0);
-  */
+    /*ce truc marche pas!
+      ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(_fileNameWithFaces.c_str(), mesh1->getName());
+      vector<const ParaMEDMEM::MEDCouplingUMesh*> ms;
+      ms.push_back(mesh2);
+      mfm->setGroupsFromScratch(-1, ms);
+      mfm->write(_fileNameWithFaces.c_str(),0);
+    */
   
-  if (_verbose) cout<<endl<<_fileNameWithFaces<<" created"<<endl;
-  if (_ntot<1000000) //too long
-  {
-    MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileNameWithFaces.c_str(),mesh1->getName(),0);
-    if (_verbose) cout<<_fileNameWithFaces<<" reread"<<endl;
-    CPPUNIT_ASSERT(mesh1->isEqual(mesh_rw,1e-12));
-    mesh_rw->decrRef();
-  }
-  mesh1->decrRef();
-  mesh2->decrRef();
+    if (_verbose) cout<<endl<<_fileNameWithFaces<<" created"<<endl;
+    if (_ntot<1000000) //too long
+      {
+        MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileNameWithFaces.c_str(),mesh1->getName(),0);
+        if (_verbose) cout<<_fileNameWithFaces<<" reread"<<endl;
+        CPPUNIT_ASSERT(mesh1->isEqual(mesh_rw,1e-12));
+        mesh_rw->decrRef();
+      }
+    mesh1->decrRef();
+    mesh2->decrRef();
   }
    
   {
-  MEDCouplingUMesh * mesh = buildCARRE3DMesh();
-  MEDLoader::WriteUMesh(_fileName2.c_str(),mesh,true);
-  if (_verbose) cout<<endl<<_fileName2<<" created"<<endl;
-  MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileName2.c_str(),mesh->getName(),0);
-  if (_verbose) cout<<_fileName2<<" reread"<<endl;
-  CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12));
-  mesh_rw->decrRef();
-  mesh->decrRef();
+    MEDCouplingUMesh * mesh = buildCARRE3DMesh();
+    MEDLoader::WriteUMesh(_fileName2.c_str(),mesh,true);
+    if (_verbose) cout<<endl<<_fileName2<<" created"<<endl;
+    MEDCouplingUMesh *mesh_rw=MEDLoader::ReadUMeshFromFile(_fileName2.c_str(),mesh->getName(),0);
+    if (_verbose) cout<<_fileName2<<" reread"<<endl;
+    CPPUNIT_ASSERT(mesh->isEqual(mesh_rw,1e-12));
+    mesh_rw->decrRef();
+    mesh->decrRef();
   }
 }
 
@@ -524,44 +512,44 @@ void MEDPARTITIONERTest::createHugeTestMesh(int ni, int nj, int nk, int nbx, int
   
   double dz=0.;
   for (int z=0; z<nbz; z++)
-  {
-    double dy=0.;
-    for (int y=0; y<nby; y++)
     {
-      double dx=0.;
-      for (int x=0; x<nbx; x++)
-      {
-        string fileName;
-        sxyz=intToStr(xyz);
-        fileName="tmp_testMeshHuge_"+intToStr(_ni)+"x"+intToStr(_nj)+"x"+intToStr(_nk)+"_"+sxyz+".med";
-        
-        DataArrayDouble* coords=mesh->getCoords();
-        //int nbOfComp=coords->getNumberOfComponents();  //be 3D
-        int nbOfTuple=coords->getNumberOfTuples();
-        double* ptr=coords->getPointer();
-        double* ptrini=ptrInit;
-        for (int i=0; i<nbOfTuple; i++)
+      double dy=0.;
+      for (int y=0; y<nby; y++)
         {
-          *ptr=(*ptrini)+dx; ptr++; ptrini++; //be 3D
-          *ptr=(*ptrini)+dy; ptr++; ptrini++;
-          *ptr=(*ptrini)+dz; ptr++; ptrini++;
-        }
+          double dx=0.;
+          for (int x=0; x<nbx; x++)
+            {
+              string fileName;
+              sxyz=IntToStr(xyz);
+              fileName="tmp_testMeshHuge_"+IntToStr(_ni)+"x"+IntToStr(_nj)+"x"+IntToStr(_nk)+"_"+sxyz+".med";
+        
+              DataArrayDouble* coords=mesh->getCoords();
+              //int nbOfComp=coords->getNumberOfComponents();  //be 3D
+              int nbOfTuple=coords->getNumberOfTuples();
+              double* ptr=coords->getPointer();
+              double* ptrini=ptrInit;
+              for (int i=0; i<nbOfTuple; i++)
+                {
+                  *ptr=(*ptrini)+dx; ptr++; ptrini++; //be 3D
+                  *ptr=(*ptrini)+dy; ptr++; ptrini++;
+                  *ptr=(*ptrini)+dz; ptr++; ptrini++;
+                }
 
-        MEDLoader::WriteUMesh(fileName.c_str(),mesh,true);
+              MEDLoader::WriteUMesh(fileName.c_str(),mesh,true);
         
-        tagSubfiles+=tagSubfile;
-        tagSubfiles.replace(tagSubfiles.find("$xyz"),4,sxyz);
-        tagSubfiles.replace(tagSubfiles.find("$fileName"),9,fileName);
+              tagSubfiles+=tagSubfile;
+              tagSubfiles.replace(tagSubfiles.find("$xyz"),4,sxyz);
+              tagSubfiles.replace(tagSubfiles.find("$fileName"),9,fileName);
         
-        tagMeshes+=tagMesh;
-        tagMeshes.replace(tagMeshes.find("$xyz"),4,sxyz);
-        xyz++;
-        dx+=deltax;
-      }
-      dy+=deltay;
+              tagMeshes+=tagMesh;
+              tagMeshes.replace(tagMeshes.find("$xyz"),4,sxyz);
+              xyz++;
+              dx+=deltax;
+            }
+          dy+=deltay;
+        }
+      dz+=deltaz;
     }
-    dz+=deltaz;
-  }
   coordsInit->decrRef();
   
   tagXml.replace(tagXml.find("$subdomainNumber"),16,sxyz);
@@ -569,7 +557,7 @@ void MEDPARTITIONERTest::createHugeTestMesh(int ni, int nj, int nk, int nbx, int
   tagXml.replace(tagXml.find("$tagMesh"),8,tagMeshes);
 
   string nameFileXml;
-  _fileNameHugeXml="tmp_testMeshHuge_"+intToStr(_ni)+"x"+intToStr(_nj)+"x"+intToStr(_nk)+"_"+sxyz+".xml";
+  _fileNameHugeXml="tmp_testMeshHuge_"+IntToStr(_ni)+"x"+IntToStr(_nj)+"x"+IntToStr(_nk)+"_"+sxyz+".xml";
   std::ofstream f(_fileNameHugeXml.c_str());
   f<<tagXml;
   f.close();
@@ -581,95 +569,95 @@ void MEDPARTITIONERTest::createHugeTestMesh(int ni, int nj, int nk, int nbx, int
 void MEDPARTITIONERTest::createTestMeshWithVecFieldOnCells()
 {
   {
-  string name=_fileName;
-  MEDCouplingFieldDouble *f1=buildVecFieldOnCells(name);
-  name.replace(name.find(".med"),4,"_WithVecFieldOnCells.med");
-  MEDLoader::WriteField(name.c_str(),f1,true);
-  f1->setTime(3.,1,1);  //time,it,order
-  f1->applyFunc("x/2.");
-  MEDLoader::WriteField(name.c_str(),f1,false);
-  if (_verbose) cout<<endl<<name<<" created"<<endl;
-  if (_ntot<1000000) //too long
-  {
-     MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
-    //DataArrayDouble *res=f2->getArray();
-    if (_verbose) cout<<name<<" reread"<<endl;
-    //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
-    f2->decrRef();
-  }
-  f1->decrRef();
+    string name=_fileName;
+    MEDCouplingFieldDouble *f1=buildVecFieldOnCells(name);
+    name.replace(name.find(".med"),4,"_WithVecFieldOnCells.med");
+    MEDLoader::WriteField(name.c_str(),f1,true);
+    f1->setTime(3.,1,1);  //time,it,order
+    f1->applyFunc("x/2.");
+    MEDLoader::WriteField(name.c_str(),f1,false);
+    if (_verbose) cout<<endl<<name<<" created"<<endl;
+    if (_ntot<1000000) //too long
+      {
+        MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
+        //DataArrayDouble *res=f2->getArray();
+        if (_verbose) cout<<name<<" reread"<<endl;
+        //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12));
+        f2->decrRef();
+      }
+    f1->decrRef();
   }
   {
-  string name=_fileName;
-  MEDCouplingFieldDouble *f1=buildVecFieldOnCells(name);
-  name.replace(name.find(".med"),4,"_WithVecFieldOnGaussNe.med");
-  MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME);
-  f3->setMesh(f1->getMesh());
-  //cout<<"\nNumberOfMeshPlacesExpected "<<f3->getNumberOfMeshPlacesExpected()<<" "
-  //                                     /*<<getNumberOfTuples(f1->getMesh())<<" "*/
-  //                                     <<f3->getMesh()->getNumberOfNodes()<<" "
-  //                                     <<f3->getMesh()->getNumberOfCells()<<endl;
-  f3->setName("MyFieldOnGaussNE");
-  f3->setDescription("MyDescriptionNE");
-  DataArrayDouble *array=DataArrayDouble::New();
-  //int nb=f1->getMesh()->getNumberOfNodes();
+    string name=_fileName;
+    MEDCouplingFieldDouble *f1=buildVecFieldOnCells(name);
+    name.replace(name.find(".med"),4,"_WithVecFieldOnGaussNe.med");
+    MEDCouplingFieldDouble *f3=MEDCouplingFieldDouble::New(ON_GAUSS_NE,ONE_TIME);
+    f3->setMesh(f1->getMesh());
+    //cout<<"\nNumberOfMeshPlacesExpected "<<f3->getNumberOfMeshPlacesExpected()<<" "
+    //                                     /*<<getNumberOfTuples(f1->getMesh())<<" "*/
+    //                                     <<f3->getMesh()->getNumberOfNodes()<<" "
+    //                                     <<f3->getMesh()->getNumberOfCells()<<endl;
+    f3->setName("MyFieldOnGaussNE");
+    f3->setDescription("MyDescriptionNE");
+    DataArrayDouble *array=DataArrayDouble::New();
+    //int nb=f1->getMesh()->getNumberOfNodes();
   
-  /*8 pt de gauss by cell
-  int nb=f3->getMesh()->getNumberOfCells()*8;
-  array->alloc(nb,2);
-  double *ptr=array->getPointer();
-  for (int i=0; i<nb*2; i=i+2) {ptr[i]=(double)(i/8) ; ptr[i]=2.*(double)(i/8);}
-  */
+    /*8 pt de gauss by cell
+      int nb=f3->getMesh()->getNumberOfCells()*8;
+      array->alloc(nb,2);
+      double *ptr=array->getPointer();
+      for (int i=0; i<nb*2; i=i+2) {ptr[i]=(double)(i/8) ; ptr[i]=2.*(double)(i/8);}
+    */
   
-  //more nbptgauss=8 by default needs set MEDCouplingFieldDiscretizationPerCell
-  //theory: (may be) http://www.code-aster.org/V2/doc/v9/fr/man_r/r3/r3.06.03.pdf
-  int nbptgauss=8; //nb pt de gauss by cell 
-  int nbcell=f3->getMesh()->getNumberOfCells();
-  int nb=nbcell*nbptgauss;
-  int nbcomp=2;
-  array->alloc(nb,nbcomp);
-  double *ptr=array->getPointer();
-  int ii=0;
-  for (int i=0; i<nbcell; i++)
-    for (int j=0; j<nbptgauss; j++)
-      for (int k=0; k<nbcomp; k++)
+    //more nbptgauss=8 by default needs set MEDCouplingFieldDiscretizationPerCell
+    //theory: (may be) http://www.code-aster.org/V2/doc/v9/fr/man_r/r3/r3.06.03.pdf
+    int nbptgauss=8; //nb pt de gauss by cell 
+    int nbcell=f3->getMesh()->getNumberOfCells();
+    int nb=nbcell*nbptgauss;
+    int nbcomp=2;
+    array->alloc(nb,nbcomp);
+    double *ptr=array->getPointer();
+    int ii=0;
+    for (int i=0; i<nbcell; i++)
+      for (int j=0; j<nbptgauss; j++)
+        for (int k=0; k<nbcomp; k++)
+          {
+            //123.4 for 12th cell,3rd component, 4th gausspoint
+            ptr[ii]=(double)((i+1)*10+(k+1))+((double)(j+1))/10.;
+            ii++;
+          }
+    array->setInfoOnComponent(0,"vGx");
+    array->setInfoOnComponent(1,"vGy");
+    f3->setTime(4.,5,6);
+    f3->setArray(array);
+    array->decrRef();
+    MEDLoader::WriteField(name.c_str(),f3,true);
+    if (_verbose) cout<<endl<<name<<" created"<<endl;
+    f3->checkCoherency();
+    f1->decrRef();
+    if (_ntot<1000000) //too long
       {
-        //123.4 for 12th cell,3rd component, 4th gausspoint
-        ptr[ii]=(double)((i+1)*10+(k+1))+((double)(j+1))/10.;
-        ii++;
+        MEDCouplingFieldDouble* f4=MEDLoader::ReadField(ON_GAUSS_NE,
+                                                        name.c_str(), f3->getMesh()->getName(), 0, "MyFieldOnGaussNE", 5, 6);
+        if (_verbose) cout<<"MyFieldOnGaussNE reread"<<endl;
+        f4->decrRef();
       }
-  array->setInfoOnComponent(0,"vGx");
-  array->setInfoOnComponent(1,"vGy");
-  f3->setTime(4.,5,6);
-  f3->setArray(array);
-  array->decrRef();
-  MEDLoader::WriteField(name.c_str(),f3,true);
-  if (_verbose) cout<<endl<<name<<" created"<<endl;
-  f3->checkCoherency();
-  f1->decrRef();
-  if (_ntot<1000000) //too long
-  {
-    MEDCouplingFieldDouble* f4=MEDLoader::ReadField(ON_GAUSS_NE,
-           name.c_str(), f3->getMesh()->getName(), 0, "MyFieldOnGaussNE", 5, 6);
-    if (_verbose) cout<<"MyFieldOnGaussNE reread"<<endl;
-    f4->decrRef();
+    f3->decrRef();
   }
-  f3->decrRef();
-  }
-  {
-  string name=_fileNameWithFaces;
-  MEDCouplingFieldDouble *f1=buildVecFieldOnCells(name);
-  name.replace(name.find(".med"),4,"_WithVecFieldOnCells.med");
-  MEDLoader::WriteField(name.c_str(),f1,true);
-  if (_verbose) cout<<endl<<name<<" created"<<endl;
-  if (_ntot<1000000) //too long
   {
-    MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
-    if (_verbose) cout<<name<<" reread"<<endl;
-    //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); assertion failed!!
-    f2->decrRef();
-  }
-  f1->decrRef();
+    string name=_fileNameWithFaces;
+    MEDCouplingFieldDouble *f1=buildVecFieldOnCells(name);
+    name.replace(name.find(".med"),4,"_WithVecFieldOnCells.med");
+    MEDLoader::WriteField(name.c_str(),f1,true);
+    if (_verbose) cout<<endl<<name<<" created"<<endl;
+    if (_ntot<1000000) //too long
+      {
+        MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
+        if (_verbose) cout<<name<<" reread"<<endl;
+        //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); assertion failed!!
+        f2->decrRef();
+      }
+    f1->decrRef();
   }
 }
 
@@ -681,12 +669,12 @@ void MEDPARTITIONERTest::createTestMeshWithVecFieldOnNodes()
   MEDLoader::WriteField(name.c_str(),f1,true);
   if (_verbose) cout<<endl<<name<<" created"<<endl;
   if (_ntot<1000000) //too long
-  {
-    MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldNode(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
-    if (_verbose) cout<<name<<" reread"<<endl;
-    //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); assertion failed!!
-    f2->decrRef();
-  }
+    {
+      MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldNode(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1);
+      if (_verbose) cout<<name<<" reread"<<endl;
+      //CPPUNIT_ASSERT(f1->isEqual(f2,1e-12,1e-12)); assertion failed!!
+      f2->decrRef();
+    }
   f1->decrRef();
 }
 
@@ -697,16 +685,16 @@ void MEDPARTITIONERTest::verifyTestMeshWithVecFieldOnNodes()
   MEDCouplingUMesh * m=MEDLoader::ReadUMeshFromFile(name.c_str(),_meshName.c_str(),0);
   const std::set<INTERP_KERNEL::NormalizedCellType>& types=m->getAllTypes();
   if (_verbose)
-  {
-    cout<<"\n types in "<<name<<" : ";
-    //for (std::set<INTERP_KERNEL::NormalizedCellType>::iterator t=types.begin(); t!=types.end(); ++t) cout<<" "<<*t;
-    for (std::set<INTERP_KERNEL::NormalizedCellType>::iterator t=types.begin(); t!=types.end(); ++t) 
     {
-      //INTERP_KERNEL::CellModel essai=INTERP_KERNEL::CellModel::GetCellModel(*t);
-      cout<<" "<<(INTERP_KERNEL::CellModel::GetCellModel(*t)).getRepr();
+      cout<<"\n types in "<<name<<" : ";
+      //for (std::set<INTERP_KERNEL::NormalizedCellType>::iterator t=types.begin(); t!=types.end(); ++t) cout<<" "<<*t;
+      for (std::set<INTERP_KERNEL::NormalizedCellType>::iterator t=types.begin(); t!=types.end(); ++t) 
+        {
+          //INTERP_KERNEL::CellModel essai=INTERP_KERNEL::CellModel::GetCellModel(*t);
+          cout<<" "<<(INTERP_KERNEL::CellModel::GetCellModel(*t)).getRepr();
+        }
+      cout<<endl;
     }
-    cout<<endl;
-  }
   m->decrRef();
   
   MEDFileUMesh * mf;
@@ -714,11 +702,11 @@ void MEDPARTITIONERTest::verifyTestMeshWithVecFieldOnNodes()
   vector<int> lev;
   lev=mf->getNonEmptyLevels();
   if (_verbose)
-  {
-    cout<<" levels in "<<name<<" : ";
-    for (vector<int>::iterator l=lev.begin(); l!=lev.end(); ++l) cout<<" "<<*l;
-    cout<<endl;
-  }
+    {
+      cout<<" levels in "<<name<<" : ";
+      for (vector<int>::iterator l=lev.begin(); l!=lev.end(); ++l) cout<<" "<<*l;
+      cout<<endl;
+    }
   mf->decrRef();
 }
 
@@ -738,18 +726,18 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForMesh()
   sourceName=fileName;
   targetName=fileName;
   targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
   input=targetName+".xml";
   
   MPI_Init(0,0);
-  MPI_Comm_size(MPI_COMM_WORLD, &MyGlobals::_world_size);
-  MPI_Comm_rank(MPI_COMM_WORLD, &MyGlobals::_rank);
+  MPI_Comm_size(MPI_COMM_WORLD, &MyGlobals::_World_Size);
+  MPI_Comm_rank(MPI_COMM_WORLD, &MyGlobals::_Rank);
 
   MEDPARTITIONER::ParaDomainSelector parallelizer(false);
-  MEDPARTITIONER::MESHCollection collection(input,parallelizer); //cvwat01
+  MEDPARTITIONER::MeshCollection collection(input,parallelizer); //cvwat01
   CPPUNIT_ASSERT_EQUAL(3, collection.getMeshDimension());
   std::vector<ParaMEDMEM::MEDCouplingUMesh*>cellMeshes=collection.getMesh();
   CPPUNIT_ASSERT_EQUAL(5, (int) cellMeshes.size());
@@ -768,7 +756,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForMesh()
   sourceName=targetName+".xml";
   targetName=fileName;
   targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -782,13 +770,13 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForMesh()
   CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), refusedFaceMesh->getNumberOfCells());
   
   /*not the good job
-  ParaMEDMEM::MEDCouplingMesh* mergeCell=cellMesh->mergeMyselfWith(refusedCellMesh);
-  CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), mergeCell->getNumberOfCells());
+    ParaMEDMEM::MEDCouplingMesh* mergeCell=cellMesh->mergeMyselfWith(refusedCellMesh);
+    CPPUNIT_ASSERT_EQUAL(cellMesh->getNumberOfCells(), mergeCell->getNumberOfCells());
   
-  ParaMEDMEM::MEDCouplingMesh* mergeFace=faceMesh->mergeMyselfWith(refusedFaceMesh);
-  CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), mergeFace->getNumberOfCells());
+    ParaMEDMEM::MEDCouplingMesh* mergeFace=faceMesh->mergeMyselfWith(refusedFaceMesh);
+    CPPUNIT_ASSERT_EQUAL(faceMesh->getNumberOfCells(), mergeFace->getNumberOfCells());
   
-  CPPUNIT_ASSERT(faceMesh->isEqual(refusedFaceMesh,1e-12));
+    CPPUNIT_ASSERT(faceMesh->isEqual(refusedFaceMesh,1e-12));
   */
   
   std::vector<const MEDCouplingUMesh *> meshes;
@@ -836,7 +824,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnCells()
   sourceName=fileName;
   targetName=fileName;
   targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -847,7 +835,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnCells()
   sourceName=targetName+".xml";
   targetName=fileName;
   targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -875,27 +863,27 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnCells()
   DataArrayDouble* f1=field1->getArray();
   DataArrayDouble* f2=field2->getArray();
   if (_verbose) 
-  {
-    cout<<"\nf1 : "<<f1->reprZip();
-    cout<<"\nf2 : "<<f2->reprZip(); //field2->advancedRepradvancedRepr();
-    for (int i = 0; i < corr.size(); i++) cout<<"\ncorr "<<i<<" : "<<corr[i]->reprZip();
+    {
+      cout<<"\nf1 : "<<f1->reprZip();
+      cout<<"\nf2 : "<<f2->reprZip(); //field2->advancedRepradvancedRepr();
+      for (int i = 0; i < corr.size(); i++) cout<<"\ncorr "<<i<<" : "<<corr[i]->reprZip();
     
-  }
+    }
   int nbequal=0;
   int nbcomp=field1->getNumberOfComponents();
   double* p1=f1->getPointer();
   double* p2=f2->getPointer();
   int* pc=corr[1]->getPointer();
   for (int i = 0; i < nbcells; i++)
-  {
-    int i1=pc[i]*nbcomp;
-    int i2=i*nbcomp;
-    for (int j = 0; j < nbcomp; j++)
     {
-      if (p1[i1+j]==p2[i2+j]) nbequal++;
-      //cout<<" "<<p1[i1+j]<<"="<<p2[i2+j];
+      int i1=pc[i]*nbcomp;
+      int i2=i*nbcomp;
+      for (int j = 0; j < nbcomp; j++)
+        {
+          if (p1[i1+j]==p2[i2+j]) nbequal++;
+          //cout<<" "<<p1[i1+j]<<"="<<p2[i2+j];
+        }
     }
-  }
   CPPUNIT_ASSERT_EQUAL(nbcells*nbcomp, nbequal);
   
   for (int i = 0; i < corr.size(); i++) corr[i]->decrRef();
@@ -922,7 +910,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   sourceName=fileName;
   targetName=fileName;
   targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -933,7 +921,7 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   sourceName=targetName+".xml";
   targetName=fileName;
   targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -961,12 +949,12 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   DataArrayDouble* f1=field1->getArray();
   DataArrayDouble* f2=field2->getArray();
   if (_verbose) 
-  {
-    cout<<"\nf1 : "<<f1->reprZip(); //123.4 for 12th cell,3rd component, 4th gausspoint
-    cout<<"\nf2 : "<<f2->reprZip(); //field2->advancedRepradvancedRepr();
-    for (int i = 0; i < corr.size(); i++) cout<<"\ncorr "<<i<<" : "<<corr[i]->reprZip();
+    {
+      cout<<"\nf1 : "<<f1->reprZip(); //123.4 for 12th cell,3rd component, 4th gausspoint
+      cout<<"\nf2 : "<<f2->reprZip(); //field2->advancedRepradvancedRepr();
+      for (int i = 0; i < corr.size(); i++) cout<<"\ncorr "<<i<<" : "<<corr[i]->reprZip();
     
-  }
+    }
   int nbequal=0;
   int nbptgauss=8;
   int nbcomp=field1->getNumberOfComponents();
@@ -974,15 +962,15 @@ void MEDPARTITIONERTest::verifyMedpartitionerOnSmallSizeForFieldOnGaussNe()
   double* p2=f2->getPointer();
   int* pc=corr[1]->getPointer();
   for (int i = 0; i < nbcells; i++)
-  {
-    int i1=pc[i]*nbcomp*nbptgauss;
-    int i2=i*nbcomp*nbptgauss;
-    for (int j = 0; j < nbcomp*nbptgauss; j++)
     {
-      if (p1[i1+j]==p2[i2+j]) nbequal++;
-      //cout<<" "<<p1[i1+j]<<"="<<p2[i2+j];
+      int i1=pc[i]*nbcomp*nbptgauss;
+      int i2=i*nbcomp*nbptgauss;
+      for (int j = 0; j < nbcomp*nbptgauss; j++)
+        {
+          if (p1[i1+j]==p2[i2+j]) nbequal++;
+          //cout<<" "<<p1[i1+j]<<"="<<p2[i2+j];
+        }
     }
-  }
   CPPUNIT_ASSERT_EQUAL(nbcells*nbcomp*nbptgauss, nbequal);
   
   for (int i = 0; i < corr.size(); i++) corr[i]->decrRef();
@@ -1012,13 +1000,13 @@ void MEDPARTITIONERTest::launchMedpartitionerOnTestMeshes()
 {
   
   /* examples 
-  export INFI=/home/vb144235/resources/blade.med
-  //no need export MESH=Fuse_1
-  export INFI=tmp_testMeshxxx.med
-  //no need export MESH=testMesh
-  mpirun -np 2 medpartitioner_para --input-file=$INFI --output-file=ttmp1_ --ndomains=4
-  mpirun -np 5 medpartitioner_para --input-file=ttmp1_.xml --output-file=ttmp2_ --ndomains=5
-  mpirun -np 2 valgrind  medpartitioner_para --input-file=tmp_testMesh_20x30x50.med  --output-file=ttmp1petit_ --ndomains=4  --dump-cpu-memory --verbose=111
+     export INFI=/home/vb144235/resources/blade.med
+     //no need export MESH=Fuse_1
+     export INFI=tmp_testMeshxxx.med
+     //no need export MESH=testMesh
+     mpirun -np 2 medpartitioner_para --input-file=$INFI --output-file=ttmp1_ --ndomains=4
+     mpirun -np 5 medpartitioner_para --input-file=ttmp1_.xml --output-file=ttmp2_ --ndomains=5
+     mpirun -np 2 valgrind  medpartitioner_para --input-file=tmp_testMesh_20x30x50.med  --output-file=ttmp1petit_ --ndomains=4  --dump-cpu-memory --verbose=111
   */
   int res;
   string cmd,execName,sourceName,targetName;
@@ -1037,7 +1025,7 @@ void MEDPARTITIONERTest::launchMedpartitionerOnTestMeshes()
   sourceName=_fileName;
   targetName=_fileName;
   targetName.replace(targetName.find(".med"),4,"_partitionedTo2_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -1046,7 +1034,7 @@ void MEDPARTITIONERTest::launchMedpartitionerOnTestMeshes()
   sourceName=_fileName;
   targetName=_fileName;
   targetName.replace(targetName.find(".med"),4,"_partitionedTo5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -1055,7 +1043,7 @@ void MEDPARTITIONERTest::launchMedpartitionerOnTestMeshes()
   sourceName=targetName+".xml";
   targetName=_fileName;
   targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -1064,7 +1052,7 @@ void MEDPARTITIONERTest::launchMedpartitionerOnTestMeshes()
   //sourceName=targetName+".xml";
   targetName=_fileName;
   targetName.replace(targetName.find(".med"),4,"_remergedFrom5_");
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
@@ -1077,13 +1065,13 @@ void MEDPARTITIONERTest::launchMedpartitionerOnHugeTestMeshes()
   execName=getenv("MED_ROOT_DIR");  //.../INSTALL/MED
   execName+="/bin/salome/medpartitioner_para";
 
-  string snbTarget=intToStr(_nbTargetHuge);
+  string snbTarget=IntToStr(_nbTargetHuge);
   cmd="mpirun -np "+snbTarget+" "+execName+" --ndomains="+snbTarget+" --split-method=metis";  //on same proc
   sourceName=_fileNameHugeXml;
   targetName=_fileNameHugeXml;
   string tmp="_partitionedTo"+snbTarget+"_";
   targetName.replace(targetName.find(".xml"),4,tmp);
-  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+intToStr(_verbose);
+  cmd+=" --input-file="+sourceName+" --output-file="+targetName+" --verbose="+IntToStr(_verbose);
   if (_verbose) cout<<endl<<cmd<<endl;
   res=system(cmd.c_str());
   CPPUNIT_ASSERT_EQUAL(0, res);
index aebe95e6eeaf86e45dd0c15ec6f6b6e957133a79..5dfa8e78a069e1e517352fe9aea711a1e437ce83 100644 (file)
@@ -17,8 +17,8 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-#ifndef _MEDPARTITIONERTEST_HXX_
-#define _MEDPARTITIONERTEST_HXX_
+#ifndef __MEDPARTITIONERTEST_HXX__
+#define __MEDPARTITIONERTEST_HXX__
 
 #include <cppunit/extensions/HelperMacros.h>
 
 
 namespace MEDPARTITIONER {
   class MESH;
-  /*class DataArrayDouble;
-  class MEDCouplingUMesh;
-  class MEDCouplingFieldDouble;
-  class MEDCouplingMultiFields;*/
 };
 
 class MEDPARTITIONERTest : public CppUnit::TestFixture
index 5598e1730fc730064e38a77bf3a06b1c94932834..3b00f7c4d6d8c2dd3d9b5fe7c80c2ed4fd2b63ff 100644 (file)
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-// --- include all MEDMEM Test
-//
+//include all MEDPARTITIONER Test
 #include "MEDPARTITIONERTest.hxx"
 
-// --- Registers the fixture into the 'registry'
-
+//Registers the fixture into the 'registry'
 CPPUNIT_TEST_SUITE_REGISTRATION( MEDPARTITIONERTest );
 
-// --- generic Main program from KERNEL_SRC/src/Basics/Test
-
+//generic Main program from KERNEL_SRC/src/Basics/Test
 #include "BasicMainTest.hxx"
diff --git a/src/MEDPartitioner/medpartitioner.cxx b/src/MEDPartitioner/medpartitioner.cxx
deleted file mode 100644 (file)
index 572af0c..0000000
+++ /dev/null
@@ -1,311 +0,0 @@
-//  Copyright (C) 2007-2010  CEA/DEN, EDF R&D
-//
-//  This library is free software; you can redistribute it and/or
-//  modify it under the terms of the GNU Lesser General Public
-//  License as published by the Free Software Foundation; either
-//  version 2.1 of the License.
-//
-//  This library is distributed in the hope that it will be useful,
-//  but WITHOUT ANY WARRANTY; without even the implied warranty of
-//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-//  Lesser General Public License for more details.
-//
-//  You should have received a copy of the GNU Lesser General Public
-//  License along with this library; if not, write to the Free Software
-//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
-//
-//  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-//
-//  MED medsplitter : tool to split n MED files into p separate 
-//                    MED files with a partitioning specified 
-//                    by an external tool
-//  File   : medsplitter.cxx
-//  Author : Vincent BERGEAUD (CEA-DEN/DANS/DM2S/SFME/LGLS)
-//  Module : MED
-//
-#ifdef BOOST_PROGRAM_OPTIONS_LIB
-#include <boost/program_options.hpp>
-namespace po=boost::program_options;
-#endif
-
-#include <iostream>
-#include <string>
-#include <fstream>
-#include <cstring>
-#include <cstdlib>
-
-#include "MEDPARTITIONER_Graph.hxx"
-#include "MEDPARTITIONER_MESHCollection.hxx"
-#include "MEDPARTITIONER_Topology.hxx"
-
-using namespace std;
-
-int main(int argc, char** argv)
-{
-#ifndef ENABLE_METIS
-#ifndef ENABLE_SCOTCH
-  cout << "Sorry, no one split method is available. Please, compile with METIS or SCOTCH."<<endl;
-  return 1;
-#endif
-#endif
-
-  // Defining options
-  // by parsing the command line
-  bool mesh_only = false;
-  bool is_sequential = true;
-  bool xml_output_master=true;
-  bool creates_boundary_faces=false;  
-  bool split_families=false;
-  bool empty_groups=false;
-
-  string input;
-  string output;
-  string meshname;
-  string library;
-  int ndomains;
-
-#ifdef BOOST_PROGRAM_OPTIONS_LIB
-  // Use boost::program_options for command-line options parsing
-  po::options_description desc("Available options of medpartitioner V1.0");
-  desc.add_options()
-    ("help","produces this help message")
-    ("mesh-only","prevents the splitter from creating the fields contained in the original file(s)")
-    ("distributed","specifies that the input file is distributed")
-    ("input-file",po::value<string>(),"name of the input MED file")
-    ("output-file",po::value<string>(),"name of the resulting file")
-    ("meshname",po::value<string>(),"name of the input mesh")
-#ifdef ENABLE_METIS
-#ifdef ENABLE_SCOTCH
-    ("split-method",po::value<string>(&library)->default_value("metis"),"name of the splitting library (metis,scotch)")
-#endif
-#endif
-    ("ndomains",po::value<int>(&ndomains)->default_value(1),"number of subdomains in the output file")
-    ("plain-master","creates a plain masterfile instead of an XML file")
-    ("creates-boundary-faces","creates the necessary faces so that faces joints are created in the output files")
-    ("family-splitting","preserves the family names instead of focusing on the groups")
-    ("empty-groups","creates empty groups in zones that do not contain a group from the original domain");
-
-  po::variables_map vm;
-  po::store(po::parse_command_line(argc,argv,desc),vm);
-  po::notify(vm);
-
-  if (vm.count("help"))
-  {
-    cout<<desc<<"\n";
-    return 1;
-  }
-
-  if (!vm.count("ndomains"))
-  {
-    cout << "ndomains must be specified !"<<endl;
-    return 1;
-  }
-
-  ndomains = vm["ndomains"].as<int>();
-  if (!vm.count("input-file") || !vm.count("output-file"))
-  {
-    cout << "input-file and output-file names must be specified"<<endl;
-    return 1;
-  }
-
-  if (!vm.count("distributed") && !vm.count("meshname") )
-  {
-    cout << "for a serial MED file, mesh name must be selected with --meshname=..."<<endl;
-    return 1;
-  }
-
-  input = vm["input-file"].as<string>();
-  output = vm["output-file"].as<string>();
-
-  if (vm.count("mesh-only"))
-    mesh_only=true;
-
-  if (vm.count("distributed"))
-    is_sequential=false;
-
-  if (is_sequential)
-    meshname = vm["meshname"].as<string>();
-
-  if (vm.count("plain-master"))
-    xml_output_master=false;
-
-  if (vm.count("creates-boundary-faces"))
-    creates_boundary_faces=true;
-
-  if (vm.count("split-families"))
-    split_families=true;
-
-  if (vm.count("empty-groups"))
-    empty_groups=true;
-
-#else // BOOST_PROGRAM_OPTIONS_LIB
-
-  // Primitive parsing of command-line options
-
-  string desc ("Available options of medpartitioner V1.0:\n"
-               "\t--help                 : produces this help message\n"
-               "\t--mesh-only            : do not create the fields contained in the original file(s)\n"
-               "\t--distributed          : specifies that the input file is distributed\n"
-               "\t--input-file=<string>  : name of the input MED file\n"
-               "\t--output-file=<string> : name of the resulting file\n"
-               "\t--meshname=<string>    : name of the input mesh (not used with --distributed option)\n"
-               "\t--ndomains=<number>    : number of subdomains in the output file, default is 1\n"
-#ifdef ENABLE_METIS
-#ifdef ENABLE_SCOTCH
-               "\t--split-method=<string>: name of the splitting library (metis/scotch), default is metis\n"
-#endif
-#endif
-               "\t--plain-master         : creates a plain masterfile instead of an XML file\n"
-               "\t--creates-boundary-faces: creates the necessary faces so that faces joints are created in the output files\n"
-               "\t--family-splitting     : preserves the family names instead of focusing on the groups\n"
-               "\t--empty-groups         : creates empty groups in zones that do not contain a group from the original domain"
-                );
-
-  if (argc < 4) {
-    cout << desc.c_str() << endl;
-    return 1;
-  }
-
-  for (int i = 1; i < argc; i++) {
-    if (strlen(argv[i]) < 3) {
-      cout << desc.c_str() << endl;
-      return 1;
-    }
-
-    if (strncmp(argv[i],"--m",3) == 0) {
-      if (strcmp(argv[i],"--mesh-only") == 0) {
-        mesh_only = true;
-        cout << "\tmesh-only = " << mesh_only << endl; // tmp
-      }
-      else if (strlen(argv[i]) > 11) { // "--meshname="
-        meshname = (argv[i] + 11);
-        cout << "\tmeshname = " << meshname << endl; // tmp
-      }
-    }
-    else if (strncmp(argv[i],"--d",3) == 0) {
-      is_sequential = false;
-      cout << "\tis_sequential = " << is_sequential << endl; // tmp
-    }
-    else if (strncmp(argv[i],"--i",3) == 0) {
-      if (strlen(argv[i]) > 13) { // "--input-file="
-        input = (argv[i] + 13);
-        cout << "\tinput-file = " << input << endl; // tmp
-      }
-    }
-    else if (strncmp(argv[i],"--o",3) == 0) {
-      if (strlen(argv[i]) > 14) { // "--output-file="
-        output = (argv[i] + 14);
-        cout << "\toutput-file = " << output << endl; // tmp
-      }
-    }
-    else if (strncmp(argv[i],"--s",3) == 0) {
-      if (strlen(argv[i]) > 15) { // "--split-method="
-        library = (argv[i] + 15);
-        cout << "\tsplit-method = " << library << endl; // tmp
-      }
-    }
-    else if (strncmp(argv[i],"--f",3) == 0) { //"--family-splitting"
-      split_families=true;
-      cout << "\tfamily-splitting true" << endl; // tmp
-    }
-    else if (strncmp(argv[i],"--n",3) == 0) {
-      if (strlen(argv[i]) > 11) { // "--ndomains="
-        ndomains = atoi(argv[i] + 11);
-        cout << "\tndomains = " << ndomains << endl; // tmp
-      }
-    }
-    else if (strncmp(argv[i],"--p",3) == 0) { // "--plain-master"
-      xml_output_master = false;
-      cout << "\txml_output_master = " << xml_output_master << endl; // tmp
-    }
-    else if (strncmp(argv[i],"--c",3) == 0) { // "--creates-boundary-faces"
-      creates_boundary_faces = true;
-      cout << "\tcreates_boundary_faces = " << creates_boundary_faces << endl; // tmp
-    }
-    else if (strncmp(argv[i],"--e",3) == 0) { // "--empty-groups"
-      empty_groups = true;
-      cout << "\tempty_groups = true" << endl; // tmp
-    }
-    else {
-      cout << desc.c_str() << endl;
-      return 1;
-    }
-  }
-
-  if (is_sequential && meshname.empty()) {
-    cout << "Mesh name must be given for sequential(not distributed) input file." << endl;
-    cout << desc << endl;
-    return 1;
-  }
-
-#endif // BOOST_PROGRAM_OPTIONS_LIB
-
-
-  //testing whether it is possible to write a file at the specified location
-  string outputtest = output + ".testioms.";
-  ofstream testfile (outputtest.c_str());
-  if (testfile.fail())
-  { 
-    cout << "MEDPARTITIONER : output-file directory does not exist or is in read-only access" << endl;
-    return 1;
-  };
-  //deletes test file
-  remove(outputtest.c_str());
-
-  // Beginning of the computation
-
-  // Loading the mesh collection
-  MEDPARTITIONER::MESHCollection* collection;
-  cout << "MEDPARTITIONER : reading input files "<<endl;
-  if (is_sequential)
-    collection = new MEDPARTITIONER::MESHCollection(input,meshname);
-  else
-    collection = new MEDPARTITIONER::MESHCollection(input);
-
-  cout << "MEDPARTITIONER : computing partition "<<endl;
-
-  // Creating the graph and partitioning it   
-#ifdef ENABLE_METIS
-#ifndef ENABLE_SCOTCH
-  library = "metis";
-#endif
-#else
-  library = "scotch";
-#endif
-  cout << "\tsplit-method = " << library << endl; // tmp
-
-  MEDPARTITIONER::Topology* new_topo;
-  if (library == "metis")
-    new_topo = collection->createPartition(ndomains,MEDPARTITIONER::Graph::METIS);
-  else
-    new_topo = collection->createPartition(ndomains,MEDPARTITIONER::Graph::SCOTCH);
-
-  cout << "MEDPARTITIONER : creating new meshes"<<endl;
-
-  // Creating a new mesh collection from the partitioning
-  MEDPARTITIONER::MESHCollection new_collection(*collection, new_topo, split_families, empty_groups);
-  if (mesh_only)
-  {
-    delete collection;
-    collection=0;
-  }
-
-  if (!xml_output_master)
-    new_collection.setDriverType(MEDPARTITIONER::MedAscii);
-
-  //  new_collection.setSubdomainBoundaryCreates(creates_boundary_faces);
-
-  cout << "MEDPARTITIONER : writing output files "<<endl;
-  new_collection.write(output);
-
-  // Casting the fields on the new collection
-//   if (!mesh_only)
-//     new_collection.castAllFields(*collection);
-
-
-  // Cleaning memory
-  delete collection;
-  delete new_topo;
-
-  return 0;
-}