]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_Support.hxx
Salome HOME
NRI : Update 1.1a and New organisation.
[modules/med.git] / src / MEDMEM / MEDMEM_Support.hxx
1 /*
2  File Support.hxx
3  $Header$
4 */
5
6 #ifndef SUPPORT_HXX
7 #define SUPPORT_HXX
8
9 #include <vector>
10 #include <string>
11
12 #include "utilities.h"
13 #include "MEDMEM_Exception.hxx"
14 #include "MEDMEM_define.hxx"
15
16 #include "MEDMEM_SkyLineArray.hxx"
17 #include "MEDMEM_Mesh.hxx"
18
19 using namespace MED_EN;
20
21 class MESH ;
22
23 class SUPPORT 
24 {
25 protected:
26                                                  /*! name of the support */
27   string                   _name;
28                                                  /*! description of the support (optionnal) */
29   string                   _description;
30                                                  /*! reference to the mesh on which the support is defined */
31   MESH *                   _mesh;
32                                                  /*! type of entity on which the support is defined 
33                                                      (only one for each support) */
34   medEntityMesh            _entity ;
35                                                  /*! number of geometric type defined in the support */
36   int                      _numberOfGeometricType;
37                                                  /*! array of all geometric type defined in the support */
38   medGeometryElement *     _geometricType;
39                                                  /*! array of size _numberOfGeometricType which contains 
40                                                      for each type the number of gauss point 
41                                                      (not yet implemented) */
42   int *                    _numberOfGaussPoint ; 
43                                                  /*! array of size _numberOfGeometricType 
44                                                      which contains number of geometric
45                                                      entity type in Mesh 
46                                                      (to get corresponding CellModel)*/
47   int *                    _geometricTypeNumber; 
48                                                  /*! If true, we consider all entities of type _entity */
49   bool                     _isOnAllElts;        
50                                                  /*! array of size _numberOfGeometricType wich contains
51                                                      for each geometric type, count of entities. 
52                                                      (if _isOnAllElts is true, we could get same 
53                                                      information from _mesh) */
54   int *                    _numberOfEntities;   
55                                                  /*! sum of each _numberOfEntities component (if 
56                                                      _isOnAllElts is true, we could get same 
57                                                      information from _mesh) */
58   int                      _totalNumberOfEntities;    
59
60   // the two following arrays are defined only if _isOnAllElts is false :
61
62                              /* array of size _numberOfType+1 wich contains for 
63                                  each geometric type, index in _number._value 
64                                  (if _all is true, we must ask _mesh to get 
65                                  information). _typeIndex[i+1]-_typeIndex[i] 
66                                  represents count of entities of ith geometric 
67                                  type. _typeIndex[_numberOfType] contains total 
68                                  entities count. If _numberOf[i]=0, 
69                                  _typeIndex[i+1]=_typeIndex[i] 
70                                  defined only if _isOnAllElts is false*/
71   //  int *      _typeIndex; 
72                              /*! array of size _index[_numberOfType] wich contain number of 
73                                  entities of each geometric type. We use global numbering.
74                                  defined only if _isOnAllElts is false*/
75   MEDSKYLINEARRAY * _number;   
76
77 public:
78   SUPPORT(); 
79   SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL); 
80   SUPPORT(SUPPORT & m);
81   ~SUPPORT();
82   friend ostream & operator<<(ostream &os,const SUPPORT &my);
83   
84   // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
85   void update();
86   
87   inline void setName(string Name);
88   inline void setDescription(string Description); 
89   inline void setMesh(MESH *Mesh);               
90   inline void setAll(bool All);                          
91   inline void setEntity(medEntityMesh Entity); 
92   inline void setNumberOfGeometricType(int NumberOfGeometricType); 
93   inline void setGeometricType(medGeometryElement *GeometricType); 
94   inline void setNumberOfGaussPoint(int *NumberOfGaussPoint);
95   //  inline void setGeometricTypeNumber(int *GeometricTypeNumber); 
96   inline void setNumberOfEntities(int *NumberOfEntities); 
97   inline void setTotalNumberOfEntities(int TotalNumberOfEntities); 
98   inline void setNumber(MEDSKYLINEARRAY * Number); 
99   
100   inline string getName() const; 
101   inline string getDescription() const; 
102   inline MESH * getMesh() const; 
103   inline medEntityMesh getEntity() const;
104
105   inline bool   isOnAllElements() const; 
106   inline int    getNumberOfTypes() const;
107   inline medGeometryElement* getTypes() const ;
108   inline int *  getNumberOfGaussPoint() const throw (MEDEXCEPTION);
109   inline int    getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
110   //inline int *  getGeometricTypeNumber() const; 
111   //  inline int    getNumberOfTotalEntity() const;
112   inline int    getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
113   inline MEDSKYLINEARRAY *  getnumber() const throw (MEDEXCEPTION);
114   inline int *  getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
115   inline int *  getNumberIndex() const throw (MEDEXCEPTION);
116
117   void blending(SUPPORT * mySupport);
118
119   /*
120     This function allows the user to set a support not on all entities Entity,
121     it should be used after an initialisation with the constructor
122     SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
123     after the call to the function setAll(false).
124     It allocates and initialises all the attributs of the class SUPPORT.
125   */
126
127   void setpartial(string Description, int NumberOfGeometricType,
128                   int TotalNumberOfEntity, medGeometryElement *GeometricType,
129                   int *NumberOfEntity, int *NumberValue);
130 };
131 // _____________________
132 // Methodes Inline
133 // _____________________
134
135 /*!  If isOnAllElements is false, returns number of elements in the
136      support else returns number of nodes.
137
138       Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
139       in entity of support.
140
141       Note : If SUPPORT is defined on MED_NODE, use MED_NONE
142       medGeometryElement type.  */
143 //-----------------------------------------------------------------------------
144 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
145 throw (MEDEXCEPTION) 
146 //-----------------------------------------------------------------------------
147 {
148   if (_isOnAllElts){ 
149     return _mesh->getNumberOfElements(_entity,GeometricType);
150   } else {
151     if (GeometricType==MED_ALL_ELEMENTS)
152       return _totalNumberOfEntities;
153     for (int i=0;i<_numberOfGeometricType;i++)
154       if (_geometricType[i]==GeometricType)
155         return _numberOfEntities[i] ;
156     throw MEDEXCEPTION("Support::getNumberOfElements : Type not found !") ;
157   }
158 }
159 //  inline int SUPPORT::getNumberOf(medGeometryElement GeometricType) const 
160 //  throw (MEDEXCEPTION) 
161 //  {
162 //      if (GeometricType==MED_ALL_ELEMENTS)
163 //          return _totalNumberOfEntities ; 
164 //      for (int i=0;i<_numberOfGeometricType;i++)
165 //          if (_geometricType[i]==GeometricType)
166 //      return _numberOfEntities[i] ;
167 //      throw MEDEXCEPTION("Support::getNumberOf: GeometricType not found !");
168 //  }
169
170 //  inline int SUPPORT::getNumberOfTotalEntity() const 
171 //  { 
172 //    return _totalNumberOfEntities ; 
173 //  }
174
175 //---------------------------------------------------------------------
176 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const 
177   throw (MEDEXCEPTION) 
178 //---------------------------------------------------------------------
179 {
180   if (_number==NULL) 
181     throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
182   return _number ;
183 }
184
185 /*!   If isOnAllElements is false, returns an array which contains
186       all number of given medGeometryElement.
187
188       Numbering is global, ie numbers are bounded by 1 and
189       MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
190       MESH::getNumberOfElement(entity,geomElement).
191
192       Note : If SUPPORT is defined on MED_NODE, use MED_NONE
193       medGeometryElement type. */
194 //---------------------------------------------------------------------
195 inline int * SUPPORT::getNumber(medGeometryElement GeometricType) const 
196   throw (MEDEXCEPTION) 
197 //---------------------------------------------------------------------
198 {
199   const char * LOC = "Support::getNumber : " ;
200   if (_isOnAllElts) 
201     throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
202   if (GeometricType==MED_ALL_ELEMENTS)
203     return _number->getValue() ; 
204   for (int i=0;i<_numberOfGeometricType;i++)
205     if (_geometricType[i]==GeometricType)
206       return _number->getI(i+1) ;
207   throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
208 }
209
210 /*!  If isOnAllElements is false, returns index of element number.
211       Use it with getNumber(MED_ALL_ELEMENTS).
212
213       Note : See getConnectivityIndex for details.  */
214 //-------------------------------------------
215 inline int * SUPPORT::getNumberIndex() const 
216 //-------------------------------------------
217 throw (MEDEXCEPTION) 
218 {
219     if (_isOnAllElts) 
220       throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
221       return _number->getIndex() ;
222 }
223
224 /*! A DOCUMENTER */
225 //-------------------------------------------------
226 inline int * SUPPORT::getNumberOfGaussPoint() const 
227 throw (MEDEXCEPTION) 
228 //-------------------------------------------------
229 {
230   if (_numberOfGaussPoint!=NULL)
231     return _numberOfGaussPoint ;
232   else
233     throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
234 }
235
236 /*!  Returns number of Gauss points for this medGeometryElement.
237
238       Note :
239       - Not defined if SUPPORT is on MED_NODE.
240       - Not defined for MED_ALL_ELEMENTS medGeometryElement type.  */
241 //-----------------------------------------------------------------------------
242 inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const 
243 throw (MEDEXCEPTION) 
244 //-----------------------------------------------------------------------------
245 {
246   if (_numberOfGaussPoint!=NULL) {
247     for (int i=0;i<_numberOfGeometricType;i++)
248       if (_geometricType[i]==geomElement)
249         return _numberOfGaussPoint[i] ;
250     throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
251   } else
252     throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
253 }
254 //  inline int SUPPORT::getNumberLength() const 
255 //  throw (MEDEXCEPTION) 
256 //  {
257 //      if (_isOnAllElts) 
258 //        throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
259 //        return _number->getLength() ;
260 //  }
261
262 /*! set the attribute _name to Name   */
263 //--------------------------------------
264 inline void SUPPORT::setName(string Name)
265 //--------------------------------------
266
267   _name=Name; 
268 }
269
270 /*! set the attribute _description to Description */
271 //--------------------------------------------------
272 inline void SUPPORT::setDescription(string Description)
273 //--------------------------------------------------
274
275   _description=Description; 
276 }
277
278 /*! set the reference _mesh to Mesh   */
279 //--------------------------------------
280 inline void SUPPORT::setMesh(MESH *Mesh)
281 //--------------------------------------
282
283   _mesh=Mesh; 
284 }
285
286 /*! set the attribute _isOnAllElts to All */
287 //------------------------------------------
288 inline void SUPPORT::setAll(bool All)
289 //------------------------------------------
290
291   _isOnAllElts=All; 
292 }
293
294 /*! set the attribute _entity to Entity */
295 //------------------------------------------
296 inline void SUPPORT::setEntity(medEntityMesh Entity)
297
298   _entity=Entity; 
299   if ( Entity == MED_NODE) {
300     _numberOfGeometricType=1 ;
301     _geometricType=new medGeometryElement[1] ; // delete previous ???
302     _geometricType[0]=MED_NONE ;
303   }
304 }
305
306 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
307 //---------------------------------------------------------------------
308 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
309 //---------------------------------------------------------------------
310
311   _numberOfGeometricType=NumberOfGeometricType; 
312 }
313
314 /*! set the attribute _geometricType to geometricType                */
315 //---------------------------------------------------------------------
316 inline void SUPPORT::setGeometricType(medGeometryElement *GeometricType)
317 //---------------------------------------------------------------------
318
319   _geometricType=GeometricType; 
320 }
321
322 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint  */
323 //-----------------------------------------------------------------
324 inline void SUPPORT::setNumberOfGaussPoint(int *NumberOfGaussPoint)
325 //-----------------------------------------------------------------
326 {
327   _numberOfGaussPoint = NumberOfGaussPoint ;
328 }
329
330 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber  */
331 //-------------------------------------------------------------------
332 //inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
333 //-------------------------------------------------------------------
334 //{ 
335 //  _geometricTypeNumber=GeometricTypeNumber; 
336 //}
337
338 /*! set the attribute _numberOfEntities to NumberOfEntities */
339 //----------------------------------------------------------
340 inline void SUPPORT::setNumberOfEntities(int *NumberOfEntities)
341 //----------------------------------------------------------
342
343   _numberOfEntities=NumberOfEntities; 
344 }
345
346 /*! set the attribute _totalNumberOfEntities to TotalNumberOfEntities */
347 //--------------------------------------------------------------------
348 inline void SUPPORT::setTotalNumberOfEntities(int TotalNumberOfEntities)
349 //--------------------------------------------------------------------
350
351   _totalNumberOfEntities=TotalNumberOfEntities; 
352 }
353
354 /*! set the attribute _number to Number           */
355 //---------------------------------------------------
356 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
357 //---------------------------------------------------
358
359   _number=Number; 
360 }
361
362 /*! returns the name of the support. */
363 //------------------------------------
364 inline string SUPPORT::getName() const 
365 //------------------------------------
366
367   return _name; 
368 }
369
370
371 /*! returns the description of the support. */
372 //--------------------------------------------
373 inline string SUPPORT::getDescription() const 
374 //--------------------------------------------
375
376   return _description; 
377 }
378
379 /*! returns a refernce to the mesh  */
380 //------------------------------------
381 inline MESH * SUPPORT::getMesh() const 
382 //------------------------------------
383
384   return _mesh; 
385 }
386
387 /*!  Returns true if all elements of this entity are
388      concerned, false otherwise.
389      If true, you must use mesh reference (getMesh) to get more information.*/
390 //------------------------------------------
391 inline bool SUPPORT::isOnAllElements() const 
392 //------------------------------------------
393
394   return _isOnAllElts; 
395 }
396
397 /*!  Returns number of geometric Types
398      defines in the support              */ 
399 //------------------------------------------
400 inline int SUPPORT::getNumberOfTypes() const 
401 //------------------------------------------
402
403   if ((_isOnAllElts)&(_entity != MED_NODE))
404     return _mesh->getNumberOfTypes(_entity) ;
405   else
406     return _numberOfGeometricType ; 
407 }
408
409 /*!  Returns the medEntityMesh's type used by the support.
410      Note : A support deals only with one entity's type
411      (for example : MED_FACE or MED_NODE)*/
412 //---------------------------------------------
413 inline medEntityMesh SUPPORT::getEntity() const 
414 //---------------------------------------------
415
416   return _entity; 
417 }
418
419 /*!  If isOnAllElements is false, returns an array of <medGeometryElement>
420      types used by the support.
421
422      <medEntityMesh> is given by getEntity.  */
423 //---------------------------------------------------
424 inline medGeometryElement * SUPPORT::getTypes() const 
425 //---------------------------------------------------
426 {
427   if ((_isOnAllElts)&(_entity != MED_NODE))
428     return _mesh->getTypes(_entity) ;
429   else
430     return _geometricType; 
431 }
432
433 //---------------------------------------------------
434 //inline int * SUPPORT::getGeometricTypeNumber() const
435 //---------------------------------------------------
436 //  {
437 //    const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
438 //    if (_isOnAllElts)
439 //      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
440 //    if (_geometricTypeNumber==NULL)
441 //      throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
442 //    return _geometricTypeNumber; 
443 //  }
444
445     
446 #endif /* SUPPORT_HXX */