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);
81 friend ostream & operator<<(ostream &os,const SUPPORT &my);
83 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
86 inline void setName(string Name);
87 inline void setDescription(string Description);
88 inline void setMesh(MESH *Mesh);
89 inline void setAll(bool All);
90 inline void setEntity(medEntityMesh Entity);
91 inline void setNumberOfGeometricType(int NumberOfGeometricType);
92 inline void setGeometricType(medGeometryElement *GeometricType);
93 inline void setNumberOfGaussPoint(int *NumberOfGaussPoint);
94 inline void setGeometricTypeNumber(int *GeometricTypeNumber);
95 inline void setNumberOfEntities(int *NumberOfEntities);
96 inline void setTotalNumberOfEntities(int TotalNumberOfEntities);
97 inline void setNumber(MEDSKYLINEARRAY * Number);
99 inline string getName() const;
100 inline string getDescription() const;
101 inline MESH * getMesh() const;
102 inline medEntityMesh getEntity() const;
104 inline bool isOnAllElements() const;
105 inline int getNumberOfTypes() const;
106 inline medGeometryElement* getTypes() const ;
107 inline int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
108 inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
109 inline int * getGeometricTypeNumber() const;
110 // inline int getNumberOfTotalEntity() const;
111 inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
112 inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
113 inline int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
114 inline int * getNumberIndex() const throw (MEDEXCEPTION);
116 void blending(SUPPORT * mySupport);
119 This function allows the user to set a support not on all entities Entity,
120 it should be used after an initialisation with the constructor
121 SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL) and
122 after the call to the function setAll(false).
123 It allocates and initialises all the attributs of the class SUPPORT.
126 void setpartial(string Description, int NumberOfGeometricType,
127 int TotalNumberOfEntity, medGeometryElement *GeometricType,
128 int *NumberOfEntity, int *NumberValue);
130 // _____________________
132 // _____________________
134 /*! If isOnAllElements is false, returns number of elements in the
135 support else returns number of nodes.
137 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
138 in entity of support.
140 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
141 medGeometryElement type. */
142 //-----------------------------------------------------------------------------
143 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
145 //-----------------------------------------------------------------------------
148 return _mesh->getNumberOfElements(_entity,GeometricType);
150 if (GeometricType==MED_ALL_ELEMENTS)
151 return _totalNumberOfEntities;
152 for (int i=0;i<_numberOfGeometricType;i++)
153 if (_geometricType[i]==GeometricType)
154 return _numberOfEntities[i] ;
155 throw MEDEXCEPTION("Support::getNumberOfElements : Type not found !") ;
158 // inline int SUPPORT::getNumberOf(medGeometryElement GeometricType) const
159 // throw (MEDEXCEPTION)
161 // if (GeometricType==MED_ALL_ELEMENTS)
162 // return _totalNumberOfEntities ;
163 // for (int i=0;i<_numberOfGeometricType;i++)
164 // if (_geometricType[i]==GeometricType)
165 // return _numberOfEntities[i] ;
166 // throw MEDEXCEPTION("Support::getNumberOf: GeometricType not found !");
169 // inline int SUPPORT::getNumberOfTotalEntity() const
171 // return _totalNumberOfEntities ;
174 //---------------------------------------------------------------------
175 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
177 //---------------------------------------------------------------------
180 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
184 /*! If isOnAllElements is false, returns an array which contains
185 all number of given medGeometryElement.
187 Numbering is global, ie numbers are bounded by 1 and
188 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
189 MESH::getNumberOfElement(entity,geomElement).
191 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
192 medGeometryElement type. */
193 //---------------------------------------------------------------------
194 inline int * SUPPORT::getNumber(medGeometryElement GeometricType) const
196 //---------------------------------------------------------------------
198 const char * LOC = "Support::getNumber : " ;
200 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
201 if (GeometricType==MED_ALL_ELEMENTS)
202 return _number->getValue() ;
203 for (int i=0;i<_numberOfGeometricType;i++)
204 if (_geometricType[i]==GeometricType)
205 return _number->getI(i+1) ;
206 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
209 /*! If isOnAllElements is false, returns index of element number.
210 Use it with getNumber(MED_ALL_ELEMENTS).
212 Note : See getConnectivityIndex for details. */
213 //-------------------------------------------
214 inline int * SUPPORT::getNumberIndex() const
215 //-------------------------------------------
219 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
220 return _number->getIndex() ;
224 //-------------------------------------------------
225 inline int * SUPPORT::getNumberOfGaussPoint() const
227 //-------------------------------------------------
229 if (_numberOfGaussPoint!=NULL)
230 return _numberOfGaussPoint ;
232 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
235 /*! Returns number of Gauss points for this medGeometryElement.
238 - Not defined if SUPPORT is on MED_NODE.
239 - Not defined for MED_ALL_ELEMENTS medGeometryElement type. */
240 //-----------------------------------------------------------------------------
241 inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
243 //-----------------------------------------------------------------------------
245 if (_numberOfGaussPoint!=NULL) {
246 for (int i=0;i<_numberOfGeometricType;i++)
247 if (_geometricType[i]==geomElement)
248 return _numberOfGaussPoint[i] ;
249 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
251 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
253 // inline int SUPPORT::getNumberLength() const
254 // throw (MEDEXCEPTION)
257 // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
258 // return _number->getLength() ;
261 /*! set the attribute _name to Name */
262 //--------------------------------------
263 inline void SUPPORT::setName(string Name)
264 //--------------------------------------
269 /*! set the attribute _description to Description */
270 //--------------------------------------------------
271 inline void SUPPORT::setDescription(string Description)
272 //--------------------------------------------------
274 _description=Description;
277 /*! set the reference _mesh to Mesh */
278 //--------------------------------------
279 inline void SUPPORT::setMesh(MESH *Mesh)
280 //--------------------------------------
285 /*! set the attribute _isOnAllElts to All */
286 //------------------------------------------
287 inline void SUPPORT::setAll(bool All)
288 //------------------------------------------
293 /*! set the attribute _entity to Entity */
294 //------------------------------------------
295 inline void SUPPORT::setEntity(medEntityMesh Entity)
298 if ( Entity == MED_NODE) {
299 _numberOfGeometricType=1 ;
300 _geometricType=new medGeometryElement[1] ; // delete previous ???
301 _geometricType[0]=MED_NONE ;
305 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
306 //---------------------------------------------------------------------
307 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
308 //---------------------------------------------------------------------
310 _numberOfGeometricType=NumberOfGeometricType;
313 /*! set the attribute _geometricType to geometricType */
314 //---------------------------------------------------------------------
315 inline void SUPPORT::setGeometricType(medGeometryElement *GeometricType)
316 //---------------------------------------------------------------------
318 _geometricType=GeometricType;
321 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
322 //-----------------------------------------------------------------
323 inline void SUPPORT::setNumberOfGaussPoint(int *NumberOfGaussPoint)
324 //-----------------------------------------------------------------
326 _numberOfGaussPoint = NumberOfGaussPoint ;
329 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
330 //-------------------------------------------------------------------
331 inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
332 //-------------------------------------------------------------------
334 _geometricTypeNumber=GeometricTypeNumber;
337 /*! set the attribute _numberOfEntities to NumberOfEntities */
338 //----------------------------------------------------------
339 inline void SUPPORT::setNumberOfEntities(int *NumberOfEntities)
340 //----------------------------------------------------------
342 _numberOfEntities=NumberOfEntities;
345 /*! set the attribute _totalNumberOfEntities to TotalNumberOfEntities */
346 //--------------------------------------------------------------------
347 inline void SUPPORT::setTotalNumberOfEntities(int TotalNumberOfEntities)
348 //--------------------------------------------------------------------
350 _totalNumberOfEntities=TotalNumberOfEntities;
353 /*! set the attribute _number to Number */
354 //---------------------------------------------------
355 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
356 //---------------------------------------------------
361 /*! returns the name of the support. */
362 //------------------------------------
363 inline string SUPPORT::getName() const
364 //------------------------------------
370 /*! returns the description of the support. */
371 //--------------------------------------------
372 inline string SUPPORT::getDescription() const
373 //--------------------------------------------
378 /*! returns a refernce to the mesh */
379 //------------------------------------
380 inline MESH * SUPPORT::getMesh() const
381 //------------------------------------
386 /*! Returns true if all elements of this entity are
387 concerned, false otherwise.
388 If true, you must use mesh reference (getMesh) to get more information.*/
389 //------------------------------------------
390 inline bool SUPPORT::isOnAllElements() const
391 //------------------------------------------
396 /*! Returns number of geometric Types
397 defines in the support */
398 //------------------------------------------
399 inline int SUPPORT::getNumberOfTypes() const
400 //------------------------------------------
402 if ((_isOnAllElts)&(_entity != MED_NODE))
403 return _mesh->getNumberOfTypes(_entity) ;
405 return _numberOfGeometricType ;
408 /*! Returns the medEntityMesh's type used by the support.
409 Note : A support deals only with one entity's type
410 (for example : MED_FACE or MED_NODE)*/
411 //---------------------------------------------
412 inline medEntityMesh SUPPORT::getEntity() const
413 //---------------------------------------------
418 /*! If isOnAllElements is false, returns an array of <medGeometryElement>
419 types used by the support.
421 <medEntityMesh> is given by getEntity. */
422 //---------------------------------------------------
423 inline medGeometryElement * SUPPORT::getTypes() const
424 //---------------------------------------------------
426 if ((_isOnAllElts)&(_entity != MED_NODE))
427 return _mesh->getTypes(_entity) ;
429 return _geometricType;
432 //---------------------------------------------------
433 inline int * SUPPORT::getGeometricTypeNumber() const
434 //---------------------------------------------------
436 const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
438 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
439 if (_geometricTypeNumber==NULL)
440 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
441 return _geometricTypeNumber;
445 #endif /* SUPPORT_HXX */