1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #ifndef __MEDFILEFIELDOVERVIEW_HXX__
22 #define __MEDFILEFIELDOVERVIEW_HXX__
24 #include "MEDLoaderDefines.hxx"
26 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
27 #include "MEDCouplingRefCountObject.hxx"
28 #include "MEDCoupling1GTUMesh.hxx"
30 #include "NormalizedUnstructuredMesh.hxx"
31 #include "InterpKernelException.hxx"
38 class MEDCouplingMesh;
42 class MEDFileCurveLinearMesh;
43 class MEDFileFieldGlobs;
44 class MEDFileFieldGlobsReal;
45 class MEDFileAnyTypeField1TS;
46 class MEDFileAnyTypeFieldMultiTS;
48 class MEDFileMeshStruct : public RefCountObject
51 MEDLOADER_EXPORT static MEDFileMeshStruct *New(const MEDFileMesh *mesh);
52 std::size_t getHeapMemorySize() const;
53 const MEDFileMesh *getTheMesh() const { return _mesh; }
54 int getNumberOfNodes() const { return _nb_nodes; }
55 int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
56 int getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
57 int getNumberOfLevs() const;
58 int getNumberOfGeoTypesInLev(int relativeLev) const throw(INTERP_KERNEL::Exception);
60 MEDFileMeshStruct(const MEDFileMesh *mesh);
62 const MEDFileMesh *_mesh;
65 std::vector< std::vector<int> > _geo_types_distrib;
68 class MEDFileField1TSStructItem;
70 class MEDMeshMultiLev : public RefCountObject
73 std::size_t getHeapMemorySize() const;
75 static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
76 static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
77 static MEDMeshMultiLev *NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode) throw(INTERP_KERNEL::Exception);
78 void setNodeReduction(const DataArrayInt *nr);
79 bool isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
80 MEDLOADER_EXPORT DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception);
81 virtual void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception) = 0;
82 virtual MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception) = 0;
83 int getNumberOfCells() const throw(INTERP_KERNEL::Exception);
84 int getNumberOfNodes() const throw(INTERP_KERNEL::Exception);
86 std::string getPflNameOfId(int id) const;
87 DataArray *constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception);
90 MEDMeshMultiLev(const MEDMeshMultiLev& other);
91 MEDMeshMultiLev(int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
93 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
94 std::vector< INTERP_KERNEL::NormalizedCellType > _geo_types;
95 std::vector<int> _nb_entities;
96 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _node_reduction;
99 static const int PARAMEDMEM_2_VTKTYPE_LGTH=34;
100 static const unsigned char PARAMEDMEM_2_VTKTYPE[PARAMEDMEM_2_VTKTYPE_LGTH];
103 class MEDStructuredMeshMultiLev;
105 class MEDUMeshMultiLev : public MEDMeshMultiLev
108 static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
109 static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
110 void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception);
111 MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception);
112 MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part);
113 MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const throw(INTERP_KERNEL::Exception);
115 void reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const throw(INTERP_KERNEL::Exception);
117 MEDUMeshMultiLev(const MEDUMeshMultiLev& other);
118 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs);
119 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
121 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _parts;
124 class MEDStructuredMeshMultiLev : public MEDMeshMultiLev
127 void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception);
128 virtual std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception) = 0;
130 MEDStructuredMeshMultiLev();
131 MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other);
132 MEDStructuredMeshMultiLev(int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
135 class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
138 static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
139 static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
140 std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception);
141 MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception);
142 MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays() const throw(INTERP_KERNEL::Exception);
144 MEDCMeshMultiLev(const MEDCMeshMultiLev& other);
145 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs);
146 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
148 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _coords;
151 class MEDCurveLinearMeshMultiLev : public MEDStructuredMeshMultiLev
154 static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
155 static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls , const std::vector<int>& nbEntities) throw(INTERP_KERNEL::Exception);
156 std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception);
157 MEDMeshMultiLev *prepare() const throw(INTERP_KERNEL::Exception);
158 MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const throw(INTERP_KERNEL::Exception);
160 MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other);
161 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
162 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
164 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
165 std::vector<int> _structure;
168 class MEDFileField1TSStructItem2 : public RefCountObject
171 MEDFileField1TSStructItem2();
172 MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
173 void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
174 void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
175 void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
177 MEDLOADER_EXPORT std::size_t getHeapMemorySize() const;
179 const DataArrayInt *getPfl(const MEDFileFieldGlobsReal *globs) const;
180 INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
181 int getNbEntity() const { return _nb_of_entity; }
182 const std::pair<int,int>& getStartStop() const { return _start_end; }
183 std::string getPflName() const;
184 int getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const;
185 //! warning this method also set _nb_of_entity attribute !
186 void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
187 bool isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const;
188 bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
189 bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
190 bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
191 static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
193 static const char NEWLY_CREATED_PFL_NAME[];
195 INTERP_KERNEL::NormalizedCellType _geo_type;
196 std::pair<int,int> _start_end;
197 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
202 class MEDFileField1TSStructItem : public RefCountObject
205 MEDFileField1TSStructItem() { }
206 MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
207 void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
208 bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
209 MEDLOADER_EXPORT std::size_t getHeapMemorySize() const;
210 bool isEntityCell() const;
211 bool isComputed() const { return _computed; }
212 TypeOfField getType() const { return _type; }
213 std::size_t getNumberOfItems() const { return _items.size(); }
214 const MEDFileField1TSStructItem2& operator[](std::size_t i) const throw(INTERP_KERNEL::Exception);
216 bool isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
217 bool isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
218 MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
219 bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
220 bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception);
221 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
222 MEDLOADER_EXPORT static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
226 std::vector< MEDFileField1TSStructItem2 > _items;
229 class MEDFileField1TSStruct : public RefCountObject
232 static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception);
233 void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
234 std::size_t getHeapMemorySize() const;
235 bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception);
236 bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
237 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
238 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
239 bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
241 MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
242 bool presenceOfCellDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
243 bool presenceOfPartialNodeDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
245 std::vector<MEDFileField1TSStructItem> _already_checked;
248 class MEDFileFastCellSupportComparator : public RefCountObject
251 MEDLOADER_EXPORT static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
252 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
253 MEDLOADER_EXPORT bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
254 bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
255 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
256 std::size_t getHeapMemorySize() const;
258 MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
260 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
261 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;