]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Implementation finished and tested agy/symmetry
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 4 Oct 2016 09:09:17 +0000 (11:09 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 4 Oct 2016 09:09:17 +0000 (11:09 +0200)
src/MEDLoader/MEDFileData.cxx
src/MEDLoader/MEDFileField.cxx
src/MEDLoader/MEDFileField.txx
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/Swig/MEDLoaderCommon.i
src/MEDLoader/Swig/MEDLoaderTest3.py
src/MEDLoader/Swig/MEDLoaderTypemaps.i

index d6288a52398ecc441003d48371465e15d93e5fd8..72606a8d8f445149e8937c28d7c5ed06c2094eb2 100644 (file)
@@ -259,6 +259,7 @@ MCAuto<MEDFileData> MEDFileData::Aggregate(const std::vector<const MEDFileData *
   if(fieldNames.size()!=fieldNamess.size())
     throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : field names must be different each other !");
   std::vector< std::vector<const MEDFileAnyTypeFieldMultiTS *> > vectOfFields(fieldNames.size());
+  std::vector< std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > > vectOfFields2(fieldNames.size());
   MCAuto<MEDFileFields> fss(MEDFileFields::New());
   for(std::vector<const MEDFileData *>::const_iterator it=mfds.begin();it!=mfds.end();it++)
     {
@@ -269,10 +270,10 @@ MCAuto<MEDFileData> MEDFileData::Aggregate(const std::vector<const MEDFileData *
       i=0;
       for(std::vector<std::string>::const_iterator it1=fieldNames.begin();it1!=fieldNames.end();it1++,i++)
         {
-          const MEDFileAnyTypeFieldMultiTS *fmts((*it)->getFields()->getFieldWithName(*it1));
-          if(!fmts)
+          MCAuto<MEDFileAnyTypeFieldMultiTS> fmts((*it)->getFields()->getFieldWithName(*it1));
+          if(fmts.isNull())
             throw INTERP_KERNEL::Exception("MEDFileData::Aggregate : internal error 1 !");
-          vectOfFields[i].push_back(fmts);
+          vectOfFields2[i].push_back(fmts); vectOfFields[i].push_back(fmts);
         }
     }
   i=0;
index 2663844dfc7695f1095872ba39affca9c6f24ce5..81292d8407d4c095864b36fce1ae078fe2f79a50 100644 (file)
@@ -6254,7 +6254,7 @@ MEDFileField1TS *MEDFileField1TS::New(const std::string& fileName, const std::st
  */
 MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent)
 {
-  MCAuto<MEDFileField1TS> ret=new MEDFileField1TS(other,shallowCopyOfContent);
+  MCAuto<MEDFileField1TS> ret(new MEDFileField1TS(other,shallowCopyOfContent));
   ret->contentNotNull();
   return ret.retn();
 }
@@ -6266,7 +6266,7 @@ MEDFileField1TS *MEDFileField1TS::New(const MEDFileField1TSWithoutSDA& other, bo
  */
 MEDFileField1TS *MEDFileField1TS::New()
 {
-  MCAuto<MEDFileField1TS> ret=new MEDFileField1TS;
+  MCAuto<MEDFileField1TS> ret(new MEDFileField1TS);
   ret->contentNotNull();
   return ret.retn();
 }
@@ -7415,6 +7415,8 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::pushBackTimeStep(MCAuto<MEDFileAnyTyp
       setInfo(tse2->getInfo());
     }
   checkThatComponentsMatch(tse2->getInfo());
+  if(getDtUnit().empty() && !tse->getDtUnit().empty())
+    setDtUnit(tse->getDtUnit());
   _time_steps.push_back(tse);
 }
 
@@ -7466,6 +7468,7 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR
         _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
       else
         _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
+      synchronizeNameScope();
     }
 }
 
@@ -9039,6 +9042,7 @@ MCAuto<MEDFileAnyTypeField1TS> AggregateHelperF1TS(const std::vector< typename M
   if(!retc)
     throw INTERP_KERNEL::Exception("AggregateHelperF1TS : internal error 1 !");
   retc->aggregate(f1tsw,dts);
+  ret->setDtUnit(f1tss[0]->getDtUnit());
   return DynamicCast<typename MLFieldTraits<T>::F1TSType , MEDFileAnyTypeField1TS>(ret);
 }
 
@@ -9063,12 +9067,12 @@ MCAuto< MEDFileAnyTypeFieldMultiTS > AggregateHelperFMTS(const std::vector< type
     {
       std::size_t i(0);
       std::vector< typename MLFieldTraits<T>::F1TSType const *> f1tss(sz);
+      std::vector< MCAuto<typename MLFieldTraits<T>::F1TSType> > f1tss2(sz);
       for(typename std::vector< typename MLFieldTraits<T>::FMTSType const *>::const_iterator it=fmtss.begin();it!=fmtss.end();it++,i++)
-        {
-          f1tss[i]=(*it)->getTimeStepAtPos(i);
-        }
+        { f1tss2[i]=(*it)->getTimeStepAtPos(iterTS); f1tss[i]=f1tss2[i]; }
       MCAuto<MEDFileAnyTypeField1TS> f1ts(AggregateHelperF1TS<T>(f1tss,dts));
       ret->pushBackTimeStep(f1ts);
+      ret->setDtUnit(f1ts->getDtUnit());
     }
   return DynamicCast<typename MLFieldTraits<T>::FMTSType , MEDFileAnyTypeFieldMultiTS>(ret);
 }
index b2363fc908a158f46f2e77d3d84aa6658f97ec0a..ae2b3a93a82a8311a959342fd9e6ad9bbfda81b9 100644 (file)
@@ -127,7 +127,7 @@ namespace MEDCoupling
     std::size_t sz(f1tss.size()),ii(0);
     std::vector<const MEDFileFieldPerMesh *> pms;
     std::vector<const DataArray *> das(sz);
-    for(typename std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,ii)
+    for(typename std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++,ii++)
       {
         if(!*it)
           throw INTERP_KERNEL::Exception("MEDFileField1TSTemplateWithoutSDA::aggregate : presence of null pointer in input vector !");
@@ -140,6 +140,8 @@ namespace MEDCoupling
         pms.push_back((*it)->_field_per_mesh[0]);
       }
     typename MLFieldTraits<T>::F1TSWSDAType const *refPt(f1tss[0]);
+    setName(refPt->getName());
+    
     const DataArray *arr(refPt->getUndergroundDataArray());
     int nbCompo(arr->getNumberOfComponents());
     for(typename std::vector<typename MLFieldTraits<T>::F1TSWSDAType const *>::const_iterator it=f1tss.begin();it!=f1tss.end();it++)
@@ -162,7 +164,7 @@ namespace MEDCoupling
       {
         const DataArray *zeArr(das[(*it).first]);
         _arr->setContigPartOfSelectedValuesSlice(start,zeArr,(*it).second.first,(*it).second.second,1);
-        start=(*it).second.second-(*it).second.first;
+        start+=(*it).second.second-(*it).second.first;
       }
   }
 }
index 62f59518f5270e79712106f55fe7d6985429c228..0332e42d6eb037c6a2a3751c8685a9f0289612a8 100644 (file)
@@ -4545,6 +4545,7 @@ MCAuto<MEDFileUMesh> MEDFileUMesh::Aggregate(const std::vector<const MEDFileUMes
   int spaceDim(ref->getSpaceDimension()),meshDim(ref->getMeshDimension());
   std::vector<int> levs(ref->getNonEmptyLevels());
   std::map<int, std::vector<const DataArrayInt *> > m_fam,m_renum;
+  std::map<int, std::vector< MCAuto< MEDCouplingUMesh > > > m_mesh2;
   std::map<int, std::vector<const MEDCouplingUMesh *> > m_mesh;
   std::map<std::string,int> map1;
   std::map<std::string, std::vector<std::string> > map2;
@@ -4558,7 +4559,8 @@ MCAuto<MEDFileUMesh> MEDFileUMesh::Aggregate(const std::vector<const MEDFileUMes
         throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : levels must be the same for elements in input vector !");
       for(std::vector<int>::const_iterator it2=levs.begin();it2!=levs.end();it2++)
         {
-          m_mesh[*it2].push_back((*it)->getMeshAtLevel(*it2));
+          MCAuto<MEDCouplingUMesh> locMesh((*it)->getMeshAtLevel(*it2));
+          m_mesh[*it2].push_back(locMesh); m_mesh2[*it2].push_back(locMesh);
           m_fam[*it2].push_back((*it)->getFamilyFieldAtLevel(*it2));
           m_renum[*it2].push_back((*it)->getNumberFieldAtLevel(*it2));
         }
@@ -4591,8 +4593,8 @@ MCAuto<MEDFileUMesh> MEDFileUMesh::Aggregate(const std::vector<const MEDFileUMes
         throw INTERP_KERNEL::Exception("MEDFileUMesh::Aggregate : internal error 1 !");
       MCAuto<MEDCouplingUMesh> mesh(MEDCouplingUMesh::MergeUMeshes((*it2).second));
       mesh->setCoords(coo); mesh->setName(ref->getName());
-      ret->setMeshAtLevel(*it,mesh);
       MCAuto<DataArrayInt> renum(mesh->sortCellsInMEDFileFrmt());
+      ret->setMeshAtLevel(*it,mesh);
       std::map<int, std::vector<const DataArrayInt *> >::const_iterator it3(m_fam.find(*it)),it4(m_renum.find(*it));
       if(it3!=m_fam.end())
         {
@@ -4611,7 +4613,7 @@ MCAuto<MEDFileUMesh> MEDFileUMesh::Aggregate(const std::vector<const MEDFileUMes
             {
               MCAuto<DataArrayInt> renumm(DataArrayInt::Aggregate(renums));
               renumm->renumberInPlace(renum->begin());
-              ret->setRenumFieldArr(1,renumm);
+              ret->setRenumFieldArr(*it,renumm);
             }
         }
     }
index cf03880e61b0bda17dcdc4b3e03b20a6bc9f7a8e..3a348ebde8ff090e0178ae1fa9b630b90dbbe5c3 100644 (file)
@@ -126,6 +126,7 @@ using namespace MEDCoupling;
 %newobject MEDCoupling::MEDFileUMesh::linearToQuadratic;
 %newobject MEDCoupling::MEDFileUMesh::quadraticToLinear;
 %newobject MEDCoupling::MEDFileUMesh::symmetry3DPlane;
+%newobject MEDCoupling::MEDFileUMesh::Aggregate;
 %newobject MEDCoupling::MEDFileCMesh::New;
 %newobject MEDCoupling::MEDFileCurveLinearMesh::New;
 %newobject MEDCoupling::MEDFileMeshMultiTS::New;
@@ -206,6 +207,7 @@ using namespace MEDCoupling;
 %newobject MEDCoupling::MEDFileData::getMeshes;
 %newobject MEDCoupling::MEDFileData::getFields;
 %newobject MEDCoupling::MEDFileData::getParams;
+%newobject MEDCoupling::MEDFileData::Aggregate;
 
 %newobject MEDCoupling::MEDFileParameterDouble1TS::New;
 %newobject MEDCoupling::MEDFileParameterDouble1TS::deepCopy;
@@ -1396,7 +1398,7 @@ namespace MEDCoupling
            self->removeMeshAtLevel(meshDimRelToMax);
          }
 
-         MEDFileUMesh *symmetry3DPlane(PyObject *point, PyObject *normalVector) const
+         MEDFileUMesh *symmetry3DPlane(PyObject *point, PyObject *normalVector) const throw(INTERP_KERNEL::Exception)
          {
            const char msg[]="Python wrap of MEDFileUMesh::symmetry3DPlane : ";
            double val,val2;
@@ -1409,6 +1411,20 @@ namespace MEDCoupling
            MCAuto<MEDFileUMesh> ret(self->symmetry3DPlane(centerPtr,vectorPtr));
            return ret.retn();
          }
+
+         static MEDFileUMesh *Aggregate(PyObject *meshes) throw(INTERP_KERNEL::Exception)
+         {
+           std::vector<const MEDFileUMesh *> meshesCpp;
+           convertFromPyObjVectorOfObj<const MEDCoupling::MEDFileUMesh *>(meshes,SWIGTYPE_p_MEDCoupling__MEDFileUMesh,"MEDFileUMesh",meshesCpp);
+           MCAuto<MEDFileUMesh> ret(MEDFileUMesh::Aggregate(meshesCpp));
+           return ret.retn();
+         }
+
+         PyObject *getAllDistributionOfTypes() const throw(INTERP_KERNEL::Exception)
+         {
+           std::vector< std::pair<int,int> > ret(self->getAllDistributionOfTypes());
+           return convertVecPairIntToPy(ret);
+         }
          
          DataArrayInt *deduceNodeSubPartFromCellSubPart(PyObject *extractDef) const throw(INTERP_KERNEL::Exception)
          {
@@ -2320,17 +2336,8 @@ namespace MEDCoupling
       
       PyObject *getIterations() const throw(INTERP_KERNEL::Exception)
       {
-        std::vector< std::pair<int,int> > res=self->getIterations();
-        PyObject *ret=PyList_New(res.size());
-        int rk=0;
-        for(std::vector< std::pair<int,int> >::const_iterator iter=res.begin();iter!=res.end();iter++,rk++)
-          {
-            PyObject *elt=PyTuple_New(2);
-            PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
-            PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
-            PyList_SetItem(ret,rk,elt);
-          }
-        return ret;
+        std::vector< std::pair<int,int> > res(self->getIterations());
+        return convertVecPairIntToPy(res);
       }
       
       PyObject *getTimeSteps() const throw(INTERP_KERNEL::Exception)
@@ -3476,6 +3483,14 @@ namespace MEDCoupling
            std::vector< std::pair<std::string,std::string> > modifTab=convertVecPairStStFromPy(li);
            return self->changeMeshNames(modifTab);
          }
+
+         static MEDFileData *Aggregate(PyObject *mfds) throw(INTERP_KERNEL::Exception)
+         {
+           std::vector<const MEDFileData *> mfdsCpp;
+           convertFromPyObjVectorOfObj<const MEDCoupling::MEDFileData *>(mfds,SWIGTYPE_p_MEDCoupling__MEDFileData,"MEDFileData",mfdsCpp);
+           MCAuto<MEDFileData> ret(MEDFileData::Aggregate(mfdsCpp));
+           return ret.retn();
+         }
        }
   };
 
index 9ec3797c1ae5ac888ea0425cb84469e208441d9b..7dc76b2a200a004a2f033fefa259f4e8bd629533 100644 (file)
@@ -5527,6 +5527,222 @@ class MEDLoaderTest3(unittest.TestCase):
             self.assertEqual(fPart.getTime(),list(tt))
             pass
         pass
+
+    def test42(self):
+        """ Testing of MEDFileData::Aggregate and MEDFileUMesh::Aggregate and MEDFileUMesh::getAllDistributionOfType """
+        fname1="Pyfile106_1.med"
+        fname2="Pyfile106_2.med"
+        fname3="Pyfile106_3.med"
+        meshName="mesh"
+        mm1=MEDFileUMesh()
+        da1=DataArrayDouble([1,2,10,3,4,11,5,6,12,7,8,13],4,3) ; da1.setInfoOnComponents(["aa [m]","bbb [kg]","cccc [MW]"])
+        mm1.setCoords(da1)
+        mm1_0=MEDCouplingUMesh(meshName,3) ; mm1_0.allocateCells()
+        mm1_0.setCoords(da1)
+        mm1_0.insertNextCell(NORM_TETRA4,[0,1,2,3])
+        mm1_0.insertNextCell(NORM_TETRA4,[4,5,6,7])
+        mm1_0.insertNextCell(NORM_PENTA6,[8,9,10,11,12,13])
+        mm1_0.insertNextCell(NORM_PENTA6,[14,15,16,17,18,19])
+        mm1_0.insertNextCell(NORM_PENTA6,[20,21,22,23,24,25])
+        mm1[0]=mm1_0
+        mm1.setFamilyFieldArr(0,DataArrayInt([1,2,3,4,5]))
+        mm1.setRenumFieldArr(0,DataArrayInt([11,12,13,14,15]))
+        #
+        mm1_1=MEDCouplingUMesh(meshName,2) ; mm1_1.allocateCells()
+        mm1_1.setCoords(da1)
+        mm1_1.insertNextCell(NORM_TRI3,[0,1,2])
+        mm1_1.insertNextCell(NORM_TRI3,[3,4,5])
+        mm1_1.insertNextCell(NORM_QUAD4,[6,7,8,9])
+        mm1_1.insertNextCell(NORM_QUAD4,[10,11,12,13])
+        mm1_1.insertNextCell(NORM_QUAD4,[14,15,16,17])
+        mm1_1.insertNextCell(NORM_QUAD4,[18,19,20,21])
+        mm1[-1]=mm1_1
+        mm1.setFamilyFieldArr(-1,DataArrayInt([6,7,8,9,10,11]))
+        mm1.setRenumFieldArr(-1,DataArrayInt([16,17,18,19,20,21]))
+        for i in range(1,10):
+            mm1.setFamilyId("F%d"%i,i)
+        mm1.setFamilyId("FAMILLE_ZERO",0)
+        mm1.setFamilyId("H1",100)
+        mm1.setFamiliesOnGroup("myGRP",["F2","F6"])
+        mm1.setFamiliesOnGroup("myGRP1",["F2","F6"])
+        mm1.setFamilyFieldArr(1,DataArrayInt([12,13,14,15]))
+        mm1.setRenumFieldArr(1,DataArrayInt([22,23,24,25]))
+        ##############
+        mm2=MEDFileUMesh()
+        da1=DataArrayDouble([9,10,30,11,12,31,13,14,32,15,16,33,17,18,34],5,3) ; da1.setInfoOnComponents(["aa [m]","bbb [kg]","cccc [MW]"])
+        mm2.setCoords(da1)
+        mm2_0=MEDCouplingUMesh(meshName,3) ; mm2_0.allocateCells()
+        mm2_0.setCoords(da1)
+        mm2_0.insertNextCell(NORM_TETRA4,[100,101,102,103])
+        mm2_0.insertNextCell(NORM_TETRA4,[104,105,106,107])
+        mm2_0.insertNextCell(NORM_TETRA4,[108,109,110,111])
+        mm2_0.insertNextCell(NORM_PENTA6,[112,113,114,115,116,117])
+        mm2[0]=mm2_0
+        mm2.setFamilyFieldArr(0,DataArrayInt([40,41,42,43]))
+        mm2.setRenumFieldArr(0,DataArrayInt([50,51,52,53]))
+        #
+        mm2_1=MEDCouplingUMesh(meshName,2) ; mm2_1.allocateCells()
+        mm2_1.setCoords(da1)
+        mm2_1.insertNextCell(NORM_TRI3,[100,101,102])
+        mm2_1.insertNextCell(NORM_TRI3,[103,104,105])
+        mm2_1.insertNextCell(NORM_TRI3,[106,107,108])
+        mm2_1.insertNextCell(NORM_QUAD4,[109,110,111,112])
+        mm2_1.insertNextCell(NORM_QUAD4,[113,114,115,116])
+        mm2_1.insertNextCell(NORM_QUAD4,[117,118,119,120])
+        mm2_1.insertNextCell(NORM_QUAD4,[121,122,123,124])
+        mm2_1.insertNextCell(NORM_QUAD4,[125,126,127,128])
+        mm2[-1]=mm2_1
+        mm2.setFamilyFieldArr(-1,DataArrayInt([200,201,202,203,204,205,206,207]))
+        mm2.setRenumFieldArr(-1,DataArrayInt([300,301,302,303,304,305,306,307]))
+        for i in range(1,12):
+            mm2.setFamilyId("G%d"%i,i+30)
+        mm2.setFamilyId("H1",100)
+        mm2.setFamilyId("FAMILLE_ZERO",0)
+        mm2.setFamiliesOnGroup("myGRP",["G2","G6"])
+        mm2.setFamiliesOnGroup("myGRP2",["G4","G7"])
+        mm2.setFamilyFieldArr(1,DataArrayInt([112,113,114,115,116]))
+        mm2.setRenumFieldArr(1,DataArrayInt([122,123,124,125,126]))
+        #
+        mm=MEDFileUMesh.Aggregate([mm1,mm2])
+        #######
+        def CheckMesh(tester,mm):
+            cooExp=DataArrayDouble([(1,2,10),(3,4,11),(5,6,12),(7,8,13),(9,10,30),(11,12,31),(13,14,32),(15,16,33),(17,18,34)]) ; cooExp.setInfoOnComponents(["aa [m]","bbb [kg]","cccc [MW]"])
+            tester.assertTrue(mm.getCoords().isEqual(cooExp,1e-12))
+            tester.assertTrue(mm[0].getNodalConnectivity().isEqual(DataArrayInt([14,0,1,2,3,14,4,5,6,7,14,104,105,106,107,14,108,109,110,111,14,112,113,114,115,16,8,9,10,11,12,13,16,14,15,16,17,18,19,16,20,21,22,23,24,25,16,116,117,118,119,120,121])))
+            tester.assertTrue(mm[0].getNodalConnectivityIndex().isEqual(DataArrayInt([0,5,10,15,20,25,32,39,46,53])))
+            tester.assertTrue(mm[-1].getNodalConnectivity().isEqual(DataArrayInt([3,0,1,2,3,3,4,5,3,104,105,106,3,107,108,109,3,110,111,112,4,6,7,8,9,4,10,11,12,13,4,14,15,16,17,4,18,19,20,21,4,113,114,115,116,4,117,118,119,120,4,121,122,123,124,4,125,126,127,128,4,129,130,131,132])))
+            tester.assertTrue(mm[-1].getNodalConnectivityIndex().isEqual(DataArrayInt([0,4,8,12,16,20,25,30,35,40,45,50,55,60,65])))
+            tester.assertTrue(mm.getFamilyFieldAtLevel(0).isEqual(DataArrayInt([1,2,40,41,42,3,4,5,43])))
+            tester.assertTrue(mm.getNumberFieldAtLevel(0).isEqual(DataArrayInt([11,12,50,51,52,13,14,15,53])))
+            tester.assertTrue(mm.getFamilyFieldAtLevel(-1).isEqual(DataArrayInt([6,7,200,201,202,8,9,10,11,203,204,205,206,207])))
+            tester.assertTrue(mm.getNumberFieldAtLevel(-1).isEqual(DataArrayInt([16,17,300,301,302,18,19,20,21,303,304,305,306,307])))
+            refFamIds=[("FAMILLE_ZERO",0),('F1',1),('F2',2),('F3',3),('F4',4),('F5',5),('F6',6),('F7',7),('F8',8),('F9',9),('G1',31),('G10',40),('G11',41),('G2',32),('G3',33),('G4',34),('G5',35),('G6',36),('G7',37),('G8',38),('G9',39),("H1",100)]
+            tester.assertEqual(set(mm.getFamiliesNames()),set([elt[0] for elt in refFamIds]))
+            tester.assertEqual(set([mm.getFamilyId(elt) for elt in mm.getFamiliesNames()]),set([elt[1] for elt in refFamIds]))
+            tester.assertEqual(mm.getGroupsNames(),('myGRP','myGRP1','myGRP2'))
+            tester.assertEqual(mm.getAllDistributionOfTypes(),[(NORM_TRI3,5),(NORM_QUAD4,9),(NORM_TETRA4,5),(NORM_PENTA6,4),(NORM_ERROR,9)])
+            pass
+        CheckMesh(self,mm)
+        ##
+        fieldName="zeField"
+        t1=(2.3,3,5)
+        t2=(5.6,7,12)
+        infoc=["dd [W]","eee [kA]"]
+        ##
+        fmts1=MEDFileFieldMultiTS()
+        f1ts1=MEDFileField1TS()
+        f1_1=MEDCouplingFieldDouble(ON_CELLS) ; f1_1.setMesh(mm1[0]) ; f1_1.setName(fieldName)
+        arr1=DataArrayDouble([(10,110),(11,111),(12,112),(13,113),(14,114)])
+        arr1.setInfoOnComponents(infoc)
+        f1_1.setArray(arr1) ; f1_1.setTime(*t1) ; f1_1.setTimeUnit("ms")
+        f1_1.checkConsistencyLight()
+        f1ts1.setFieldNoProfileSBT(f1_1)
+        #
+        f1_2=MEDCouplingFieldDouble(ON_CELLS) ; f1_2.setMesh(mm1[-1]) ; f1_2.setName(fieldName)
+        arr2=DataArrayDouble([(15,115),(16,116),(17,117),(18,118),(19,119),(20,120)])
+        arr2.setInfoOnComponents(infoc)
+        f1_2.setArray(arr2) ; f1_2.setTime(*t1) ; f1_2.setTimeUnit("ms")
+        f1_2.checkConsistencyLight()
+        f1ts1.setFieldNoProfileSBT(f1_2)
+        f1_3=MEDCouplingFieldDouble(ON_NODES) ; f1_3.setMesh(mm1[0]) ; f1_3.setName(fieldName)
+        arr3=DataArrayDouble([(21,121),(22,122),(23,123),(24,124)])
+        arr3.setInfoOnComponents(infoc)
+        f1_3.setArray(arr3) ; f1_3.setTime(*t1) ; f1_3.setTimeUnit("ms")
+        f1_3.checkConsistencyLight()
+        f1ts1.setFieldNoProfileSBT(f1_3)
+        fmts1.pushBackTimeStep(f1ts1)
+        #
+        f1ts2=f1ts1.deepCopy()
+        f1ts2.setTime(t2[1],t2[2],t2[0])
+        f1ts2.getUndergroundDataArray()[:]+=2000
+        fmts1.pushBackTimeStep(f1ts2)
+        ### fmts2
+        fmts2=MEDFileFieldMultiTS()
+        f1ts3=MEDFileField1TS()
+        f2_1=MEDCouplingFieldDouble(ON_CELLS) ; f2_1.setMesh(mm2[0]) ; f2_1.setName(fieldName)
+        arr4=DataArrayDouble([(50,150),(51,151),(52,152),(53,153)])
+        arr4.setInfoOnComponents(infoc)
+        f2_1.setArray(arr4) ; f2_1.setTime(*t1) ; f2_1.setTimeUnit("ms")
+        f2_1.checkConsistencyLight()
+        f1ts3.setFieldNoProfileSBT(f2_1)
+        f2_2=MEDCouplingFieldDouble(ON_CELLS) ; f2_2.setMesh(mm2[-1]) ; f2_2.setName(fieldName)
+        arr5=DataArrayDouble([(54,154),(55,155),(56,156),(57,157),(158,158),(59,159),(60,160),(61,161)])
+        arr5.setInfoOnComponents(infoc)
+        f2_2.setArray(arr5) ; f2_2.setTime(*t1) ; f2_2.setTimeUnit("ms")
+        f2_2.checkConsistencyLight()
+        f1ts3.setFieldNoProfileSBT(f2_2)
+        f2_3=MEDCouplingFieldDouble(ON_NODES) ; f2_3.setMesh(mm2[0]) ; f2_3.setName(fieldName)
+        arr6=DataArrayDouble([(62,162),(63,163),(64,164),(65,165),(66,166)])
+        arr6.setInfoOnComponents(infoc)
+        f2_3.setArray(arr6) ; f2_3.setTime(*t1) ; f2_3.setTimeUnit("ms")
+        f2_3.checkConsistencyLight()
+        f1ts3.setFieldNoProfileSBT(f2_3)
+        fmts2.pushBackTimeStep(f1ts3)
+        #
+        f1ts4=f1ts3.deepCopy()
+        f1ts4.setTime(t2[1],t2[2],t2[0])
+        f1ts4.getUndergroundDataArray()[:]+=2000
+        fmts2.pushBackTimeStep(f1ts4)
+        #
+        mfd1=MEDFileData()
+        mfd1.setMeshes(MEDFileMeshes())
+        mfd1.getMeshes().pushMesh(mm1)
+        mfd1.setFields(MEDFileFields())
+        mfd1.getFields().pushField(fmts1)
+        #
+        mfd2=MEDFileData()
+        mfd2.setMeshes(MEDFileMeshes())
+        mfd2.getMeshes().pushMesh(mm2)
+        mfd2.setFields(MEDFileFields())
+        mfd2.getFields().pushField(fmts2)
+        # ze Call !
+        mfd=MEDFileData.Aggregate([mfd1,mfd2])
+        def CheckMFD(tester,mfd):
+            tester.assertEqual(len(mfd.getMeshes()),1)
+            tester.assertEqual(len(mfd.getFields()),1)
+            CheckMesh(self,mfd.getMeshes()[0])
+            tester.assertEqual(len(mfd.getFields()[0]),2)
+            zeF1=mfd.getFields()[0][0]
+            zeF1_1=zeF1.getFieldOnMeshAtLevel(ON_CELLS,0,mfd.getMeshes()[0])
+            ref=MEDCouplingFieldDouble.MergeFields([f1_1,f2_1])
+            o2n=ref.getMesh().deepCopy().sortCellsInMEDFileFrmt()
+            ref.renumberCells(o2n)
+            tester.assertTrue(ref.isEqual(zeF1_1,1e-12,1e-12))
+            zeF1_2=zeF1.getFieldOnMeshAtLevel(ON_CELLS,-1,mfd.getMeshes()[0])
+            ref=MEDCouplingFieldDouble.MergeFields([f1_2,f2_2])
+            o2n=ref.getMesh().deepCopy().sortCellsInMEDFileFrmt()
+            ref.renumberCells(o2n)
+            tester.assertTrue(ref.isEqual(zeF1_2,1e-12,1e-12))
+            zeF1_3=zeF1.getFieldOnMeshAtLevel(ON_NODES,0,mfd.getMeshes()[0])
+            ref=MEDCouplingFieldDouble.MergeFields([f1_3,f2_3])
+            o2n=ref.getMesh().deepCopy().sortCellsInMEDFileFrmt()
+            ref.renumberCells(o2n)
+            tester.assertTrue(ref.isEqual(zeF1_3,1e-12,1e-12))
+            #
+            zeF2=mfd.getFields()[0][1]
+            zeF2_1=zeF2.getFieldOnMeshAtLevel(ON_CELLS,0,mfd.getMeshes()[0])
+            ref=MEDCouplingFieldDouble.MergeFields([f1_1,f2_1])
+            o2n=ref.getMesh().deepCopy().sortCellsInMEDFileFrmt()
+            ref.renumberCells(o2n)
+            ref.setTime(*t2) ; ref.getArray()[:]+=2000
+            tester.assertTrue(ref.isEqual(zeF2_1,1e-12,1e-12))
+            zeF2_2=zeF2.getFieldOnMeshAtLevel(ON_CELLS,-1,mfd.getMeshes()[0])
+            ref=MEDCouplingFieldDouble.MergeFields([f1_2,f2_2])
+            o2n=ref.getMesh().deepCopy().sortCellsInMEDFileFrmt()
+            ref.renumberCells(o2n)
+            ref.setTime(*t2) ; ref.getArray()[:]+=2000
+            tester.assertTrue(ref.isEqual(zeF2_2,1e-12,1e-12))
+            zeF2_3=zeF2.getFieldOnMeshAtLevel(ON_NODES,0,mfd.getMeshes()[0])
+            ref=MEDCouplingFieldDouble.MergeFields([f1_3,f2_3])
+            o2n=ref.getMesh().deepCopy().sortCellsInMEDFileFrmt()
+            ref.renumberCells(o2n)
+            ref.setTime(*t2) ; ref.getArray()[:]+=2000
+            tester.assertTrue(ref.isEqual(zeF2_3,1e-12,1e-12))
+        CheckMFD(self,mfd)
+        mfd1.write(fname1,2) ; mfd2.write(fname2,2)
+        mfd=MEDFileData.Aggregate([MEDFileData(fname1),MEDFileData(fname2)])
+        CheckMFD(self,mfd)
+        pass
     
     pass
 
index 6c0fb4ae715bd1a580bede60f496b64f4f9ca7b9..9df1cb801a82838371eeb58baf06ea15a9cdad2a 100644 (file)
@@ -197,6 +197,20 @@ static PyObject *convertFieldDoubleVecToPy(const std::vector<MEDCoupling::MEDCou
   return ret;
 }
 
+PyObject *convertVecPairIntToPy(const std::vector< std::pair<int,int> >& vec)
+{
+  PyObject *ret(PyList_New(vec.size()));
+  int rk=0;
+  for(std::vector< std::pair<int,int> >::const_iterator iter=vec.begin();iter!=vec.end();iter++,rk++)
+    {
+      PyObject *elt=PyTuple_New(2);
+      PyTuple_SetItem(elt,0,SWIG_From_int((*iter).first));
+      PyTuple_SetItem(elt,1,SWIG_From_int((*iter).second));
+      PyList_SetItem(ret,rk,elt);
+    }
+  return ret;
+}
+
 PyObject *convertVecPairVecStToPy(const std::vector< std::pair<std::vector<std::string>, std::string > >& vec)
 {
   int sz=(int)vec.size();