Salome HOME
Merge branch 'abn/fix_orient' into V7_main
[tools/medcoupling.git] / src / MEDLoader / MEDFileMeshLL.cxx
index d023393e7b95a2d931d1eededc4e8b849cd56f61..7e12d9406b535caffca5a5e828fc065c819ee3b2 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2014  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.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -40,7 +40,17 @@ MEDFileMeshL2::MEDFileMeshL2():_name(MED_NAME_SIZE),_description(MED_COMMENT_SIZ
 {
 }
 
-int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const char *mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1) throw(INTERP_KERNEL::Exception)
+std::size_t MEDFileMeshL2::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<const BigMemoryObject *> MEDFileMeshL2::getDirectChildren() const
+{
+  return std::vector<const BigMemoryObject *>();
+}
+
+int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const std::string& mname, ParaMEDMEM::MEDCouplingMeshType& meshType, int& dt, int& it, std::string& dtunit1)
 {
   med_mesh_type type_maillage;
   char maillage_description[MED_COMMENT_SIZE+1];
@@ -84,7 +94,7 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const char *mname, ParaMEDMEM:
     case MED_STRUCTURED_MESH:
       {
         med_grid_type gt;
-        MEDmeshGridTypeRd(fid,mname,&gt);
+        MEDmeshGridTypeRd(fid,mname.c_str(),&gt);
         switch(gt)
           {
           case MED_CARTESIAN_GRID:
@@ -103,12 +113,12 @@ int MEDFileMeshL2::GetMeshIdFromName(med_idt fid, const char *mname, ParaMEDMEM:
     }
   med_int numdt,numit;
   med_float dtt;
-  MEDmeshComputationStepInfo(fid,mname,1,&numdt,&numit,&dtt);
+  MEDmeshComputationStepInfo(fid,mname.c_str(),1,&numdt,&numit,&dtt);
   dt=numdt; it=numit;
   return ret;
 }
 
-double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const char *mName, int nstep, int dt, int it) throw(INTERP_KERNEL::Exception)
+double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const std::string& mName, int nstep, int dt, int it)
 {
   bool found=false;
   med_int numdt,numit;
@@ -116,7 +126,7 @@ double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const char *mName, int nste
   std::vector< std::pair<int,int> > p(nstep);
   for(int i=0;i<nstep;i++)
     {
-      MEDmeshComputationStepInfo(fid,mName,i+1,&numdt,&numit,&dtt);
+      MEDmeshComputationStepInfo(fid,mName.c_str(),i+1,&numdt,&numit,&dtt);
       p[i]=std::make_pair<int,int>(numdt,numit);
       found=(numdt==dt) && (numit==numit);
     }
@@ -131,7 +141,7 @@ double MEDFileMeshL2::CheckMeshTimeStep(med_idt fid, const char *mName, int nste
   return dtt;
 }
 
-std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const char *mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim) throw(INTERP_KERNEL::Exception)
+std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId, const std::string& mName, ParaMEDMEM::MEDCouplingMeshType& meshType, int& nstep, int& Mdim)
 {
   med_mesh_type type_maillage;
   med_int spaceDim;
@@ -154,7 +164,7 @@ std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId,
     case MED_STRUCTURED_MESH:
       {
         med_grid_type gt;
-        MEDmeshGridTypeRd(fid,mName,&gt);
+        MEDmeshGridTypeRd(fid,mName.c_str(),&gt);
         switch(gt)
           {
           case MED_CARTESIAN_GRID:
@@ -181,22 +191,22 @@ std::vector<std::string> MEDFileMeshL2::getAxisInfoOnMesh(med_idt fid, int mId,
   return infosOnComp;
 }
 
-void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const char *meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
+void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const std::string& meshName, std::map<std::string,int>& fams, std::map<std::string, std::vector<std::string> >& grps, MEDFileMeshReadSelector *mrs)
 {
   if(mrs && !(mrs->isCellFamilyFieldReading() || mrs->isNodeFamilyFieldReading()))
     return ;
   char nomfam[MED_NAME_SIZE+1];
   med_int numfam;
-  int nfam=MEDnFamily(fid,meshName);
+  int nfam=MEDnFamily(fid,meshName.c_str());
   for(int i=0;i<nfam;i++)
     {
-      int ngro=MEDnFamilyGroup(fid,meshName,i+1);
-      med_int natt=MEDnFamily23Attribute(fid,meshName,i+1);
+      int ngro=MEDnFamilyGroup(fid,meshName.c_str(),i+1);
+      med_int natt=MEDnFamily23Attribute(fid,meshName.c_str(),i+1);
       INTERP_KERNEL::AutoPtr<med_int> attide=new med_int[natt];
       INTERP_KERNEL::AutoPtr<med_int> attval=new med_int[natt];
       INTERP_KERNEL::AutoPtr<char> attdes=new char[MED_COMMENT_SIZE*natt+1];
       INTERP_KERNEL::AutoPtr<char> gro=new char[MED_LNAME_SIZE*ngro+1];
-      MEDfamily23Info(fid,meshName,i+1,nomfam,attide,attval,attdes,&numfam,gro);
+      MEDfamily23Info(fid,meshName.c_str(),i+1,nomfam,attide,attval,attdes,&numfam,gro);
       std::string famName=MEDLoaderBase::buildStringFromFortran(nomfam,MED_NAME_SIZE);
       fams[famName]=numfam;
       for(int j=0;j<ngro;j++)
@@ -207,7 +217,7 @@ void MEDFileMeshL2::ReadFamiliesAndGrps(med_idt fid, const char *meshName, std::
     }
 }
 
-void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const char *mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
+void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const std::string& mname, const std::map<std::string,int>& fams, const std::map<std::string, std::vector<std::string> >& grps, int tooLongStrPol)
 {
   for(std::map<std::string,int>::const_iterator it=fams.begin();it!=fams.end();it++)
     {
@@ -224,7 +234,7 @@ void MEDFileMeshL2::WriteFamiliesAndGrps(med_idt fid, const char *mname, const s
         MEDLoaderBase::safeStrCpy2((*it2).c_str(),MED_LNAME_SIZE-1,groName+i*MED_LNAME_SIZE,tooLongStrPol);
       INTERP_KERNEL::AutoPtr<char> famName=MEDLoaderBase::buildEmptyString(MED_NAME_SIZE);
       MEDLoaderBase::safeStrCpy((*it).first.c_str(),MED_NAME_SIZE,famName,tooLongStrPol);
-      int ret=MEDfamilyCr(fid,mname,famName,(*it).second,ngro,groName);
+      int ret=MEDfamilyCr(fid,mname.c_str(),famName,(*it).second,ngro,groName);
       ret++;
     }
 }
@@ -233,13 +243,13 @@ MEDFileUMeshL2::MEDFileUMeshL2()
 {
 }
 
-void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
 {
-  _name.set(mName);
+  _name.set(mName.c_str());
   int nstep;
   int Mdim;
   ParaMEDMEM::MEDCouplingMeshType meshType;
-  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
   if(meshType!=UNSTRUCTURED)
     throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected an unstructured one whereas in file it is not an unstructured !");
   _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
@@ -249,55 +259,55 @@ void MEDFileUMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, in
   loadCoords(fid,mId,infosOnComp,mName,dt,it);
 }
 
-void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const char *mName, int dt, int it, MEDFileMeshReadSelector *mrs)
+void MEDFileUMeshL2::loadConnectivity(med_idt fid, int mdim, const std::string& mName, int dt, int it, MEDFileMeshReadSelector *mrs)
 {
   _per_type_mesh.resize(1);
   _per_type_mesh[0].clear();
   for(int j=0;j<MED_N_CELL_FIXED_GEO;j++)
     {
-      MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName,dt,it,mdim,typmai[j],typmai2[j],mrs);
+      MEDFileUMeshPerType *tmp=MEDFileUMeshPerType::New(fid,mName.c_str(),dt,it,mdim,typmai[j],typmai2[j],mrs);
       if(tmp)
         _per_type_mesh[0].push_back(tmp);
     }
   sortTypes();
 }
 
-void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshL2::loadCoords(med_idt fid, int mId, const std::vector<std::string>& infosOnComp, const std::string& mName, int dt, int it)
 {
   int spaceDim=infosOnComp.size();
   med_bool changement,transformation;
-  int nCoords=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
+  int nCoords=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&changement,&transformation);
   _coords=DataArrayDouble::New();
   _coords->alloc(nCoords,spaceDim);
   double *coordsPtr=_coords->getPointer();
-  MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,coordsPtr);
-  if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
+  MEDmeshNodeCoordinateRd(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,coordsPtr);
+  if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_FAMILY_NUMBER,MED_NODAL,&changement,&transformation)>0)
     {
       _fam_coords=DataArrayInt::New();
       _fam_coords->alloc(nCoords,1);
-      MEDmeshEntityFamilyNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
+      MEDmeshEntityFamilyNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_fam_coords->getPointer());
     }
   else
     _fam_coords=0;
-  if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
+  if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NUMBER,MED_NODAL,&changement,&transformation)>0)
     {
       _num_coords=DataArrayInt::New();
       _num_coords->alloc(nCoords,1);
-      MEDmeshEntityNumberRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
+      MEDmeshEntityNumberRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_num_coords->getPointer());
     }
   else
     _num_coords=0;
-  if(MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0)
+  if(MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,MED_NAME,MED_NODAL,&changement,&transformation)>0)
     {
       _name_coords=DataArrayAsciiChar::New();
       _name_coords->alloc(nCoords+1,MED_SNAME_SIZE);//not a bug to avoid the memory corruption due to last \0 at the end
-      MEDmeshEntityNameRd(fid,mName,dt,it,MED_NODE,MED_NO_GEOTYPE,_name_coords->getPointer());
+      MEDmeshEntityNameRd(fid,mName.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,_name_coords->getPointer());
       _name_coords->reAlloc(nCoords);//not a bug to avoid the memory corruption due to last \0 at the end
     }
   else
     _name_coords=0;
   for(int i=0;i<spaceDim;i++)
-    _coords->setInfoOnComponent(i,infosOnComp[i].c_str());
+    _coords->setInfoOnComponent(i,infosOnComp[i]);
 }
 
 void MEDFileUMeshL2::sortTypes()
@@ -333,15 +343,15 @@ void MEDFileUMeshL2::sortTypes()
   _per_type_mesh.resize(_per_type_mesh.size()-nbOfUselessLev);
 }
 
-void MEDFileUMeshL2::WriteCoords(med_idt fid, const char *mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords)
+void MEDFileUMeshL2::WriteCoords(med_idt fid, const std::string& mname, int dt, int it, double time, const DataArrayDouble *coords, const DataArrayInt *famCoords, const DataArrayInt *numCoords, const DataArrayAsciiChar *nameCoords)
 {
   if(!coords)
     return ;
-  MEDmeshNodeCoordinateWr(fid,mname,dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
+  MEDmeshNodeCoordinateWr(fid,mname.c_str(),dt,it,time,MED_FULL_INTERLACE,coords->getNumberOfTuples(),coords->getConstPointer());
   if(famCoords)
-    MEDmeshEntityFamilyNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
+    MEDmeshEntityFamilyNumberWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,famCoords->getNumberOfTuples(),famCoords->getConstPointer());
   if(numCoords)
-    MEDmeshEntityNumberWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
+    MEDmeshEntityNumberWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,numCoords->getNumberOfTuples(),numCoords->getConstPointer());
   if(nameCoords)
     {
       if(nameCoords->getNumberOfComponents()!=MED_SNAME_SIZE)
@@ -350,7 +360,7 @@ void MEDFileUMeshL2::WriteCoords(med_idt fid, const char *mname, int dt, int it,
           oss << " ! The array has " << nameCoords->getNumberOfComponents() << " components !";
           throw INTERP_KERNEL::Exception(oss.str().c_str());
         }
-      MEDmeshEntityNameWr(fid,mname,dt,it,MED_NODE,MED_NO_GEOTYPE,nameCoords->getNumberOfTuples(),nameCoords->getConstPointer());
+      MEDmeshEntityNameWr(fid,mname.c_str(),dt,it,MED_NODE,MED_NO_GEOTYPE,nameCoords->getNumberOfTuples(),nameCoords->getConstPointer());
     }
 }
 
@@ -382,13 +392,13 @@ MEDFileCMeshL2::MEDFileCMeshL2()
 {
 }
 
-void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
 {
-  _name.set(mName);
+  _name.set(mName.c_str());
   int nstep;
   int Mdim;
   ParaMEDMEM::MEDCouplingMeshType meshType;
-  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName,meshType,nstep,Mdim);
+  std::vector<std::string> infosOnComp=getAxisInfoOnMesh(fid,mId,mName.c_str(),meshType,nstep,Mdim);
   if(meshType!=CARTESIAN)
     throw INTERP_KERNEL::Exception("Invalid mesh type ! You are expected a structured one whereas in file it is not a structured !");
   _time=CheckMeshTimeStep(fid,mName,nstep,dt,it);
@@ -396,7 +406,7 @@ void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, in
   _order=it;
   //
   med_grid_type gridtype;
-  MEDmeshGridTypeRd(fid,mName,&gridtype);
+  MEDmeshGridTypeRd(fid,mName.c_str(),&gridtype);
   if(gridtype!=MED_CARTESIAN_GRID)
     throw INTERP_KERNEL::Exception("Invalid structured mesh ! Expected cartesian mesh type !");
   _cmesh=MEDCouplingCMesh::New();
@@ -404,16 +414,16 @@ void MEDFileCMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, in
     {
       med_data_type dataTypeReq=GetDataTypeCorrespondingToSpaceId(i);
       med_bool chgt=MED_FALSE,trsf=MED_FALSE;
-      int nbOfElt=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
+      int nbOfElt=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,dataTypeReq,MED_NO_CMODE,&chgt,&trsf);
       MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
       da->alloc(nbOfElt,1);
-      da->setInfoOnComponent(0,infosOnComp[i].c_str());
-      MEDmeshGridIndexCoordinateRd(fid,mName,dt,it,i+1,da->getPointer());
+      da->setInfoOnComponent(0,infosOnComp[i]);
+      MEDmeshGridIndexCoordinateRd(fid,mName.c_str(),dt,it,i+1,da->getPointer());
       _cmesh->setCoordsAt(i,da);
     }
 }
 
-med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id) throw(INTERP_KERNEL::Exception)
+med_data_type MEDFileCMeshL2::GetDataTypeCorrespondingToSpaceId(int id)
 {
   switch(id)
     {
@@ -432,9 +442,9 @@ MEDFileCLMeshL2::MEDFileCLMeshL2()
 {
 }
 
-void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, int it) throw(INTERP_KERNEL::Exception)
+void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const std::string& mName, int dt, int it)
 {
-  _name.set(mName);
+  _name.set(mName.c_str());
   int nstep;
   int Mdim;
   ParaMEDMEM::MEDCouplingMeshType meshType;
@@ -447,14 +457,14 @@ void MEDFileCLMeshL2::loadAll(med_idt fid, int mId, const char *mName, int dt, i
   //
   _clmesh=MEDCouplingCurveLinearMesh::New();
   INTERP_KERNEL::AutoPtr<int> stGrid=new int[Mdim];
-  MEDmeshGridStructRd(fid,mName,dt,it,stGrid);
+  MEDmeshGridStructRd(fid,mName.c_str(),dt,it,stGrid);
   _clmesh->setNodeGridStructure(stGrid,((int *)stGrid)+Mdim);
   med_bool chgt=MED_FALSE,trsf=MED_FALSE;
-  int nbNodes=MEDmeshnEntity(fid,mName,dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf);
+  int nbNodes=MEDmeshnEntity(fid,mName.c_str(),dt,it,MED_NODE,MED_NONE,MED_COORDINATE,MED_NO_CMODE,&chgt,&trsf);
   MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> da=DataArrayDouble::New();
   da->alloc(nbNodes,infosOnComp.size());
   da->setInfoOnComponents(infosOnComp);
-  MEDmeshNodeCoordinateRd(fid,mName,dt,it,MED_FULL_INTERLACE,da->getPointer());
+  MEDmeshNodeCoordinateRd(fid,mName.c_str(),dt,it,MED_FULL_INTERLACE,da->getPointer());
   _clmesh->setCoords(da);
 }
 
@@ -500,11 +510,11 @@ void MEDFileUMeshPermCompute::updateTime() const
   _num_time=_st->_num->getTimeOfThis();
 }
 
-MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other):_m_by_types(other._m_by_types),_fam(other._fam),_num(other._num),_names(other._names),_rev_num(other._rev_num),_m(this)
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other):RefCountObject(other),_m_by_types(other._m_by_types),_fam(other._fam),_num(other._num),_names(other._names),_rev_num(other._rev_num),_m(this)
 {
 }
 
-MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *mName, int id):_m(this)
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const std::string& mName, int id):_m(this)
 {
   const std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileUMeshPerType> >& v=l2.getLev(id);
   if(v.empty())
@@ -525,13 +535,25 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *m
     {
       for(int i=0;i<sz;i++)
         fams[i]=v[i]->getFam();
-      _fam=DataArrayInt::Aggregate(fams);
+      if(sz!=1)
+        _fam=DataArrayInt::Aggregate(fams);
+      else
+        {
+          fams[0]->incrRef();
+          _fam=const_cast<DataArrayInt *>(fams[0]);
+        }
     }
   if(l2.isNumDefinedOnLev(id))
     {
       for(int i=0;i<sz;i++)
         nums[i]=v[i]->getNum();
-      _num=DataArrayInt::Aggregate(nums);
+      if(sz!=1)
+        _num=DataArrayInt::Aggregate(nums);
+      else
+        {
+          nums[0]->incrRef();
+          _num=const_cast<DataArrayInt *>(nums[0]);
+        }
       computeRevNum();
     }
   if(l2.isNamesDefinedOnLev(id))
@@ -542,6 +564,13 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *m
     }
 }
 
+MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCoupling1GTUMesh *m):_m(this)
+{
+  std::vector< const MEDCoupling1GTUMesh * > v(1);
+  v[0]=m;
+  assignParts(v);
+}
+
 MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m):_m(this)
 {
   assignMesh(m,true);
@@ -552,18 +581,28 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(MEDCouplingUMesh *m, bool newOrOld):_m(
   assignMesh(m,newOrOld);
 }
 
-std::size_t MEDFileUMeshSplitL1::getHeapMemorySize() const
+void MEDFileUMeshSplitL1::setName(const std::string& name)
+{
+  _m_by_types.setName(name);
+}
+
+std::size_t MEDFileUMeshSplitL1::getHeapMemorySizeWithoutChildren() const
+{
+  return 0;
+}
+
+std::vector<const BigMemoryObject *> MEDFileUMeshSplitL1::getDirectChildren() const
 {
-  std::size_t ret=0;
-  ret+=_m_by_types.getHeapMemorySize();
+  std::vector<const BigMemoryObject *> ret;
+  ret.push_back(&_m_by_types);
   if((const DataArrayInt*)_fam)
-    ret+=_fam->getHeapMemorySize();
+    ret.push_back((const DataArrayInt*)_fam);
   if((const DataArrayInt*)_num)
-    ret+=_num->getHeapMemorySize();
+    ret.push_back((const DataArrayInt*)_num);
   if((const DataArrayInt*)_rev_num)
-    ret+=_rev_num->getHeapMemorySize();
+    ret.push_back((const DataArrayInt*)_rev_num);
   if((const DataArrayAsciiChar*)_names)
-    ret+=_names->getHeapMemorySize();
+    ret.push_back((const DataArrayAsciiChar*)_names);
   return ret;
 }
 
@@ -648,12 +687,12 @@ void MEDFileUMeshSplitL1::ClearNonDiscrAttributes(const MEDCouplingMesh *tmp)
   (const_cast<MEDCouplingMesh *>(tmp))->setTimeUnit("");
 }
 
-void MEDFileUMeshSplitL1::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshSplitL1::setCoords(DataArrayDouble *coords)
 {
   _m_by_types.setCoords(coords);
 }
 
-void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld)
 {
   if(newOrOld)
     {
@@ -676,8 +715,24 @@ void MEDFileUMeshSplitL1::assignMesh(MEDCouplingUMesh *m, bool newOrOld) throw(I
       m->incrRef();
       _m_by_types.assignUMesh(m);
     }
+  assignCommonPart();
+}
+
+void MEDFileUMeshSplitL1::forceComputationOfParts() const
+{
+  _m_by_types.forceComputationOfPartsFromUMesh();
+}
+
+void MEDFileUMeshSplitL1::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
+{
+  _m_by_types.assignParts(mParts);
+  assignCommonPart();
+}
+
+void MEDFileUMeshSplitL1::assignCommonPart()
+{
   _fam=DataArrayInt::New();
-  _fam->alloc(m->getNumberOfCells(),1);
+  _fam->alloc(_m_by_types.getSize(),1);
   _fam->fillWithValue(0);
 }
 
@@ -710,7 +765,7 @@ void MEDFileUMeshSplitL1::simpleRepr(std::ostream& oss) const
     }
 }
 
-int MEDFileUMeshSplitL1::getSize() const throw(INTERP_KERNEL::Exception)
+int MEDFileUMeshSplitL1::getSize() const
 {
   return _m_by_types.getSize();
 }
@@ -732,6 +787,11 @@ DataArrayInt *MEDFileUMeshSplitL1::getFamilyPartArr(const int *idsBg, const int
   return da.retn();
 }
 
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileUMeshSplitL1::getGeoTypes() const
+{
+  return _m_by_types.getGeoTypes();
+}
+
 MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
 {
   MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> tmp;
@@ -742,7 +802,27 @@ MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const
   return tmp.retn();
 }
 
-DataArrayInt *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField() throw(INTERP_KERNEL::Exception)
+DataArrayInt *MEDFileUMeshSplitL1::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const
+{
+  const DataArrayInt *fam(_fam);
+  if(!fam)
+    return 0;
+  int start(0),stop(0);
+  _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop);
+  return fam->selectByTupleId2(start,stop,1);
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const
+{
+  const DataArrayInt *num(_num);
+  if(!num)
+    return 0;
+  int start(0),stop(0);
+  _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop);
+  return num->selectByTupleId2(start,stop,1);
+}
+
+DataArrayInt *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField()
 {
   if((DataArrayInt *)_fam)
     return _fam;
@@ -797,7 +877,7 @@ void MEDFileUMeshSplitL1::setGroupsFromScratch(const std::vector<const MEDCoupli
     *w=famIdTrad[*w];
 }
 
-void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
+void MEDFileUMeshSplitL1::write(med_idt fid, const std::string& mName, int mdim) const
 {
   std::vector<MEDCoupling1GTUMesh *> ms(_m_by_types.getParts());
   int start=0;
@@ -818,7 +898,7 @@ void MEDFileUMeshSplitL1::write(med_idt fid, const char *mName, int mdim) const
     }
 }
 
-void MEDFileUMeshSplitL1::renumberNodesInConn(const int *newNodeNumbersO2N) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshSplitL1::renumberNodesInConn(const int *newNodeNumbersO2N)
 {
   MEDCouplingUMesh *m(_m_by_types.getUmesh());
   if(!m)
@@ -826,7 +906,7 @@ void MEDFileUMeshSplitL1::renumberNodesInConn(const int *newNodeNumbersO2N) thro
   m->renumberNodesInConn(newNodeNumbersO2N);
 }
 
-void MEDFileUMeshSplitL1::changeFamilyIdArr(int oldId, int newId) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshSplitL1::changeFamilyIdArr(int oldId, int newId)
 {
   DataArrayInt *arr=_fam;
   if(arr)
@@ -941,6 +1021,25 @@ MEDFileUMeshAggregateCompute::MEDFileUMeshAggregateCompute():_mp_time(0),_m_time
 {
 }
 
+void MEDFileUMeshAggregateCompute::setName(const std::string& name)
+{
+  if(_m_time>=_mp_time)
+    {
+      MEDCouplingUMesh *um(_m);
+      if(um)
+        um->setName(name);
+    }
+  if(_mp_time>=_m_time)
+    {
+      for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
+        {
+          MEDCoupling1GTUMesh *tmp(*it);
+          if(tmp)
+            tmp->setName(name);
+        }
+    }
+}
+
 void MEDFileUMeshAggregateCompute::assignParts(const std::vector< const MEDCoupling1GTUMesh * >& mParts)
 {
   std::size_t sz(mParts.size());
@@ -976,7 +1075,21 @@ MEDCouplingUMesh *MEDFileUMeshAggregateCompute::getUmesh() const
   return _m;
 }
 
-std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const throw(INTERP_KERNEL::Exception)
+std::vector<INTERP_KERNEL::NormalizedCellType> MEDFileUMeshAggregateCompute::getGeoTypes() const
+{
+  if(_mp_time>=_m_time)
+    {
+      std::size_t sz(_m_parts.size());
+      std::vector<INTERP_KERNEL::NormalizedCellType> ret(sz);
+      for(std::size_t i=0;i<sz;i++)
+        ret[i]=_m_parts[i]->getCellModelEnum();
+      return ret;
+    }
+  else
+    return _m->getAllGeoTypesSorted();
+}
+
+std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getPartsWithoutComputation() const
 {
   if(_mp_time<_m_time)
     throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartsWithoutComputation : the parts require a computation !");
@@ -998,7 +1111,7 @@ std::vector<MEDCoupling1GTUMesh *> MEDFileUMeshAggregateCompute::getParts() cons
   return getPartsWithoutComputation();
 }
 
-MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception)
+MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const
 {
   std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
   std::size_t sz(v.size());
@@ -1011,6 +1124,27 @@ MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INT
   throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartWithoutComputation : the geometric type is not existing !");
 }
 
+void MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const
+{
+  start=0; stop=0;
+  std::vector<MEDCoupling1GTUMesh *> v(getPartsWithoutComputation());
+  std::size_t sz(v.size());
+  for(std::size_t i=0;i<sz;i++)
+    {
+      if(v[i])
+        {
+          if(v[i]->getCellModelEnum()==gt)
+            {
+              stop=start+v[i]->getNumberOfCells();
+              return;
+            }
+          else
+            start+=v[i]->getNumberOfCells();
+        }
+    }
+  throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation : the geometric type is not existing !");
+}
+
 void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
 {
   const MEDCouplingUMesh *m(_m);
@@ -1022,7 +1156,7 @@ void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
   _m_parts.resize(sz);
   for(std::size_t i=0;i<sz;i++)
     _m_parts[i]=MEDCoupling1GTUMesh::New(ms[i]);
-  _mp_time=std::max(_mp_time,_m_time)+1;
+  _mp_time=std::max(_mp_time,_m_time);
 }
 
 std::size_t MEDFileUMeshAggregateCompute::getTimeOfThis() const
@@ -1057,33 +1191,24 @@ std::size_t MEDFileUMeshAggregateCompute::getTimeOfUMesh() const
   return m->getTimeOfThis();
 }
 
-/*!
- * Coordinates pointer is not counted because father instance already count it !
- */
-std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySize() const
-{ 
-  std::size_t ret(0);
-  ret+=_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>);
-  std::size_t sz(_m_parts.size());
-  for(std::size_t i=0;i<sz;i++)
+std::size_t MEDFileUMeshAggregateCompute::getHeapMemorySizeWithoutChildren() const
+{
+  std::size_t ret(_m_parts.size()*sizeof(MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>));
+  return ret;
+}
+
+std::vector<const BigMemoryObject *> MEDFileUMeshAggregateCompute::getDirectChildren() const
+{
+  std::vector<const BigMemoryObject *> ret;
+  for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::const_iterator it=_m_parts.begin();it!=_m_parts.end();it++)
     {
-      const MEDCoupling1GTUMesh *pt(_m_parts[i]);
-      if(pt)
-        {
-          ret+=pt->getHeapMemorySize();
-          const DataArrayDouble *coo(pt->getCoords());
-          if(coo)
-            ret-=coo->getHeapMemorySize();
-        }
+      const MEDCoupling1GTUMesh *cur(*it);
+      if(cur)
+        ret.push_back(cur);
     }
   const MEDCouplingUMesh *m(_m);
   if(m)
-    {
-      ret+=m->getHeapMemorySize();
-      const DataArrayDouble *coo(m->getCoords());
-      if(coo)
-            ret-=coo->getHeapMemorySize();
-    }
+    ret.push_back(m);
   return ret;
 }
 
@@ -1213,7 +1338,7 @@ std::vector<int> MEDFileUMeshAggregateCompute::getDistributionOfTypes() const
     }
 }
 
-int MEDFileUMeshAggregateCompute::getSize() const throw(INTERP_KERNEL::Exception)
+int MEDFileUMeshAggregateCompute::getSize() const
 {
   if(_mp_time<_m_time)
     {
@@ -1236,7 +1361,7 @@ int MEDFileUMeshAggregateCompute::getSize() const throw(INTERP_KERNEL::Exception
     }
 }
 
-void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords) throw(INTERP_KERNEL::Exception)
+void MEDFileUMeshAggregateCompute::setCoords(DataArrayDouble *coords)
 {
   for(std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> >::iterator it=_m_parts.begin();it!=_m_parts.end();it++)
     {