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 // 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) ;
198 // _____________________
200 // _____________________
202 using namespace MEDMEM;
204 This method returns the number of all elements of the type GeometricType.
206 If isOnAllElements is false, it returns the number of elements in the
207 support else it returns number of elements in the whole mesh.
209 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
210 in entity of support.
212 Note : If SUPPORT is defined on MED_NODE, use MED_ALL_ELEMENTS as
213 medGeometryElement GeometricType and it will returns the number
214 of nodes in the support (or in the whole mesh).
216 //-----------------------------------------------------------------------------
217 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
219 //-----------------------------------------------------------------------------
221 if (GeometricType==MED_ALL_ELEMENTS)
222 return _totalNumberOfElements;
223 for (int i=0;i<_numberOfGeometricType;i++)
224 if (_geometricType[i]==GeometricType)
225 return _numberOfElements[i];
226 throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
229 //---------------------------------------------------------------------
230 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
232 //---------------------------------------------------------------------
235 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
240 If isOnAllElements is false, returns an array which contains
241 all number of given medGeometryElement.
243 Numbering is global, ie numbers are bounded by 1 and
244 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
245 MESH::getNumberOfElement(entity,geomElement).
247 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
248 medGeometryElement type.
250 //---------------------------------------------------------------------
251 inline const int * SUPPORT::getNumber(medGeometryElement GeometricType) const
253 //---------------------------------------------------------------------
255 const char * LOC = "Support::getNumber : " ;
257 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
258 if (GeometricType==MED_ALL_ELEMENTS)
259 return _number->getValue() ;
260 for (int i=0;i<_numberOfGeometricType;i++)
261 if (_geometricType[i]==GeometricType)
262 return _number->getI(i+1) ;
263 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
267 If isOnAllElements is false, returns index of element number.
268 Use it with getNumber(MED_ALL_ELEMENTS).
270 Note : See getConnectivityIndex for details.
272 //-------------------------------------------
273 inline const int * SUPPORT::getNumberIndex() const
274 //-------------------------------------------
278 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
279 return _number->getIndex() ;
283 //-------------------------------------------------
284 inline const int * SUPPORT::getNumberOfGaussPoint() const
286 //-------------------------------------------------
288 if (_numberOfGaussPoint!=NULL)
289 return _numberOfGaussPoint ;
291 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
295 Returns number of Gauss points for this medGeometryElement.
298 - Not defined if SUPPORT is on MED_NODE.
299 - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
301 //-----------------------------------------------------------------------------
302 inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
304 //-----------------------------------------------------------------------------
306 if (_numberOfGaussPoint!=NULL) {
307 for (int i=0;i<_numberOfGeometricType;i++)
308 if (_geometricType[i]==geomElement)
309 return _numberOfGaussPoint[i] ;
310 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
312 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
314 // inline int SUPPORT::getNumberLength() const
315 // throw (MEDEXCEPTION)
318 // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
319 // return _number->getLength() ;
322 /*! set the attribute _name to Name */
323 //--------------------------------------
324 inline void SUPPORT::setName(string Name)
325 //--------------------------------------
330 /*! set the attribute _description to Description */
331 //--------------------------------------------------
332 inline void SUPPORT::setDescription(string Description)
333 //--------------------------------------------------
335 _description=Description;
338 /*! set the reference _mesh to Mesh */
339 //--------------------------------------
340 inline void SUPPORT::setMesh(MESH *Mesh)
341 //--------------------------------------
346 /*! set the attribute _isOnAllElts to All */
347 //------------------------------------------
348 inline void SUPPORT::setAll(bool All)
349 //------------------------------------------
354 /*! set the attribute _entity to Entity */
355 //------------------------------------------
356 inline void SUPPORT::setEntity(medEntityMesh Entity)
359 // if ( Entity == MED_NODE) {
360 // _numberOfGeometricType=1 ;
361 // if (_geometricType == (medGeometryElement *) NULL)
362 // _geometricType=new medGeometryElement[1] ;
365 // // delete previous ???
366 // delete [] _geometricType;
367 // _geometricType=new medGeometryElement[1] ;
369 // _geometricType[0]=MED_NONE ;
373 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
374 //---------------------------------------------------------------------
375 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
376 //---------------------------------------------------------------------
378 _numberOfGeometricType=NumberOfGeometricType;
379 if (_geometricType!=NULL) {
380 delete[] _geometricType ;
381 _geometricType = NULL ;
383 if (_numberOfElements!=NULL) {
384 delete[] _numberOfElements ;
385 _numberOfElements = NULL ;
387 if (_numberOfGaussPoint!=NULL) {
388 delete[] _numberOfGaussPoint ;
389 _numberOfGaussPoint = NULL ;
393 /*! set the attribute _geometricType to geometricType */
394 //---------------------------------------------------------------------
395 inline void SUPPORT::setGeometricType(const medGeometryElement *GeometricType)
396 //---------------------------------------------------------------------
398 if (NULL == _geometricType)
399 _geometricType=new medGeometryElement[_numberOfGeometricType];
400 for (int i=0;i<_numberOfGeometricType;i++)
401 _geometricType[i] = GeometricType[i];
402 // _geometricType=GeometricType;
405 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
406 //-----------------------------------------------------------------
407 inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
408 //-----------------------------------------------------------------
410 if (NULL == _numberOfGaussPoint)
411 _numberOfGaussPoint=new int[_numberOfGeometricType];
412 for (int i=0;i<_numberOfGeometricType;i++)
413 _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
414 // _numberOfGaussPoint = NumberOfGaussPoint ;
417 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
418 //-------------------------------------------------------------------
419 //inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
420 //-------------------------------------------------------------------
422 // _geometricTypeNumber=GeometricTypeNumber;
426 Set the attribute _numberOfElements to NumberOfElements and
427 calculate the total number of elements.
429 //----------------------------------------------------------
430 inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
431 //----------------------------------------------------------
433 if (NULL == _numberOfElements)
434 _numberOfElements=new int[_numberOfGeometricType];
435 memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
436 _totalNumberOfElements = 0 ;
437 for (int i=0;i<_numberOfGeometricType;i++)
438 _totalNumberOfElements+=_numberOfElements[i];
441 /*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
442 //--------------------------------------------------------------------
443 inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
444 //--------------------------------------------------------------------
446 _totalNumberOfElements=TotalNumberOfElements;
449 /*! set the attribute _number to Number */
450 //---------------------------------------------------
451 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
452 //---------------------------------------------------
454 if (_number != NULL) delete _number ;
458 /*! set the attribute _number with index and value arrays */
459 //---------------------------------------------------
460 inline void SUPPORT::setNumber(const int * index, const int* value)
461 //---------------------------------------------------
463 if (_number != NULL) delete _number ;
464 _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value);
467 /*! returns the name of the support. */
468 //------------------------------------
469 inline string SUPPORT::getName() const
470 //------------------------------------
476 /*! returns the description of the support. */
477 //--------------------------------------------
478 inline string SUPPORT::getDescription() const
479 //--------------------------------------------
484 /*! returns a reference to the mesh */
485 //------------------------------------
486 inline MESH * SUPPORT::getMesh() const
487 //------------------------------------
493 Returns true if all elements of this entity are
494 concerned, false otherwise.
495 If true, you must use mesh reference (getMesh) to get more information.
497 //------------------------------------------
498 inline bool SUPPORT::isOnAllElements() const
499 //------------------------------------------
505 Returns number of geometric Types
506 defines in the support
508 //------------------------------------------
509 inline int SUPPORT::getNumberOfTypes() const
510 //------------------------------------------
512 // if ((_isOnAllElts)&(_entity != MED_NODE))
513 // return _mesh->getNumberOfTypes(_entity) ;
515 return _numberOfGeometricType ;
519 Returns the medEntityMesh's type used by the support.
520 Note : A support deals only with one entity's type
521 (for example : MED_FACE or MED_NODE)
523 //---------------------------------------------
524 inline medEntityMesh SUPPORT::getEntity() const
525 //---------------------------------------------
531 If isOnAllElements is false, returns an array of <medGeometryElement>
532 types used by the support.
534 <medEntityMesh> is given by getEntity.
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 */