12 #include "utilities.h"
13 #include "MEDMEM_STRING.hxx"
14 #include "MEDMEM_Exception.hxx"
15 #include "MEDMEM_define.hxx"
16 #include "MEDMEM_SkyLineArray.hxx"
20 This class describe a support of elements on an entity of the mesh.
22 It contains the list of meshes elements for an entity (MED_NODE,
23 MED_CELL, MED_FACE or MED_EDGE).
41 Description of the support (optional).
48 Reference to the mesh on which the support is defined.
55 Type of entity on which the support is defined
56 (only one for each support).
59 MED_EN::medEntityMesh _entity ;
63 Number of geometric type defined in the support.
66 int _numberOfGeometricType;
70 Array of all geometric type defined in the support.
73 MED_EN::medGeometryElement * _geometricType;
77 Array of size _numberOfGeometricType which contains
78 for each type the number of gauss point
79 (not yet implemented).
82 mutable int * _numberOfGaussPoint ;
86 Array of size _numberOfGeometricType
87 which contains number of geometric
89 (to get corresponding CellModel).
92 //int * _geometricTypeNumber;
96 If true, we consider all entities of type _entity.
103 Index array of size _numberOfGeometricType wich contains
104 for each geometric type, the number of elements of this type.
107 int * _numberOfElements;
111 Sum of each _numberOfElements component.
114 int _totalNumberOfElements;
116 // the two following arrays are defined only if _isOnAllElts is false :
120 array of size _numberOfType+1 wich contains for
121 each geometric type, index in _number._value
122 (if _all is true, we must ask _mesh to get
123 information). _typeIndex[i+1]-_typeIndex[i]
124 represents count of entities of ith geometric
125 type. _typeIndex[_numberOfType] contains total
126 entities count. If _numberOf[i]=0,
127 _typeIndex[i+1]=_typeIndex[i]
128 defined only if _isOnAllElts is false
135 Array of size _index[_numberOfType]-1 wich contain number of
136 entities of each geometric type. We use global numbering.\n
137 Defined only if _isOnAllElts is false.
140 mutable MEDSKYLINEARRAY * _number;
144 SUPPORT(MESH* Mesh, string Name="", MED_EN::medEntityMesh Entity=MED_EN::MED_CELL);
145 SUPPORT(const SUPPORT & m);
147 friend ostream & operator<<(ostream &os,const SUPPORT &my);
149 bool operator == (const SUPPORT &support) const;
151 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
154 inline void setName(string Name);
155 inline void setDescription(string Description);
156 inline void setMesh(MESH *Mesh);
157 inline void setAll(bool All);
158 inline void setEntity(MED_EN::medEntityMesh Entity);
159 inline void setNumberOfGeometricType(int NumberOfGeometricType);
160 inline void setGeometricType(const MED_EN::medGeometryElement *GeometricType);
161 inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
162 // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
163 inline void setNumberOfElements(const int *NumberOfElements);
164 inline void setTotalNumberOfElements(int TotalNumberOfElements);
165 inline void setNumber(MEDSKYLINEARRAY * Number);
166 inline void setNumber(const int * index, const int* value, bool shallowCopy=false);
168 inline string getName() const;
169 inline string getDescription() const;
170 virtual inline MESH * getMesh() const;
171 inline MED_EN::medEntityMesh getEntity() const;
173 inline bool isOnAllElements() const;
174 inline int getNumberOfTypes() const;
175 inline const MED_EN::medGeometryElement* getTypes() const ;
176 inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
177 inline int getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION);
178 //inline int * getGeometricTypeNumber() const;
179 //inline int getTotalNumberOfElement() const;
180 inline int getNumberOfElements(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
181 virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
182 virtual inline const int * getNumber(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
183 virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION);
185 void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
187 void setpartial(string Description, int NumberOfGeometricType,
188 int TotalNumberOfEntity, MED_EN::medGeometryElement *GeometricType,
189 int *NumberOfEntity, int *NumberValue);
191 void getBoundaryElements() throw (MEDEXCEPTION);
193 void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
196 // _____________________
198 // _____________________
201 This method returns the number of all elements of the type GeometricType.
203 If isOnAllElements is false, it returns the number of elements in the
204 support else it returns number of elements in the whole mesh.
206 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
207 in entity of support.
209 Note : If SUPPORT is defined on MED_NODE, use MED_ALL_ELEMENTS as
210 medGeometryElement GeometricType and it will returns the number
211 of nodes in the support (or in the whole mesh).
213 //-----------------------------------------------------------------------------
214 inline int SUPPORT::getNumberOfElements(MED_EN::medGeometryElement GeometricType) const
216 //-----------------------------------------------------------------------------
218 if (GeometricType==MED_EN::MED_ALL_ELEMENTS)
219 return _totalNumberOfElements;
220 for (int i=0;i<_numberOfGeometricType;i++)
221 if (_geometricType[i]==GeometricType)
222 return _numberOfElements[i];
223 throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
226 //---------------------------------------------------------------------
227 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
229 //---------------------------------------------------------------------
232 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
237 If isOnAllElements is false, returns an array which contains
238 all number of given medGeometryElement.
240 Numbering is global, ie numbers are bounded by 1 and
241 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
242 MESH::getNumberOfElement(entity,geomElement).
244 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
245 medGeometryElement type.
247 //---------------------------------------------------------------------
248 inline const int * SUPPORT::getNumber(MED_EN::medGeometryElement GeometricType) const
250 //---------------------------------------------------------------------
252 const char * LOC = "Support::getNumber : " ;
254 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
255 if (GeometricType==MED_EN::MED_ALL_ELEMENTS)
256 return _number->getValue() ;
257 for (int i=0;i<_numberOfGeometricType;i++)
258 if (_geometricType[i]==GeometricType)
259 return _number->getI(i+1) ;
260 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
264 If isOnAllElements is false, returns index of element number.
265 Use it with getNumber(MED_ALL_ELEMENTS).
267 Note : See getConnectivityIndex for details.
269 //-------------------------------------------
270 inline const int * SUPPORT::getNumberIndex() const
271 //-------------------------------------------
275 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
276 return _number->getIndex() ;
280 //-------------------------------------------------
281 inline const int * SUPPORT::getNumberOfGaussPoint() const
283 //-------------------------------------------------
285 if (_numberOfGaussPoint!=NULL)
286 return _numberOfGaussPoint ;
288 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
292 Returns number of Gauss points for this medGeometryElement.
295 - Not defined if SUPPORT is on MED_NODE.
296 - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
298 //-----------------------------------------------------------------------------
299 inline int SUPPORT::getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const
301 //-----------------------------------------------------------------------------
303 if (_numberOfGaussPoint!=NULL) {
304 for (int i=0;i<_numberOfGeometricType;i++)
305 if (_geometricType[i]==geomElement)
306 return _numberOfGaussPoint[i] ;
307 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
309 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
311 // inline int SUPPORT::getNumberLength() const
312 // throw (MEDEXCEPTION)
315 // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
316 // return _number->getLength() ;
319 /*! set the attribute _name to Name */
320 //--------------------------------------
321 inline void SUPPORT::setName(string Name)
322 //--------------------------------------
327 /*! set the attribute _description to Description */
328 //--------------------------------------------------
329 inline void SUPPORT::setDescription(string Description)
330 //--------------------------------------------------
332 _description=Description;
335 /*! set the reference _mesh to Mesh */
336 //--------------------------------------
337 inline void SUPPORT::setMesh(MESH *Mesh)
338 //--------------------------------------
343 /*! set the attribute _isOnAllElts to All */
344 //------------------------------------------
345 inline void SUPPORT::setAll(bool All)
346 //------------------------------------------
351 /*! set the attribute _entity to Entity */
352 //------------------------------------------
353 inline void SUPPORT::setEntity(MED_EN::medEntityMesh Entity)
356 // if ( Entity == MED_NODE) {
357 // _numberOfGeometricType=1 ;
358 // if (_geometricType == (medGeometryElement *) NULL)
359 // _geometricType=new medGeometryElement[1] ;
362 // // delete previous ???
363 // delete [] _geometricType;
364 // _geometricType=new medGeometryElement[1] ;
366 // _geometricType[0]=MED_NONE ;
370 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
371 //---------------------------------------------------------------------
372 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
373 //---------------------------------------------------------------------
375 _numberOfGeometricType=NumberOfGeometricType;
376 if (_geometricType!=NULL) {
377 delete[] _geometricType ;
378 _geometricType = NULL ;
380 if (_numberOfElements!=NULL) {
381 delete[] _numberOfElements ;
382 _numberOfElements = NULL ;
384 if (_numberOfGaussPoint!=NULL) {
385 delete[] _numberOfGaussPoint ;
386 _numberOfGaussPoint = NULL ;
390 /*! set the attribute _geometricType to geometricType */
391 //---------------------------------------------------------------------
392 inline void SUPPORT::setGeometricType(const MED_EN::medGeometryElement *GeometricType)
393 //---------------------------------------------------------------------
395 if (NULL == _geometricType)
396 _geometricType=new MED_EN::medGeometryElement[_numberOfGeometricType];
397 for (int i=0;i<_numberOfGeometricType;i++)
398 _geometricType[i] = GeometricType[i];
399 // _geometricType=GeometricType;
402 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
403 //-----------------------------------------------------------------
404 inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
405 //-----------------------------------------------------------------
407 if (NULL == _numberOfGaussPoint)
408 _numberOfGaussPoint=new int[_numberOfGeometricType];
409 for (int i=0;i<_numberOfGeometricType;i++)
410 _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
411 // _numberOfGaussPoint = NumberOfGaussPoint ;
414 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
415 //-------------------------------------------------------------------
416 //inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
417 //-------------------------------------------------------------------
419 // _geometricTypeNumber=GeometricTypeNumber;
423 Set the attribute _numberOfElements to NumberOfElements and
424 calculate the total number of elements.
426 //----------------------------------------------------------
427 inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
428 //----------------------------------------------------------
430 if (NULL == _numberOfElements)
431 _numberOfElements=new int[_numberOfGeometricType];
432 memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
433 _totalNumberOfElements = 0 ;
434 for (int i=0;i<_numberOfGeometricType;i++)
435 _totalNumberOfElements+=_numberOfElements[i];
438 /*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
439 //--------------------------------------------------------------------
440 inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
441 //--------------------------------------------------------------------
443 _totalNumberOfElements=TotalNumberOfElements;
446 /*! set the attribute _number to Number */
447 //---------------------------------------------------
448 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
449 //---------------------------------------------------
451 if (_number != NULL) delete _number ;
455 /*! set the attribute _number with index and value arrays */
456 //---------------------------------------------------
457 inline void SUPPORT::setNumber(const int * index, const int* value, bool shallowCopy)
458 //---------------------------------------------------
460 if (_number != NULL) delete _number ;
461 _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy);
464 /*! returns the name of the support. */
465 //------------------------------------
466 inline string SUPPORT::getName() const
467 //------------------------------------
473 /*! returns the description of the support. */
474 //--------------------------------------------
475 inline string SUPPORT::getDescription() const
476 //--------------------------------------------
481 /*! returns a reference to the mesh */
482 //------------------------------------
483 inline MESH * SUPPORT::getMesh() const
484 //------------------------------------
490 Returns true if all elements of this entity are
491 concerned, false otherwise.
492 If true, you must use mesh reference (getMesh) to get more information.
494 //------------------------------------------
495 inline bool SUPPORT::isOnAllElements() const
496 //------------------------------------------
502 Returns number of geometric Types
503 defines in the support
505 //------------------------------------------
506 inline int SUPPORT::getNumberOfTypes() const
507 //------------------------------------------
509 // if ((_isOnAllElts)&(_entity != MED_NODE))
510 // return _mesh->getNumberOfTypes(_entity) ;
512 return _numberOfGeometricType ;
516 Returns the %medEntityMesh's type used by the support.
517 Note : A support deals only with one entity's type
518 (for example : MED_FACE or MED_NODE)
520 //---------------------------------------------
521 inline MED_EN::medEntityMesh SUPPORT::getEntity() const
522 //---------------------------------------------
528 If isOnAllElements is false, returns an array of %medGeometryElement
529 types used by the support.
531 //---------------------------------------------------
532 inline const MED_EN::medGeometryElement * SUPPORT::getTypes() const
533 //---------------------------------------------------
535 // if ((_isOnAllElts)&(_entity != MED_NODE))
536 // return _mesh->getTypes(_entity) ;
538 return _geometricType;
541 //---------------------------------------------------
542 //inline int * SUPPORT::getGeometricTypeNumber() const
543 //---------------------------------------------------
545 // const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
547 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
548 // if (_geometricTypeNumber==NULL)
549 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
550 // return _geometricTypeNumber;
553 }//End namespace MEDMEM
556 #endif /* SUPPORT_HXX */