1 // Copyright (C) 2007-2022 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, or (at your option) any later version.
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 (EDF R&D)
23 #include "MEDLoaderDefines.hxx"
25 #include "MEDFileFieldInternal.hxx"
26 #include "MEDFileFieldGlobs.hxx"
27 #include "MEDFileField1TS.hxx"
28 #include "MEDFileFieldMultiTS.hxx"
30 #include "MEDFileFieldOverView.hxx"
31 #include "MEDFileUtilities.txx"
32 #include "MEDFileEntities.hxx"
35 #include "MEDLoaderTraits.hxx"
36 #include "MEDCouplingTraits.hxx"
37 #include "MEDCouplingRefCountObject.hxx"
38 #include "MEDCouplingMemArray.hxx"
39 #include "MEDCouplingPartDefinition.hxx"
41 #include "NormalizedUnstructuredMesh.hxx"
42 #include "InterpKernelException.hxx"
53 class MEDFileFieldGlobs;
54 class MEDCouplingMesh;
55 class MEDCouplingFieldDouble;
57 class MEDFileFieldVisitor;
61 class MEDFileFieldsIterator;
62 class MEDFileStructureElements;
67 class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritableStandAlone
70 MEDLOADER_EXPORT static MEDFileFields *New();
71 MEDLOADER_EXPORT static MEDFileFields *New(const std::string& fileName, bool loadAll=true);
72 MEDLOADER_EXPORT static MEDFileFields *New(med_idt fid, bool loadAll=true);
73 MEDLOADER_EXPORT static MEDFileFields *NewAdv(const std::string& fileName, bool loadAll, const MEDFileEntities *entities);
74 MEDLOADER_EXPORT static MEDFileFields *NewAdv(med_idt fid, bool loadAll, const MEDFileEntities *entities);
75 MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(const std::string& fileName, const MEDFileStructureElements *se, bool loadAll=true);
76 MEDLOADER_EXPORT static MEDFileFields *NewWithDynGT(med_idt fid, const MEDFileStructureElements *se, bool loadAll=true);
77 MEDLOADER_EXPORT static MEDFileFields *New(DataArrayByte *db) { return BuildFromMemoryChunk<MEDFileFields>(db); }
78 MEDLOADER_EXPORT std::string getClassName() const override { return std::string("MEDFileFields"); }
79 MEDLOADER_EXPORT static MEDFileFields *LoadPartOf(const std::string& fileName, bool loadAll=true, const MEDFileMeshes *ms=0);
80 MEDLOADER_EXPORT static MEDFileFields *LoadSpecificEntities(const std::string& fileName, const std::vector< std::pair<TypeOfField,INTERP_KERNEL::NormalizedCellType> >& entities, bool loadAll=true);
81 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
82 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
83 MEDLOADER_EXPORT MEDFileFields *deepCopy() const;
84 MEDLOADER_EXPORT MEDFileFields *shallowCpy() const;
85 MEDLOADER_EXPORT void writeLL(med_idt fid) const;
86 MEDLOADER_EXPORT void loadArrays();
87 MEDLOADER_EXPORT void loadArraysIfNecessary();
88 MEDLOADER_EXPORT void unloadArrays();
89 MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
90 MEDLOADER_EXPORT int getNumberOfFields() const;
91 MEDLOADER_EXPORT std::vector< std::pair<int,int> > getCommonIterations(bool& areThereSomeForgottenTS) const;
92 MEDLOADER_EXPORT std::vector<std::string> getFieldsNames() const;
93 MEDLOADER_EXPORT std::vector<std::string> getMeshesNames() const;
94 MEDLOADER_EXPORT std::string simpleRepr() const;
95 MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss) const;
97 MEDLOADER_EXPORT void resize(int newSize);
98 MEDLOADER_EXPORT void pushField(MEDFileAnyTypeFieldMultiTS *field);
99 MEDLOADER_EXPORT void pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields);
100 MEDLOADER_EXPORT void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field);
101 MEDLOADER_EXPORT int getPosFromFieldName(const std::string& fieldName) const;
102 MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const;
103 MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const;
104 MEDLOADER_EXPORT MEDFileFields *buildSubPart(const int *startIds, const int *endIds) const;
105 MEDLOADER_EXPORT bool removeFieldsWithoutAnyTimeStep();
106 MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const;
107 MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
108 MEDLOADER_EXPORT MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
109 MEDLOADER_EXPORT bool presenceOfStructureElements() const;
110 MEDLOADER_EXPORT void killStructureElements();
111 MEDLOADER_EXPORT void keepOnlyStructureElements();
112 MEDLOADER_EXPORT void keepOnlyOnMeshSE(const std::string& meshName, const std::string& seName);
113 MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
114 MEDLOADER_EXPORT void blowUpSE(MEDFileMeshes *ms, const MEDFileStructureElements *ses);
115 MEDLOADER_EXPORT void aggregateFieldsOnSameMeshes(MEDFileMeshes *ms);
116 MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisOnStructureElements() const;
117 MEDLOADER_EXPORT MCAuto<MEDFileFields> partOfThisLyingOnSpecifiedMeshSEName(const std::string& meshName, const std::string& seName) const;
118 MEDLOADER_EXPORT void aggregate(const MEDFileFields& other);
119 MEDLOADER_EXPORT MEDFileFieldsIterator *iterator();
120 MEDLOADER_EXPORT void destroyFieldAtPos(int i);
121 MEDLOADER_EXPORT void destroyFieldsAtPos(const int *startIds, const int *endIds);
122 MEDLOADER_EXPORT void destroyFieldsAtPos2(int bg, int end, int step);
123 MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
124 MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<mcIdType>& oldCode, const std::vector<mcIdType>& newCode, const DataArrayIdType *renumO2N);
125 MEDLOADER_EXPORT void accept(MEDFileFieldVisitor& visitor) const;
126 MEDLOADER_EXPORT MCAuto<MEDFileFields> linearToQuadratic(const MEDFileMeshes *oldLin, const MEDFileMeshes *newQuad) const;
128 MEDLOADER_EXPORT MEDFileFields *extractPart(const std::map<int, MCAuto<DataArrayIdType> >& extractDef, MEDFileMesh *mm) const;
130 MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
131 MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed() const;
132 MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti() const;
133 MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti() const;
134 MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
135 MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
139 MEDFileFields(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
141 std::vector< MCAuto<MEDFileAnyTypeFieldMultiTSWithoutSDA> > _fields;
144 class MEDFileFieldsIterator
147 MEDLOADER_EXPORT MEDFileFieldsIterator(MEDFileFields *fs);
148 MEDLOADER_EXPORT ~MEDFileFieldsIterator();
149 MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *nextt();
151 MCAuto<MEDFileFields> _fs;