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 MEDLOADER_EXPORT void retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const;
84 MEDLOADER_EXPORT void retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const;
85 void setFamilyIdsOnCells(DataArrayInt *famIds, bool isNoCopy);
86 void setNumberIdsOnCells(DataArrayInt *numIds, bool isNoCopy);
87 virtual void selectPartOfNodes(const DataArrayInt *pflNodes) = 0;
88 virtual MEDMeshMultiLev *prepare() const = 0;
89 int getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const;
90 int getNumberOfNodes() const;
92 std::string getPflNameOfId(int id) const;
93 DataArray *constructDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const;
96 MEDMeshMultiLev(const MEDMeshMultiLev& other);
97 MEDMeshMultiLev(int nbNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
99 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
100 std::vector< INTERP_KERNEL::NormalizedCellType > _geo_types;
101 std::vector<int> _nb_entities;
102 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _node_reduction;
105 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _cell_fam_ids;
106 bool _cell_fam_ids_nocpy;
107 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _cell_num_ids;
108 bool _cell_num_ids_nocpy;
110 static const int PARAMEDMEM_2_VTKTYPE_LGTH=34;
111 static const unsigned char PARAMEDMEM_2_VTKTYPE[PARAMEDMEM_2_VTKTYPE_LGTH];
114 class MEDStructuredMeshMultiLev;
116 class MEDUMeshMultiLev : public MEDMeshMultiLev
119 static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<int>& levs);
120 static MEDUMeshMultiLev *New(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
121 void selectPartOfNodes(const DataArrayInt *pflNodes);
122 MEDMeshMultiLev *prepare() const;
123 MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh>& part);
124 MEDLOADER_EXPORT bool buildVTUArrays(DataArrayDouble *& coords, DataArrayByte *&types, DataArrayInt *&cellLocations, DataArrayInt *& cells, DataArrayInt *&faceLocations, DataArrayInt *&faces) const;
126 void reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const;
128 MEDUMeshMultiLev(const MEDUMeshMultiLev& other);
129 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<int>& levs);
130 MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
132 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCoupling1GTUMesh> > _parts;
135 class MEDStructuredMeshMultiLev : public MEDMeshMultiLev
138 void selectPartOfNodes(const DataArrayInt *pflNodes);
139 virtual std::vector<int> getNodeGridStructure() const = 0;
141 MEDStructuredMeshMultiLev();
142 MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other);
143 MEDStructuredMeshMultiLev(int nbOfNodes, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
146 class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev
149 static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<int>& levs);
150 static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
151 std::vector<int> getNodeGridStructure() const;
152 MEDMeshMultiLev *prepare() const;
153 MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays() const;
155 MEDCMeshMultiLev(const MEDCMeshMultiLev& other);
156 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<int>& levs);
157 MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
159 std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _coords;
162 class MEDCurveLinearMeshMultiLev : public MEDStructuredMeshMultiLev
165 static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
166 static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls , const std::vector<int>& nbEntities);
167 std::vector<int> getNodeGridStructure() const;
168 MEDMeshMultiLev *prepare() const;
169 MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector<int>& nodeStrct) const;
171 MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other);
172 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<int>& levs);
173 MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector<INTERP_KERNEL::NormalizedCellType>& gts, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& nbEntities);
175 MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> _coords;
176 std::vector<int> _structure;
179 class MEDFileField1TSStructItem2 : public BigMemoryObject
182 MEDFileField1TSStructItem2();
183 MEDFileField1TSStructItem2(INTERP_KERNEL::NormalizedCellType a, const std::pair<int,int>& b, const std::string& pfl, const std::string& loc);
184 void checkWithMeshStructForCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
185 void checkWithMeshStructForGaussNE(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
186 void checkWithMeshStructForGaussPT(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
188 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
189 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
191 const DataArrayInt *getPfl(const MEDFileFieldGlobsReal *globs) const;
192 INTERP_KERNEL::NormalizedCellType getGeo() const { return _geo_type; }
193 int getNbEntity() const { return _nb_of_entity; }
194 const std::pair<int,int>& getStartStop() const { return _start_end; }
195 std::string getPflName() const;
196 int getNbOfIntegrationPts(const MEDFileFieldGlobsReal *globs) const;
197 //! warning this method also set _nb_of_entity attribute !
198 void checkInRange(int nbOfEntity, int nip, const MEDFileFieldGlobsReal *globs);
199 bool isFastlyEqual(int& startExp, INTERP_KERNEL::NormalizedCellType gt, const char *pflName) const;
200 bool operator==(const MEDFileField1TSStructItem2& other) const throw(INTERP_KERNEL::Exception);
201 bool isCellSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const;
202 bool isNodeSupportEqual(const MEDFileField1TSStructItem2& other, const MEDFileFieldGlobsReal *globs) const;
203 static MEDFileField1TSStructItem2 BuildAggregationOf(const std::vector<const MEDFileField1TSStructItem2 *>& objs, const MEDFileFieldGlobsReal *globs);
205 static const char NEWLY_CREATED_PFL_NAME[];
207 INTERP_KERNEL::NormalizedCellType _geo_type;
208 std::pair<int,int> _start_end;
209 MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _pfl;
214 class MEDFileField1TSStructItem : public BigMemoryObject
217 MEDFileField1TSStructItem() { }
218 MEDFileField1TSStructItem(TypeOfField a, const std::vector< MEDFileField1TSStructItem2 >& b);
219 void checkWithMeshStruct(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
220 bool operator==(const MEDFileField1TSStructItem& other) const throw(INTERP_KERNEL::Exception);
221 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
222 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
223 bool isEntityCell() const;
224 bool isComputed() const { return _computed; }
225 TypeOfField getType() const { return _type; }
226 std::size_t getNumberOfItems() const { return _items.size(); }
227 const MEDFileField1TSStructItem2& operator[](std::size_t i) const throw(INTERP_KERNEL::Exception);
229 bool isCellSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const;
230 bool isNodeSupportEqual(const MEDFileField1TSStructItem& other, const MEDFileFieldGlobsReal *globs) const;
231 MEDFileField1TSStructItem simplifyMeOnCellEntity(const MEDFileFieldGlobsReal *globs) const;
232 bool isCompatibleWithNodesDiscr(const MEDFileField1TSStructItem& other, const MEDFileMeshStruct *meshSt, const MEDFileFieldGlobsReal *globs) const;
233 bool isFullyOnOneLev(const MEDFileMeshStruct *meshSt, int& theFirstLevFull) const;
234 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupportOnCells(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
235 MEDLOADER_EXPORT static MEDFileField1TSStructItem BuildItemFrom(const MEDFileAnyTypeField1TS *ref, const MEDFileMeshStruct *meshSt);
239 std::vector< MEDFileField1TSStructItem2 > _items;
242 class MEDFileField1TSStruct : public RefCountObject
245 static MEDFileField1TSStruct *New(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
246 void checkWithMeshStruct(MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs);
247 std::size_t getHeapMemorySizeWithoutChildren() const;
248 std::vector<const BigMemoryObject *> getDirectChildren() const;
249 bool isEqualConsideringThePast(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *mst) const;
250 bool isSupportSameAs(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt);
251 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeField1TS *other, const MEDFileMeshStruct *meshSt);
252 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(const MEDFileMeshStruct *mst, const MEDFileFieldGlobsReal *globs) const;
253 bool isDataSetSupportFastlyEqualTo(const MEDFileField1TSStruct& other, const MEDFileFieldGlobsReal *globs) const;
255 MEDFileField1TSStruct(const MEDFileAnyTypeField1TS *ref, MEDFileMeshStruct *mst);
256 bool presenceOfCellDiscr(int& pos) const;
257 bool presenceOfPartialNodeDiscr(int& pos) const;
259 std::vector<MEDFileField1TSStructItem> _already_checked;
262 class MEDFileFastCellSupportComparator : public RefCountObject
265 MEDLOADER_EXPORT static MEDFileFastCellSupportComparator *New(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
266 MEDLOADER_EXPORT MEDMeshMultiLev *buildFromScratchDataSetSupport(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
267 MEDLOADER_EXPORT bool isDataSetSupportEqualToThePreviousOne(int timeStepId, const MEDFileFieldGlobsReal *globs) const;
268 bool isEqual(const MEDFileAnyTypeFieldMultiTS *other);
269 bool isCompatibleWithNodesDiscr(const MEDFileAnyTypeFieldMultiTS *other);
270 std::size_t getHeapMemorySizeWithoutChildren() const;
271 std::vector<const BigMemoryObject *> getDirectChildren() const;
273 MEDFileFastCellSupportComparator(const MEDFileMeshStruct *m, const MEDFileAnyTypeFieldMultiTS *ref);
275 MEDCouplingAutoRefCountObjectPtr<MEDFileMeshStruct> _mesh_comp;
276 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSStruct> > _f1ts_cmps;