Salome HOME
remove src/MEDCalc/doc
[modules/med.git] / src / MEDLoader / MEDFileJoint.hxx
1 // Copyright (C) 2007-2015  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, or (at your option) any later version.
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
20 #ifndef __MEDFILEJOINT_HXX__
21 #define __MEDFILEJOINT_HXX__
22
23 #include "MEDLoaderDefines.hxx"
24 #include "MEDFileUtilities.hxx"
25 #include "MEDCouplingMemArray.hxx"
26 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
27
28 namespace ParaMEDMEM
29 {
30 /*!
31  * \brief Joint Correspondence enumerates pairs of corresponding entities of a
32  *        certain geometrical type in adjacent mesh domains.
33  *        Correspondence of nodes is constructed when you specify no cell type,
34  *        else Correspondence of cells is constructed.
35  */
36 class MEDFileJointCorrespondence : public RefCountObject, public MEDFileWritable
37 {
38 public:
39   MEDLOADER_EXPORT static MEDFileJointCorrespondence *New();
40   MEDLOADER_EXPORT static MEDFileJointCorrespondence *New(DataArrayInt* correspondence); // nodes
41   MEDLOADER_EXPORT static MEDFileJointCorrespondence *New(DataArrayInt* correspondence,  // cells
42                                                           INTERP_KERNEL::NormalizedCellType loc_geo_type,
43                                                           INTERP_KERNEL::NormalizedCellType rem_geo_type);
44   MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
45   MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
46   MEDLOADER_EXPORT MEDFileJointCorrespondence *deepCpy() const;
47   MEDLOADER_EXPORT MEDFileJointCorrespondence *shallowCpy() const;
48   MEDLOADER_EXPORT bool isEqual(const MEDFileJointCorrespondence *other) const;
49   MEDLOADER_EXPORT void setIsNodal(bool isNodal) { _is_nodal = isNodal; }
50   MEDLOADER_EXPORT bool getIsNodal() const { return _is_nodal; }
51   MEDLOADER_EXPORT void setLocalGeometryType(INTERP_KERNEL::NormalizedCellType type) { _loc_geo_type=type; }
52   MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getLocalGeometryType() const { return _loc_geo_type; }
53   MEDLOADER_EXPORT void setRemoteGeometryType(INTERP_KERNEL::NormalizedCellType type) { _rem_geo_type=type; }
54   MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getRemoteGeometryType() const { return _rem_geo_type; }
55   MEDLOADER_EXPORT void setCorrespondence(DataArrayInt *corr);
56   MEDLOADER_EXPORT const DataArrayInt *getCorrespondence() const { return _correspondence; }
57   MEDLOADER_EXPORT void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const;
58
59   MEDLOADER_EXPORT std::string simpleRepr() const;
60   MEDLOADER_EXPORT void writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName, int order, int iteration) const;
61 private:
62   MEDFileJointCorrespondence();
63   MEDFileJointCorrespondence(DataArrayInt*                     correspondence,
64                              bool                              is_nodal = true,
65                              INTERP_KERNEL::NormalizedCellType loc_geo_type = INTERP_KERNEL::NORM_ERROR,
66                              INTERP_KERNEL::NormalizedCellType rem_geo_type = INTERP_KERNEL::NORM_ERROR);
67 private:
68   bool                                           _is_nodal;
69   INTERP_KERNEL::NormalizedCellType              _loc_geo_type;
70   INTERP_KERNEL::NormalizedCellType              _rem_geo_type;
71   MEDCouplingAutoRefCountObjectPtr<DataArrayInt> _correspondence;
72 };
73
74 /*!
75  * \brief Joint of one iteration holds correspondences of entities of all types
76  */
77 class MEDFileJointOneStep : public RefCountObject, public MEDFileWritable
78 {
79 public:
80   MEDLOADER_EXPORT static MEDFileJointOneStep *New(int dt=-1, int it=-1);
81   MEDLOADER_EXPORT static MEDFileJointOneStep *New(const std::string& fileName, const std::string& mName, const std::string& jointName, int number=1);
82   MEDLOADER_EXPORT static MEDFileJointOneStep *New(med_idt fid, const std::string& mName, const std::string& jointName, int number=1);
83   MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
84   MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
85   MEDLOADER_EXPORT MEDFileJointOneStep *deepCpy() const;
86   MEDLOADER_EXPORT MEDFileJointOneStep *shallowCpy() const;
87   MEDLOADER_EXPORT bool isEqual(const MEDFileJointOneStep *other) const;
88   MEDLOADER_EXPORT void setOrder(int order) { _order=order; }
89   MEDLOADER_EXPORT int getOrder() const { return _order; }
90   MEDLOADER_EXPORT void setIteration(int it) { _iteration=it; }
91   MEDLOADER_EXPORT int getIteration() const { return _iteration; }
92   MEDLOADER_EXPORT void pushCorrespondence(MEDFileJointCorrespondence* correspondence);
93   MEDLOADER_EXPORT int getNumberOfCorrespondences() const;
94   MEDLOADER_EXPORT MEDFileJointCorrespondence *getCorrespondenceAtPos(int i) const;
95
96   MEDLOADER_EXPORT void write(const std::string& fileName, int mode, const std::string& localMeshName, const std::string& jointName) const;
97
98   MEDLOADER_EXPORT std::string simpleRepr() const;
99   MEDLOADER_EXPORT void writeLL(med_idt fid, const std::string& localMeshName, const std::string& jointName) const;
100 private:
101   MEDFileJointOneStep();
102   MEDFileJointOneStep(med_idt fid, const std::string& mName, const std::string& jointName, int number);
103   MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType convertGeometryType(med_geometry_type geotype);
104 protected:
105   int _order;
106   int _iteration;
107 private:
108   std::vector<MEDCouplingAutoRefCountObjectPtr<MEDFileJointCorrespondence> > _correspondences;
109 };
110
111 /*!
112  * \brief Joint holds a sequence of joints of different iterations relating to
113  *        a pair of mesh domains: a local one and a distant one
114  */
115 class MEDFileJoint : public RefCountObject, public MEDFileWritable
116 {
117 public:
118     MEDLOADER_EXPORT static MEDFileJoint *New();
119     MEDLOADER_EXPORT static MEDFileJoint *New(const std::string& fileName, const std::string& mName, int num);
120     MEDLOADER_EXPORT static MEDFileJoint *New(med_idt fid, const std::string& mName, int num);
121     MEDLOADER_EXPORT static MEDFileJoint *New(const std::string& jointName, const std::string& locMeshName, const std::string& remoteMeshName, int remoteMeshNum );
122     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
123     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
124     MEDLOADER_EXPORT MEDFileJoint *deepCpy() const;
125     MEDLOADER_EXPORT MEDFileJoint *shallowCpy() const;
126     MEDLOADER_EXPORT bool isEqual(const MEDFileJoint *other) const;
127     MEDLOADER_EXPORT void setLocalMeshName(const std::string& name) { _loc_mesh_name=name; }
128     MEDLOADER_EXPORT std::string getLocalMeshName() const { return _loc_mesh_name; }
129     MEDLOADER_EXPORT void setRemoteMeshName(const std::string& name) { _rem_mesh_name=name; }
130     MEDLOADER_EXPORT std::string getRemoteMeshName() const { return _rem_mesh_name; }
131     MEDLOADER_EXPORT void setDescription(const std::string& name) { _desc_name=name; }
132     MEDLOADER_EXPORT std::string getDescription() const { return _desc_name; }
133     MEDLOADER_EXPORT void setJointName(const std::string& name) { _joint_name=name; }
134     MEDLOADER_EXPORT std::string getJointName() const { return _joint_name; }
135     MEDLOADER_EXPORT bool changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
136     MEDLOADER_EXPORT void setDomainNumber(const int& number) { _domain_number=number; }
137     MEDLOADER_EXPORT int getDomainNumber() const { return _domain_number; }
138     MEDLOADER_EXPORT void pushStep(MEDFileJointOneStep* step);
139     MEDLOADER_EXPORT int getNumberOfSteps() const;
140     MEDLOADER_EXPORT MEDFileJointOneStep *getStepAtPos(int i) const;
141
142     MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
143     MEDLOADER_EXPORT void write(med_idt fid) const;
144
145     MEDLOADER_EXPORT std::string simpleRepr() const;
146   private:
147     MEDFileJoint();
148     MEDFileJoint(med_idt fid, const std::string& mName, int num);
149   private:
150     std::string _loc_mesh_name;
151     std::string _joint_name;
152     std::string _desc_name;
153     int _domain_number;
154     std::string _rem_mesh_name;
155     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJointOneStep> > _joint;
156   };
157
158   /*!
159    * \brief Joints of a mesh domain relating to all other mesh domains
160    */
161   class MEDFileJoints : public RefCountObject, public MEDFileWritable
162   {
163   public:
164     MEDLOADER_EXPORT static MEDFileJoints *New();
165     MEDLOADER_EXPORT static MEDFileJoints *New(const std::string& fileName, const std::string& meshName);
166     MEDLOADER_EXPORT static MEDFileJoints *New(med_idt fid, const std::string& meshName);
167     MEDLOADER_EXPORT MEDFileJoints *deepCpy() const;
168     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
169     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
170     MEDLOADER_EXPORT std::string simpleRepr() const;
171     MEDLOADER_EXPORT void simpleReprWithoutHeader(std::ostream& oss) const;
172     MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
173     MEDLOADER_EXPORT void write(med_idt fid) const;
174     MEDLOADER_EXPORT std::string getMeshName() const;
175     MEDLOADER_EXPORT int getNumberOfJoints() const;
176     MEDLOADER_EXPORT MEDFileJoint *getJointAtPos(int i) const;
177     MEDLOADER_EXPORT MEDFileJoint *getJointWithName(const std::string& jname) const;
178     MEDLOADER_EXPORT std::vector<std::string> getJointsNames() const;
179     MEDLOADER_EXPORT bool changeJointNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
180     //
181     MEDLOADER_EXPORT void resize(int newSize);
182     MEDLOADER_EXPORT void pushJoint(MEDFileJoint *joint);
183     MEDLOADER_EXPORT void setJointAtPos(int i, MEDFileJoint *joint);
184     MEDLOADER_EXPORT void destroyJointAtPos(int i);
185   private:
186     ~MEDFileJoints() { }
187     MEDFileJoints();
188     MEDFileJoints(med_idt fid, const std::string& meshName);
189   private:
190     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileJoint> > _joints;
191   };
192 }
193
194 #endif