Salome HOME
Merge from V7_3_BR branch 18/12/2013
[modules/med.git] / src / MEDLoader / MEDLoader.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDLOADER_HXX__
22 #define __MEDLOADER_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25 #include "InterpKernelException.hxx"
26 #include "MEDCouplingRefCountObject.hxx"
27 #include "NormalizedUnstructuredMesh.hxx"
28
29 #include <list>
30 #include <vector>
31
32 namespace ParaMEDMEM
33 {
34   class DataArrayInt;
35   class MEDCouplingMesh;
36   class MEDCouplingUMesh;
37   class MEDCouplingFieldDouble;
38   class MEDFileWritable;
39 }
40
41 class MEDLOADER_EXPORT MEDLoader
42 {
43  public:
44   static void SetEpsilonForNodeComp(double val);
45   static void SetCompPolicyForCell(int val);
46   static void SetTooLongStrPolicy(int val);
47   static bool HasXDR();
48   static std::string MEDFileVersionStr();
49   static void MEDFileVersion(int& major, int& minor, int& release);
50   static void CheckFileForRead(const char *fileName);
51   static std::vector<std::string> GetMeshNames(const char *fileName);
52   static std::vector< std::vector< std::pair<INTERP_KERNEL::NormalizedCellType,int> > > GetUMeshGlobalInfo(const char *fileName, const char *meshName, int &meshDim, int& spaceDim, int& numberOfNodes);
53   static std::vector< std::pair<std::string,std::string> > GetComponentsNamesOfField(const char *fileName, const char *fieldName);
54   static std::vector<std::string> GetMeshNamesOnField(const char *fileName, const char *fieldName);
55   static std::vector<std::string> GetMeshGroupsNames(const char *fileName, const char *meshName);
56   static std::vector<std::string> GetMeshFamiliesNames(const char *fileName, const char *meshName);
57   static std::vector<std::string> GetMeshFamiliesNamesOnGroup(const char *fileName, const char *meshName, const char *grpName);
58   static std::vector<std::string> GetMeshGroupsNamesOnFamily(const char *fileName, const char *meshName, const char *famName);
59   static std::vector<std::string> GetAllFieldNames(const char *fileName);
60   static std::vector<std::string> GetAllFieldNamesOnMesh(const char *fileName, const char *meshName);
61   static std::vector<ParaMEDMEM::TypeOfField> GetTypesOfField(const char *fileName, const char *meshName, const char *fieldName);
62   static std::vector<std::string> GetFieldNamesOnMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName);
63   static std::vector<std::string> GetCellFieldNamesOnMesh(const char *fileName, const char *meshName);
64   static std::vector<std::string> GetNodeFieldNamesOnMesh(const char *fileName, const char *meshName);
65   static std::vector< std::pair<int,int> > GetFieldIterations(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, const char *fieldName);
66   static std::vector< std::pair<int,int> > GetCellFieldIterations(const char *fileName, const char *meshName, const char *fieldName);
67   static std::vector< std::pair<int,int> > GetNodeFieldIterations(const char *fileName, const char *meshName, const char *fieldName);
68   static std::vector< std::pair< std::pair<int,int>, double> > GetAllFieldIterations(const char *fileName, const char *fieldName);
69   static double GetTimeAttachedOnFieldIteration(const char *fileName, const char *fieldName, int iteration, int order);
70   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFamilies(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& fams);
71   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromGroups(const char *fileName, const char *meshName, int meshDimRelToMax, const std::vector<std::string>& grps);
72   static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0);
73   static ParaMEDMEM::MEDCouplingMesh *ReadMeshFromFile(const char *fileName, int meshDimRelToMax=0);
74   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, const char *meshName, int meshDimRelToMax=0);
75   static ParaMEDMEM::MEDCouplingUMesh *ReadUMeshFromFile(const char *fileName, int meshDimRelToMax=0);
76   static int ReadUMeshDimFromFile(const char *fileName, const char *meshName);
77   static ParaMEDMEM::MEDCouplingFieldDouble *ReadField(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
78   static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsOnSameMesh(ParaMEDMEM::TypeOfField type, const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
79                                                                                 const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
80   static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsCellOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
81                                                                                     const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
82   static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsNodeOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
83                                                                                     const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
84   static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
85                                                                                      const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
86   static std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> ReadFieldsGaussNEOnSameMesh(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName,
87                                                                                        const std::vector<std::pair<int,int> >& its) throw(INTERP_KERNEL::Exception);
88   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldCell(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
89   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldNode(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
90   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGauss(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
91   static ParaMEDMEM::MEDCouplingFieldDouble *ReadFieldGaussNE(const char *fileName, const char *meshName, int meshDimRelToMax, const char *fieldName, int iteration, int order);
92   static void WriteMesh(const char *fileName, const ParaMEDMEM::MEDCouplingMesh *mesh, bool writeFromScratch);
93   static void WriteUMesh(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
94   static void WriteUMeshDep(const char *fileName, const ParaMEDMEM::MEDCouplingUMesh *mesh, bool writeFromScratch);
95   static void WriteUMeshesPartition(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
96   static void WriteUMeshesPartitionDep(const char *fileName, const char *meshName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
97   static void WriteUMeshes(const char *fileName, const std::vector<const ParaMEDMEM::MEDCouplingUMesh *>& meshes, bool writeFromScratch);
98   static void WriteField(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch);
99   static void WriteFieldDep(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f, bool writeFromScratch);
100   static void WriteFieldUsingAlreadyWrittenMesh(const char *fileName, const ParaMEDMEM::MEDCouplingFieldDouble *f);
101  public:
102   static void AssignStaticWritePropertiesTo(ParaMEDMEM::MEDFileWritable& obj);
103  private:
104   MEDLoader();
105  public:
106   static double _EPS_FOR_NODE_COMP;
107   static int _COMP_FOR_CELL;
108   static int _TOO_LONG_STR;
109 };
110
111 #endif