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 "MEDCouplingAutoRefCountObjectPtr.hxx"
25 #include "MEDCouplingRefCountObject.hxx"
26 #include "MEDCoupling1GTUMesh.hxx"
28 #include "NormalizedUnstructuredMesh.hxx"
29 #include "InterpKernelException.hxx"
36 class MEDCouplingMesh;
40 class MEDFileCurveLinearMesh;
41 class MEDFileFieldGlobs;
42 class MEDFileFieldGlobsReal;
43 class MEDFileAnyTypeField1TS;
44 class MEDFileAnyTypeFieldMultiTS;
46 class MEDFileMeshStruct : public RefCountObject
49 static MEDFileMeshStruct *New(const MEDFileMesh *mesh);
50 std::size_t getHeapMemorySize() const;
51 const MEDFileMesh *getTheMesh() const { return _mesh; }
52 int getNumberOfNodes() const { return _nb_nodes; }
53 int getNumberOfElemsOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
54 int getLevelOfGeoType(INTERP_KERNEL::NormalizedCellType t) const throw(INTERP_KERNEL::Exception);
55 int getNumberOfLevs() const;
56 int getNumberOfGeoTypesInLev(int relativeLev) const throw(INTERP_KERNEL::Exception);
58 MEDFileMeshStruct(const MEDFileMesh *mesh);
60 const MEDFileMesh *_mesh;
63 std::vector< std::vector<int> > _geo_types_distrib;
66 class MEDMeshMultiLev : public RefCountObject
69 std::size_t getHeapMemorySize() const;
71 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);
72 static MEDMeshMultiLev *New(const MEDFileMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
73 static MEDMeshMultiLev *NewOnlyOnNode(const MEDFileMesh *m, const DataArrayInt *pflOnNode) throw(INTERP_KERNEL::Exception);
74 void setNodeReduction(const DataArrayInt *nr);
75 virtual void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception) = 0;
78 MEDMeshMultiLev(const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
80 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
81 std::vector< INTERP_KERNEL::NormalizedCellType > _geo_types;
82 std::vector<int> _nb_entities;
83 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _node_reduction;
86 class MEDUMeshMultiLev : public MEDMeshMultiLev
89 static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
90 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);
91 void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception);
93 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs);
94 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
96 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _parts;
99 class MEDStructuredMeshMultiLev : public MEDMeshMultiLev
102 void selectPartOfNodes(const DataArrayInt *pflNodes) throw(INTERP_KERNEL::Exception);
103 virtual std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception) = 0;
105 MEDStructuredMeshMultiLev();
106 MEDStructuredMeshMultiLev(const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
109 class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
112 static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
113 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);
114 std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception);
116 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs);
117 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
119 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _coords;
122 class MEDCurveLinearMeshMultiLev : public MEDStructuredMeshMultiLev
125 static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs) throw(INTERP_KERNEL::Exception);
126 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);
127 std::vector<int> getNodeGridStructure() const throw(INTERP_KERNEL::Exception);
129 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
130 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
132 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
133 std::vector<int> _structure;
136 class MEDFileField1TSStructItem2 : public RefCountObject
139 MEDFileField1TSStructItem2();
140 MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
141 void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
142 void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
143 void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
145 std::size_t getHeapMemorySize() const;
147 const DataArrayInt *getPfl(const MEDFileFieldGlobsReal *globs) const;
148 INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
149 std::string getPflName() const;
150 //! warning this method also set _nb_of_entity attribute !
151 void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
152 bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
153 bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
154 bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
155 static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
157 static const char NEWLY_CREATED_PFL_NAME[];
159 INTERP_KERNEL::NormalizedCellType _geo_type;
160 std::pair<int,int> _start_end;
161 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
166 class MEDFileField1TSStructItem : public RefCountObject
169 MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
170 void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
171 bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
172 std::size_t getHeapMemorySize() const;
173 bool isEntityCell() const;
174 bool isComputed() const { return _computed; }
175 TypeOfField getType() const { return _type; }
176 std::size_t getNumberOfItems() const { return _items.size(); }
177 const MEDFileField1TSStructItem2& operator[](std::size_t i) const throw(INTERP_KERNEL::Exception);
179 bool isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
180 bool isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
181 MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
182 bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
183 bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const throw(INTERP_KERNEL::Exception);
184 MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
188 std::vector< MEDFileField1TSStructItem2 > _items;
191 class MEDFileField1TSStruct : public RefCountObject
194 static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst) throw(INTERP_KERNEL::Exception);
195 void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) throw(INTERP_KERNEL::Exception);
196 std::size_t getHeapMemorySize() const;
197 bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const throw(INTERP_KERNEL::Exception);
198 bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
199 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt) throw(INTERP_KERNEL::Exception);
200 MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
201 bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
203 MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
204 static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
205 bool presenceOfCellDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
206 bool presenceOfPartialNodeDiscr(int& pos) const throw(INTERP_KERNEL::Exception);
208 std::vector<MEDFileField1TSStructItem> _already_checked;
211 class MEDFileFastCellSupportComparator : public RefCountObject
214 static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref) throw(INTERP_KERNEL::Exception);
215 MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
216 bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const throw(INTERP_KERNEL::Exception);
217 bool isEqual(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
218 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other) throw(INTERP_KERNEL::Exception);
219 std::size_t getHeapMemorySize() const;
221 MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
223 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
224 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;