X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDLoader%2FMEDFileFieldOverView.hxx;h=bcce70af29d4ea4d415db8984bc33c38eac44de7;hb=662a2a2393a25baef77e42f74204b11b70a9646c;hp=7951df90c3d1943b7065630372e68a71a79bf446;hpb=aa6df0bd86f74a1a90d64bd8bcf44f50922b4e87;p=tools%2Fmedcoupling.git diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index 7951df90c..bcce70af2 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -1,9 +1,9 @@ -// Copyright (C) 2007-2013 CEA/DEN, EDF R&D +// Copyright (C) 2007-2023 CEA, EDF // // 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 @@ -21,81 +21,255 @@ #ifndef __MEDFILEFIELDOVERVIEW_HXX__ #define __MEDFILEFIELDOVERVIEW_HXX__ -#include "MEDCouplingAutoRefCountObjectPtr.hxx" +#include "MEDLoaderDefines.hxx" + +#include "MCAuto.hxx" #include "MEDCouplingRefCountObject.hxx" +#include "MEDCoupling1GTUMesh.hxx" #include "NormalizedUnstructuredMesh.hxx" #include "InterpKernelException.hxx" #include -namespace ParaMEDMEM +namespace MEDCoupling { class DataArrayInt; + class MEDCouplingMesh; class MEDFileMesh; + class MEDFileUMesh; + class MEDFileCMesh; + class MEDFileStructuredMesh; + class MEDFileCurveLinearMesh; class MEDFileFieldGlobs; + class MEDFileFieldGlobsReal; class MEDFileAnyTypeField1TS; class MEDFileAnyTypeFieldMultiTS; class MEDFileMeshStruct : public RefCountObject { public: - static MEDFileMeshStruct *New(const MEDFileMesh *mesh); - std::size_t getHeapMemorySize() const; + MEDLOADER_EXPORT static MEDFileMeshStruct *New(const MEDFileMesh *mesh); + std::string getClassName() const override { return std::string("MEDFileMeshStruct"); } + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; const MEDFileMesh *getTheMesh() const { return _mesh; } - int getNumberOfNodes() const { return _nb_nodes; } - int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception); - int getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception); + mcIdType getNumberOfNodes() const { return _nb_nodes; } + bool doesManageGeoType(INTERP_KERNEL::NormalizedCellType t) const; + mcIdType getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const; + int getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const; int getNumberOfLevs() const; - int getNumberOfGeoTypesInLev(int relativeLev) const throw(INTERP_KERNEL::Exception); + int getNumberOfGeoTypesInLev(int relativeLev) const; + // non const methods + void appendIfImplicitType(INTERP_KERNEL::NormalizedCellType t); private: MEDFileMeshStruct(const MEDFileMesh *mesh); private: const MEDFileMesh *_mesh; std::string _name; - int _nb_nodes; - std::vector< std::vector > _geo_types_distrib; + mcIdType _nb_nodes; + std::vector< std::vector > _geo_types_distrib; + }; + + class MEDFileField1TSStructItem; + + class MEDMeshMultiLev : public RefCountObject + { + public: + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; + std::string getClassName() const override { return std::string("MEDMeshMultiLev"); } + public: + static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector& levs); + static MEDMeshMultiLev *NewOnlyOnNode(const MEDFileMesh *m, const DataArrayIdType *pflOnNode); + void setNodeReduction(const DataArrayIdType *nr); + void setCellReduction(const DataArrayIdType *cr); + bool isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const; + MEDLOADER_EXPORT DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const; + MEDLOADER_EXPORT void retrieveFamilyIdsOnCells(DataArrayIdType *& famIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT void retrieveNumberIdsOnCells(DataArrayIdType *& numIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT void retrieveFamilyIdsOnNodes(DataArrayIdType *& famIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT void retrieveNumberIdsOnNodes(DataArrayIdType *& numIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT DataArrayIdType *retrieveGlobalNodeIdsIfAny() const; + MEDLOADER_EXPORT std::vector< INTERP_KERNEL::NormalizedCellType > getGeoTypes() const; + void setFamilyIdsOnCells(DataArrayIdType *famIds); + void setNumberIdsOnCells(DataArrayIdType *numIds); + void setFamilyIdsOnNodes(DataArrayIdType *famIds); + void setNumberIdsOnNodes(DataArrayIdType *numIds); + virtual void selectPartOfNodes(const DataArrayIdType *pflNodes) = 0; + virtual MEDMeshMultiLev *prepare() const = 0; + mcIdType getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const; + mcIdType getNumberOfNodes() const; + protected: + std::string getPflNameOfId(int id) const; + DataArray *constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const; + virtual void appendVertices(const DataArrayIdType *verticesToAdd, DataArrayIdType *nr); + protected: + MEDMeshMultiLev(const MEDFileMesh *mesh); + MEDMeshMultiLev(const MEDMeshMultiLev& other); + MEDMeshMultiLev(const MEDFileMesh *mesh, mcIdType nbNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + protected: + const MEDFileMesh *_mesh; + std::vector< MCAuto > _pfls; + std::vector< INTERP_KERNEL::NormalizedCellType > _geo_types; + std::vector _nb_entities; + MCAuto _node_reduction; + mcIdType _nb_nodes; + // + MCAuto _cell_fam_ids; + MCAuto _cell_num_ids; + MCAuto _node_fam_ids; + MCAuto _node_num_ids; + public: + MEDLOADER_EXPORT static const int PARAMEDMEM_2_VTKTYPE_LGTH=MEDCOUPLING2VTKTYPETRADUCER_LGTH; + MEDLOADER_EXPORT static const unsigned char *PARAMEDMEM_2_VTKTYPE; + MEDLOADER_EXPORT static const unsigned char HEXA27_PERM_ARRAY[27]; + }; + + class MEDStructuredMeshMultiLev; + + class MEDUMeshMultiLev : public MEDMeshMultiLev + { + public: + static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector& levs); + static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + void selectPartOfNodes(const DataArrayIdType *pflNodes); + std::string getClassName() const override { return std::string("MEDUMeshMultiLev"); } + MEDMeshMultiLev *prepare() const; + MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MCAuto& part); + MEDLOADER_EXPORT bool buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayIdType *&cellLocations, DataArrayIdType *& cells, DataArrayIdType *&faceLocations, DataArrayIdType *&faces) const; + protected: + void appendVertices(const DataArrayIdType *verticesToAdd, DataArrayIdType *nr); + private: + void reorderNodesIfNecessary(MCAuto& coords, DataArrayIdType *nodalConnVTK, DataArrayIdType *polyhedNodalConnVTK) const; + private: + MEDUMeshMultiLev(const MEDUMeshMultiLev& other); + MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& levs); + MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + private: + std::vector< MCAuto > _parts; + //! this attribute is used only for mesh with no cells but having coordinates. For classical umeshes those pointer is equal to pointer of coordinates of instances in this->_parts. + MCAuto _coords; + }; + + class MEDStructuredMeshMultiLev : public MEDMeshMultiLev + { + public: + void selectPartOfNodes(const DataArrayIdType *pflNodes); + virtual std::vector getNodeGridStructure() const = 0; + std::string getClassName() const override { return std::string("MEDStructuredMeshMultiLev"); } + protected: + MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other); + MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev); + MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, mcIdType nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + void dealWithImplicitUnstructuredMesh(const MEDFileMesh *m); + protected: + void moveFaceToCell() const; + bool prepareForImplicitUnstructuredMeshCase(MEDMeshMultiLev *&ret) const; + private: + void initStdFieldOfIntegers(const MEDFileStructuredMesh *m); + protected: + bool _is_internal; + MCAuto _face_fam_ids; + MCAuto _face_num_ids; + }; + + class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev + { + public: + static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector& levs); + static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + std::vector getNodeGridStructure() const; + std::string getClassName() const override { return std::string("MEDCMeshMultiLev"); } + MEDMeshMultiLev *prepare() const; + MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays(bool& isInternal) const; + private: + MEDCMeshMultiLev(const MEDCMeshMultiLev& other); + MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& levs); + MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + private: + std::vector< MCAuto > _coords; }; - class MEDFileField1TSStructItem2 + class MEDCurveLinearMeshMultiLev : public MEDStructuredMeshMultiLev + { + public: + static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector& levs); + static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls , const std::vector& nbEntities); + std::string getClassName() const override { return std::string("MEDCurveLinearMeshMultiLev"); } + std::vector getNodeGridStructure() const; + MEDMeshMultiLev *prepare() const; + MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector& nodeStrct, bool& isInternal) const; + private: + MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other); + MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& levs); + MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); + private: + MCAuto _coords; + std::vector _structure; + }; + + class MEDFileField1TSStructItem2 : public BigMemoryObject { public: MEDFileField1TSStructItem2(); - MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair& b, const std::string& pfl, const std::string& loc); - void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); - void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); - void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); + MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair& b, const std::string& pfl, const std::string& loc); + std::string getClassName() const override { return std::string("MEDFileField1TSStructItem2"); } + void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); + void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); + void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); // + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; + // + const DataArrayIdType *getPfl(const MEDFileFieldGlobsReal *globs) const; INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; } + mcIdType getNbEntity() const { return _nb_of_entity; } + const std::pair& getStartStop() const { return _start_end; } std::string getPflName() const; + int getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const; //! warning this method also set _nb_of_entity attribute ! - void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); - bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception); - bool isCellSupportEqual(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception); - static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector& objs, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); + void checkInRange(mcIdType nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs); + bool isFastlyEqual(mcIdType& startExp, INTERP_KERNEL::NormalizedCellType gt, const std::string& pflName) const; + bool operator==(const MEDFileField1TSStructItem2& other) const; + bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const; + bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const; + static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector& objs, const MEDFileFieldGlobsReal *globs); + public: + static const char NEWLY_CREATED_PFL_NAME[]; private: INTERP_KERNEL::NormalizedCellType _geo_type; - std::pair _start_end; - MEDCouplingAutoRefCountObjectPtr _pfl; + std::pair _start_end; + MCAuto _pfl; std::string _loc; - int _nb_of_entity; + mcIdType _nb_of_entity; }; - class MEDFileField1TSStructItem + class MEDFileField1TSStructItem : public BigMemoryObject { public: + MEDFileField1TSStructItem():_computed(false),_type(ON_CELLS) { } MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b); - void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); - bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception); + void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); + bool operator==(const MEDFileField1TSStructItem& other) const; + std::string getClassName() const override { return std::string("MEDFileField1TSStructItem"); } + MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; + MEDLOADER_EXPORT std::vector getDirectChildrenWithNull() const; bool isEntityCell() const; bool isComputed() const { return _computed; } + TypeOfField getType() const { return _type; } std::size_t getNumberOfItems() const { return _items.size(); } - const MEDFileField1TSStructItem2& operator[](std::size_t i) const throw(INTERP_KERNEL::Exception); + const MEDFileField1TSStructItem2& operator[](std::size_t i) const; // - bool isCellSupportEqual(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception); - MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception); - bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobs *globs) const throw(INTERP_KERNEL::Exception); - bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception); + bool isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const; + bool isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const; + MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const; + bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const; + bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const; + std::vector getGeoTypes(const MEDFileMesh *m) const; + MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const; + MEDLOADER_EXPORT static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt); private: bool _computed; TypeOfField _type; @@ -105,15 +279,21 @@ namespace ParaMEDMEM class MEDFileField1TSStruct : public RefCountObject { public: - static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception); - void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobs *globs) throw(INTERP_KERNEL::Exception); - std::size_t getHeapMemorySize() const; - bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception); - bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception); - bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception); + static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst); + void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs); + std::size_t getHeapMemorySizeWithoutChildren() const; + std::string getClassName() const override { return std::string("MEDFileField1TSStruct"); } + std::vector getDirectChildrenWithNull() const; + bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const; + bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt); + bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt); + MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const; + bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const; + std::vector getGeoTypes(const MEDFileMesh *m) const; private: MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst); - static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt); + bool presenceOfCellDiscr(int& pos) const; + bool presenceOfPartialNodeDiscr(int& pos) const; private: std::vector _already_checked; }; @@ -121,15 +301,21 @@ namespace ParaMEDMEM class MEDFileFastCellSupportComparator : public RefCountObject { public: - static MEDFileFastCellSupportComparator *New(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception); - bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception); - bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception); - std::size_t getHeapMemorySize() const; + MEDLOADER_EXPORT static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref); + MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFastCellSupportComparator"); } + MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const; + MEDLOADER_EXPORT bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const; + MEDLOADER_EXPORT int getNumberOfTS() const; + MEDLOADER_EXPORT std::vector getGeoTypesAt(int timeStepId, const MEDFileMesh *m) const; + bool isEqual(const MEDFileAnyTypeFieldMultiTS *other); + bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other); + std::size_t getHeapMemorySizeWithoutChildren() const; + std::vector getDirectChildrenWithNull() const; private: - MEDFileFastCellSupportComparator(const MEDFileMesh *m, const MEDFileAnyTypeFieldMultiTS *ref); + MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref); private: - MEDCouplingAutoRefCountObjectPtr _mesh_comp; - std::vector< MEDCouplingAutoRefCountObjectPtr > _f1ts_cmps; + MCAuto _mesh_comp; + std::vector< MCAuto > _f1ts_cmps; }; }