14 #include "utilities.h"
15 #include "MEDMEM_STRING.hxx"
16 #include "MEDMEM_Exception.hxx"
17 #include "MEDMEM_define.hxx"
18 #include "MEDMEM_SkyLineArray.hxx"
19 #include "MEDMEM_RCBase.hxx"
23 This class describe a support of elements on an entity of the mesh.
25 It contains the list of meshes elements for an entity (MED_NODE,
26 MED_CELL, MED_FACE or MED_EDGE).
33 class SUPPORT : public RCBASE
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 MED_EN::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 MED_EN::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 _index[_numberOfType]-1 wich contain number of
125 entities of each geometric type. We use global numbering.\n
126 Defined only if _isOnAllElts is false.
129 mutable MEDSKYLINEARRAY * _number;
133 SUPPORT(MESH* Mesh, string Name="", MED_EN::medEntityMesh Entity=MED_EN::MED_CELL);
134 SUPPORT(const SUPPORT & m);
136 friend ostream & operator<<(ostream &os,const SUPPORT &my);
138 SUPPORT& operator=(const SUPPORT &support);
139 bool operator == (const SUPPORT &support) const;
140 bool deepCompare(const SUPPORT &support) const;
141 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
144 inline void setName(string Name);
145 inline void setDescription(string Description);
146 void setMesh(MESH *Mesh);
147 inline void setAll(bool All);
148 inline void setEntity(MED_EN::medEntityMesh Entity);
149 inline void setNumberOfGeometricType(int NumberOfGeometricType);
150 inline void setGeometricType(const MED_EN::medGeometryElement *GeometricType);
151 inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
152 inline void setNumberOfElements(const int *NumberOfElements);
153 inline void setTotalNumberOfElements(int TotalNumberOfElements);
154 inline void setNumber(MEDSKYLINEARRAY * Number);
155 inline void setNumber(const int * index, const int* value, bool shallowCopy=false);
157 inline string getName() const;
158 inline string getDescription() const;
159 virtual inline MESH * getMesh() const;
160 inline MED_EN::medEntityMesh getEntity() const;
162 inline bool isOnAllElements() const;
163 inline int getNumberOfTypes() const;
164 inline const MED_EN::medGeometryElement* getTypes() const ;
165 inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
166 inline int getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION);
167 inline int getNumberOfElements(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
168 virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
169 virtual inline const int * getNumber(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
170 virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION);
172 void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
174 void setpartial(string Description, int NumberOfGeometricType,
175 int TotalNumberOfEntity, MED_EN::medGeometryElement *GeometricType,
176 int *NumberOfEntity, int *NumberValue);
178 void getBoundaryElements() throw (MEDEXCEPTION);
179 void changeElementsNbs(MED_EN::medEntityMesh entity, const int *renumberingFromOldToNew, int limitNbClassicPoly, const int *renumberingFromOldToNewPoly=0);
180 void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
181 bool belongsTo(const SUPPORT& other, bool deepCompare=false) const;
182 SUPPORT *getComplement() const;
183 SUPPORT *substract(const SUPPORT& other) const throw (MEDEXCEPTION) ;
184 SUPPORT *getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION);
185 void fillFromNodeList(const list<int>& listOfNode) throw (MEDEXCEPTION);
186 void fillFromElementList(const list<int>& listOfElt) throw (MEDEXCEPTION);
187 void clearDataOnNumbers();
188 //A.G. Addings for RC
189 virtual void addReference() const;
190 virtual void removeReference() const;
192 static list<int> *sub(int start,int end,const int *idsToSuppress,int lgthIdsToSuppress);
193 static list<int> *sub(const int *ids,int lgthIds,const int *idsToSuppress,int lgthIdsToSuppress);
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 //---------------------------------------------------------------------
253 throw MEDEXCEPTION("Support::getNumber : Not defined, support is on all entity !") ;
254 if (GeometricType==MED_EN::MED_ALL_ELEMENTS)
255 return _number->getValue() ;
256 for (int i=0;i<_numberOfGeometricType;i++)
257 if (_geometricType[i]==GeometricType)
258 return _number->getI(i+1) ;
259 throw MEDEXCEPTION("Support::getNumber : GeometricType not found !") ;
263 If isOnAllElements is false, returns index of element number.
264 Use it with getNumber(MED_ALL_ELEMENTS).
266 Note : See getConnectivityIndex for details.
268 //-------------------------------------------
269 inline const int * SUPPORT::getNumberIndex() const
270 //-------------------------------------------
274 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
275 return _number->getIndex() ;
279 //-------------------------------------------------
280 inline const int * SUPPORT::getNumberOfGaussPoint() const
282 //-------------------------------------------------
284 if (_numberOfGaussPoint!=NULL)
285 return _numberOfGaussPoint ;
287 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
291 Returns number of Gauss points for this medGeometryElement.
294 - Not defined if SUPPORT is on MED_NODE.
295 - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
297 //-----------------------------------------------------------------------------
298 inline int SUPPORT::getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const
300 //-----------------------------------------------------------------------------
302 if (_numberOfGaussPoint!=NULL) {
303 for (int i=0;i<_numberOfGeometricType;i++)
304 if (_geometricType[i]==geomElement)
305 return _numberOfGaussPoint[i] ;
306 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
308 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
311 /*! set the attribute _name to Name */
312 //--------------------------------------
313 inline void SUPPORT::setName(string Name)
314 //--------------------------------------
319 /*! set the attribute _description to Description */
320 //--------------------------------------------------
321 inline void SUPPORT::setDescription(string Description)
322 //--------------------------------------------------
324 _description=Description;
327 /*! set the attribute _isOnAllElts to All */
328 //------------------------------------------
329 inline void SUPPORT::setAll(bool All)
330 //------------------------------------------
335 /*! set the attribute _entity to Entity */
336 //------------------------------------------
337 inline void SUPPORT::setEntity(MED_EN::medEntityMesh Entity)
342 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
343 //---------------------------------------------------------------------
344 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
345 //---------------------------------------------------------------------
347 _numberOfGeometricType=NumberOfGeometricType;
348 if (_geometricType!=NULL) {
349 delete[] _geometricType ;
350 _geometricType = NULL ;
352 if (_numberOfElements!=NULL) {
353 delete[] _numberOfElements ;
354 _numberOfElements = NULL ;
356 if (_numberOfGaussPoint!=NULL) {
357 delete[] _numberOfGaussPoint ;
358 _numberOfGaussPoint = NULL ;
362 /*! set the attribute _geometricType to geometricType */
363 //---------------------------------------------------------------------
364 inline void SUPPORT::setGeometricType(const MED_EN::medGeometryElement *GeometricType)
365 //---------------------------------------------------------------------
367 if (NULL == _geometricType)
368 _geometricType=new MED_EN::medGeometryElement[_numberOfGeometricType];
369 for (int i=0;i<_numberOfGeometricType;i++)
370 _geometricType[i] = GeometricType[i];
373 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
374 //-----------------------------------------------------------------
375 inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
376 //-----------------------------------------------------------------
378 if (NULL == _numberOfGaussPoint)
379 _numberOfGaussPoint=new int[_numberOfGeometricType];
380 for (int i=0;i<_numberOfGeometricType;i++)
381 _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
385 Set the attribute _numberOfElements to NumberOfElements and
386 calculate the total number of elements.
388 //----------------------------------------------------------
389 inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
390 //----------------------------------------------------------
392 if (NULL == _numberOfElements)
393 _numberOfElements=new int[_numberOfGeometricType];
394 memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
395 _totalNumberOfElements = 0 ;
396 for (int i=0;i<_numberOfGeometricType;i++)
397 _totalNumberOfElements+=_numberOfElements[i];
400 /*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
401 //--------------------------------------------------------------------
402 inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
403 //--------------------------------------------------------------------
405 _totalNumberOfElements=TotalNumberOfElements;
408 /*! set the attribute _number to Number */
409 //---------------------------------------------------
410 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
411 //---------------------------------------------------
413 if (_number != NULL) delete _number ;
417 /*! set the attribute _number with index and value arrays */
418 //---------------------------------------------------
419 inline void SUPPORT::setNumber(const int * index, const int* value, bool shallowCopy)
420 //---------------------------------------------------
422 if (_number != NULL) delete _number ;
423 _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy);
426 /*! returns the name of the support. */
427 //------------------------------------
428 inline string SUPPORT::getName() const
429 //------------------------------------
435 /*! returns the description of the support. */
436 //--------------------------------------------
437 inline string SUPPORT::getDescription() const
438 //--------------------------------------------
443 /*! returns a reference to the mesh */
444 //------------------------------------
445 inline MESH * SUPPORT::getMesh() const
446 //------------------------------------
452 Returns true if all elements of this entity are
453 concerned, false otherwise.
454 If true, you must use mesh reference (getMesh) to get more information.
456 //------------------------------------------
457 inline bool SUPPORT::isOnAllElements() const
458 //------------------------------------------
464 Returns number of geometric Types
465 defines in the support
467 //------------------------------------------
468 inline int SUPPORT::getNumberOfTypes() const
469 //------------------------------------------
471 // if ((_isOnAllElts)&(_entity != MED_NODE))
472 // return _mesh->getNumberOfTypes(_entity) ;
474 return _numberOfGeometricType ;
478 Returns the %medEntityMesh's type used by the support.
479 Note : A support deals only with one entity's type
480 (for example : MED_FACE or MED_NODE)
482 //---------------------------------------------
483 inline MED_EN::medEntityMesh SUPPORT::getEntity() const
484 //---------------------------------------------
490 If isOnAllElements is false, returns an array of %medGeometryElement
491 types used by the support.
493 //---------------------------------------------------
494 inline const MED_EN::medGeometryElement * SUPPORT::getTypes() const
495 //---------------------------------------------------
497 return _geometricType;
500 }//End namespace MEDMEM
503 #endif /* SUPPORT_HXX */