12 #include "utilities.h"
13 #include "MEDMEM_STRING.hxx"
14 #include "MEDMEM_Exception.hxx"
15 #include "MEDMEM_define.hxx"
16 #include "MEDMEM_SkyLineArray.hxx"
18 using namespace MED_EN;
19 using namespace MEDMEM;
24 This class describe a support of elements on an entity of the mesh.
26 It contains the list of meshes elements for an entity (MED_NODE,
27 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 bool operator == (const SUPPORT &support) const;
155 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
158 inline void setName(string Name);
159 inline void setDescription(string Description);
160 inline void setMesh(MESH *Mesh);
161 inline void setAll(bool All);
162 inline void setEntity(medEntityMesh Entity);
163 inline void setNumberOfGeometricType(int NumberOfGeometricType);
164 inline void setGeometricType(const medGeometryElement *GeometricType);
165 inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
166 // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
167 inline void setNumberOfElements(const int *NumberOfElements);
168 inline void setTotalNumberOfElements(int TotalNumberOfElements);
169 inline void setNumber(MEDSKYLINEARRAY * Number);
170 inline void setNumber(const int * index, const int* value);
172 inline string getName() const;
173 inline string getDescription() const;
174 virtual inline MESH * getMesh() const;
175 inline medEntityMesh getEntity() const;
177 inline bool isOnAllElements() const;
178 inline int getNumberOfTypes() const;
179 inline const medGeometryElement* getTypes() const ;
180 inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
181 inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
182 //inline int * getGeometricTypeNumber() const;
183 //inline int getTotalNumberOfElement() const;
184 inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
185 virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
186 virtual inline const int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
187 virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION);
189 void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
191 void setpartial(string Description, int NumberOfGeometricType,
192 int TotalNumberOfEntity, medGeometryElement *GeometricType,
193 int *NumberOfEntity, int *NumberValue);
195 void getBoundaryElements() throw (MEDEXCEPTION);
197 void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
200 // _____________________
202 // _____________________
204 using namespace MEDMEM;
206 This method returns the number of all elements of the type GeometricType.
208 If isOnAllElements is false, it returns the number of elements in the
209 support else it returns number of elements in the whole mesh.
211 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
212 in entity of support.
214 Note : If SUPPORT is defined on MED_NODE, use MED_ALL_ELEMENTS as
215 medGeometryElement GeometricType and it will returns the number
216 of nodes in the support (or in the whole mesh).
218 //-----------------------------------------------------------------------------
219 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
221 //-----------------------------------------------------------------------------
223 if (GeometricType==MED_ALL_ELEMENTS)
224 return _totalNumberOfElements;
225 for (int i=0;i<_numberOfGeometricType;i++)
226 if (_geometricType[i]==GeometricType)
227 return _numberOfElements[i];
228 throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
231 //---------------------------------------------------------------------
232 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
234 //---------------------------------------------------------------------
237 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
242 If isOnAllElements is false, returns an array which contains
243 all number of given medGeometryElement.
245 Numbering is global, ie numbers are bounded by 1 and
246 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
247 MESH::getNumberOfElement(entity,geomElement).
249 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
250 medGeometryElement type.
252 //---------------------------------------------------------------------
253 inline const int * SUPPORT::getNumber(medGeometryElement GeometricType) const
255 //---------------------------------------------------------------------
257 const char * LOC = "Support::getNumber : " ;
259 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
260 if (GeometricType==MED_ALL_ELEMENTS)
261 return _number->getValue() ;
262 for (int i=0;i<_numberOfGeometricType;i++)
263 if (_geometricType[i]==GeometricType)
264 return _number->getI(i+1) ;
265 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
269 If isOnAllElements is false, returns index of element number.
270 Use it with getNumber(MED_ALL_ELEMENTS).
272 Note : See getConnectivityIndex for details.
274 //-------------------------------------------
275 inline const int * SUPPORT::getNumberIndex() const
276 //-------------------------------------------
280 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
281 return _number->getIndex() ;
285 //-------------------------------------------------
286 inline const int * SUPPORT::getNumberOfGaussPoint() const
288 //-------------------------------------------------
290 if (_numberOfGaussPoint!=NULL)
291 return _numberOfGaussPoint ;
293 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
297 Returns number of Gauss points for this medGeometryElement.
300 - Not defined if SUPPORT is on MED_NODE.
301 - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
303 //-----------------------------------------------------------------------------
304 inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
306 //-----------------------------------------------------------------------------
308 if (_numberOfGaussPoint!=NULL) {
309 for (int i=0;i<_numberOfGeometricType;i++)
310 if (_geometricType[i]==geomElement)
311 return _numberOfGaussPoint[i] ;
312 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
314 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
316 // inline int SUPPORT::getNumberLength() const
317 // throw (MEDEXCEPTION)
320 // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
321 // return _number->getLength() ;
324 /*! set the attribute _name to Name */
325 //--------------------------------------
326 inline void SUPPORT::setName(string Name)
327 //--------------------------------------
332 /*! set the attribute _description to Description */
333 //--------------------------------------------------
334 inline void SUPPORT::setDescription(string Description)
335 //--------------------------------------------------
337 _description=Description;
340 /*! set the reference _mesh to Mesh */
341 //--------------------------------------
342 inline void SUPPORT::setMesh(MESH *Mesh)
343 //--------------------------------------
348 /*! set the attribute _isOnAllElts to All */
349 //------------------------------------------
350 inline void SUPPORT::setAll(bool All)
351 //------------------------------------------
356 /*! set the attribute _entity to Entity */
357 //------------------------------------------
358 inline void SUPPORT::setEntity(medEntityMesh Entity)
361 // if ( Entity == MED_NODE) {
362 // _numberOfGeometricType=1 ;
363 // if (_geometricType == (medGeometryElement *) NULL)
364 // _geometricType=new medGeometryElement[1] ;
367 // // delete previous ???
368 // delete [] _geometricType;
369 // _geometricType=new medGeometryElement[1] ;
371 // _geometricType[0]=MED_NONE ;
375 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
376 //---------------------------------------------------------------------
377 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
378 //---------------------------------------------------------------------
380 _numberOfGeometricType=NumberOfGeometricType;
381 if (_geometricType!=NULL) {
382 delete[] _geometricType ;
383 _geometricType = NULL ;
385 if (_numberOfElements!=NULL) {
386 delete[] _numberOfElements ;
387 _numberOfElements = NULL ;
389 if (_numberOfGaussPoint!=NULL) {
390 delete[] _numberOfGaussPoint ;
391 _numberOfGaussPoint = NULL ;
395 /*! set the attribute _geometricType to geometricType */
396 //---------------------------------------------------------------------
397 inline void SUPPORT::setGeometricType(const medGeometryElement *GeometricType)
398 //---------------------------------------------------------------------
400 if (NULL == _geometricType)
401 _geometricType=new medGeometryElement[_numberOfGeometricType];
402 for (int i=0;i<_numberOfGeometricType;i++)
403 _geometricType[i] = GeometricType[i];
404 // _geometricType=GeometricType;
407 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
408 //-----------------------------------------------------------------
409 inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
410 //-----------------------------------------------------------------
412 if (NULL == _numberOfGaussPoint)
413 _numberOfGaussPoint=new int[_numberOfGeometricType];
414 for (int i=0;i<_numberOfGeometricType;i++)
415 _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
416 // _numberOfGaussPoint = NumberOfGaussPoint ;
419 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
420 //-------------------------------------------------------------------
421 //inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
422 //-------------------------------------------------------------------
424 // _geometricTypeNumber=GeometricTypeNumber;
428 Set the attribute _numberOfElements to NumberOfElements and
429 calculate the total number of elements.
431 //----------------------------------------------------------
432 inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
433 //----------------------------------------------------------
435 if (NULL == _numberOfElements)
436 _numberOfElements=new int[_numberOfGeometricType];
437 memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
438 _totalNumberOfElements = 0 ;
439 for (int i=0;i<_numberOfGeometricType;i++)
440 _totalNumberOfElements+=_numberOfElements[i];
443 /*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
444 //--------------------------------------------------------------------
445 inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
446 //--------------------------------------------------------------------
448 _totalNumberOfElements=TotalNumberOfElements;
451 /*! set the attribute _number to Number */
452 //---------------------------------------------------
453 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
454 //---------------------------------------------------
456 if (_number != NULL) delete _number ;
460 /*! set the attribute _number with index and value arrays */
461 //---------------------------------------------------
462 inline void SUPPORT::setNumber(const int * index, const int* value)
463 //---------------------------------------------------
465 if (_number != NULL) delete _number ;
466 _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value);
469 /*! returns the name of the support. */
470 //------------------------------------
471 inline string SUPPORT::getName() const
472 //------------------------------------
478 /*! returns the description of the support. */
479 //--------------------------------------------
480 inline string SUPPORT::getDescription() const
481 //--------------------------------------------
486 /*! returns a reference to the mesh */
487 //------------------------------------
488 inline MESH * SUPPORT::getMesh() const
489 //------------------------------------
495 Returns true if all elements of this entity are
496 concerned, false otherwise.
497 If true, you must use mesh reference (getMesh) to get more information.
499 //------------------------------------------
500 inline bool SUPPORT::isOnAllElements() const
501 //------------------------------------------
507 Returns number of geometric Types
508 defines in the support
510 //------------------------------------------
511 inline int SUPPORT::getNumberOfTypes() const
512 //------------------------------------------
514 // if ((_isOnAllElts)&(_entity != MED_NODE))
515 // return _mesh->getNumberOfTypes(_entity) ;
517 return _numberOfGeometricType ;
521 Returns the %medEntityMesh's type used by the support.
522 Note : A support deals only with one entity's type
523 (for example : MED_FACE or MED_NODE)
525 //---------------------------------------------
526 inline medEntityMesh SUPPORT::getEntity() const
527 //---------------------------------------------
533 If isOnAllElements is false, returns an array of %medGeometryElement
534 types used by the support.
536 //---------------------------------------------------
537 inline const medGeometryElement * SUPPORT::getTypes() const
538 //---------------------------------------------------
540 // if ((_isOnAllElts)&(_entity != MED_NODE))
541 // return _mesh->getTypes(_entity) ;
543 return _geometricType;
546 //---------------------------------------------------
547 //inline int * SUPPORT::getGeometricTypeNumber() const
548 //---------------------------------------------------
550 // const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
552 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
553 // if (_geometricTypeNumber==NULL)
554 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
555 // return _geometricTypeNumber;
559 #endif /* SUPPORT_HXX */