X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileField.hxx;h=c39bfdafdffd61fb68b1a43225e73b1bcccc0825;hb=3531e8f47b047f0176ec094e51ab2474284f3cd9;hp=fc98cbcda9112d8a0fa242c107c640eb2e562b65;hpb=0511285d155a0682ff6dad10ac916ac53f577476;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileField.hxx b/src/MEDLoader/MEDFileField.hxx index fc98cbcda..c39bfdafd 100644 --- a/src/MEDLoader/MEDFileField.hxx +++ b/src/MEDLoader/MEDFileField.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2012 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public // License as published by the Free Software Foundation; either -// version 2.1 of the License. +// version 2.1 of the License, or (at your option) any later version. // // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -16,18 +16,24 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// Author : Anthony Geay (CEA/DEN) +// Author : Anthony Geay (EDF R&D) #ifndef __MEDFILEFIELD_HXX__ #define __MEDFILEFIELD_HXX__ #include "MEDLoaderDefines.hxx" -#include "MEDFileUtilities.hxx" +#include "MEDFileFieldOverView.hxx" +#include "MEDFileUtilities.txx" +#include "MEDFileEntities.hxx" -#include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include "MCAuto.hxx" +#include "MEDLoaderTraits.hxx" +#include "MEDCouplingTraits.hxx" #include "MEDCouplingRefCountObject.hxx" +#include "MEDCouplingFieldInt.hxx" #include "MEDCouplingMemArray.hxx" +#include "MEDCouplingPartDefinition.hxx" #include "NormalizedUnstructuredMesh.hxx" #include "InterpKernelException.hxx" @@ -39,119 +45,175 @@ #include "med.h" -namespace ParaMEDMEM +namespace MEDCoupling { class MEDFileFieldGlobs; class MEDCouplingMesh; class MEDCouplingFieldDouble; class MEDFileMesh; + class MEDFileFieldVisitor; + class MEDFileGTKeeper + { + public: + virtual MEDFileGTKeeper *deepCopy() const = 0; + virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0; + virtual std::string getRepr() const = 0; + virtual bool isEqual(const MEDFileGTKeeper *other) const = 0; + virtual ~MEDFileGTKeeper(); + }; + + class MEDFileGTKeeperSta : public MEDFileGTKeeper + { + public: + MEDFileGTKeeperSta(INTERP_KERNEL::NormalizedCellType gt):_geo_type(gt) { } + MEDFileGTKeeper *deepCopy() const; + INTERP_KERNEL::NormalizedCellType getGeoType() const; + std::string getRepr() const; + bool isEqual(const MEDFileGTKeeper *other) const; + private: + INTERP_KERNEL::NormalizedCellType _geo_type; + }; + + + class MEDFileGTKeeperDyn : public MEDFileGTKeeper + { + public: + MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se); + MEDFileGTKeeper *deepCopy() const; + INTERP_KERNEL::NormalizedCellType getGeoType() const; + std::string getRepr() const; + bool isEqual(const MEDFileGTKeeper *other) const; + const MEDFileUMesh *getMesh() const { return _mesh; } + const MEDFileUMesh *getSection() const { return _section; } + const MEDFileStructureElement *getSE() const { return _se; } + private: + MCConstAuto _mesh; + MCConstAuto _section; + MCConstAuto _se; + }; + class MEDFileFieldLoc : public RefCountObject { public: - void MEDLOADER_EXPORT simpleRepr(std::ostream& oss) const; - const MEDLOADER_EXPORT std::string& 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; - bool MEDLOADER_EXPORT isName(const char *name) const { return _name==name; } - int MEDLOADER_EXPORT getDimension() const { return _dim; } - int MEDLOADER_EXPORT getNumberOfGaussPoints() const { return _nb_gauss_pt; } - int MEDLOADER_EXPORT getNumberOfPointsInCells() const { return _nb_node_per_cell; } - const MEDLOADER_EXPORT std::vector& getRefCoords() const { return _ref_coo; } - const MEDLOADER_EXPORT std::vector& getGaussCoords() const { return _gs_coo; } - const MEDLOADER_EXPORT std::vector& getGaussWeights() const { return _w; } - bool MEDLOADER_EXPORT isEqual(const MEDFileFieldLoc& other, double eps) const; + MEDLOADER_EXPORT void simpleRepr(std::ostream& oss) const; + MEDLOADER_EXPORT std::string getName() const { return _name; } + MEDLOADER_EXPORT void setName(const std::string& name); + static MEDFileFieldLoc *New(med_idt fid, const std::string& locName); + static MEDFileFieldLoc *New(med_idt fid, int i, const MEDFileEntities *entities); + static MEDFileFieldLoc *New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; + MEDFileFieldLoc *deepCopy() const; + bool isOnStructureElement() const; + const MEDFileGTKeeper *getUndergroundGTKeeper() const { return _gt; } + MEDLOADER_EXPORT int getNbOfGaussPtPerCell() const { return _nb_gauss_pt; } + MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT std::string repr() const; + MEDLOADER_EXPORT bool isName(const std::string& name) const { return _name==name; } + MEDLOADER_EXPORT int getDimension() const { return _dim; } + MEDLOADER_EXPORT int getNumberOfGaussPoints() const { return _nb_gauss_pt; } + MEDLOADER_EXPORT int getNumberOfPointsInCells() const { return _nb_node_per_cell; } + MEDLOADER_EXPORT const std::vector& getRefCoords() const { return _ref_coo; } + MEDLOADER_EXPORT const std::vector& getGaussCoords() const { return _gs_coo; } + MEDLOADER_EXPORT const std::vector& getGaussWeights() const { return _w; } + MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _gt->getGeoType(); } + MEDLOADER_EXPORT bool isEqual(const MEDFileFieldLoc& other, double eps) const; private: - MEDFileFieldLoc(med_idt fid, const char *locName); - MEDFileFieldLoc(med_idt fid, int id); - MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); + MEDFileFieldLoc(const MEDFileFieldLoc& other); + MEDFileFieldLoc(med_idt fid, const std::string& locName); + MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities); + MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); private: int _dim; int _nb_gauss_pt; + INTERP_KERNEL::AutoCppPtr _gt; int _nb_node_per_cell; std::string _name; - INTERP_KERNEL::NormalizedCellType _geo_type; std::vector _ref_coo; std::vector _gs_coo; std::vector _w; }; -/// @cond INTERNAL + /// @cond INTERNAL + class MEDFileAnyTypeField1TSWithoutSDA; + class MEDFileFieldPerMeshPerTypeCommon; class MEDFileFieldPerMeshPerType; class MEDFileField1TSWithoutSDA; + class MEDFileFieldNameScope; class MEDFileFieldGlobsReal; class MEDFileFieldPerMesh; class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable { public: - static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception); - static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId); + static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd); + static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int locId); static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other); - 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, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, 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 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); - 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 setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; + MEDFileFieldPerMeshPerTypePerDisc *deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const; + void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob); + void getCoarseData(TypeOfField& type, std::pair& dad, std::string& pfl, std::string& loc) const; + void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const; + const MEDFileFieldPerMeshPerTypeCommon *getFather() const; + void loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc); + void loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc); + void setNewStart(int newValueOfStart); 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; - void fillTypesOfFieldAvailable(std::set& types) const throw(INTERP_KERNEL::Exception); + void fillTypesOfFieldAvailable(std::set& types) const; void setType(TypeOfField newType); INTERP_KERNEL::NormalizedCellType getGeoType() const; int getNumberOfComponents() const; int getNumberOfTuples() const; int getStart() const { return _start; } - DataArrayDouble *getArray(); - const DataArrayDouble *getArray() const; + int getEnd() const { return _end; } + void setEnd(int endd) { _end=endd; } + int getNumberOfVals() const { return _nval; } + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; const std::vector& getInfo() const; std::string getProfile() const; - void setProfile(const char *newPflName); + void setProfile(const std::string& newPflName); std::string getLocalization() const; - void setLocalization(const char *newLocName); + void setLocalization(const std::string& newLocName); int getLocId() const { return _loc_id; } void setLocId(int newId) const { _loc_id=newId; } - void setFather(MEDFileFieldPerMeshPerType *newFather) { _father=newFather; } - 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); + void setFather(MEDFileFieldPerMeshPerTypeCommon *newFather) { _father=newFather; } + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); void getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; void fillValues(int discId, int& startEntryId, std::vector< std::pair,std::pair > >& entries) const; - int fillEltIdsFromCode(int offset, const std::vector& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception); - int fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception); - static int ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception); + int fillEltIdsFromCode(int offset, const std::vector& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const; + int fillTupleIds(int *ptToFill) const; + static int ConvertType(TypeOfField type, int locId); static std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries); static bool RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc, const DataArrayInt *explicitIdsInMesh, const std::vector& newCode, - MEDFileFieldGlobsReal& glob, DataArrayDouble *arr, std::vector< MEDCouplingAutoRefCountObjectPtr >& result); + MEDFileFieldGlobsReal& glob, DataArrayDouble *arr, std::vector< MCAuto >& result); static MEDFileFieldPerMeshPerTypePerDisc *NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt, bool isPfl, int nbi, int offset, std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc, - MEDFileFieldGlobsReal& glob, bool ¬InExisting) throw(INTERP_KERNEL::Exception); + MEDFileFieldGlobsReal& glob, bool ¬InExisting); + static MCAuto Aggregate(int &start, const std::vector >& pms, const std::vector< std::vector< std::pair > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector > >& extractInfo); + MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type):_type(type),_father(fath),_start(-1),_end(-1),_nval(-1),_loc_id(-5),_profile_it(-1) { } private: - MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception); - MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const std::string& dummy); + MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd); + MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const std::string& dummy); MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other); MEDFileFieldPerMeshPerTypePerDisc(); + private: + void goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr); private: TypeOfField _type; - MEDFileFieldPerMeshPerType *_father; + MEDFileFieldPerMeshPerTypeCommon *_father; int _start; int _end; //! _nval is different than end-start in case of ON_GAUSS_PT and ON_GAUSS_NE ! (_nval=(_end-_start)/nbi) @@ -160,135 +222,202 @@ 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; + MCAuto _pd; public: mutable int _tmp_work1; }; - class MEDFileFieldPerMeshPerType : public RefCountObject, public MEDFileWritable + class MEDFileFieldPerMeshPerTypeCommon : public RefCountObject, public MEDFileWritable { 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); - 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, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception); - void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, 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); + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; + void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignFieldProfile(bool isPflAlone, int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); + void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); 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 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); + void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc); + void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc); + void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const; + bool isUniqueLevel(int& dim) const; + void fillTypesOfFieldAvailable(std::set& types) const; + void fillFieldSplitedByType(std::vector< std::pair >& dads, std::vector& types, std::vector& pfls, std::vector& locs) const; 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; + bool presenceOfMultiDiscPerGeoType() const; + void pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc); + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; const std::vector& getInfo() 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); - MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception); - const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception); - 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 changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId); + const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) const; + int getNumberOfLoc() const { return _field_pm_pt_pd.size(); } void fillValues(int& startEntryId, std::vector< std::pair,std::pair > >& entries) const; - void setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception); + void setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves); + bool keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair >& its); + bool keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair >& its); 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(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception); + MEDFileFieldPerMeshPerTypeCommon(MEDFileFieldPerMesh *father):_father(father) { } + void setFather(MEDFileFieldPerMesh *father); + void accept(MEDFileFieldVisitor& visitor) const; + public: + virtual ~MEDFileFieldPerMeshPerTypeCommon(); + virtual void getDimension(int& dim) const = 0; + virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0; + virtual void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const = 0; + virtual void simpleRepr(int bkOffset, std::ostream& oss, int id) const = 0; + virtual std::string getGeoTypeRepr() const = 0; + virtual MEDFileFieldPerMeshPerTypeCommon *deepCopy(MEDFileFieldPerMesh *father) const = 0; + virtual void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const = 0; + protected: + void deepCopyElements(); + std::vector addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells); + std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, int offset, int nbOfCells); + std::vector addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells); + std::vector addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayInt *subCells); private: MEDFileFieldPerMesh *_father; - std::vector< MEDCouplingAutoRefCountObjectPtr > _field_pm_pt_pd; + protected: + std::vector< MCAuto > _field_pm_pt_pd; + }; + + class MEDFileFieldPerMeshPerType : public MEDFileFieldPerMeshPerTypeCommon + { + public: + static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType); + static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); + static MCAuto Aggregate(int &start, const std::vector< std::pair >& pms, const std::vector< std::vector< std::pair > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector > >& extractInfo); + public:// overload of abstract methods + void getDimension(int& dim) const; + INTERP_KERNEL::NormalizedCellType getGeoType() const; + void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const; + void simpleRepr(int bkOffset, std::ostream& oss, int id) const; + std::string getGeoTypeRepr() const; + MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const; + void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; + private: + MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd); + MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt); + private: INTERP_KERNEL::NormalizedCellType _geo_type; }; + class MEDFileFieldPerMeshPerTypeDyn : public MEDFileFieldPerMeshPerTypeCommon + { + public: + static MEDFileFieldPerMeshPerTypeDyn *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc); + int getDynGT() const; + std::string getModelName() const; + public: + void getDimension(int& dim) const; + INTERP_KERNEL::NormalizedCellType getGeoType() const; + void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const; + void simpleRepr(int bkOffset, std::ostream& oss, int id) const; + std::string getGeoTypeRepr() const; + MEDFileFieldPerMeshPerTypeDyn *deepCopy(MEDFileFieldPerMesh *father) const; + void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair >& dads, std::vector& pfls, std::vector& locs, std::vector& geoTypes) const; + private: + MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc); + private: + MCConstAuto _se; + }; + + class MEDFileMesh; + 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); - std::size_t getHeapMemorySize() const; - MEDFileFieldPerMesh *deepCpy(MEDFileField1TSWithoutSDA *_father) const 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, const MEDFileMesh *mm, const MEDFileEntities *entities); + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; + MEDFileFieldPerMesh *deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const; 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& code2, 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 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 copyTinyInfoFrom(const MEDCouplingMesh *mesh); + void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector& code, const std::vector& code2, const std::vector& idsInPflPerType, const std::vector& idsPerType, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignFieldNoProfileNoRenum(int& start, const std::vector& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); + void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc); + void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc); + void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const; + void fillTypesOfFieldAvailable(std::set& types) const; + 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; + void accept(MEDFileFieldVisitor& visitor) const; void getDimension(int& dim) const; + bool isUniqueLevel(int& dim) const; double getTime() const; int getIteration() const; 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; } + std::string getMeshName() const; + void setMeshName(const std::string& meshName); int getNumberOfComponents() const; - DataArrayDouble *getArray(); - const DataArrayDouble *getArray() const; + bool presenceOfMultiDiscPerGeoType() const; + bool presenceOfStructureElements() const; + bool onlyStructureElements() const; + void killStructureElements(); + void keepOnlyStructureElements(); + void keepOnlyOnSE(const std::string& seName); + void getMeshSENames(std::vector< std::pair >& ps) const; + DataArray *getOrCreateAndGetArray(); + const DataArray *getOrCreateAndGetArray() const; const std::vector& getInfo() const; std::vector getPflsReallyUsed() const; std::vector getLocsReallyUsed() const; std::vector getPflsReallyUsedMulti() const; 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 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); - 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); + void convertMedBallIntoClassic(); + bool changeMeshNames(const std::vector< std::pair >& modifTab); + bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob); + void keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair >& its); + void keepOnlyGaussDiscretization(std::size_t idOfDisc, int &globalNum, std::vector< std::pair >& its); + void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; + DataArray *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const; + void getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId); + const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const; + static MCAuto Aggregate(int &start, const std::vector& pms, const std::vector< std::vector< std::pair > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector > >& extractInfo); 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, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; 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); + const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; MEDCouplingFieldDouble *finishFieldNode2(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); - void assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception); + const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; + DataArray *finishField4(const std::vector< std::pair >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const; + void assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves); 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); + static int ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector& geoTypes, const std::vector< std::pair >& dads, const std::vector& locs); + MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities); + MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh); + MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const std::string& meshName, int meshIt, int meshOrd):_father(fath),_mesh_iteration(meshIt),_mesh_order(meshOrd) { } private: - std::string _mesh_name; int _mesh_iteration; int _mesh_order; - int _mesh_csit; - MEDFileField1TSWithoutSDA *_father; - std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > _field_pm_pt; + MEDFileAnyTypeField1TSWithoutSDA *_father; + std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > _field_pm_pt; }; class MEDFileFieldGlobsReal; @@ -296,473 +425,1044 @@ namespace ParaMEDMEM class MEDFileFieldGlobs : public RefCountObject { public: - static MEDFileFieldGlobs *New(const char *fname); + static MEDFileFieldGlobs *New(med_idt fid); static MEDFileFieldGlobs *New(); - std::size_t getHeapMemorySize() const; - MEDFileFieldGlobs *deepCpy() const throw(INTERP_KERNEL::Exception); + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; + MEDFileFieldGlobs *deepCopy() const; + MEDFileFieldGlobs *shallowCpyPart(const std::vector& pfls, const std::vector& locs) const; + MEDFileFieldGlobs *deepCpyPart(const std::vector& pfls, const std::vector& locs) const; void simpleRepr(std::ostream& oss) const; - void appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception); - void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception); + void appendGlobs(const MEDFileFieldGlobs& other, double eps); + void checkGlobsPflsPartCoherency(const std::vector& pflsUsed) const; + void checkGlobsLocsPartCoherency(const std::vector& locsUsed) const; + void loadProfileInFile(med_idt fid, int id, const std::string& pflName); void loadProfileInFile(med_idt fid, int id); - void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception); - void loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception); - void writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception); + void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real); + void loadAllGlobals(med_idt fid, const MEDFileEntities *entities); + void writeGlobals(med_idt fid, const MEDFileWritable& opt) const; std::vector getPfls() const; std::vector getLocs() const; - bool existsPfl(const char *pflName) const; - bool existsLoc(const char *locName) const; - std::string createNewNameOfPfl() const throw(INTERP_KERNEL::Exception); - std::string createNewNameOfLoc() const throw(INTERP_KERNEL::Exception); + bool existsPfl(const std::string& pflName) const; + bool existsLoc(const std::string& locName) const; + std::string createNewNameOfPfl() const; + std::string createNewNameOfLoc() const; std::vector< std::vector > whichAreEqualProfiles() const; std::vector< std::vector > whichAreEqualLocs(double eps) const; - void setFileName(const char *fileName); - void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception); - int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception); - const char *getFileName() const { return _file_name.c_str(); } - std::string getFileName2() const { return _file_name; } - const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception); - const MEDFileFieldLoc& getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception); - const DataArrayInt *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception); - const DataArrayInt *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception); - MEDFileFieldLoc& getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception); - MEDFileFieldLoc& getLocalization(const char *locName) throw(INTERP_KERNEL::Exception); - DataArrayInt *getProfile(const char *pflName) throw(INTERP_KERNEL::Exception); - DataArrayInt *getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception); - void killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception); - void killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception); + void setFileName(const std::string& fileName) { _file_name=fileName; } + void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif); + void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif); + int getNbOfGaussPtPerCell(int locId) const; + int getLocalizationId(const std::string& loc) const; + std::string getFileName() const { return _file_name; } + const MEDFileFieldLoc& getLocalizationFromId(int locId) const; + const MEDFileFieldLoc& getLocalization(const std::string& locName) const; + const DataArrayInt *getProfileFromId(int pflId) const; + const DataArrayInt *getProfile(const std::string& pflName) const; + MEDFileFieldLoc& getLocalizationFromId(int locId); + MEDFileFieldLoc& getLocalization(const std::string& locName); + DataArrayInt *getProfile(const std::string& pflName); + DataArrayInt *getProfileFromId(int pflId); + void killProfileIds(const std::vector& pflIds); + void killLocalizationIds(const std::vector& locIds); + void killStructureElementsInGlobs(); // - 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); + void appendProfile(DataArrayInt *pfl); + void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); // - static std::string CreateNewNameNotIn(const char *prefix, const std::vector& namesToAvoid) throw(INTERP_KERNEL::Exception); + static std::string CreateNewNameNotIn(const std::string& prefix, const std::vector& namesToAvoid); protected: - MEDFileFieldGlobs(const char *fname); + MEDFileFieldGlobs(med_idt fid); MEDFileFieldGlobs(); ~MEDFileFieldGlobs(); protected: - std::vector< MEDCouplingAutoRefCountObjectPtr > _pfls; - std::vector< MEDCouplingAutoRefCountObjectPtr > _locs; + std::vector< MCAuto > _pfls; + std::vector< MCAuto > _locs; std::string _file_name; }; -/// @endcond INTERNAL + /// @endcond INTERNAL - class MEDLOADER_EXPORT MEDFileFieldGlobsReal + class MEDFileFieldGlobsReal { public: - MEDFileFieldGlobsReal(const char *fname); - MEDFileFieldGlobsReal(); - std::size_t getHeapMemorySize() const; - void simpleRepr(std::ostream& oss) const; - void shallowCpyGlobs(const MEDFileFieldGlobsReal& other); - void deepCpyGlobs(const MEDFileFieldGlobsReal& other); - void appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception); - virtual std::vector getPflsReallyUsed() const = 0; - virtual std::vector getLocsReallyUsed() const = 0; - virtual std::vector getPflsReallyUsedMulti() const = 0; - virtual std::vector getLocsReallyUsedMulti() const = 0; - virtual void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) = 0; - virtual void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) = 0; - virtual ~MEDFileFieldGlobsReal(); + MEDLOADER_EXPORT MEDFileFieldGlobsReal(med_idt fid); + MEDLOADER_EXPORT MEDFileFieldGlobsReal(); + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT void simpleReprGlobs(std::ostream& oss) const; + MEDLOADER_EXPORT void resetContent(); + MEDLOADER_EXPORT void killStructureElementsInGlobs(); + MEDLOADER_EXPORT void shallowCpyGlobs(const MEDFileFieldGlobsReal& other); + MEDLOADER_EXPORT void deepCpyGlobs(const MEDFileFieldGlobsReal& other); + MEDLOADER_EXPORT void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other); + MEDLOADER_EXPORT void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other); + MEDLOADER_EXPORT void appendGlobs(const MEDFileFieldGlobsReal& other, double eps); + MEDLOADER_EXPORT void checkGlobsCoherency() const; + MEDLOADER_EXPORT void checkGlobsPflsPartCoherency() const; + MEDLOADER_EXPORT void checkGlobsLocsPartCoherency() const; + MEDLOADER_EXPORT virtual std::vector getPflsReallyUsed() const = 0; + MEDLOADER_EXPORT virtual std::vector getLocsReallyUsed() const = 0; + MEDLOADER_EXPORT virtual std::vector getPflsReallyUsedMulti() const = 0; + MEDLOADER_EXPORT virtual std::vector getLocsReallyUsedMulti() const = 0; + MEDLOADER_EXPORT virtual void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) = 0; + MEDLOADER_EXPORT virtual void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif) = 0; + MEDLOADER_EXPORT virtual ~MEDFileFieldGlobsReal(); // - 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) throw(INTERP_KERNEL::Exception); - void loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception); - void writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception); - std::vector getPfls() const; - std::vector getLocs() const; - bool existsPfl(const char *pflName) const; - bool existsLoc(const char *locName) const; - std::string createNewNameOfPfl() const throw(INTERP_KERNEL::Exception); - std::string createNewNameOfLoc() const throw(INTERP_KERNEL::Exception); - std::vector< std::vector > whichAreEqualProfiles() const; - std::vector< std::vector > whichAreEqualLocs(double eps) const; - void setFileName(const char *fileName); - void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - void changePflsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - void changeLocsNames(const std::vector< std::pair, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception); - void changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); - void changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception); - std::vector< std::pair, std::string > > zipPflsNames() throw(INTERP_KERNEL::Exception); - std::vector< std::pair, std::string > > zipLocsNames(double eps) throw(INTERP_KERNEL::Exception); - int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception); - int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception); - const char *getFileName() const; - std::string getFileName2() const; - const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception); - const MEDFileFieldLoc& getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception); - MEDFileFieldLoc& getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception); - MEDFileFieldLoc& getLocalization(const char *locName) throw(INTERP_KERNEL::Exception); - const DataArrayInt *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception); - const DataArrayInt *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception); - DataArrayInt *getProfile(const char *pflName) throw(INTERP_KERNEL::Exception); - DataArrayInt *getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception); - void killProfileIds(const std::vector& pflIds) throw(INTERP_KERNEL::Exception); - void killLocalizationIds(const std::vector& locIds) throw(INTERP_KERNEL::Exception); + MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const std::string& pflName); + MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id); + MEDLOADER_EXPORT void loadGlobals(med_idt fid); + MEDLOADER_EXPORT void loadAllGlobals(med_idt fid, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT void writeGlobals(med_idt fid, const MEDFileWritable& opt) const; + MEDLOADER_EXPORT std::vector getPfls() const; + MEDLOADER_EXPORT std::vector getLocs() const; + MEDLOADER_EXPORT bool existsPfl(const std::string& pflName) const; + MEDLOADER_EXPORT bool existsLoc(const std::string& locName) const; + MEDLOADER_EXPORT std::string createNewNameOfPfl() const; + MEDLOADER_EXPORT std::string createNewNameOfLoc() const; + MEDLOADER_EXPORT std::vector< std::vector > whichAreEqualProfiles() const; + MEDLOADER_EXPORT std::vector< std::vector > whichAreEqualLocs(double eps) const; + MEDLOADER_EXPORT void setFileName(const std::string& fileName); + MEDLOADER_EXPORT void changePflsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changeLocsNamesInStruct(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changePflsNames(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changeLocsNames(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changePflName(const std::string& oldName, const std::string& newName); + MEDLOADER_EXPORT void changeLocName(const std::string& oldName, const std::string& newName); + MEDLOADER_EXPORT std::vector< std::pair, std::string > > zipPflsNames(); + MEDLOADER_EXPORT std::vector< std::pair, std::string > > zipLocsNames(double eps); + MEDLOADER_EXPORT int getNbOfGaussPtPerCell(int locId) const; + MEDLOADER_EXPORT int getLocalizationId(const std::string& loc) const; + MEDLOADER_EXPORT std::string getFileName() const; + MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalizationFromId(int locId) const; + MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalization(const std::string& locName) const; + MEDLOADER_EXPORT MEDFileFieldLoc& getLocalizationFromId(int locId); + MEDLOADER_EXPORT MEDFileFieldLoc& getLocalization(const std::string& locName); + MEDLOADER_EXPORT const DataArrayInt *getProfile(const std::string& pflName) const; + MEDLOADER_EXPORT const DataArrayInt *getProfileFromId(int pflId) const; + MEDLOADER_EXPORT DataArrayInt *getProfile(const std::string& pflName); + MEDLOADER_EXPORT DataArrayInt *getProfileFromId(int pflId); + MEDLOADER_EXPORT void killProfileIds(const std::vector& pflIds); + MEDLOADER_EXPORT void killLocalizationIds(const std::vector& locIds); // - 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); + MEDLOADER_EXPORT void appendProfile(DataArrayInt *pfl); + MEDLOADER_EXPORT void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector& refCoo, const std::vector& gsCoo, const std::vector& w); protected: - MEDCouplingAutoRefCountObjectPtr< MEDFileFieldGlobs > _globals; + MEDFileFieldGlobs *contentNotNull(); + const MEDFileFieldGlobs *contentNotNull() const; + protected: + MCAuto< MEDFileFieldGlobs > _globals; }; + class MEDFileFieldNameScope + { + public: + MEDLOADER_EXPORT MEDFileFieldNameScope(); + MEDLOADER_EXPORT MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName); + MEDLOADER_EXPORT std::string getName() const; + MEDLOADER_EXPORT void setName(const std::string& fieldName); + MEDLOADER_EXPORT std::string getDtUnit() const; + MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit); + MEDLOADER_EXPORT void copyNameScope(const MEDFileFieldNameScope& other); + MEDLOADER_EXPORT std::string getMeshName() const; + MEDLOADER_EXPORT void setMeshName(const std::string& meshName); + protected: + std::string _name; + std::string _dt_unit; + std::string _mesh_name; + }; + + class MEDFileMeshes; + /*! * SDA is for Shared Data Arrays such as profiles. */ - class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public RefCountObject - { - public: - int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - int getDimension() const; - 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; } - 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(); + class MEDFileAnyTypeField1TSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope + { + public: + MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA(); + MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order); + MEDLOADER_EXPORT int getIteration() const { return _iteration; } + MEDLOADER_EXPORT int getOrder() const { return _order; } + MEDLOADER_EXPORT double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; } + MEDLOADER_EXPORT void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; } + MEDLOADER_EXPORT int getDimension() const; + MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair >& modifTab); + MEDLOADER_EXPORT int getMeshIteration() const; + MEDLOADER_EXPORT int getMeshOrder() const; + MEDLOADER_EXPORT bool isDealingTS(int iteration, int order) const; + MEDLOADER_EXPORT std::pair getDtIt() const; + MEDLOADER_EXPORT void fillIteration(std::pair& p) const; + MEDLOADER_EXPORT void fillTypesOfFieldAvailable(std::vector& types) const; + MEDLOADER_EXPORT std::vector getTypesOfFieldAvailable() const; + // + MEDLOADER_EXPORT std::vector getPflsReallyUsed2() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsed2() const; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti2() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti2() const; + MEDLOADER_EXPORT void changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif); // - 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); - 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); - 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); - 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); - 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); - MEDFileField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception); - std::size_t getHeapMemorySize() const; - DataArrayDouble *getOrCreateAndGetArray(); - const DataArrayDouble *getOrCreateAndGetArray() const; + MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector& levs) const; + MEDLOADER_EXPORT void convertMedBallIntoClassic(); + MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl); + MEDLOADER_EXPORT std::vector< std::vector > > getFieldSplitedByType(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + // + MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId); + MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const; + MEDLOADER_EXPORT void deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other); + MEDLOADER_EXPORT void accept(MEDFileFieldVisitor& visitor) const; + public: + MEDLOADER_EXPORT int getNumberOfComponents() const; + MEDLOADER_EXPORT const std::vector& getInfo() const; + MEDLOADER_EXPORT std::vector& getInfo(); + MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const; + MEDLOADER_EXPORT bool presenceOfStructureElements() const; + MEDLOADER_EXPORT bool onlyStructureElements() const; + MEDLOADER_EXPORT void killStructureElements(); + MEDLOADER_EXPORT void keepOnlyStructureElements(); + MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName); + MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair >& ps) const; + MEDLOADER_EXPORT void setInfo(const std::vector& infos); + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT int copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr); + MEDLOADER_EXPORT void setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + MEDLOADER_EXPORT void setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc); + MEDLOADER_EXPORT virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *deepCopy() const = 0; + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const = 0; + MEDLOADER_EXPORT virtual std::vector< MCAuto > splitComponents() const; + MEDLOADER_EXPORT virtual const char *getTypeStr() const = 0; + MEDLOADER_EXPORT virtual DataArray *getUndergroundDataArray() const = 0; + MEDLOADER_EXPORT virtual DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const = 0; + MEDLOADER_EXPORT virtual void setArray(DataArray *arr) = 0; + MEDLOADER_EXPORT virtual DataArray *createNewEmptyDataArrayInstance() const = 0; + MEDLOADER_EXPORT virtual DataArray *getOrCreateAndGetArray() = 0; + MEDLOADER_EXPORT virtual const DataArray *getOrCreateAndGetArray() const = 0; + public: + MEDLOADER_EXPORT MEDCouplingFieldDouble *fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto& arrOut, const MEDFileFieldNameScope& nasc) const; + MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; + MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; + MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; + MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto &arrOut, const MEDFileFieldNameScope& nasc) const; + DataArray *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const; + public: + MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob); + MEDLOADER_EXPORT std::vector< MCAuto > splitDiscretizations() const; + MEDLOADER_EXPORT std::vector< MCAuto > splitMultiDiscrPerGeoTypes() const; + MEDLOADER_EXPORT int keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair >& its); + MEDLOADER_EXPORT int keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair >& its); + public: + MEDLOADER_EXPORT void allocNotFromFile(int newNbOfTuples); + MEDLOADER_EXPORT bool allocIfNecessaryTheArrayToReceiveDataFromFile(); + MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities); + 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); + MEDLOADER_EXPORT void unloadArrays(); + MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const; protected: - std::string _dt_unit; - MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr; - std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > > _field_per_mesh; + int getMeshIdFromMeshName(const std::string& mName) const; + int addNewEntryIfNecessary(const MEDCouplingMesh *mesh); + void updateData(int newLgth, const std::vector< std::pair >& oldStartStops); + protected: + std::vector< MCAuto< MEDFileFieldPerMesh > > _field_per_mesh; int _iteration; int _order; double _dt; 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; + + template + class MEDFileField1TSTemplateWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA + { + protected: + MEDFileField1TSTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileAnyTypeField1TSWithoutSDA(fieldName,meshName,csit,iteration,order) { } + MEDFileField1TSTemplateWithoutSDA() { } + public: + MEDLOADER_EXPORT void setArray(DataArray *arr); + MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const; + MEDLOADER_EXPORT typename Traits::ArrayType *getOrCreateAndGetArrayTemplate(); + MEDLOADER_EXPORT typename Traits::ArrayType const *getOrCreateAndGetArrayTemplate() const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayTemplate() const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayTemplateExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray(); + MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const; + MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const; + MEDLOADER_EXPORT void aggregate(const typename std::vector< typename MLFieldTraits::F1TSWSDAType const * >& f1tss, const std::vector< std::vector< std::pair > >& dts); + protected: + MCAuto< typename Traits::ArrayType > _arr; + }; + + /*! + * SDA is for Shared Data Arrays such as profiles. + */ + class MEDFileField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + { + public: + MEDLOADER_EXPORT const char *getTypeStr() const; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + MEDLOADER_EXPORT static void CheckMeshDimRel(int meshDimRelToMax); + MEDLOADER_EXPORT static std::vector CheckSBTMesh(const MEDCouplingMesh *mesh); + MEDLOADER_EXPORT static MEDFileField1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); + public: + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(); + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *shallowCpy() const; + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *deepCopy() const; + MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *convertToInt() const; + public: + static const char TYPE_STR[]; + }; + + template + class MEDFileField1TSNDTemplateWithoutSDA : public MEDFileField1TSTemplateWithoutSDA + { + public: + MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const; + protected: + MEDFileField1TSNDTemplateWithoutSDA() { } + MEDFileField1TSNDTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos):MEDFileField1TSTemplateWithoutSDA(fieldName,meshName,csit,iteration,order) { } + }; + + /*! + * SDA is for Shared Data Arrays such as profiles. + */ + class MEDFileIntField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA + { + public: + MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA(); + MEDLOADER_EXPORT static MEDFileIntField1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); + MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *deepCopy() const; + MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *shallowCpy() const; + MEDLOADER_EXPORT const char *getTypeStr() const; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair,std::pair > >& entries) const; + protected: + MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); + public: + MEDLOADER_EXPORT static const char TYPE_STR[]; + }; + + /*! + * SDA is for Shared Data Arrays such as profiles. + */ + class MEDFileFloatField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA + { + public: + MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA(); + MEDLOADER_EXPORT static MEDFileFloatField1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); + MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *deepCopy() const; + MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *shallowCpy() const; + MEDLOADER_EXPORT const char *getTypeStr() const; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT DataArrayFloat *getUndergroundDataArrayFloatExt(std::vector< std::pair,std::pair > >& entries) const; + protected: + MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector& infos); + public: + MEDLOADER_EXPORT static const char TYPE_STR[]; }; /*! * User class. */ - class MEDLOADER_EXPORT MEDFileField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal - { - 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 shallowCopyOfContent); - 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 - public: - std::size_t getHeapMemorySize() const; - MEDFileField1TS *deepCpy() const throw(INTERP_KERNEL::Exception); - int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception); - int getDimension() const; - int getIteration() const; - int getOrder() const; - double getTime(int& iteration, int& order) const; - void setTime(int iteration, int order, double val); - std::string getName() const; - void setName(const char *name); - void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; - const std::string& getDtUnit() 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(); - 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); + class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileFieldGlobsReal + { + protected: + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT void writeLL(med_idt fid) const; + // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content + public: + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities); + MEDLOADER_EXPORT int getDimension() const; + MEDLOADER_EXPORT int getIteration() const; + MEDLOADER_EXPORT int getOrder() const; + MEDLOADER_EXPORT double getTime(int& iteration, int& order) const; + MEDLOADER_EXPORT void setTime(int iteration, int order, double val); + MEDLOADER_EXPORT std::string getName() const; + MEDLOADER_EXPORT void setName(const std::string& name); + MEDLOADER_EXPORT std::string simpleRepr() const; + MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const; + MEDLOADER_EXPORT std::string getDtUnit() const; + MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit); + MEDLOADER_EXPORT std::string getMeshName() const; + MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName); + MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair >& modifTab); + MEDLOADER_EXPORT int getMeshIteration() const; + MEDLOADER_EXPORT int getMeshOrder() const; + MEDLOADER_EXPORT int getNumberOfComponents() const; + MEDLOADER_EXPORT bool isDealingTS(int iteration, int order) const; + MEDLOADER_EXPORT std::pair getDtIt() const; + MEDLOADER_EXPORT void fillIteration(std::pair& p) const; + MEDLOADER_EXPORT void fillTypesOfFieldAvailable(std::vector& types) const; + MEDLOADER_EXPORT void setInfo(const std::vector& infos); + MEDLOADER_EXPORT const std::vector& getInfo() const; + MEDLOADER_EXPORT std::vector& getInfo(); + MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const; + MEDLOADER_EXPORT std::vector getTypesOfFieldAvailable() const; + MEDLOADER_EXPORT std::vector< std::vector > > getFieldSplitedByType(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, + std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId); + MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const; + MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector& levs) const; + MEDLOADER_EXPORT void convertMedBallIntoClassic(); + MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl); + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const = 0; + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *shallowCpy() const = 0; + public: + MEDLOADER_EXPORT void loadArrays(); + MEDLOADER_EXPORT void loadArraysIfNecessary(); + MEDLOADER_EXPORT void unloadArrays(); + MEDLOADER_EXPORT void unloadArraysWithoutDataLoss(); + MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeField1TS > > splitComponents() const; + MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeField1TS > > splitDiscretizations() const; + MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeField1TS > > splitMultiDiscrPerGeoTypes() const; + MEDLOADER_EXPORT MEDFileAnyTypeField1TS *deepCopy() const; + MEDLOADER_EXPORT int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr); + MEDLOADER_EXPORT int copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr); 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); + MEDLOADER_EXPORT void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false); //! 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); - 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); + MEDLOADER_EXPORT void setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false); + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT std::vector getPflsReallyUsed() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsed() const; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const; + MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + public: + MEDLOADER_EXPORT static int LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName); + MEDLOADER_EXPORT static int LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector& infos, std::string& dtunitOut, std::string& meshName); + public: + MEDLOADER_EXPORT virtual med_field_type getMEDFileFieldType() const = 0; + MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase(); + MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase() const; + protected: + MCAuto _content; + }; + + class MEDFileIntField1TS; + + template + class MEDFileTemplateField1TS : public MEDFileAnyTypeField1TS + { + public: + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(); + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(med_idt fid, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(DataArrayByte *db) { return BuildFromMemoryChunk::F1TSType>(db); } + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(med_idt fid, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::F1TSType *New(const typename MLFieldTraits::F1TSWSDAType& other, bool shallowCopyOfContent); + public: + MEDLOADER_EXPORT static typename Traits::ArrayType *ReturnSafelyTypedDataArray(MCAuto& arr); + MEDLOADER_EXPORT typename Traits::ArrayType *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArray() const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayExt(std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT static MCAuto::FieldType> SetDataArrayInField(MEDCouplingFieldDouble *f, MCAuto& arr); + MEDLOADER_EXPORT static MCAuto ToFieldTemplateWithTime(const typename Traits::FieldType *f); + public: + MEDLOADER_EXPORT typename Traits::FieldType *field(const MEDFileMesh *mesh) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT void setFieldNoProfileSBT(const typename Traits::FieldType *field); + MEDLOADER_EXPORT void setFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); + MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const; + MEDLOADER_EXPORT MEDFileAnyTypeField1TS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const { return this->extractPartImpl(extractDef,mm); } + protected: + ~MEDFileTemplateField1TS() { } + MEDFileTemplateField1TS(); + MEDFileTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,loadAll,ms) { } + MEDFileTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms) { } + MEDFileTemplateField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + MEDFileTemplateField1TS(const typename MLFieldTraits::F1TSWSDAType& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent) { } + const typename MLFieldTraits::F1TSWSDAType *contentNotNull() const; + typename MLFieldTraits::F1TSWSDAType *contentNotNull(); + }; + + /*! + * User class. + */ + class MEDFileField1TS : public MEDFileTemplateField1TS + { + friend class MEDFileTemplateField1TS; + public: + MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const; + public: + MEDLOADER_EXPORT MEDFileField1TS *shallowCpy() const; + MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, + std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + public: private: - void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception); - MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception); + med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } + private: + ~MEDFileField1TS() { } + MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms); + MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms); MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent); - MEDFileField1TS(); + MEDFileField1TS() { } + }; + + template + class MEDFileNDTemplateField1TS : public MEDFileTemplateField1TS + { + public: + MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const; protected: - MEDCouplingAutoRefCountObjectPtr _content; + ~MEDFileNDTemplateField1TS() { } + MEDFileNDTemplateField1TS() { } + MEDFileNDTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,loadAll,ms) { } + MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + MEDFileNDTemplateField1TS(const typename MLFieldTraits::F1TSWSDAType& other, bool shallowCopyOfContent):MEDFileTemplateField1TS(other,shallowCopyOfContent) { } }; - - class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA : public RefCountObject - { - 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; - MEDFileFieldMultiTSWithoutSDA *deepCpy() const 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; - int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); - int getPosGivenTime(double time, double eps=1e-8) 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); - 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); - 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); - 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); - 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); - 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); - public: - MEDFileFieldMultiTSWithoutSDA(); + + class MEDFileIntField1TS : public MEDFileNDTemplateField1TS + { + friend class MEDFileTemplateField1TS; + public: + MEDLOADER_EXPORT MEDFileIntField1TS *shallowCpy() const { return new MEDFileIntField1TS(*this); } + public: + MEDLOADER_EXPORT static MCAuto ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f); + private: + med_field_type getMEDFileFieldType() const { return MED_INT32; } + private: + ~MEDFileIntField1TS() { } + MEDFileIntField1TS() { } + MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + /*! + * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. + * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. + * + * \warning this is a shallow copy constructor + */ + MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS(other,shallowCopyOfContent) { } + }; + + class MEDFileFloatField1TS : public MEDFileNDTemplateField1TS + { + friend class MEDFileTemplateField1TS; + private: + med_field_type getMEDFileFieldType() const { return MED_INT32; }//6432 + MEDLOADER_EXPORT MEDFileFloatField1TS *shallowCpy() const { return new MEDFileFloatField1TS(*this); } + private: + ~MEDFileFloatField1TS() { } + MEDFileFloatField1TS() { } + MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,loadAll,ms) { } + MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,loadAll,ms) { } + MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS(fid,fieldName,iteration,order,loadAll,ms) { } + /*! + * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied. + * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this. + * + * \warning this is a shallow copy constructor + */ + MEDFileFloatField1TS(const MEDFileFloatField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS(other,shallowCopyOfContent) { } + }; + + class MEDFileAnyTypeFieldMultiTSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope + { + protected: + MEDFileAnyTypeFieldMultiTSWithoutSDA(); + MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName); + MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + public: + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCopy() const; + MEDLOADER_EXPORT virtual std::vector< MCAuto > splitComponents() const; + MEDLOADER_EXPORT virtual std::vector< MCAuto > splitDiscretizations() const; + MEDLOADER_EXPORT virtual std::vector< MCAuto > splitMultiDiscrPerGeoTypes() const; + MEDLOADER_EXPORT virtual const char *getTypeStr() const = 0; + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const = 0; + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const = 0; + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const = 0; + MEDLOADER_EXPORT virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const = 0; + MEDLOADER_EXPORT const std::vector& getInfo() const; + MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const; + MEDLOADER_EXPORT void setInfo(const std::vector& info); + MEDLOADER_EXPORT int getTimeStepPos(int iteration, int order) const; + MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const; + MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order); + MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair >& modifTab); + MEDLOADER_EXPORT int getNumberOfTS() const; + MEDLOADER_EXPORT void eraseEmptyTS(); + MEDLOADER_EXPORT void eraseTimeStepIds(const int *startIds, const int *endIds); + MEDLOADER_EXPORT void eraseTimeStepIds2(int bg, int end, int step); + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds(const int *startIds, const int *endIds) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds2(int bg, int end, int step) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const; + MEDLOADER_EXPORT bool presenceOfStructureElements() const; + MEDLOADER_EXPORT bool onlyStructureElements() const; + MEDLOADER_EXPORT void killStructureElements(); + MEDLOADER_EXPORT void keepOnlyStructureElements(); + MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName); + MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair >& ps) const; + MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const; + MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const; + MEDLOADER_EXPORT std::vector< std::pair > getIterations() const; + MEDLOADER_EXPORT std::vector< std::pair > getTimeSteps(std::vector& ret1) const; + MEDLOADER_EXPORT void pushBackTimeStep(MCAuto& tse); + MEDLOADER_EXPORT void synchronizeNameScope(); + MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const; + MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector& levs) const; + MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob); + MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob); + MEDLOADER_EXPORT std::vector< std::vector< std::pair > > getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + MEDLOADER_EXPORT std::vector< std::vector > getTypesOfFieldAvailable() const; + MEDLOADER_EXPORT DataArray *getUndergroundDataArray(int iteration, int order) const; + MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob); + MEDLOADER_EXPORT void accept(MEDFileFieldVisitor& visitor) const; + MEDLOADER_EXPORT void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts) const; + MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc); + MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc); + MEDLOADER_EXPORT void unloadArrays(); + public: + MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) const; + MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos); + MEDLOADER_EXPORT std::vector getPflsReallyUsed2() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsed2() const; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti2() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti2() const; + MEDLOADER_EXPORT void changePflsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void setIteration(int i, MCAuto ts); + protected: + virtual med_field_type getMEDFileFieldType() const = 0; + void copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr); + void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const; + void checkThatComponentsMatch(const std::vector& compos) const; + void checkThatNbOfCompoOfTSMatchThis() const; 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; + std::vector< MCAuto > _time_steps; }; - class MEDFileFieldMultiTSIterator; + class MEDFileIntFieldMultiTSWithoutSDA; + template + class MEDFileTemplateFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA + { + public: + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSWSDAType *New(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); + MEDLOADER_EXPORT const char *getTypeStr() const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const; + MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const; + protected: + MEDFileTemplateFieldMultiTSWithoutSDA() { } + MEDFileTemplateFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileAnyTypeFieldMultiTSWithoutSDA(fieldName,meshName) { } + /** \param [in] fieldId field id in C mode */ + MEDFileTemplateFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDFileTemplateFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileAnyTypeFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const; + }; + + class MEDFileFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA + { + friend class MEDFileTemplateFieldMultiTSWithoutSDA; + public: + MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA *convertToInt() const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFieldMultiTSWithoutSDA(*this); } + protected: + MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + med_field_type getMEDFileFieldType() const { return MED_FLOAT64; } + public: + MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA() { } + }; + + template + class MEDFileNDTemplateFieldMultiTSWithoutSDA : public MEDFileTemplateFieldMultiTSWithoutSDA + { + public: + MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA *convertToDouble() const; + protected: + MEDFileNDTemplateFieldMultiTSWithoutSDA() { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileNDTemplateFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + }; + + class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA + { + friend class MEDFileTemplateFieldMultiTSWithoutSDA; + public: + MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileIntFieldMultiTSWithoutSDA(*this); } + protected: + MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + med_field_type getMEDFileFieldType() const { return MED_INT32; } + public: + MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA() { } + }; + + class MEDFileFloatFieldMultiTSWithoutSDA : public MEDFileNDTemplateFieldMultiTSWithoutSDA + { + friend class MEDFileTemplateFieldMultiTSWithoutSDA; + public: + MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldId,loadAll,ms,entities) { } + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const { return new MEDFileFloatFieldMultiTSWithoutSDA(*this); } + protected: + MEDFileFloatFieldMultiTSWithoutSDA(const std::string& fieldName, const std::string& meshName):MEDFileNDTemplateFieldMultiTSWithoutSDA(fieldName,meshName) { } + MEDFileFloatFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, const std::string& meshName, med_field_type fieldTyp, const std::vector& infos, int nbOfStep, const std::string& dtunit, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileNDTemplateFieldMultiTSWithoutSDA(fid,fieldName,meshName,fieldTyp,infos,nbOfStep,dtunit,loadAll,ms,entities) { } + med_field_type getMEDFileFieldType() const { return MED_INT32; }//6432 + public: + MEDLOADER_EXPORT MEDFileFloatFieldMultiTSWithoutSDA() { } + }; + + class MEDFileAnyTypeFieldMultiTSIterator; + class MEDFileFastCellSupportComparator; /*! * User class. */ - class MEDLOADER_EXPORT MEDFileFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal + class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileFieldGlobsReal { + protected: + MEDFileAnyTypeFieldMultiTS(); + MEDFileAnyTypeFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileAnyTypeFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); + static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, med_idt fid); + static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); 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 shallowCopyOfContent); - std::size_t getHeapMemorySize() const; - MEDFileFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception); + MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(med_idt fid, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(med_idt fid, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c); + MEDLOADER_EXPORT void loadArrays(); + MEDLOADER_EXPORT void loadArraysIfNecessary(); + MEDLOADER_EXPORT void unloadArrays(); + MEDLOADER_EXPORT void unloadArraysWithoutDataLoss(); + MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *deepCopy() const; + MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > splitComponents() const; + MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > splitDiscretizations() const; + MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeFieldMultiTS > > splitMultiDiscrPerGeoTypes() const; + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const = 0; + MEDLOADER_EXPORT virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const = 0; // - 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); + MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const = 0; + MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const; + MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const; + MEDLOADER_EXPORT static std::vector< std::vector > SplitIntoCommonTimeSeries(const std::vector& vectFMTS); + MEDLOADER_EXPORT static std::vector< std::vector > SplitPerCommonSupport(const std::vector& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto >& fsc); + MEDLOADER_EXPORT static int CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1); + public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content + MEDLOADER_EXPORT std::string getName() const; + MEDLOADER_EXPORT void setName(const std::string& name); + MEDLOADER_EXPORT std::string getDtUnit() const; + MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit); + MEDLOADER_EXPORT std::string getMeshName() const; + MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName); + MEDLOADER_EXPORT std::string simpleRepr() const; + MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const; + MEDLOADER_EXPORT int getNumberOfTS() const; + MEDLOADER_EXPORT void eraseEmptyTS(); + MEDLOADER_EXPORT void eraseTimeStepIds(const int *startIds, const int *endIds); + MEDLOADER_EXPORT void eraseTimeStepIds2(int bg, int end, int step); + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *buildSubPart(const int *startIds, const int *endIds) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *buildSubPartSlice(int bg, int end, int step) const; + MEDLOADER_EXPORT std::vector< std::pair > getTimeSteps(std::vector& ret1) const; + MEDLOADER_EXPORT std::vector< std::pair > getIterations() const; + MEDLOADER_EXPORT void pushBackTimeSteps(const std::vector& f1ts); + MEDLOADER_EXPORT void pushBackTimeSteps(MEDFileAnyTypeFieldMultiTS *fmts); + MEDLOADER_EXPORT void pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts); + MEDLOADER_EXPORT void synchronizeNameScope(); + MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const; + MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSIterator *iterator(); + MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair >& modifTab); + MEDLOADER_EXPORT const std::vector& getInfo() const; + MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const; + MEDLOADER_EXPORT void setInfo(const std::vector& info); + MEDLOADER_EXPORT int getNumberOfComponents() const; + MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector& levs) const; + MEDLOADER_EXPORT std::vector< std::vector > getTypesOfFieldAvailable() const; + MEDLOADER_EXPORT std::vector< std::vector< std::pair > > getFieldSplitedByType(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + MEDLOADER_EXPORT MCAuto getContent(); + public: + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *buildNewEmpty() const = 0; + MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const = 0; + MEDLOADER_EXPORT static MCAuto Aggregate(const std::vector& fmtss, const std::vector< std::vector< std::pair > >& dts); + public: + MEDLOADER_EXPORT std::vector getPflsReallyUsed() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsed() const; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const; + MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + protected: + MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase(); + const MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() const; + private: + static std::vector< std::vector > SplitPerCommonSupportNotNodesAlg(const std::vector& vectFMTS, const MEDFileMesh *mesh, std::vector< MCAuto >& cmps); + protected: + MCAuto _content; + }; + + template + class MEDFileTemplateFieldMultiTS : public MEDFileAnyTypeFieldMultiTS + { + public: + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(med_idt fid, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(DataArrayByte *db) { return BuildFromMemoryChunk::FMTSType>(db); } + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(med_idt fid, const std::string& fieldName, bool loadAll=true); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *New(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent); + MEDLOADER_EXPORT static typename MLFieldTraits::FMTSType *LoadSpecificEntities(const std::string& fileName, const std::string& fieldName, const std::vector< std::pair >& entities, bool loadAll=true); + MEDLOADER_EXPORT typename MLFieldTraits::FMTSType *extractPartImpl(const std::map >& extractDef, MEDFileMesh *mm) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const { return this->extractPartImpl(extractDef,mm); } // - std::string simpleRepr() const; - 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); + MEDLOADER_EXPORT typename Traits::FieldType *field(int iteration, int order, const MEDFileMesh *mesh) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::FieldType *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, int renumPol=0) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const; // - 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); - public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content - 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; - int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception); - int getPosGivenTime(double time, double eps=1e-8) 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); + MEDLOADER_EXPORT void appendFieldNoProfileSBT(const typename Traits::FieldType *field); + MEDLOADER_EXPORT void appendFieldProfile(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile); + // + MEDLOADER_EXPORT typename MLFieldTraits::F1TSType *getTimeStepAtPos(int pos) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArray(int iteration, int order) const; + MEDLOADER_EXPORT typename Traits::ArrayType *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair,std::pair > >& entries) const; + MEDLOADER_EXPORT typename MLFieldTraits::FMTSType *buildNewEmptyImpl() const; + MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const; + protected: + const typename MLFieldTraits::FMTSWSDAType *contentNotNull() const; + typename MLFieldTraits::FMTSWSDAType *contentNotNull(); + protected: + ~MEDFileTemplateFieldMultiTS() { } + MEDFileTemplateFieldMultiTS(); + MEDFileTemplateFieldMultiTS(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent); + MEDFileTemplateFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileTemplateFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + }; + + class MEDFileIntFieldMultiTS; + + /*! + * User class. + */ + class MEDFileFieldMultiTS : public MEDFileTemplateFieldMultiTS + { + friend class MEDFileTemplateFieldMultiTS; public: - 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); + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const; + MEDLOADER_EXPORT MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const; + // + MEDLOADER_EXPORT std::vector< std::vector > getFieldSplitedByType2(int iteration, int order, const std::string& mname, std::vector& types, std::vector< std::vector >& typesF, std::vector< std::vector >& pfls, std::vector< std::vector >& locs) const; + MEDLOADER_EXPORT MEDFileFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } public: - MEDCouplingAutoRefCountObjectPtr getContent(); private: - MEDFileFieldMultiTS(); + ~MEDFileFieldMultiTS() { } + MEDFileFieldMultiTS() { } MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent); - MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception); - MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception); + MEDFileFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms); + MEDFileFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0); + }; + + template + class MEDFileNDTemplateFieldMultiTS : public MEDFileTemplateFieldMultiTS + { + public: + MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const; protected: - MEDCouplingAutoRefCountObjectPtr _content; + ~MEDFileNDTemplateFieldMultiTS() { } + MEDFileNDTemplateFieldMultiTS() { } + MEDFileNDTemplateFieldMultiTS(const typename MLFieldTraits::FMTSWSDAType& other, bool shallowCopyOfContent):MEDFileTemplateFieldMultiTS(other,shallowCopyOfContent) { } + MEDFileNDTemplateFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateFieldMultiTS(fid,loadAll,ms) { } + MEDFileNDTemplateFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities):MEDFileTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } }; - class MEDCOUPLING_EXPORT MEDFileFieldMultiTSIterator + /*! + * User class. + */ + class MEDFileIntFieldMultiTS : public MEDFileNDTemplateFieldMultiTS { + friend class MEDFileTemplateFieldMultiTS; public: - MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts); - ~MEDFileFieldMultiTSIterator(); - MEDFileField1TS *nextt(); + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileIntFieldMultiTS(*this); } + MEDLOADER_EXPORT MEDFileIntFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } private: - MEDCouplingAutoRefCountObjectPtr _fmts; - int _iter_id; - int _nb_iter; + ~MEDFileIntFieldMultiTS() { } + MEDFileIntFieldMultiTS() { } + MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateFieldMultiTS(other,shallowCopyOfContent) { } + MEDFileIntFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateFieldMultiTS(fid,loadAll,ms) { } + MEDFileIntFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } }; - class MEDFileFieldsIterator; + /*! + * User class. + */ + class MEDFileFloatFieldMultiTS : public MEDFileNDTemplateFieldMultiTS + { + friend class MEDFileTemplateFieldMultiTS; + public: + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const { return new MEDFileFloatFieldMultiTS(*this); } + MEDLOADER_EXPORT MEDFileFloatFieldMultiTS *buildNewEmpty() const { return buildNewEmptyImpl(); } + private: + ~MEDFileFloatFieldMultiTS() { } + MEDFileFloatFieldMultiTS() { } + MEDFileFloatFieldMultiTS(const MEDFileFloatFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateFieldMultiTS(other,shallowCopyOfContent) { } + MEDFileFloatFieldMultiTS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateFieldMultiTS(fid,loadAll,ms) { } + MEDFileFloatFieldMultiTS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0):MEDFileNDTemplateFieldMultiTS(fid,fieldName,loadAll,ms,entities) { } + }; + + class MEDFileAnyTypeFieldMultiTSIterator + { + public: + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts); + MEDLOADER_EXPORT ~MEDFileAnyTypeFieldMultiTSIterator(); + MEDLOADER_EXPORT MEDFileAnyTypeField1TS *nextt(); + private: + MCAuto _fmts; + int _iter_id; + int _nb_iter; + }; + class MEDFileFieldsIterator; + class MEDFileStructureElements; + /*! * Use class. */ - class MEDLOADER_EXPORT MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable - { - public: - static MEDFileFields *New(); - static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception); - std::size_t getHeapMemorySize() const; - MEDFileFields *deepCpy() 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); - int getNumberOfFields() const; - 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; + class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone + { + public: + MEDLOADER_EXPORT static MEDFileFields *New(); + MEDLOADER_EXPORT static MEDFileFields *New(const std::string& fileName, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileFields *New(med_idt fid, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileFields *NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileFields *NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities); + MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll=true); + MEDLOADER_EXPORT static MEDFileFields *New(DataArrayByte *db) { return BuildFromMemoryChunk(db); } + MEDLOADER_EXPORT static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0); + MEDLOADER_EXPORT static MEDFileFields *LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair >& entities, bool loadAll=true); + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + MEDLOADER_EXPORT MEDFileFields *deepCopy() const; + MEDLOADER_EXPORT MEDFileFields *shallowCpy() const; + MEDLOADER_EXPORT void writeLL(med_idt fid) const; + MEDLOADER_EXPORT void loadArrays(); + MEDLOADER_EXPORT void loadArraysIfNecessary(); + MEDLOADER_EXPORT void unloadArrays(); + MEDLOADER_EXPORT void unloadArraysWithoutDataLoss(); + MEDLOADER_EXPORT int getNumberOfFields() const; + MEDLOADER_EXPORT std::vector< std::pair > getCommonIterations(bool& areThereSomeForgottenTS) const; + MEDLOADER_EXPORT std::vector getFieldsNames() const; + MEDLOADER_EXPORT std::vector getMeshesNames() const; + MEDLOADER_EXPORT std::string simpleRepr() const; + MEDLOADER_EXPORT 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); - MEDFileFieldsIterator *iterator() throw(INTERP_KERNEL::Exception); - void destroyFieldAtPos(int i) 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); - public: - int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception); - 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); + MEDLOADER_EXPORT void resize(int newSize); + MEDLOADER_EXPORT void pushField(MEDFileAnyTypeFieldMultiTS *field); + MEDLOADER_EXPORT void pushFields(const std::vector& fields); + MEDLOADER_EXPORT void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field); + MEDLOADER_EXPORT int getPosFromFieldName(const std::string& fieldName) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const; + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const; + MEDLOADER_EXPORT MEDFileFields *buildSubPart(const int *startIds, const int *endIds) const; + MEDLOADER_EXPORT bool removeFieldsWithoutAnyTimeStep(); + MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const; + MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const; + MEDLOADER_EXPORT MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair >& timeSteps) const; + MEDLOADER_EXPORT bool presenceOfStructureElements() const; + MEDLOADER_EXPORT void killStructureElements(); + MEDLOADER_EXPORT void keepOnlyStructureElements(); + MEDLOADER_EXPORT void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName); + MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair >& ps) const; + MEDLOADER_EXPORT void blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses); + MEDLOADER_EXPORT MCAuto partOfThisOnStructureElements() const; + MEDLOADER_EXPORT MCAuto partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const; + MEDLOADER_EXPORT void aggregate(const MEDFileFields& other); + MEDLOADER_EXPORT MEDFileFieldsIterator *iterator(); + MEDLOADER_EXPORT void destroyFieldAtPos(int i); + MEDLOADER_EXPORT void destroyFieldsAtPos(const int *startIds, const int *endIds); + MEDLOADER_EXPORT void destroyFieldsAtPos2(int bg, int end, int step); + MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair >& modifTab); + MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector& oldCode, const std::vector& newCode, const DataArrayInt *renumO2N); + MEDLOADER_EXPORT void accept(MEDFileFieldVisitor& visitor) const; + public: + MEDLOADER_EXPORT MEDFileFields *extractPart(const std::map >& extractDef, MEDFileMesh *mm) const; + public: + MEDLOADER_EXPORT std::vector getPflsReallyUsed() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsed() const; + MEDLOADER_EXPORT std::vector getPflsReallyUsedMulti() const; + MEDLOADER_EXPORT std::vector getLocsReallyUsedMulti() const; + MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); + MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair, std::string > >& mapOfModif); private: + ~MEDFileFields() { } MEDFileFields(); - MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception); + MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities); private: - std::vector< MEDCouplingAutoRefCountObjectPtr > _fields; + std::vector< MCAuto > _fields; }; - class MEDCOUPLING_EXPORT MEDFileFieldsIterator + class MEDFileFieldsIterator { public: - MEDFileFieldsIterator(MEDFileFields *fs); - ~MEDFileFieldsIterator(); - MEDFileFieldMultiTS *nextt(); + MEDLOADER_EXPORT MEDFileFieldsIterator(MEDFileFields *fs); + MEDLOADER_EXPORT ~MEDFileFieldsIterator(); + MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *nextt(); private: - MEDCouplingAutoRefCountObjectPtr _fs; - int _iter_id; - int _nb_iter; + MCAuto _fs; + int _iter_id; + int _nb_iter; }; }