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 getHeapMemorySizeWithoutChildren() const;
53 std::vector<const BigMemoryObject *> getDirectChildren() const;
54 const MEDFileMesh *getTheMesh() const { return _mesh; }
55 int getNumberOfNodes() const { return _nb_nodes; }
56 int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const;
57 int getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const;
58 int getNumberOfLevs() const;
59 int getNumberOfGeoTypesInLev(int relativeLev) const;
61 MEDFileMeshStruct(const MEDFileMesh *mesh);
63 const MEDFileMesh *_mesh;
66 std::vector< std::vector<int> > _geo_types_distrib;
69 class MEDFileField1TSStructItem;
71 class MEDMeshMultiLev : public RefCountObject
74 std::size_t getHeapMemorySizeWithoutChildren() const;
75 std::vector<const BigMemoryObject *> getDirectChildren() const;
77 static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
78 static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<int>& levs);
79 static MEDMeshMultiLev *NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode);
80 void setNodeReduction(const DataArrayInt *nr);
81 bool isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const;
82 MEDLOADER_EXPORT DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const;
83 virtual void selectPartOfNodes(const DataArrayInt *pflNodes) = 0;
84 virtual MEDMeshMultiLev *prepare() const = 0;
85 int getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const;
86 int getNumberOfNodes() const;
88 std::string getPflNameOfId(int id) const;
89 DataArray *constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const;
92 MEDMeshMultiLev(const MEDMeshMultiLev& other);
93 MEDMeshMultiLev(int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
95 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
96 std::vector< INTERP_KERNEL::NormalizedCellType > _geo_types;
97 std::vector<int> _nb_entities;
98 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _node_reduction;
101 static const int PARAMEDMEM_2_VTKTYPE_LGTH=34;
102 static const unsigned char PARAMEDMEM_2_VTKTYPE[PARAMEDMEM_2_VTKTYPE_LGTH];
105 class MEDStructuredMeshMultiLev;
107 class MEDUMeshMultiLev : public MEDMeshMultiLev
110 static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<int>& levs);
111 static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
112 void selectPartOfNodes(const DataArrayInt *pflNodes);
113 MEDMeshMultiLev *prepare() const;
114 MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part);
115 MEDLOADER_EXPORT bool buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const;
117 void reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const;
119 MEDUMeshMultiLev(const MEDUMeshMultiLev& other);
120 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs);
121 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
123 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _parts;
126 class MEDStructuredMeshMultiLev : public MEDMeshMultiLev
129 void selectPartOfNodes(const DataArrayInt *pflNodes);
130 virtual std::vector<int> getNodeGridStructure() const = 0;
132 MEDStructuredMeshMultiLev();
133 MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other);
134 MEDStructuredMeshMultiLev(int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
137 class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
140 static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<int>& levs);
141 static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
142 std::vector<int> getNodeGridStructure() const;
143 MEDMeshMultiLev *prepare() const;
144 MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays() const;
146 MEDCMeshMultiLev(const MEDCMeshMultiLev& other);
147 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs);
148 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
150 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _coords;
153 class MEDCurveLinearMeshMultiLev : public MEDStructuredMeshMultiLev
156 static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
157 static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls , const std::vector<int>& nbEntities);
158 std::vector<int> getNodeGridStructure() const;
159 MEDMeshMultiLev *prepare() const;
160 MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const;
162 MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other);
163 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
164 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
166 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
167 std::vector<int> _structure;
170 class MEDFileField1TSStructItem2 : public BigMemoryObject
173 MEDFileField1TSStructItem2();
174 MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
175 void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
176 void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
177 void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
179 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
180 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
182 const DataArrayInt *getPfl(const MEDFileFieldGlobsReal *globs) const;
183 INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
184 int getNbEntity() const { return _nb_of_entity; }
185 const std::pair<int,int>& getStartStop() const { return _start_end; }
186 std::string getPflName() const;
187 int getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const;
188 //! warning this method also set _nb_of_entity attribute !
189 void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs);
190 bool isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const;
191 bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
192 bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const;
193 bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const;
194 static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs);
196 static const char NEWLY_CREATED_PFL_NAME[];
198 INTERP_KERNEL::NormalizedCellType _geo_type;
199 std::pair<int,int> _start_end;
200 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
205 class MEDFileField1TSStructItem : public BigMemoryObject
208 MEDFileField1TSStructItem() { }
209 MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
210 void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
211 bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
212 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
213 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
214 bool isEntityCell() const;
215 bool isComputed() const { return _computed; }
216 TypeOfField getType() const { return _type; }
217 std::size_t getNumberOfItems() const { return _items.size(); }
218 const MEDFileField1TSStructItem2& operator[](std::size_t i) const throw(INTERP_KERNEL::Exception);
220 bool isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const;
221 bool isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const;
222 MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const;
223 bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const;
224 bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const;
225 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
226 MEDLOADER_EXPORT static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
230 std::vector< MEDFileField1TSStructItem2 > _items;
233 class MEDFileField1TSStruct : public RefCountObject
236 static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
237 void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
238 std::size_t getHeapMemorySizeWithoutChildren() const;
239 std::vector<const BigMemoryObject *> getDirectChildren() const;
240 bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const;
241 bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt);
242 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt);
243 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
244 bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const;
246 MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
247 bool presenceOfCellDiscr(int& pos) const;
248 bool presenceOfPartialNodeDiscr(int& pos) const;
250 std::vector<MEDFileField1TSStructItem> _already_checked;
253 class MEDFileFastCellSupportComparator : public RefCountObject
256 MEDLOADER_EXPORT static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
257 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
258 MEDLOADER_EXPORT bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
259 bool isEqual(const MEDFileAnyTypeFieldMultiTS *other);
260 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other);
261 std::size_t getHeapMemorySizeWithoutChildren() const;
262 std::vector<const BigMemoryObject *> getDirectChildren() const;
264 MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
266 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
267 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;