1 // Copyright (C) 2007-2023 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)
21 #ifndef __MEDFILEFIELDGLOBS_HXX__
22 #define __MEDFILEFIELDGLOBS_HXX__
24 #include "MEDLoaderDefines.hxx"
26 #include "NormalizedGeometricTypes"
27 #include "MEDCouplingMemArray.hxx"
34 class MEDFileFieldGlobsReal;
35 class MEDFileEntities;
36 class MEDFileWritable;
37 class MEDFileFieldLoc;
39 class MEDFileFieldGlobs : public RefCountObject
42 static MEDFileFieldGlobs *New(med_idt fid);
43 static MEDFileFieldGlobs *New();
44 std::string getClassName() const override { return std::string("MEDFileFieldGlobs"); }
45 std::size_t getHeapMemorySizeWithoutChildren() const;
46 std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
47 MEDFileFieldGlobs *deepCopy() const;
48 MEDFileFieldGlobs *shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const;
49 MEDFileFieldGlobs *deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const;
50 void simpleRepr(std::ostream& oss) const;
51 void appendGlobs(const MEDFileFieldGlobs& other, double eps);
52 void checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const;
53 void checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const;
54 void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
55 void loadProfileInFile(med_idt fid, int id);
56 void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real);
57 void loadAllGlobals(med_idt fid, const MEDFileEntities *entities);
58 void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
59 std::vector<std::string> getPfls() const;
60 std::vector<std::string> getLocs() const;
61 bool existsPfl(const std::string& pflName) const;
62 bool existsLoc(const std::string& locName) const;
63 std::string createNewNameOfPfl() const;
64 std::string createNewNameOfLoc() const;
65 std::vector< std::vector<int> > whichAreEqualProfiles() const;
66 std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
67 void setFileName(const std::string& fileName) { _file_name=fileName; }
68 void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
69 void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
70 int getNbOfGaussPtPerCell(int locId) const;
71 int getLocalizationId(const std::string& loc) const;
72 int getProfileId(const std::string& pfl) const;
73 std::string getFileName() const { return _file_name; }
74 const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
75 const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
76 const DataArrayIdType *getProfileFromId(int pflId) const;
77 const DataArrayIdType *getProfile(const std::string& pflName) const;
78 MEDFileFieldLoc& getLocalizationFromId(int locId);
79 MEDFileFieldLoc& getLocalization(const std::string& locName);
80 DataArrayIdType *getProfile(const std::string& pflName);
81 DataArrayIdType *getProfileFromId(int pflId);
82 void killProfileIds(const std::vector<int>& pflIds);
83 void killLocalizationIds(const std::vector<int>& locIds);
84 void killStructureElementsInGlobs();
86 void appendProfile(DataArrayIdType *pfl);
87 void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
89 static std::string CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid);
91 MEDFileFieldGlobs(med_idt fid);
95 std::vector< MCAuto<DataArrayIdType> > _pfls;
96 std::vector< MCAuto<MEDFileFieldLoc> > _locs;
97 std::string _file_name;
100 /// @endcond INTERNAL
102 class MEDFileFieldGlobsReal
105 MEDLOADER_EXPORT MEDFileFieldGlobsReal(med_idt fid);
106 MEDLOADER_EXPORT MEDFileFieldGlobsReal();
107 MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
108 MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
109 MEDLOADER_EXPORT void simpleReprGlobs(std::ostream& oss) const;
110 MEDLOADER_EXPORT void resetContent();
111 MEDLOADER_EXPORT void killStructureElementsInGlobs();
112 MEDLOADER_EXPORT void shallowCpyGlobs(const MEDFileFieldGlobsReal& other);
113 MEDLOADER_EXPORT void deepCpyGlobs(const MEDFileFieldGlobsReal& other);
114 MEDLOADER_EXPORT void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other);
115 MEDLOADER_EXPORT void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other);
116 MEDLOADER_EXPORT void appendGlobs(const MEDFileFieldGlobsReal& other, double eps);
117 MEDLOADER_EXPORT void checkGlobsCoherency() const;
118 MEDLOADER_EXPORT void checkGlobsPflsPartCoherency() const;
119 MEDLOADER_EXPORT void checkGlobsLocsPartCoherency() const;
120 MEDLOADER_EXPORT virtual std::vector<std::string> getPflsReallyUsed() const = 0;
121 MEDLOADER_EXPORT virtual std::vector<std::string> getLocsReallyUsed() const = 0;
122 MEDLOADER_EXPORT virtual std::vector<std::string> getPflsReallyUsedMulti() const = 0;
123 MEDLOADER_EXPORT virtual std::vector<std::string> getLocsReallyUsedMulti() const = 0;
124 MEDLOADER_EXPORT virtual void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) = 0;
125 MEDLOADER_EXPORT virtual void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) = 0;
126 MEDLOADER_EXPORT virtual ~MEDFileFieldGlobsReal();
128 MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
129 MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id);
130 MEDLOADER_EXPORT void loadGlobals(med_idt fid);
131 MEDLOADER_EXPORT void loadAllGlobals(med_idt fid, const MEDFileEntities *entities=0);
132 MEDLOADER_EXPORT void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
133 MEDLOADER_EXPORT std::vector<std::string> getPfls() const;
134 MEDLOADER_EXPORT std::vector<std::string> getLocs() const;
135 MEDLOADER_EXPORT bool existsPfl(const std::string& pflName) const;
136 MEDLOADER_EXPORT bool existsLoc(const std::string& locName) const;
137 MEDLOADER_EXPORT std::string createNewNameOfPfl() const;
138 MEDLOADER_EXPORT std::string createNewNameOfLoc() const;
139 MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualProfiles() const;
140 MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
141 MEDLOADER_EXPORT void setFileName(const std::string& fileName);
142 MEDLOADER_EXPORT void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
143 MEDLOADER_EXPORT void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
144 MEDLOADER_EXPORT void changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
145 MEDLOADER_EXPORT void changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
146 MEDLOADER_EXPORT void changePflName(const std::string& oldName, const std::string& newName);
147 MEDLOADER_EXPORT void changeLocName(const std::string& oldName, const std::string& newName);
148 MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipPflsNames();
149 MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipLocsNames(double eps);
150 MEDLOADER_EXPORT int getNbOfGaussPtPerCell(int locId) const;
151 MEDLOADER_EXPORT int getLocalizationId(const std::string& loc) const;
152 MEDLOADER_EXPORT int getProfileId(const std::string& pfl) const;
153 MEDLOADER_EXPORT std::string getFileName() const;
154 MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
155 MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
156 MEDLOADER_EXPORT MEDFileFieldLoc& getLocalizationFromId(int locId);
157 MEDLOADER_EXPORT MEDFileFieldLoc& getLocalization(const std::string& locName);
158 MEDLOADER_EXPORT const DataArrayIdType *getProfile(const std::string& pflName) const;
159 MEDLOADER_EXPORT const DataArrayIdType *getProfileFromId(int pflId) const;
160 MEDLOADER_EXPORT DataArrayIdType *getProfile(const std::string& pflName);
161 MEDLOADER_EXPORT DataArrayIdType *getProfileFromId(int pflId);
162 MEDLOADER_EXPORT void killProfileIds(const std::vector<int>& pflIds);
163 MEDLOADER_EXPORT void killLocalizationIds(const std::vector<int>& locIds);
165 MEDLOADER_EXPORT void appendProfile(DataArrayIdType *pfl);
166 MEDLOADER_EXPORT void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
168 MEDFileFieldGlobs *contentNotNull();
169 const MEDFileFieldGlobs *contentNotNull() const;
171 MCAuto< MEDFileFieldGlobs > _globals;
174 class MEDFileFieldNameScope
177 MEDLOADER_EXPORT MEDFileFieldNameScope();
178 MEDLOADER_EXPORT MEDFileFieldNameScope(const std::string& fieldName, const std::string& meshName);
179 MEDLOADER_EXPORT std::string getName() const;
180 MEDLOADER_EXPORT void setName(const std::string& fieldName);
181 MEDLOADER_EXPORT std::string getDtUnit() const;
182 MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
183 MEDLOADER_EXPORT void copyNameScope(const MEDFileFieldNameScope& other);
184 MEDLOADER_EXPORT std::string getMeshName() const;
185 MEDLOADER_EXPORT void setMeshName(const std::string& meshName);
188 std::string _dt_unit;
189 std::string _mesh_name;