X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileField.hxx;h=2f6e1ae386759b5050fbf09f0b833e1bb5707deb;hb=854b8c30cd78bd9c7679492863fab2128552bb92;hp=b099d369b53b0d9aa32f9cf69657d20b4793dee0;hpb=10f37bf6f33a762626d7f1093b2f5450c1688667;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index b099d369b..2f6e1ae38 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2013 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 @@ -16,6 +16,7 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// Author : Anthony Geay (CEA/DEN) #ifndef __MEDFILEFIELD_HXX__ #define __MEDFILEFIELD_HXX__ @@ -34,6 +35,7 @@ #include #include #include +#include #include "med.h" @@ -48,11 +50,13 @@ namespace ParaMEDMEM { public: void MEDLOADER_EXPORT simpleRepr(std::ostream& oss) const; - const MEDLOADER_EXPORT std::string& getName() const { return _name; } + std::string MEDLOADER_EXPORT getName() const { return _name; } void MEDLOADER_EXPORT setName(const char *name); static MEDFileFieldLoc *New(med_idt fid, const char *locName); static MEDFileFieldLoc *New(med_idt fid, int id); static MEDFileFieldLoc *New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); + std::size_t getHeapMemorySize() const; + MEDFileFieldLoc *deepCpy() const; int MEDLOADER_EXPORT getNbOfGaussPtPerCell() const { return _nb_gauss_pt; } void MEDLOADER_EXPORT writeLL(med_idt fid) const; std::string MEDLOADER_EXPORT repr() const; @@ -80,8 +84,10 @@ namespace ParaMEDMEM }; /// @cond INTERNAL + class MEDFileAnyTypeField1TSWithoutSDA; class MEDFileFieldPerMeshPerType; class MEDFileField1TSWithoutSDA; + class MEDFileFieldNameScope; class MEDFileFieldGlobsReal; class MEDFileFieldPerMesh; @@ -91,19 +97,20 @@ namespace ParaMEDMEM static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception); static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId); static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other); - void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(int& start, const char *pflName, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; + MEDFileFieldPerMeshPerTypePerDisc *deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception); + void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); void getCoarseData(TypeOfField& type, std::pair& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception); - void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMeshPerType *getFather() const; - void prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception); - void finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception); + void loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); void setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception); int getIteration() const; int getOrder() const; double getTime() const; - std::string getName() const; std::string getMeshName() const; TypeOfField getType() const; void simpleRepr(int bkOffset, std::ostream& oss, int id) const; @@ -113,8 +120,9 @@ namespace ParaMEDMEM int getNumberOfComponents() const; int getNumberOfTuples() const; int getStart() const { return _start; } - DataArrayDouble *getArray(); - const DataArrayDouble *getArray() const; + int getEnd() const { return _end; } + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; const std::vector& getInfo() const; std::string getProfile() const; void setProfile(const char *newPflName); @@ -154,6 +162,7 @@ namespace ParaMEDMEM std::string _localization; //! only on assignement -3 : ON_NODES, -2 : ON_CELLS, -1 : ON_GAUSS_NE, 0..* : ON_GAUSS_PT mutable int _loc_id; + mutable int _profile_it; public: mutable int _tmp_work1; }; @@ -162,29 +171,30 @@ namespace ParaMEDMEM { public: static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); - static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); - void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); + static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; + MEDFileFieldPerMeshPerType *deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception); + void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); + void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMesh *getFather() const; - void prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception); - void finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception); - void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); void getDimension(int& dim) const; void fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception); void fillFieldSplitedByType(std::vector< std::pair >& dads, std::vector& types, std::vector& pfls, std::vector& locs) const throw(INTERP_KERNEL::Exception); int getIteration() const; int getOrder() const; double getTime() const; - std::string getName() const; std::string getMeshName() const; void simpleRepr(int bkOffset, std::ostream& oss, int id) const; void getSizes(int& globalSz, int& nbOfEntries) const; INTERP_KERNEL::NormalizedCellType getGeoType() const; int getNumberOfComponents() const; - DataArrayDouble *getArray(); - const DataArrayDouble *getArray() const; + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; const std::vector& getInfo() const; std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; @@ -197,13 +207,14 @@ namespace ParaMEDMEM void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; void fillValues(int& startEntryId, std::vector< std::pair,std::pair > >& entries) const; void setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception); + bool keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair >& its) throw(INTERP_KERNEL::Exception); static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType); private: std::vector addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception); std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception); std::vector addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception); std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception); - MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); + MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); private: MEDFileFieldPerMesh *_father; @@ -214,18 +225,19 @@ namespace ParaMEDMEM class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable { public: - static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); - static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception); + static MEDFileFieldPerMesh *New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); + static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; + MEDFileFieldPerMesh *deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const throw(INTERP_KERNEL::Exception); void simpleRepr(int bkOffset,std::ostream& oss, int id) const; void copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfileGeneral(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignFieldNoProfileNoRenum(int& start, const std::vector& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception); - void finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception); - void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void assignFieldNoProfileNoRenum(int& start, const std::vector& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); + void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); void fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception); std::vector< std::vector< std::pair > > getFieldSplitedByType(std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); void getDimension(int& dim) const; @@ -234,12 +246,10 @@ namespace ParaMEDMEM int getOrder() const; int getMeshIteration() const { return _mesh_iteration; } int getMeshOrder() const { return _mesh_order; } - const std::string& getDtUnit() const; - std::string getName() const; std::string getMeshName() const { return _mesh_name; } int getNumberOfComponents() const; - DataArrayDouble *getArray(); - const DataArrayDouble *getArray() const; + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; const std::vector& getInfo() const; std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; @@ -247,38 +257,39 @@ namespace ParaMEDMEM std::vector getLocsReallyUsedMulti() const; bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); + void keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair >& its) throw(INTERP_KERNEL::Exception); void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + DataArray *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + void getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception); private: int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type); MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob, - const std::vector< std::pair >& dads, const std::vector& locs, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception); + const std::vector< std::pair >& dads, const std::vector& locs, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob, const std::vector< std::pair >& dads, const std::vector& locs, const std::vector& geoTypes, - const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *finishField3(const MEDFileFieldGlobsReal *glob, - const std::vector< std::pair >& dads, const std::vector& locs, - const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *finishField4(const std::vector< std::pair >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception); + const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *finishFieldNode2(const MEDFileFieldGlobsReal *glob, + const std::vector< std::pair >& dads, const std::vector& locs, + const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + DataArray *finishField4(const std::vector< std::pair >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception); void assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception); static void SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, const std::vector< std::pair >& dads, const std::vector& pfls, const std::vector& locs, std::vector& code, std::vector& notNullPfls); static int ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, const std::vector< std::pair >& dads, const std::vector& locs) throw(INTERP_KERNEL::Exception); - MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception); - MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); + MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); private: std::string _mesh_name; int _mesh_iteration; int _mesh_order; int _mesh_csit; - MEDFileField1TSWithoutSDA *_father; + MEDFileAnyTypeField1TSWithoutSDA *_father; std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > _field_pm_pt; }; @@ -289,8 +300,14 @@ namespace ParaMEDMEM public: static MEDFileFieldGlobs *New(const char *fname); static MEDFileFieldGlobs *New(); + std::size_t getHeapMemorySize() const; + MEDFileFieldGlobs *deepCpy() const throw(INTERP_KERNEL::Exception); + MEDFileFieldGlobs *shallowCpyPart(const std::vector& pfls, const std::vector& locs) const throw(INTERP_KERNEL::Exception); + MEDFileFieldGlobs *deepCpyPart(const std::vector& pfls, const std::vector& locs) const throw(INTERP_KERNEL::Exception); void simpleRepr(std::ostream& oss) const; void appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception); + void checkGlobsPflsPartCoherency(const std::vector& pflsUsed) const throw(INTERP_KERNEL::Exception); + void checkGlobsLocsPartCoherency(const std::vector& locsUsed) const throw(INTERP_KERNEL::Exception); void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception); void loadProfileInFile(med_idt fid, int id); void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception); @@ -343,9 +360,17 @@ namespace ParaMEDMEM public: MEDFileFieldGlobsReal(const char *fname); MEDFileFieldGlobsReal(); - void simpleRepr(std::ostream& oss) const; + std::size_t getHeapMemorySize() const; + void simpleReprGlobs(std::ostream& oss) const; + void resetContent(); void shallowCpyGlobs(const MEDFileFieldGlobsReal& other); + void deepCpyGlobs(const MEDFileFieldGlobsReal& other); + void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception); + void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other) throw(INTERP_KERNEL::Exception); void appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception); + void checkGlobsCoherency() const throw(INTERP_KERNEL::Exception); + void checkGlobsPflsPartCoherency() const throw(INTERP_KERNEL::Exception); + void checkGlobsLocsPartCoherency() const throw(INTERP_KERNEL::Exception); virtual std::vector getPflsReallyUsed() const = 0; virtual std::vector getLocsReallyUsed() const = 0; virtual std::vector getPflsReallyUsedMulti() const = 0; @@ -393,38 +418,51 @@ namespace ParaMEDMEM // void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception); void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w) throw(INTERP_KERNEL::Exception); + protected: + MEDFileFieldGlobs *contentNotNull() throw(INTERP_KERNEL::Exception); + const MEDFileFieldGlobs *contentNotNull() const throw(INTERP_KERNEL::Exception); protected: MEDCouplingAutoRefCountObjectPtr< MEDFileFieldGlobs > _globals; }; + class MEDLOADER_EXPORT MEDFileFieldNameScope + { + public: + MEDFileFieldNameScope(); + MEDFileFieldNameScope(const char *fieldName); + std::string getName() const throw(INTERP_KERNEL::Exception); + void setName(const char *fieldName) throw(INTERP_KERNEL::Exception); + std::string getDtUnit() const throw(INTERP_KERNEL::Exception); + void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception); + void copyNameScope(const MEDFileFieldNameScope& other); + protected: + std::string _name; + std::string _dt_unit; + }; + /*! * SDA is for Shared Data Arrays such as profiles. */ - class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public RefCountObject + class MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope { public: - int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - int getDimension() const; + MEDFileAnyTypeField1TSWithoutSDA(); + MEDFileAnyTypeField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order); int getIteration() const { return _iteration; } int getOrder() const { return _order; } double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; } void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; } - std::string getName() const; - void setName(const char *name); - void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; - const std::string& getDtUnit() const { return _dt_unit; } + int getDimension() const; std::string getMeshName() const throw(INTERP_KERNEL::Exception); void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); int getMeshIteration() const throw(INTERP_KERNEL::Exception); int getMeshOrder() const throw(INTERP_KERNEL::Exception); - int getNumberOfComponents() const; bool isDealingTS(int iteration, int order) const; std::pair getDtIt() const; void fillIteration(std::pair& p) const; void fillTypesOfFieldAvailable(std::vector& types) const throw(INTERP_KERNEL::Exception); - const std::vector& getInfo() const; - std::vector& getInfo(); + std::vector getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); // std::vector getPflsReallyUsed2() const; std::vector getLocsReallyUsed2() const; @@ -432,39 +470,57 @@ namespace ParaMEDMEM std::vector getLocsReallyUsedMulti2() const; void changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); void changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + // int getNonEmptyLevels(const char *mname, std::vector& levs) const throw(INTERP_KERNEL::Exception); - std::vector getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); std::vector< std::vector > > getFieldSplitedByType(const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); - std::vector< std::vector > getFieldSplitedByType2(const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); - MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception); + // + MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception); const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception); - static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception); - static std::vector CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); - static MEDFileField1TSWithoutSDA *New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector& infos); + void deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other) throw(INTERP_KERNEL::Exception); + public: + int getNumberOfComponents() const; + const std::vector& getInfo() const; + std::vector& getInfo(); + void setInfo(const std::vector& infos) throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; + int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception); + void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; + virtual MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception) = 0; + virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0; + virtual std::vector< MEDCouplingAutoRefCountObjectPtr > splitComponents() const throw(INTERP_KERNEL::Exception); + virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0; + virtual DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception) = 0; + virtual DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception) = 0; + virtual void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception) = 0; + virtual DataArray *createNewEmptyDataArrayInstance() const = 0; + virtual DataArray *getOrCreateAndGetArray() = 0; + virtual const DataArray *getOrCreateAndGetArray() const = 0; + public: + MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); + DataArray *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); public: - void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception); - virtual void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception); - void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception); + std::vector< MEDCouplingAutoRefCountObjectPtr > splitDiscretizations() const throw(INTERP_KERNEL::Exception); + int keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair >& its) throw(INTERP_KERNEL::Exception); + public: + void allocNotFromFile(int newNbOfTuples) throw(INTERP_KERNEL::Exception); + bool allocIfNecessaryTheArrayToReceiveDataFromFile() throw(INTERP_KERNEL::Exception); + void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); + void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception); protected: - int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); int getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception); - public: - MEDFileField1TSWithoutSDA(); - MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector& infos); - DataArrayDouble *getOrCreateAndGetArray(); - const DataArrayDouble *getOrCreateAndGetArray() const; + int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); + void updateData(int newLgth, const std::vector< std::pair >& oldStartStops) throw(INTERP_KERNEL::Exception); protected: - std::string _dt_unit; - MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr; std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > > _field_per_mesh; int _iteration; int _order; @@ -472,33 +528,99 @@ namespace ParaMEDMEM public: //! only useable on reading mutable int _csit; - //! only useable on reading. 0 is for float, 1 for int32, 2 for int64 - mutable int _field_type; + // -3 means allocated and build from scratch + // -2 means allocated and read from a file + // -1 means not allocated and build from scratch + // >=0 means not allocated and read from a file + mutable int _nb_of_tuples_to_be_allocated; }; + class MEDFileIntField1TSWithoutSDA; + /*! - * User class. + * SDA is for Shared Data Arrays such as profiles. */ - class MEDLOADER_EXPORT MEDFileField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal + class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA { public: - static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool deepCpy); - static MEDFileField1TS *New(); - std::string simpleRepr() const; - void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception); - // - void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); - // direct forwarding to MEDFileField1TSWithoutSDA instance _content + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); + DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); + DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getUndergroundDataArrayDouble() const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getUndergroundDataArrayDoubleExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + std::vector< std::vector > getFieldSplitedByType2(const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); + static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception); + static std::vector CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception); + static MEDFileField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); public: - int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); + MEDFileField1TSWithoutSDA(); + MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); + MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception); + void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception); + DataArray *createNewEmptyDataArrayInstance() const; + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; + DataArrayDouble *getOrCreateAndGetArrayDouble(); + const DataArrayDouble *getOrCreateAndGetArrayDouble() const; + MEDFileIntField1TSWithoutSDA *convertToInt() const throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr; + public: + static const char TYPE_STR[]; + }; + + /*! + * SDA is for Shared Data Arrays such as profiles. + */ + class MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA + { + public: + MEDFileIntField1TSWithoutSDA(); + static MEDFileIntField1TSWithoutSDA *New(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); + MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception); + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); + DataArray *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); + DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + void setArray(DataArray *arr) throw(INTERP_KERNEL::Exception); + DataArray *createNewEmptyDataArrayInstance() const; + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; + DataArrayInt *getOrCreateAndGetArrayInt(); + const DataArrayInt *getOrCreateAndGetArrayInt() const; + DataArrayInt *getUndergroundDataArrayInt() const throw(INTERP_KERNEL::Exception); + DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + MEDFileField1TSWithoutSDA *convertToDouble() const throw(INTERP_KERNEL::Exception); + protected: + MEDFileIntField1TSWithoutSDA(const char *fieldName, int csit, int iteration, int order, const std::vector& infos); + protected: + MEDCouplingAutoRefCountObjectPtr< DataArrayInt > _arr; + public: + static const char TYPE_STR[]; + }; + + /*! + * User class. + */ + class MEDLOADER_EXPORT MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal + { + protected: + MEDFileAnyTypeField1TS(); + MEDFileAnyTypeField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent); + static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception); + void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content + public: + static MEDFileAnyTypeField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); int getDimension() const; int getIteration() const; int getOrder() const; @@ -506,8 +628,10 @@ namespace ParaMEDMEM void setTime(int iteration, int order, double val); std::string getName() const; void setName(const char *name); + std::string simpleRepr() const; void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; - const std::string& getDtUnit() const; + std::string getDtUnit() const throw(INTERP_KERNEL::Exception); + void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception); std::string getMeshName() const throw(INTERP_KERNEL::Exception); void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); @@ -518,146 +642,312 @@ namespace ParaMEDMEM std::pair getDtIt() const; void fillIteration(std::pair& p) const; void fillTypesOfFieldAvailable(std::vector& types) const throw(INTERP_KERNEL::Exception); + void setInfo(const std::vector& infos) throw(INTERP_KERNEL::Exception); const std::vector& getInfo() const; std::vector& getInfo(); - DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); - MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception); - const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception); - int getNonEmptyLevels(const char *mname, std::vector& levs) const throw(INTERP_KERNEL::Exception); std::vector getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); std::vector< std::vector > > getFieldSplitedByType(const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); - std::vector< std::vector > getFieldSplitedByType2(const char *mname, std::vector& types, std::vector< std::vector >& typesF, - std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); + MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception); + const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception); + int getNonEmptyLevels(const char *mname, std::vector& levs) const throw(INTERP_KERNEL::Exception); + public: + void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitComponents() const throw(INTERP_KERNEL::Exception); + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitDiscretizations() const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *deepCpy() const throw(INTERP_KERNEL::Exception); + int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception); + virtual MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0; public: //! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception); //! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception); - private: - void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; std::vector getLocsReallyUsedMulti() const; void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); - MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool deepCpy); - MEDFileField1TS(); + public: + static int LocateField2(med_idt fid, const char *fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception); + static int LocateField(med_idt fid, const char *fileName, const char *fieldName, int& posCFormat, med_field_type& typcha, std::vector& infos, std::string& dtunitOut) throw(INTERP_KERNEL::Exception); + public: + virtual med_field_type getMEDFileFieldType() const = 0; + MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase() throw(INTERP_KERNEL::Exception); + const MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase() const throw(INTERP_KERNEL::Exception); protected: - MEDCouplingAutoRefCountObjectPtr _content; + MEDCouplingAutoRefCountObjectPtr _content; + }; + + class MEDFileIntField1TS; + + /*! + * User class. + */ + class MEDLOADER_EXPORT MEDFileField1TS : public MEDFileAnyTypeField1TS + { + public: + static MEDFileField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent); + static MEDFileField1TS *New(); + MEDFileIntField1TS *convertToInt(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + // + MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception); + // + void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); + void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + // direct forwarding to MEDFileField1TSWithoutSDA instance _content + public: + MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + + std::vector< std::vector > getFieldSplitedByType2(const char *mname, std::vector& types, std::vector< std::vector >& typesF, + std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); + public: + static void SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr& arr) throw(INTERP_KERNEL::Exception); + static DataArrayDouble *ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr& arr) throw(INTERP_KERNEL::Exception); + private: + med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } + const MEDFileField1TSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception); + MEDFileField1TSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception); + private: + MEDFileField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileField1TS(); + }; + + class MEDLOADER_EXPORT MEDFileIntField1TS : public MEDFileAnyTypeField1TS + { + public: + static MEDFileIntField1TS *New(); + static MEDFileIntField1TS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileIntField1TS *New(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileIntField1TS *New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileField1TS *convertToDouble(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *shallowCpy() const throw(INTERP_KERNEL::Exception); + // + MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + DataArrayInt *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception); + // + void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception); + void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + DataArrayInt *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception); + public: + static DataArrayInt *ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr& arr) throw(INTERP_KERNEL::Exception); + private: + med_field_type getMEDFileFieldType() const { return MED_INT32; } + const MEDFileIntField1TSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception); + MEDFileIntField1TSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception); + private: + MEDFileIntField1TS(); + MEDFileIntField1TS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileIntField1TS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileIntField1TS(const char *fileName, const char *fieldName, int iteration, int order, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent); }; - class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA : public RefCountObject + class MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope { + protected: + MEDFileAnyTypeFieldMultiTSWithoutSDA(); + MEDFileAnyTypeFieldMultiTSWithoutSDA(const char *fieldName); + MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception); public: - static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, int id, int ft, const std::vector& infos, int nbOfStep) throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; + virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception); + virtual std::vector< MEDCouplingAutoRefCountObjectPtr > splitComponents() const throw(INTERP_KERNEL::Exception); + virtual std::vector< MEDCouplingAutoRefCountObjectPtr > splitDiscretizations() const throw(INTERP_KERNEL::Exception); + virtual const char *getTypeStr() const throw(INTERP_KERNEL::Exception) = 0; + virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0; + virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const throw(INTERP_KERNEL::Exception) = 0; + virtual MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception) = 0; + virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception) = 0; + const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); + void setInfo(const std::vector& info) throw(INTERP_KERNEL::Exception); + int getTimeStepPos(int iteration, int order) const throw(INTERP_KERNEL::Exception); + const MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception); + std::string getMeshName() const throw(INTERP_KERNEL::Exception); + void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); + bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); int getNumberOfTS() const; void eraseEmptyTS() throw(INTERP_KERNEL::Exception); void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception); - std::vector< std::pair > getIterations() const; + void eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds2(int bg, int end, int step) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const throw(INTERP_KERNEL::Exception); int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); + std::vector< std::pair > getIterations() const; + std::vector< std::pair > getTimeSteps(std::vector& ret1) const throw(INTERP_KERNEL::Exception); + void pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr& tse) throw(INTERP_KERNEL::Exception); + void synchronizeNameScope() throw(INTERP_KERNEL::Exception); + void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const; int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector& levs) const throw(INTERP_KERNEL::Exception); - std::vector< std::vector > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); + void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); + void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); std::vector< std::vector< std::pair > > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); - std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); - virtual void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception); - std::string getName() const; - void setName(const char *name); - void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const; - std::vector< std::pair > getTimeSteps(std::vector& ret1) const throw(INTERP_KERNEL::Exception); - std::string getMeshName() const throw(INTERP_KERNEL::Exception); - void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); - bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); - const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + std::vector< std::vector > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); + DataArray *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception); + DataArray *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); + void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll) throw(INTERP_KERNEL::Exception); + void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc) throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); public: - const MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception); - MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception); - const MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception); + const MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception); std::vector getPflsReallyUsed2() const; std::vector getLocsReallyUsed2() const; std::vector getPflsReallyUsedMulti2() const; std::vector getLocsReallyUsedMulti2() const; void changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); void changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + void setIteration(int i, MEDCouplingAutoRefCountObjectPtr ts) throw(INTERP_KERNEL::Exception); + protected: + virtual med_field_type getMEDFileFieldType() const = 0; + void copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr) throw(INTERP_KERNEL::Exception); + void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const throw(INTERP_KERNEL::Exception); + void checkThatComponentsMatch(const std::vector& compos) const throw(INTERP_KERNEL::Exception); + void checkThatNbOfCompoOfTSMatchThis() const throw(INTERP_KERNEL::Exception); + protected: + std::vector _infos; + std::vector< MEDCouplingAutoRefCountObjectPtr > _time_steps; + }; + + class MEDFileIntFieldMultiTSWithoutSDA; + + class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA + { + public: + static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception); + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const throw(INTERP_KERNEL::Exception); + std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTSWithoutSDA *convertToInt() const throw(INTERP_KERNEL::Exception); protected: - MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception); - std::string getDtUnit() const throw(INTERP_KERNEL::Exception); MEDFileFieldMultiTSWithoutSDA(const char *fieldName); - MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector& infos, int nbOfStep) throw(INTERP_KERNEL::Exception); - void finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception); - void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception); + MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception); + med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } + MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception); + void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception); public: MEDFileFieldMultiTSWithoutSDA(); - protected: - std::string _name; - std::vector _infos; - //! only useable on reading. 0 is for float, 1 for int32, 2 for int64 - mutable int _field_type; - std::vector< MEDCouplingAutoRefCountObjectPtr > _time_steps; }; - class MEDFileFieldMultiTSIterator; + class MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA + { + public: + static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll) throw(INTERP_KERNEL::Exception); + const char *getTypeStr() const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const throw(INTERP_KERNEL::Exception); + MEDFileFieldMultiTSWithoutSDA *convertToDouble() const throw(INTERP_KERNEL::Exception); + protected: + MEDFileIntFieldMultiTSWithoutSDA(const char *fieldName); + MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll) throw(INTERP_KERNEL::Exception); + med_field_type getMEDFileFieldType() const { return MED_INT32; } + MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const throw(INTERP_KERNEL::Exception); + void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const throw(INTERP_KERNEL::Exception); + public: + MEDFileIntFieldMultiTSWithoutSDA(); + }; + class MEDFileAnyTypeFieldMultiTSIterator; + class MEDFileFastCellSupportComparator; /*! * User class. */ - class MEDLOADER_EXPORT MEDFileFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal + class MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal { + protected: + MEDFileAnyTypeFieldMultiTS(); + MEDFileAnyTypeFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); + static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const char *fileName) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); public: - static MEDFileFieldMultiTS *New(); - static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception); - static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); - static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy); - // - MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception); - MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); - MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTSIterator *iterator() throw(INTERP_KERNEL::Exception); - // - std::string simpleRepr() const; + static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileAnyTypeFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); - MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; + virtual MEDFileAnyTypeFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > splitComponents() const throw(INTERP_KERNEL::Exception); + std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > splitDiscretizations() const throw(INTERP_KERNEL::Exception); + virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception) = 0; + virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception) = 0; // - void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception) = 0; + MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); + static std::vector< std::vector > SplitIntoCommonTimeSeries(const std::vector& vectFMTS) throw(INTERP_KERNEL::Exception); + static std::vector< std::vector > SplitPerCommonSupport(const std::vector& vectFMTS, const MEDFileMesh *mesh) throw(INTERP_KERNEL::Exception); + static int CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1) throw(INTERP_KERNEL::Exception); public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content + std::string getName() const; + void setName(const char *name); + std::string getDtUnit() const throw(INTERP_KERNEL::Exception); + void setDtUnit(const char *dtUnit) throw(INTERP_KERNEL::Exception); + std::string getMeshName() const throw(INTERP_KERNEL::Exception); + void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); + std::string simpleRepr() const; + void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const; int getNumberOfTS() const; void eraseEmptyTS() throw(INTERP_KERNEL::Exception); void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception); + void eraseTimeStepIds2(int bg, int end, int step) throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTS *buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTS *buildSubPartSlice(int bg, int end, int step) const throw(INTERP_KERNEL::Exception); + std::vector< std::pair > getTimeSteps(std::vector& ret1) const throw(INTERP_KERNEL::Exception); std::vector< std::pair > getIterations() const; + void pushBackTimeSteps(const std::vector& f1ts) throw(INTERP_KERNEL::Exception); + void pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts) throw(INTERP_KERNEL::Exception); + void synchronizeNameScope() throw(INTERP_KERNEL::Exception); int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTSIterator *iterator() throw(INTERP_KERNEL::Exception); + bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); + const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); + void setInfo(const std::vector& info) throw(INTERP_KERNEL::Exception); + int getNumberOfComponents() const throw(INTERP_KERNEL::Exception); int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector& levs) const throw(INTERP_KERNEL::Exception); std::vector< std::vector > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception); std::vector< std::vector< std::pair > > getFieldSplitedByType(int iteration, int order, const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); -std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); - std::string getName() const; - void setName(const char *name); - void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const; - std::vector< std::pair > getTimeSteps(std::vector& ret1) const throw(INTERP_KERNEL::Exception); - std::string getMeshName() const throw(INTERP_KERNEL::Exception); - void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception); - bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); - const std::vector& getInfo() const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception); - DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + MEDCouplingAutoRefCountObjectPtr getContent(); public: std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; @@ -665,25 +955,101 @@ std::vector< std::vector > getFieldSplitedByType2(int iterati std::vector getLocsReallyUsedMulti() const; void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); + protected: + MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() throw(INTERP_KERNEL::Exception); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() const throw(INTERP_KERNEL::Exception); + private: + static std::vector< std::vector > SplitPerCommonSupportNotNodesAlg(const std::vector& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr >& cmps) throw(INTERP_KERNEL::Exception); + protected: + MEDCouplingAutoRefCountObjectPtr _content; + }; + + class MEDFileIntFieldMultiTS; + + /*! + * User class. + */ + class MEDLOADER_EXPORT MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { public: - MEDCouplingAutoRefCountObjectPtr getContent(); + static MEDFileFieldMultiTS *New(); + static MEDFileFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception); + void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTS *convertToInt(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + // + MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception); + // + MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception); + // + void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); + void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); +std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const char *mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception); + DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const throw(INTERP_KERNEL::Exception); + private: + const MEDFileFieldMultiTSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception); + MEDFileFieldMultiTSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception); private: MEDFileFieldMultiTS(); - MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool deepCpy); - MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); - protected: - MEDCouplingAutoRefCountObjectPtr _content; + MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); }; - class MEDCOUPLING_EXPORT MEDFileFieldMultiTSIterator + /*! + * User class. + */ + class MEDLOADER_EXPORT MEDFileIntFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { + public: + static MEDFileIntFieldMultiTS *New(); + static MEDFileIntFieldMultiTS *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileIntFieldMultiTS *New(const char *fileName, const char *fieldName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + static MEDFileIntFieldMultiTS *New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileAnyTypeFieldMultiTS *shallowCpy() const throw(INTERP_KERNEL::Exception); + void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception); + MEDFileFieldMultiTS *convertToDouble(bool deepCpyGlobs=true) const throw(INTERP_KERNEL::Exception); + // + MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const char *mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const throw(INTERP_KERNEL::Exception); + DataArrayInt *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception); + // + void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals) throw(INTERP_KERNEL::Exception); + void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception); + // + DataArrayInt *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception); + private: + const MEDFileIntFieldMultiTSWithoutSDA *contentNotNull() const throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTSWithoutSDA *contentNotNull() throw(INTERP_KERNEL::Exception); + private: + MEDFileIntFieldMultiTS(); + MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); + MEDFileIntFieldMultiTS(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); + MEDFileIntFieldMultiTS(const char *fileName, const char *fieldName, bool loadAll) throw(INTERP_KERNEL::Exception); + }; + + class MEDCOUPLING_EXPORT MEDFileAnyTypeFieldMultiTSIterator { public: - MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts); - ~MEDFileFieldMultiTSIterator(); - MEDFileField1TS *nextt(); + MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts); + ~MEDFileAnyTypeFieldMultiTSIterator(); + MEDFileAnyTypeField1TS *nextt() throw(INTERP_KERNEL::Exception); private: - MEDCouplingAutoRefCountObjectPtr _fmts; + MEDCouplingAutoRefCountObjectPtr _fmts; int _iter_id; int _nb_iter; }; @@ -697,26 +1063,40 @@ std::vector< std::vector > getFieldSplitedByType2(int iterati { public: static MEDFileFields *New(); - static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception); + static MEDFileFields *New(const char *fileName, bool loadAll=true) throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySize() const; + MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception); + MEDFileFields *shallowCpy() const throw(INTERP_KERNEL::Exception); void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception); void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); + void loadArrays() throw(INTERP_KERNEL::Exception); + void loadArraysIfNecessary() throw(INTERP_KERNEL::Exception); + void releaseArrays() throw(INTERP_KERNEL::Exception); int getNumberOfFields() const; + std::vector< std::pair > getCommonIterations(bool& areThereSomeForgottenTS) const throw(INTERP_KERNEL::Exception); std::vector getFieldsNames() const throw(INTERP_KERNEL::Exception); std::vector getMeshesNames() const throw(INTERP_KERNEL::Exception); std::string simpleRepr() const; void simpleRepr(int bkOffset, std::ostream& oss) const; // void resize(int newSize) throw(INTERP_KERNEL::Exception); - void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception); - void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception); + void pushField(MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception); + void pushFields(const std::vector& fields) throw(INTERP_KERNEL::Exception); + void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field) throw(INTERP_KERNEL::Exception); + int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception); + MEDFileAnyTypeFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception); + MEDFileFields *buildSubPart(const int *startIds, const int *endIds) const throw(INTERP_KERNEL::Exception); + MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const char *meshName) const throw(INTERP_KERNEL::Exception); + MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const throw(INTERP_KERNEL::Exception); + MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const throw(INTERP_KERNEL::Exception); MEDFileFieldsIterator *iterator() throw(INTERP_KERNEL::Exception); void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception); + void destroyFieldsAtPos(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception); + void destroyFieldsAtPos2(int bg, int end, int step) throw(INTERP_KERNEL::Exception); bool changeMeshNames(const std::vector< std::pair >& modifTab) throw(INTERP_KERNEL::Exception); bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception); - private: - int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception); + public: std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; @@ -725,9 +1105,9 @@ std::vector< std::vector > getFieldSplitedByType2(int iterati void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); private: MEDFileFields(); - MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception); + MEDFileFields(const char *fileName, bool loadAll) throw(INTERP_KERNEL::Exception); private: - std::vector< MEDCouplingAutoRefCountObjectPtr > _fields; + std::vector< MEDCouplingAutoRefCountObjectPtr > _fields; }; class MEDCOUPLING_EXPORT MEDFileFieldsIterator @@ -735,7 +1115,7 @@ std::vector< std::vector > getFieldSplitedByType2(int iterati public: MEDFileFieldsIterator(MEDFileFields *fs); ~MEDFileFieldsIterator(); - MEDFileFieldMultiTS *nextt(); + MEDFileAnyTypeFieldMultiTS *nextt(); private: MEDCouplingAutoRefCountObjectPtr _fs; int _iter_id;