]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
Take advantage of med4.1 capabilities.
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 4 Mar 2020 17:00:25 +0000 (18:00 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Thu, 12 Mar 2020 10:30:47 +0000 (11:30 +0100)
src/MEDCoupling_Swig/MEDCouplingMemArray.i
src/MEDLoader/MEDFileEntities.cxx
src/MEDLoader/MEDFileEntities.hxx
src/MEDLoader/MEDFileField1TS.cxx
src/MEDLoader/MEDFileField1TS.hxx
src/MEDLoader/MEDFileFieldMultiTS.cxx
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/MEDFileUtilities.cxx
src/MEDLoader/MEDFileUtilities.hxx
src/MEDLoader/MEDLoader.cxx
src/MEDLoader/Swig/MEDLoaderCommon.i

index 4c988d334bcfea69ae7b5e4e0fbdb6c6604824f1..6d7020b4bcfd15101f93955350ac92b992b34594 100644 (file)
@@ -674,7 +674,8 @@ typedef DataArrayInt64 DataArrayIdType;
         GetIndicesOfSliceExplicitely(slic,&strt,&stp,&step,"DataArray::GetSlice (wrap) : the input slice is invalid !");
         mcIdType a,b;
         DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b);
-        return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
+        AutoPyPtr ap(PyInt_FromLong(a)),bp(PyInt_FromLong(b)),stepp(PyInt_FromLong(step));
+        return PySlice_New(ap,bp,stepp);
       }
 
       PyObject *getSlice(PyObject *slic, mcIdType sliceId, mcIdType nbOfSlices) const
@@ -685,7 +686,8 @@ typedef DataArrayInt64 DataArrayIdType;
         GetIndicesOfSlice(slic,self->getNumberOfTuples(),&strt,&stp,&step,"DataArray::getSlice (wrap) : the input slice is invalid !");
         mcIdType a,b;
         DataArray::GetSlice(ToIdType(strt),ToIdType(stp),ToIdType(step),sliceId,nbOfSlices,a,b);
-        return PySlice_New(PyInt_FromLong(a),PyInt_FromLong(b),PyInt_FromLong(step));
+        AutoPyPtr ap(PyInt_FromLong(a)),bp(PyInt_FromLong(b)),stepp(PyInt_FromLong(step));
+        return PySlice_New(ap,bp,stepp);
       }
 
       static mcIdType GetNumberOfItemGivenBES(PyObject *slic)
index b6e96938c158806279a324f5c22cd7d6fb975314..dd8398d343a2503da6dbcc6de371304eaf26e376 100644 (file)
@@ -54,6 +54,11 @@ bool MEDFileStaticEntities::areAllStaticTypesPresent() const
   return false;
 }
 
+bool MEDFileStaticEntities::areAllStaticPresentAndNoDyn() const
+{
+  return false;
+}
+
 //////////////
 
 
@@ -67,6 +72,11 @@ bool MEDFileAllStaticEntites::areAllStaticTypesPresent() const
   return true;
 }
 
+bool MEDFileAllStaticEntites::areAllStaticPresentAndNoDyn() const
+{
+  return true;
+}
+
 //////////////
 
 MEDFileAllStaticEntitiesPlusDyn::MEDFileAllStaticEntitiesPlusDyn(const MEDFileStructureElements *se):_se(se)
@@ -85,6 +95,11 @@ bool MEDFileAllStaticEntitiesPlusDyn::areAllStaticTypesPresent() const
   return true;
 }
 
+bool MEDFileAllStaticEntitiesPlusDyn::areAllStaticPresentAndNoDyn() const
+{
+  return false;
+}
+
 const MEDFileStructureElement *MEDFileAllStaticEntitiesPlusDyn::getWithGT(int idGT) const
 {
   return _se->getWithGT(idGT);
index 7b7bcbcfcb382a16cd1b628e018a18ff76e2e449..6192660dab5dac77eaf7a7c7220b5efc56b17e1d 100644 (file)
@@ -37,6 +37,7 @@ namespace MEDCoupling
     static MEDFileEntities *BuildFrom(const MEDFileStructureElements& se);
     virtual std::vector<int> getDynGTAvail() const = 0;
     virtual bool areAllStaticTypesPresent() const = 0;
+    virtual bool areAllStaticPresentAndNoDyn() const = 0;
     virtual ~MEDFileEntities();
   };
 
@@ -47,6 +48,7 @@ namespace MEDCoupling
     const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& getEntries() const { return _entities; }
     std::vector<int> getDynGTAvail() const;
     bool areAllStaticTypesPresent() const;
+    bool areAllStaticPresentAndNoDyn() const override;
   private:
     std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > _entities;
   };
@@ -57,6 +59,7 @@ namespace MEDCoupling
     MEDFileAllStaticEntites() { }
     std::vector<int> getDynGTAvail() const;
     bool areAllStaticTypesPresent() const;
+    bool areAllStaticPresentAndNoDyn() const override;
   };
 
   class MEDLOADER_EXPORT MEDFileAllStaticEntitiesPlusDyn : public MEDFileEntities
@@ -65,6 +68,7 @@ namespace MEDCoupling
     MEDFileAllStaticEntitiesPlusDyn(const MEDFileStructureElements *se);
     std::vector<int> getDynGTAvail() const;
     bool areAllStaticTypesPresent() const;
+    bool areAllStaticPresentAndNoDyn() const override;
     const MEDFileStructureElement *getWithGT(int idGT) const;
     const MEDFileUMesh *getSupMeshWithName(const std::string& name) const;
   private:
index dc51ad550b7c9f69bd5986e6e359aff383cfc308..ea2514be5af94e7368a3f28882118bc6a250bf17 100644 (file)
@@ -739,19 +739,19 @@ bool MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFrom
   throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::allocIfNecessaryTheArrayToReceiveDataFromFile : internal error !");
 }
 
-void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities)
+void MEDFileAnyTypeField1TSWithoutSDA::loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities, const MEDFileCapability *capability)
 {
   med_int numdt,numit;
   med_float dt;
-  med_int meshnumdt,meshnumit;
+  med_int meshnumdt(-1),meshnumit(-1);
   MEDFILESAFECALLERRD0(MEDfieldComputingStepInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt));
+  if(!capability || !capability->isFastReader())
   {
     med_bool localMesh;
     med_int nmesh;
     INTERP_KERNEL::AutoPtr<char> meshName(MEDLoaderBase::buildEmptyString(MED_NAME_SIZE));
     MEDFILESAFECALLERRD0(MEDfield23ComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&dt,&nmesh,meshName,&localMesh,&meshnumdt,&meshnumit)); // to check with Adrien for legacy MED files
   }
-  //MEDFILESAFECALLERRD0(MEDfieldComputingStepMeshInfo,(fid,nasc.getName().c_str(),_csit,&numdt,&numit,&_dt,&meshnumdt,&meshnumit));
   if(_iteration!=numdt || _order!=numit)
     throw INTERP_KERNEL::Exception("MEDFileAnyTypeField1TSWithoutSDA::loadBigArraysRecursively : unexpected exception internal error !");
   _field_per_mesh.resize(1);
index 924ef6ee3711c1bece2a0c5fc79471a9466f6119..f88d5a6ab82073d28a14bf9990341cb04505eb84 100644 (file)
@@ -116,7 +116,7 @@ namespace MEDCoupling
   public:
     MEDLOADER_EXPORT void allocNotFromFile(mcIdType newNbOfTuples);
     MEDLOADER_EXPORT bool allocIfNecessaryTheArrayToReceiveDataFromFile();
-    MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities);
+    MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities, const MEDFileCapability *capability = nullptr);
     MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
     MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc);
     MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities);
index 3f19a60c9abcf960c1c3c6947e952040fbdfbc8d..00c118f746d213368026f7986b89a60a7c7fc954 100644 (file)
@@ -42,6 +42,8 @@ template class MEDCoupling::MEDFileTemplateFieldMultiTS<double>;
 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<int>;
 template class MEDCoupling::MEDFileNDTemplateFieldMultiTS<float>;
 
+extern INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype);
+  
 //= MEDFileAnyTypeFieldMultiTSWithoutSDA
 
 MEDFileAnyTypeFieldMultiTSWithoutSDA::MEDFileAnyTypeFieldMultiTSWithoutSDA()
@@ -484,6 +486,32 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::synchronizeNameScope()
 void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities)
 {
   _time_steps.resize(nbPdt);
+  //
+  INTERP_KERNEL::AutoCppPtr<MEDFileEntities> entitiesFast;
+  const MEDFileEntities *entitiesForSubInstances(entities);
+  MEDFileCapability mfcap(fid);
+  if( ( !entities || entities->areAllStaticPresentAndNoDyn() ) && mfcap.isFastReader())
+    {// no entities
+      int nentitype(MEDfieldnEntityType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT));
+      INTERP_KERNEL::AutoPtr<med_entity_type> types(new med_entity_type[nentitype]);
+      med_int usedbyncs;
+      MEDFILESAFECALLERRD0(MEDfieldEntityType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types,&usedbyncs));
+      std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> > entitiesFastP;
+      for(int i=0;i<nentitype;i++)
+        {
+          int ngeotype(MEDfieldnGeometryType(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i]));
+          INTERP_KERNEL::AutoPtr<med_geometry_type> geotypes(new med_geometry_type[ngeotype]);
+          med_int geousedbyncs;
+          MEDFILESAFECALLERRD0(MEDfieldGeometryType,(fid,_name.c_str(),MED_ALL_DT,MED_ALL_IT,types[i],geotypes,&geousedbyncs));
+          for(int j=0;j<ngeotype;j++)
+            {
+              std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> p(MEDFileMesh::ConvertFromMEDFileEntity(types[i]),ConvertGeometryType(geotypes[j]));
+              entitiesFastP.push_back(p);
+            }
+        }
+      entitiesFast=new MEDFileStaticEntities(entitiesFastP);
+      entitiesForSubInstances=entitiesFast;
+    }
   for(int i=0;i<nbPdt;i++)
     {
       std::vector< std::pair<int,int> > ts;
@@ -519,11 +547,11 @@ void MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysR
           throw INTERP_KERNEL::Exception("MEDFileAnyTypeFieldMultiTSWithoutSDA::loadStructureOrStructureAndBigArraysRecursively : managed field type are : FLOAT64, INT32, FLOAT32 !");
       }
       if(loadAll)
-        _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entities);
+        _time_steps[i]->loadStructureAndBigArraysRecursively(fid,*this,ms,entitiesForSubInstances);
       else
-        _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entities);
-      synchronizeNameScope();
+        _time_steps[i]->loadOnlyStructureOfDataRecursively(fid,*this,ms,entitiesForSubInstances,&mfcap);
     }
+  synchronizeNameScope();
 }
 
 void MEDFileAnyTypeFieldMultiTSWithoutSDA::writeLL(med_idt fid, const MEDFileWritable& opts) const
index b74224efbbad74f6a07f1a98d3301ff4445e04b2..f1dd3771c71f0a4ecffbfd9cda2906e38348f547 100644 (file)
@@ -7763,9 +7763,11 @@ TypeOfField MEDFileMesh::ConvertFromMEDFileEntity(med_entity_type etype)
       return ON_NODES;
     case MED_CELL:
       return ON_CELLS;
+    case MED_NODE_ELEMENT:
+      return ON_GAUSS_NE;
     default:
       {
-        std::ostringstream oss; oss << "EDFileMesh::ConvertFromMEDFileEntity : not recognized entity " << etype << " !";
+        std::ostringstream oss; oss << "MEDFileMesh::ConvertFromMEDFileEntity : not recognized entity " << etype << " !";
         throw INTERP_KERNEL::Exception(oss.str());
       }
     }
index d30377eaeb8c7c9a9d6ee96fae56930698f531c1..026905a008f9f7fa4908f0303a2308d654f667dc 100644 (file)
@@ -192,26 +192,22 @@ void MEDCoupling::MEDFileWritableStandAlone::write(const std::string& fileName,
 
 void MEDCoupling::MEDFileWritableStandAlone::write33(const std::string& fileName, int mode) const
 {
+  this->writeXX(fileName,mode,3,3,1);
+}
+
+void MEDCoupling::MEDFileWritableStandAlone::write30(const std::string& fileName, int mode) const
+{
+  this->writeXX(fileName,mode,3,0,6);
+}
+
+void MEDCoupling::MEDFileWritableStandAlone::writeXX(const std::string& fileName, int mode, med_int maj, med_int min, med_int rel) const
+{
+#if ( MED_NUM_MAJEUR>4 || ( MED_NUM_MAJEUR==4 && MED_NUM_MINEUR>=1 ) )
   med_access_mode medmod(MEDFileUtilities::TraduceWriteMode(mode));
-  static const unsigned char EMPTY_FILE_3_3[]={0x89,0x48,0x44,0x46,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0x0,0x0,0x8,0x8,0x0,0x4,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xd0,0x7,0x0,0x0,0x0,0x0,0x0,0x0,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x60,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x88,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xa8,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x1,0x0,0x1,0x0,0x1,0x0,0x0,0x0,0x18,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x11,0x0,0x10,0x0,0x0,0x0,0x0,0x0,0x88,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xa8,0x2,0x0,0x0,0x0,0x0,0x0,0x0,0x54,0x52,0x45,0x45,0x0,0x0,0x1,0x0,0xff,0x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,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0};
-#if MED_NUM_MAJEUR>3
-  med_bool fileexist,accessok;
-  MEDFILESAFECALLERRD0(MEDfileExist,(fileName.c_str(),medmod,&fileexist,&accessok));
-  if(!accessok)
-    {
-      std::ostringstream oss; oss << "MEDFileWritableStandAlone::write33 : requested access to file \"" << fileName << "\" !";
-      throw INTERP_KERNEL::Exception(oss.str());
-    }
-  if(medmod==MED_ACC_CREAT || !fileexist)
-    {
-      std::ofstream ofs(fileName);
-      ofs.write(reinterpret_cast<const char *>(EMPTY_FILE_3_3),sizeof(EMPTY_FILE_3_3));
-      medmod=MEDFileUtilities::TraduceWriteMode(0);
-    }
-  MEDFileUtilities::AutoFid fid(MEDfileVersionOpen(fileName.c_str(),medmod,3,3,1));
+  MEDFileUtilities::AutoFid fid(MEDfileVersionOpen(fileName.c_str(),medmod,maj,min,rel));
   writeLL(fid);
 #else
-  std::ostringstream oss; oss << "MEDFileWritableStandAlone::write33 : is implemented with MEDFile " << MEDFileVersionStr() << " ! If you need this feature please use version >= 3.2.1.";
+  std::ostringstream oss; oss << "MEDFileWritableStandAlone::write" << maj << min << " : the MED version used to compile medcoupling is " << MEDFileVersionStr() << " ! If you need this feature please use version >= 4.1.";
   throw INTERP_KERNEL::Exception(oss.str());
 #endif
 }
@@ -239,3 +235,8 @@ std::string MEDCoupling::MEDFileWritableStandAlone::GenerateUniqueDftFileNameInM
   std::ostringstream oss; oss << DFT_FILENAME_IN_MEM << "_" << ii++;
   return oss.str();
 }
+
+MEDCoupling::MEDFileCapability::MEDFileCapability(med_idt fid)
+{
+  MEDFILESAFECALLERRD0(MEDfileNumVersionRd,(fid,&_maj,&_min,&_rel));
+}
index 501a6d5e57295d9430cf5ff0b571782a8f8bbf1d..7f82bae3234d093825bdbb0ea8fb3351027da608 100644 (file)
@@ -71,14 +71,27 @@ namespace MEDCoupling
     MEDLOADER_EXPORT virtual void writeLL(med_idt fid) const = 0;
     MEDLOADER_EXPORT virtual void write(const std::string& fileName, int mode) const;
     MEDLOADER_EXPORT virtual void write33(const std::string& fileName, int mode) const;
+    MEDLOADER_EXPORT virtual void write30(const std::string& fileName, int mode) const;
     MEDLOADER_EXPORT MCAuto<DataArrayByte> serialize() const;
     MEDLOADER_EXPORT static std::string GenerateUniqueDftFileNameInMem();
   public:
     MEDLOADER_EXPORT static const char DFT_FILENAME_IN_MEM[];
     template<class T>
     static T *BuildFromMemoryChunk(DataArrayByte *db);
+  private:
+    void writeXX(const std::string& fileName, int mode, med_int maj, med_int min, med_int rel) const;
   };
   
+  class MEDFileCapability
+  {
+  public:
+    MEDFileCapability(med_idt fid);
+    bool isFastReader() const { return _maj>=4 && _min >=1; }
+  private:
+    med_int _maj;
+    med_int _min;
+    med_int _rel;
+  };
   MEDFileUtilities::AutoFid OpenMEDFileForRead(const std::string& fileName);
 }
 
index 597b25fc14396a1b8500e95bd4966a08aab57ee7..7f1a4d3a3d37785bc98356617f351b4451ef289b 100644 (file)
@@ -146,6 +146,20 @@ using namespace MEDCoupling;
 
 /// @cond INTERNAL
 
+INTERP_KERNEL::NormalizedCellType ConvertGeometryType(med_geometry_type geotype)
+{
+  INTERP_KERNEL::NormalizedCellType result=INTERP_KERNEL::NORM_ERROR;
+  for(int i=0; i<MED_N_CELL_FIXED_GEO; i++)
+    {
+      if (typmai[i]==geotype)
+        {
+          result=typmai2[i];
+          break;
+        }
+    }
+  return result;
+}
+
 /*!
  * This method returns a first quick overview of mesh with name \a meshName into the file \a fileName.
  * @param possibilities the relativeToMeshDim authorized to returned maxdim. This vector is systematically cleared at the begin of this method.
index a66fb85dcec8c4c99166ac654659ce0bf1a5c11e..4e5dbd3e13a4b8f59fdfd51fa4eec5e79ecc00d6 100644 (file)
@@ -624,6 +624,7 @@ namespace MEDCoupling
   public:
     void write(const std::string& fileName, int mode) const;
     void write33(const std::string& fileName, int mode) const;
+    void write30(const std::string& fileName, int mode) const;
     %extend
        {
          DataArrayByte *serialize() const