12 #include "utilities.h"
13 #include "MEDMEM_Exception.hxx"
14 #include "MEDMEM_define.hxx"
16 #include "MEDMEM_SkyLineArray.hxx"
17 #include "MEDMEM_Mesh.hxx"
19 using namespace MED_EN;
26 /*! name of the support */
28 /*! description of the support (optionnal) */
30 /*! reference to the mesh on which the support is defined */
32 /*! type of entity on which the support is defined
33 (only one for each support) */
34 medEntityMesh _entity ;
35 /*! number of geometric type defined in the support */
36 int _numberOfGeometricType;
37 /*! array of all geometric type defined in the support */
38 medGeometryElement * _geometricType;
39 /*! array of size _numberOfGeometricType which contains
40 for each type the number of gauss point
41 (not yet implemented) */
42 int * _numberOfGaussPoint ;
43 /*! array of size _numberOfGeometricType
44 which contains number of geometric
46 (to get corresponding CellModel)*/
47 int * _geometricTypeNumber;
48 /*! If true, we consider all entities of type _entity */
50 /*! array of size _numberOfGeometricType wich contains
51 for each geometric type, count of entities.
52 (if _isOnAllElts is true, we could get same
53 information from _mesh) */
54 int * _numberOfEntities;
55 /*! sum of each _numberOfEntities component (if
56 _isOnAllElts is true, we could get same
57 information from _mesh) */
58 int _totalNumberOfEntities;
60 // the two following arrays are defined only if _isOnAllElts is false :
62 /* array of size _numberOfType+1 wich contains for
63 each geometric type, index in _number._value
64 (if _all is true, we must ask _mesh to get
65 information). _typeIndex[i+1]-_typeIndex[i]
66 represents count of entities of ith geometric
67 type. _typeIndex[_numberOfType] contains total
68 entities count. If _numberOf[i]=0,
69 _typeIndex[i+1]=_typeIndex[i]
70 defined only if _isOnAllElts is false*/
72 /*! array of size _index[_numberOfType] wich contain number of
73 entities of each geometric type. We use global numbering.
74 defined only if _isOnAllElts is false*/
75 MEDSKYLINEARRAY * _number;
79 SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
82 friend ostream & operator<<(ostream &os,const SUPPORT &my);
84 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
87 inline void setName(string Name);
88 inline void setDescription(string Description);
89 inline void setMesh(MESH *Mesh);
90 inline void setAll(bool All);
91 inline void setEntity(medEntityMesh Entity);
92 inline void setNumberOfGeometricType(int NumberOfGeometricType);
93 inline void setGeometricType(medGeometryElement *GeometricType);
94 inline void setNumberOfGaussPoint(int *NumberOfGaussPoint);
95 // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
96 inline void setNumberOfEntities(int *NumberOfEntities);
97 inline void setTotalNumberOfEntities(int TotalNumberOfEntities);
98 inline void setNumber(MEDSKYLINEARRAY * Number);
100 inline string getName() const;
101 inline string getDescription() const;
102 inline MESH * getMesh() const;
103 inline medEntityMesh getEntity() const;
105 inline bool isOnAllElements() const;
106 inline int getNumberOfTypes() const;
107 inline medGeometryElement* getTypes() const ;
108 inline int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
109 inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
110 //inline int * getGeometricTypeNumber() const;
111 // inline int getNumberOfTotalEntity() const;
112 inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
113 inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
114 inline int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
115 inline int * getNumberIndex() const throw (MEDEXCEPTION);
117 void blending(SUPPORT * mySupport);
120 This function allows the user to set a support not on all entities Entity,
121 it should be used after an initialisation with the constructor
122 SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
123 after the call to the function setAll(false).
124 It allocates and initialises all the attributs of the class SUPPORT.
127 void setpartial(string Description, int NumberOfGeometricType,
128 int TotalNumberOfEntity, medGeometryElement *GeometricType,
129 int *NumberOfEntity, int *NumberValue);
131 // _____________________
133 // _____________________
135 /*! If isOnAllElements is false, returns number of elements in the
136 support else returns number of nodes.
138 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
139 in entity of support.
141 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
142 medGeometryElement type. */
143 //-----------------------------------------------------------------------------
144 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
146 //-----------------------------------------------------------------------------
149 return _mesh->getNumberOfElements(_entity,GeometricType);
151 if (GeometricType==MED_ALL_ELEMENTS)
152 return _totalNumberOfEntities;
153 for (int i=0;i<_numberOfGeometricType;i++)
154 if (_geometricType[i]==GeometricType)
155 return _numberOfEntities[i] ;
156 throw MEDEXCEPTION("Support::getNumberOfElements : Type not found !") ;
159 // inline int SUPPORT::getNumberOf(medGeometryElement GeometricType) const
160 // throw (MEDEXCEPTION)
162 // if (GeometricType==MED_ALL_ELEMENTS)
163 // return _totalNumberOfEntities ;
164 // for (int i=0;i<_numberOfGeometricType;i++)
165 // if (_geometricType[i]==GeometricType)
166 // return _numberOfEntities[i] ;
167 // throw MEDEXCEPTION("Support::getNumberOf: GeometricType not found !");
170 // inline int SUPPORT::getNumberOfTotalEntity() const
172 // return _totalNumberOfEntities ;
175 //---------------------------------------------------------------------
176 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
178 //---------------------------------------------------------------------
181 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
185 /*! If isOnAllElements is false, returns an array which contains
186 all number of given medGeometryElement.
188 Numbering is global, ie numbers are bounded by 1 and
189 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
190 MESH::getNumberOfElement(entity,geomElement).
192 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
193 medGeometryElement type. */
194 //---------------------------------------------------------------------
195 inline int * SUPPORT::getNumber(medGeometryElement GeometricType) const
197 //---------------------------------------------------------------------
199 const char * LOC = "Support::getNumber : " ;
201 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
202 if (GeometricType==MED_ALL_ELEMENTS)
203 return _number->getValue() ;
204 for (int i=0;i<_numberOfGeometricType;i++)
205 if (_geometricType[i]==GeometricType)
206 return _number->getI(i+1) ;
207 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
210 /*! If isOnAllElements is false, returns index of element number.
211 Use it with getNumber(MED_ALL_ELEMENTS).
213 Note : See getConnectivityIndex for details. */
214 //-------------------------------------------
215 inline int * SUPPORT::getNumberIndex() const
216 //-------------------------------------------
220 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
221 return _number->getIndex() ;
225 //-------------------------------------------------
226 inline int * SUPPORT::getNumberOfGaussPoint() const
228 //-------------------------------------------------
230 if (_numberOfGaussPoint!=NULL)
231 return _numberOfGaussPoint ;
233 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
236 /*! Returns number of Gauss points for this medGeometryElement.
239 - Not defined if SUPPORT is on MED_NODE.
240 - Not defined for MED_ALL_ELEMENTS medGeometryElement type. */
241 //-----------------------------------------------------------------------------
242 inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
244 //-----------------------------------------------------------------------------
246 if (_numberOfGaussPoint!=NULL) {
247 for (int i=0;i<_numberOfGeometricType;i++)
248 if (_geometricType[i]==geomElement)
249 return _numberOfGaussPoint[i] ;
250 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
252 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
254 // inline int SUPPORT::getNumberLength() const
255 // throw (MEDEXCEPTION)
258 // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
259 // return _number->getLength() ;
262 /*! set the attribute _name to Name */
263 //--------------------------------------
264 inline void SUPPORT::setName(string Name)
265 //--------------------------------------
270 /*! set the attribute _description to Description */
271 //--------------------------------------------------
272 inline void SUPPORT::setDescription(string Description)
273 //--------------------------------------------------
275 _description=Description;
278 /*! set the reference _mesh to Mesh */
279 //--------------------------------------
280 inline void SUPPORT::setMesh(MESH *Mesh)
281 //--------------------------------------
286 /*! set the attribute _isOnAllElts to All */
287 //------------------------------------------
288 inline void SUPPORT::setAll(bool All)
289 //------------------------------------------
294 /*! set the attribute _entity to Entity */
295 //------------------------------------------
296 inline void SUPPORT::setEntity(medEntityMesh Entity)
299 if ( Entity == MED_NODE) {
300 _numberOfGeometricType=1 ;
301 _geometricType=new medGeometryElement[1] ; // delete previous ???
302 _geometricType[0]=MED_NONE ;
306 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
307 //---------------------------------------------------------------------
308 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
309 //---------------------------------------------------------------------
311 _numberOfGeometricType=NumberOfGeometricType;
314 /*! set the attribute _geometricType to geometricType */
315 //---------------------------------------------------------------------
316 inline void SUPPORT::setGeometricType(medGeometryElement *GeometricType)
317 //---------------------------------------------------------------------
319 _geometricType=GeometricType;
322 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
323 //-----------------------------------------------------------------
324 inline void SUPPORT::setNumberOfGaussPoint(int *NumberOfGaussPoint)
325 //-----------------------------------------------------------------
327 _numberOfGaussPoint = NumberOfGaussPoint ;
330 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
331 //-------------------------------------------------------------------
332 //inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
333 //-------------------------------------------------------------------
335 // _geometricTypeNumber=GeometricTypeNumber;
338 /*! set the attribute _numberOfEntities to NumberOfEntities */
339 //----------------------------------------------------------
340 inline void SUPPORT::setNumberOfEntities(int *NumberOfEntities)
341 //----------------------------------------------------------
343 _numberOfEntities=NumberOfEntities;
346 /*! set the attribute _totalNumberOfEntities to TotalNumberOfEntities */
347 //--------------------------------------------------------------------
348 inline void SUPPORT::setTotalNumberOfEntities(int TotalNumberOfEntities)
349 //--------------------------------------------------------------------
351 _totalNumberOfEntities=TotalNumberOfEntities;
354 /*! set the attribute _number to Number */
355 //---------------------------------------------------
356 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
357 //---------------------------------------------------
362 /*! returns the name of the support. */
363 //------------------------------------
364 inline string SUPPORT::getName() const
365 //------------------------------------
371 /*! returns the description of the support. */
372 //--------------------------------------------
373 inline string SUPPORT::getDescription() const
374 //--------------------------------------------
379 /*! returns a refernce to the mesh */
380 //------------------------------------
381 inline MESH * SUPPORT::getMesh() const
382 //------------------------------------
387 /*! Returns true if all elements of this entity are
388 concerned, false otherwise.
389 If true, you must use mesh reference (getMesh) to get more information.*/
390 //------------------------------------------
391 inline bool SUPPORT::isOnAllElements() const
392 //------------------------------------------
397 /*! Returns number of geometric Types
398 defines in the support */
399 //------------------------------------------
400 inline int SUPPORT::getNumberOfTypes() const
401 //------------------------------------------
403 if ((_isOnAllElts)&(_entity != MED_NODE))
404 return _mesh->getNumberOfTypes(_entity) ;
406 return _numberOfGeometricType ;
409 /*! Returns the medEntityMesh's type used by the support.
410 Note : A support deals only with one entity's type
411 (for example : MED_FACE or MED_NODE)*/
412 //---------------------------------------------
413 inline medEntityMesh SUPPORT::getEntity() const
414 //---------------------------------------------
419 /*! If isOnAllElements is false, returns an array of <medGeometryElement>
420 types used by the support.
422 <medEntityMesh> is given by getEntity. */
423 //---------------------------------------------------
424 inline medGeometryElement * SUPPORT::getTypes() const
425 //---------------------------------------------------
427 if ((_isOnAllElts)&(_entity != MED_NODE))
428 return _mesh->getTypes(_entity) ;
430 return _geometricType;
433 //---------------------------------------------------
434 //inline int * SUPPORT::getGeometricTypeNumber() const
435 //---------------------------------------------------
437 // const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
439 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
440 // if (_geometricTypeNumber==NULL)
441 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
442 // return _geometricTypeNumber;
446 #endif /* SUPPORT_HXX */