12 #include "utilities.h"
13 #include "MEDMEM_STRING.hxx"
14 #include "MEDMEM_Exception.hxx"
15 #include "MEDMEM_define.hxx"
17 #include "MEDMEM_SkyLineArray.hxx"
18 //#include "MEDMEM_Mesh.hxx"
20 using namespace MED_EN;
26 This class describe a support of elements on an entity of the mesh.
28 It contains the list of meshes elements for an entity (MED_NODE,
29 MED_CELL, MED_FACE or MED_EDGE).
45 Description of the support (optional).
52 Reference to the mesh on which the support is defined.
59 Type of entity on which the support is defined
60 (only one for each support).
63 medEntityMesh _entity ;
67 Number of geometric type defined in the support.
70 int _numberOfGeometricType;
74 Array of all geometric type defined in the support.
77 medGeometryElement * _geometricType;
81 Array of size _numberOfGeometricType which contains
82 for each type the number of gauss point
83 (not yet implemented).
86 mutable int * _numberOfGaussPoint ;
90 Array of size _numberOfGeometricType
91 which contains number of geometric
93 (to get corresponding CellModel).
96 //int * _geometricTypeNumber;
100 If true, we consider all entities of type _entity.
107 Index array of size _numberOfGeometricType wich contains
108 for each geometric type, the number of elements of this type.
111 int * _numberOfElements;
115 Sum of each _numberOfElements component.
118 int _totalNumberOfElements;
120 // the two following arrays are defined only if _isOnAllElts is false :
124 array of size _numberOfType+1 wich contains for
125 each geometric type, index in _number._value
126 (if _all is true, we must ask _mesh to get
127 information). _typeIndex[i+1]-_typeIndex[i]
128 represents count of entities of ith geometric
129 type. _typeIndex[_numberOfType] contains total
130 entities count. If _numberOf[i]=0,
131 _typeIndex[i+1]=_typeIndex[i]
132 defined only if _isOnAllElts is false
139 Array of size _index[_numberOfType]-1 wich contain number of
140 entities of each geometric type. We use global numbering.\n
141 Defined only if _isOnAllElts is false.
144 mutable MEDSKYLINEARRAY * _number;
148 SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
149 SUPPORT(const SUPPORT & m);
151 friend ostream & operator<<(ostream &os,const SUPPORT &my);
153 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
156 inline void setName(string Name);
157 inline void setDescription(string Description);
158 inline void setMesh(MESH *Mesh);
159 inline void setAll(bool All);
160 inline void setEntity(medEntityMesh Entity);
161 inline void setNumberOfGeometricType(int NumberOfGeometricType);
162 inline void setGeometricType(const medGeometryElement *GeometricType);
163 inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
164 // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
165 inline void setNumberOfElements(const int *NumberOfElements);
166 inline void setTotalNumberOfElements(int TotalNumberOfElements);
167 inline void setNumber(MEDSKYLINEARRAY * Number);
168 inline void setNumber(const int * index, const int* value);
170 inline string getName() const;
171 inline string getDescription() const;
172 virtual inline MESH * getMesh() const;
173 inline medEntityMesh getEntity() const;
175 inline bool isOnAllElements() const;
176 inline int getNumberOfTypes() const;
177 inline const medGeometryElement* getTypes() const ;
178 inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
179 inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
180 //inline int * getGeometricTypeNumber() const;
181 //inline int getTotalNumberOfElement() const;
182 inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
183 virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
184 virtual inline const int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
185 virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION);
187 void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
189 void setpartial(string Description, int NumberOfGeometricType,
190 int TotalNumberOfEntity, medGeometryElement *GeometricType,
191 int *NumberOfEntity, int *NumberValue);
193 void getBoundaryElements() throw (MEDEXCEPTION);
195 void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
197 // _____________________
199 // _____________________
202 This method returns the number of all elements of the type GeometricType.
204 If isOnAllElements is false, it returns the number of elements in the
205 support else it returns number of elements in the whole mesh.
207 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
208 in entity of support.
210 Note : If SUPPORT is defined on MED_NODE, use MED_ALL_ELEMENTS as
211 medGeometryElement GeometricType and it will returns the number
212 of nodes in the support (or in the whole mesh).
214 //-----------------------------------------------------------------------------
215 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
217 //-----------------------------------------------------------------------------
219 if (GeometricType==MED_ALL_ELEMENTS)
220 return _totalNumberOfElements;
221 for (int i=0;i<_numberOfGeometricType;i++)
222 if (_geometricType[i]==GeometricType)
223 return _numberOfElements[i];
224 throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
227 //---------------------------------------------------------------------
228 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
230 //---------------------------------------------------------------------
233 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
238 If isOnAllElements is false, returns an array which contains
239 all number of given medGeometryElement.
241 Numbering is global, ie numbers are bounded by 1 and
242 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
243 MESH::getNumberOfElement(entity,geomElement).
245 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
246 medGeometryElement type.
248 //---------------------------------------------------------------------
249 inline const int * SUPPORT::getNumber(medGeometryElement GeometricType) const
251 //---------------------------------------------------------------------
253 const char * LOC = "Support::getNumber : " ;
255 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
256 if (GeometricType==MED_ALL_ELEMENTS)
257 return _number->getValue() ;
258 for (int i=0;i<_numberOfGeometricType;i++)
259 if (_geometricType[i]==GeometricType)
260 return _number->getI(i+1) ;
261 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
265 If isOnAllElements is false, returns index of element number.
266 Use it with getNumber(MED_ALL_ELEMENTS).
268 Note : See getConnectivityIndex for details.
270 //-------------------------------------------
271 inline const int * SUPPORT::getNumberIndex() const
272 //-------------------------------------------
276 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
277 return _number->getIndex() ;
281 //-------------------------------------------------
282 inline const int * SUPPORT::getNumberOfGaussPoint() const
284 //-------------------------------------------------
286 if (_numberOfGaussPoint!=NULL)
287 return _numberOfGaussPoint ;
289 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
293 Returns number of Gauss points for this medGeometryElement.
296 - Not defined if SUPPORT is on MED_NODE.
297 - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
299 //-----------------------------------------------------------------------------
300 inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
302 //-----------------------------------------------------------------------------
304 if (_numberOfGaussPoint!=NULL) {
305 for (int i=0;i<_numberOfGeometricType;i++)
306 if (_geometricType[i]==geomElement)
307 return _numberOfGaussPoint[i] ;
308 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
310 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
312 // inline int SUPPORT::getNumberLength() const
313 // throw (MEDEXCEPTION)
316 // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
317 // return _number->getLength() ;
320 /*! set the attribute _name to Name */
321 //--------------------------------------
322 inline void SUPPORT::setName(string Name)
323 //--------------------------------------
328 /*! set the attribute _description to Description */
329 //--------------------------------------------------
330 inline void SUPPORT::setDescription(string Description)
331 //--------------------------------------------------
333 _description=Description;
336 /*! set the reference _mesh to Mesh */
337 //--------------------------------------
338 inline void SUPPORT::setMesh(MESH *Mesh)
339 //--------------------------------------
344 /*! set the attribute _isOnAllElts to All */
345 //------------------------------------------
346 inline void SUPPORT::setAll(bool All)
347 //------------------------------------------
352 /*! set the attribute _entity to Entity */
353 //------------------------------------------
354 inline void SUPPORT::setEntity(medEntityMesh Entity)
357 // if ( Entity == MED_NODE) {
358 // _numberOfGeometricType=1 ;
359 // if (_geometricType == (medGeometryElement *) NULL)
360 // _geometricType=new medGeometryElement[1] ;
363 // // delete previous ???
364 // delete [] _geometricType;
365 // _geometricType=new medGeometryElement[1] ;
367 // _geometricType[0]=MED_NONE ;
371 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
372 //---------------------------------------------------------------------
373 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
374 //---------------------------------------------------------------------
376 _numberOfGeometricType=NumberOfGeometricType;
377 if (_geometricType!=NULL) {
378 delete[] _geometricType ;
379 _geometricType = NULL ;
381 if (_numberOfElements!=NULL) {
382 delete[] _numberOfElements ;
383 _numberOfElements = NULL ;
385 if (_numberOfGaussPoint!=NULL) {
386 delete[] _numberOfGaussPoint ;
387 _numberOfGaussPoint = NULL ;
391 /*! set the attribute _geometricType to geometricType */
392 //---------------------------------------------------------------------
393 inline void SUPPORT::setGeometricType(const medGeometryElement *GeometricType)
394 //---------------------------------------------------------------------
396 if (NULL == _geometricType)
397 _geometricType=new medGeometryElement[_numberOfGeometricType];
398 for (int i=0;i<_numberOfGeometricType;i++)
399 _geometricType[i] = GeometricType[i];
400 // _geometricType=GeometricType;
403 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
404 //-----------------------------------------------------------------
405 inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
406 //-----------------------------------------------------------------
408 if (NULL == _numberOfGaussPoint)
409 _numberOfGaussPoint=new int[_numberOfGeometricType];
410 for (int i=0;i<_numberOfGeometricType;i++)
411 _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
412 // _numberOfGaussPoint = NumberOfGaussPoint ;
415 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
416 //-------------------------------------------------------------------
417 //inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
418 //-------------------------------------------------------------------
420 // _geometricTypeNumber=GeometricTypeNumber;
424 Set the attribute _numberOfElements to NumberOfElements and
425 calculate the total number of elements.
427 //----------------------------------------------------------
428 inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
429 //----------------------------------------------------------
431 if (NULL == _numberOfElements)
432 _numberOfElements=new int[_numberOfGeometricType];
433 memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
434 _totalNumberOfElements = 0 ;
435 for (int i=0;i<_numberOfGeometricType;i++)
436 _totalNumberOfElements+=_numberOfElements[i];
439 /*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
440 //--------------------------------------------------------------------
441 inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
442 //--------------------------------------------------------------------
444 _totalNumberOfElements=TotalNumberOfElements;
447 /*! set the attribute _number to Number */
448 //---------------------------------------------------
449 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
450 //---------------------------------------------------
452 if (_number != NULL) delete _number ;
456 /*! set the attribute _number with index and value arrays */
457 //---------------------------------------------------
458 inline void SUPPORT::setNumber(const int * index, const int* value)
459 //---------------------------------------------------
461 if (_number != NULL) delete _number ;
462 _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value);
465 /*! returns the name of the support. */
466 //------------------------------------
467 inline string SUPPORT::getName() const
468 //------------------------------------
474 /*! returns the description of the support. */
475 //--------------------------------------------
476 inline string SUPPORT::getDescription() const
477 //--------------------------------------------
482 /*! returns a reference to the mesh */
483 //------------------------------------
484 inline MESH * SUPPORT::getMesh() const
485 //------------------------------------
491 Returns true if all elements of this entity are
492 concerned, false otherwise.
493 If true, you must use mesh reference (getMesh) to get more information.
495 //------------------------------------------
496 inline bool SUPPORT::isOnAllElements() const
497 //------------------------------------------
503 Returns number of geometric Types
504 defines in the support
506 //------------------------------------------
507 inline int SUPPORT::getNumberOfTypes() const
508 //------------------------------------------
510 // if ((_isOnAllElts)&(_entity != MED_NODE))
511 // return _mesh->getNumberOfTypes(_entity) ;
513 return _numberOfGeometricType ;
517 Returns the medEntityMesh's type used by the support.
518 Note : A support deals only with one entity's type
519 (for example : MED_FACE or MED_NODE)
521 //---------------------------------------------
522 inline medEntityMesh SUPPORT::getEntity() const
523 //---------------------------------------------
529 If isOnAllElements is false, returns an array of <medGeometryElement>
530 types used by the support.
532 <medEntityMesh> is given by getEntity.
534 //---------------------------------------------------
535 inline const medGeometryElement * SUPPORT::getTypes() const
536 //---------------------------------------------------
538 // if ((_isOnAllElts)&(_entity != MED_NODE))
539 // return _mesh->getTypes(_entity) ;
541 return _geometricType;
544 //---------------------------------------------------
545 //inline int * SUPPORT::getGeometricTypeNumber() const
546 //---------------------------------------------------
548 // const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
550 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
551 // if (_geometricTypeNumber==NULL)
552 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
553 // return _geometricTypeNumber;
557 #endif /* SUPPORT_HXX */