13 #include "utilities.h"
14 #include "MEDMEM_STRING.hxx"
15 #include "MEDMEM_Exception.hxx"
16 #include "MEDMEM_define.hxx"
17 #include "MEDMEM_SkyLineArray.hxx"
18 #include "MEDMEM_RCBase.hxx"
22 This class describe a support of elements on an entity of the mesh.
24 It contains the list of meshes elements for an entity (MED_NODE,
25 MED_CELL, MED_FACE or MED_EDGE).
31 class SUPPORT : public RCBASE
43 Description of the support (optional).
50 Reference to the mesh on which the support is defined.
57 Type of entity on which the support is defined
58 (only one for each support).
61 MED_EN::medEntityMesh _entity ;
65 Number of geometric type defined in the support.
68 int _numberOfGeometricType;
72 Array of all geometric type defined in the support.
75 MED_EN::medGeometryElement * _geometricType;
79 Array of size _numberOfGeometricType which contains
80 for each type the number of gauss point
81 (not yet implemented).
84 mutable int * _numberOfGaussPoint ;
88 Array of size _numberOfGeometricType
89 which contains number of geometric
91 (to get corresponding CellModel).
94 //int * _geometricTypeNumber;
98 If true, we consider all entities of type _entity.
105 Index array of size _numberOfGeometricType wich contains
106 for each geometric type, the number of elements of this type.
109 int * _numberOfElements;
113 Sum of each _numberOfElements component.
116 int _totalNumberOfElements;
118 // the two following arrays are defined only if _isOnAllElts is false :
122 Array of size _index[_numberOfType]-1 wich contain number of
123 entities of each geometric type. We use global numbering.\n
124 Defined only if _isOnAllElts is false.
127 mutable MEDSKYLINEARRAY * _number;
131 SUPPORT(MESH* Mesh, string Name="", MED_EN::medEntityMesh Entity=MED_EN::MED_CELL);
132 SUPPORT(const SUPPORT & m);
134 friend ostream & operator<<(ostream &os,const SUPPORT &my);
136 SUPPORT& operator=(const SUPPORT &support);
137 bool operator == (const SUPPORT &support) const;
138 bool deepCompare(const SUPPORT &support) const;
139 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
142 inline void setName(string Name);
143 inline void setDescription(string Description);
144 void setMesh(MESH *Mesh);
145 inline void setAll(bool All);
146 inline void setEntity(MED_EN::medEntityMesh Entity);
147 inline void setNumberOfGeometricType(int NumberOfGeometricType);
148 inline void setGeometricType(const MED_EN::medGeometryElement *GeometricType);
149 inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
150 inline void setNumberOfElements(const int *NumberOfElements);
151 inline void setTotalNumberOfElements(int TotalNumberOfElements);
152 inline void setNumber(MEDSKYLINEARRAY * Number);
153 inline void setNumber(const int * index, const int* value, bool shallowCopy=false);
155 inline string getName() const;
156 inline string getDescription() const;
157 virtual inline MESH * getMesh() const;
158 inline MED_EN::medEntityMesh getEntity() const;
160 inline bool isOnAllElements() const;
161 inline int getNumberOfTypes() const;
162 inline const MED_EN::medGeometryElement* getTypes() const ;
163 inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
164 inline int getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const throw (MEDEXCEPTION);
165 inline int getNumberOfElements(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
166 virtual inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
167 virtual inline const int * getNumber(MED_EN::medGeometryElement GeometricType) const throw (MEDEXCEPTION);
168 virtual inline const int * getNumberIndex() const throw (MEDEXCEPTION);
170 void blending(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
172 void setpartial(string Description, int NumberOfGeometricType,
173 int TotalNumberOfEntity, MED_EN::medGeometryElement *GeometricType,
174 int *NumberOfEntity, int *NumberValue);
176 void getBoundaryElements() throw (MEDEXCEPTION);
177 void changeElementsNbs(MED_EN::medEntityMesh entity, const int *renumberingFromOldToNew, int limitNbClassicPoly, const int *renumberingFromOldToNewPoly=0);
178 void intersecting(SUPPORT * mySupport) throw (MEDEXCEPTION) ;
179 bool belongsTo(const SUPPORT& other, bool deepCompare=false) const;
180 SUPPORT *getComplement() const;
181 SUPPORT *substract(const SUPPORT& other) const throw (MEDEXCEPTION) ;
182 SUPPORT *getBoundaryElements(MED_EN::medEntityMesh Entity) const throw (MEDEXCEPTION);
183 void fillFromNodeList(const list<int>& listOfNode) throw (MEDEXCEPTION);
184 void fillFromElementList(const list<int>& listOfElt) throw (MEDEXCEPTION);
185 void clearDataOnNumbers();
186 //A.G. Addings for RC
187 virtual void addReference() const;
188 virtual void removeReference() const;
190 static list<int> *sub(int start,int end,const int *idsToSuppress,int lgthIdsToSuppress);
191 static list<int> *sub(const int *ids,int lgthIds,const int *idsToSuppress,int lgthIdsToSuppress);
194 // _____________________
196 // _____________________
199 This method returns the number of all elements of the type GeometricType.
201 If isOnAllElements is false, it returns the number of elements in the
202 support else it returns number of elements in the whole mesh.
204 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
205 in entity of support.
207 Note : If SUPPORT is defined on MED_NODE, use MED_ALL_ELEMENTS as
208 medGeometryElement GeometricType and it will returns the number
209 of nodes in the support (or in the whole mesh).
211 //-----------------------------------------------------------------------------
212 inline int SUPPORT::getNumberOfElements(MED_EN::medGeometryElement GeometricType) const
214 //-----------------------------------------------------------------------------
216 if (GeometricType==MED_EN::MED_ALL_ELEMENTS)
217 return _totalNumberOfElements;
218 for (int i=0;i<_numberOfGeometricType;i++)
219 if (_geometricType[i]==GeometricType)
220 return _numberOfElements[i];
221 throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
224 //---------------------------------------------------------------------
225 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
227 //---------------------------------------------------------------------
230 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
235 If isOnAllElements is false, returns an array which contains
236 all number of given medGeometryElement.
238 Numbering is global, ie numbers are bounded by 1 and
239 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
240 MESH::getNumberOfElement(entity,geomElement).
242 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
243 medGeometryElement type.
245 //---------------------------------------------------------------------
246 inline const int * SUPPORT::getNumber(MED_EN::medGeometryElement GeometricType) const
248 //---------------------------------------------------------------------
251 throw MEDEXCEPTION("Support::getNumber : Not defined, support is on all entity !") ;
252 if (GeometricType==MED_EN::MED_ALL_ELEMENTS)
253 return _number->getValue() ;
254 for (int i=0;i<_numberOfGeometricType;i++)
255 if (_geometricType[i]==GeometricType)
256 return _number->getI(i+1) ;
257 throw MEDEXCEPTION("Support::getNumber : GeometricType not found !") ;
261 If isOnAllElements is false, returns index of element number.
262 Use it with getNumber(MED_ALL_ELEMENTS).
264 Note : See getConnectivityIndex for details.
266 //-------------------------------------------
267 inline const int * SUPPORT::getNumberIndex() const
268 //-------------------------------------------
272 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
273 return _number->getIndex() ;
277 //-------------------------------------------------
278 inline const int * SUPPORT::getNumberOfGaussPoint() const
280 //-------------------------------------------------
282 if (_numberOfGaussPoint!=NULL)
283 return _numberOfGaussPoint ;
285 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
289 Returns number of Gauss points for this medGeometryElement.
292 - Not defined if SUPPORT is on MED_NODE.
293 - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
295 //-----------------------------------------------------------------------------
296 inline int SUPPORT::getNumberOfGaussPoint(MED_EN::medGeometryElement geomElement) const
298 //-----------------------------------------------------------------------------
300 if (_numberOfGaussPoint!=NULL) {
301 for (int i=0;i<_numberOfGeometricType;i++)
302 if (_geometricType[i]==geomElement)
303 return _numberOfGaussPoint[i] ;
304 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
306 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
309 /*! set the attribute _name to Name */
310 //--------------------------------------
311 inline void SUPPORT::setName(string Name)
312 //--------------------------------------
317 /*! set the attribute _description to Description */
318 //--------------------------------------------------
319 inline void SUPPORT::setDescription(string Description)
320 //--------------------------------------------------
322 _description=Description;
325 /*! set the attribute _isOnAllElts to All */
326 //------------------------------------------
327 inline void SUPPORT::setAll(bool All)
328 //------------------------------------------
333 /*! set the attribute _entity to Entity */
334 //------------------------------------------
335 inline void SUPPORT::setEntity(MED_EN::medEntityMesh Entity)
340 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
341 //---------------------------------------------------------------------
342 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
343 //---------------------------------------------------------------------
345 _numberOfGeometricType=NumberOfGeometricType;
346 if (_geometricType!=NULL) {
347 delete[] _geometricType ;
348 _geometricType = NULL ;
350 if (_numberOfElements!=NULL) {
351 delete[] _numberOfElements ;
352 _numberOfElements = NULL ;
354 if (_numberOfGaussPoint!=NULL) {
355 delete[] _numberOfGaussPoint ;
356 _numberOfGaussPoint = NULL ;
360 /*! set the attribute _geometricType to geometricType */
361 //---------------------------------------------------------------------
362 inline void SUPPORT::setGeometricType(const MED_EN::medGeometryElement *GeometricType)
363 //---------------------------------------------------------------------
365 if (NULL == _geometricType)
366 _geometricType=new MED_EN::medGeometryElement[_numberOfGeometricType];
367 for (int i=0;i<_numberOfGeometricType;i++)
368 _geometricType[i] = GeometricType[i];
371 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
372 //-----------------------------------------------------------------
373 inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
374 //-----------------------------------------------------------------
376 if (NULL == _numberOfGaussPoint)
377 _numberOfGaussPoint=new int[_numberOfGeometricType];
378 for (int i=0;i<_numberOfGeometricType;i++)
379 _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
383 Set the attribute _numberOfElements to NumberOfElements and
384 calculate the total number of elements.
386 //----------------------------------------------------------
387 inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
388 //----------------------------------------------------------
390 if (NULL == _numberOfElements)
391 _numberOfElements=new int[_numberOfGeometricType];
392 memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
393 _totalNumberOfElements = 0 ;
394 for (int i=0;i<_numberOfGeometricType;i++)
395 _totalNumberOfElements+=_numberOfElements[i];
398 /*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
399 //--------------------------------------------------------------------
400 inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
401 //--------------------------------------------------------------------
403 _totalNumberOfElements=TotalNumberOfElements;
406 /*! set the attribute _number to Number */
407 //---------------------------------------------------
408 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
409 //---------------------------------------------------
411 if (_number != NULL) delete _number ;
415 /*! set the attribute _number with index and value arrays */
416 //---------------------------------------------------
417 inline void SUPPORT::setNumber(const int * index, const int* value, bool shallowCopy)
418 //---------------------------------------------------
420 if (_number != NULL) delete _number ;
421 _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy);
424 /*! returns the name of the support. */
425 //------------------------------------
426 inline string SUPPORT::getName() const
427 //------------------------------------
433 /*! returns the description of the support. */
434 //--------------------------------------------
435 inline string SUPPORT::getDescription() const
436 //--------------------------------------------
441 /*! returns a reference to the mesh */
442 //------------------------------------
443 inline MESH * SUPPORT::getMesh() const
444 //------------------------------------
450 Returns true if all elements of this entity are
451 concerned, false otherwise.
452 If true, you must use mesh reference (getMesh) to get more information.
454 //------------------------------------------
455 inline bool SUPPORT::isOnAllElements() const
456 //------------------------------------------
462 Returns number of geometric Types
463 defines in the support
465 //------------------------------------------
466 inline int SUPPORT::getNumberOfTypes() const
467 //------------------------------------------
469 // if ((_isOnAllElts)&(_entity != MED_NODE))
470 // return _mesh->getNumberOfTypes(_entity) ;
472 return _numberOfGeometricType ;
476 Returns the %medEntityMesh's type used by the support.
477 Note : A support deals only with one entity's type
478 (for example : MED_FACE or MED_NODE)
480 //---------------------------------------------
481 inline MED_EN::medEntityMesh SUPPORT::getEntity() const
482 //---------------------------------------------
488 If isOnAllElements is false, returns an array of %medGeometryElement
489 types used by the support.
491 //---------------------------------------------------
492 inline const MED_EN::medGeometryElement * SUPPORT::getTypes() const
493 //---------------------------------------------------
495 return _geometricType;
498 }//End namespace MEDMEM
501 #endif /* SUPPORT_HXX */