1 // MED MEDMEM : MED files in memory
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : MEDMEM_Support.hxx
38 #include "utilities.h"
39 #include "MEDMEM_STRING.hxx"
40 #include "MEDMEM_Exception.hxx"
41 #include "MEDMEM_define.hxx"
43 #include "MEDMEM_SkyLineArray.hxx"
44 //#include "MEDMEM_Mesh.hxx"
46 using namespace MED_EN;
52 This class describe a support of elements on an entity of the mesh.
54 It contains the list of meshes elements for an entity (MED_NODE,
55 MED_CELL, MED_FACE or MED_EDGE).
71 Description of the support (optional).
78 Reference to the mesh on which the support is defined.
85 Type of entity on which the support is defined
86 (only one for each support).
89 medEntityMesh _entity ;
93 Number of geometric type defined in the support.
96 int _numberOfGeometricType;
100 Array of all geometric type defined in the support.
103 medGeometryElement * _geometricType;
107 Array of size _numberOfGeometricType which contains
108 for each type the number of gauss point
109 (not yet implemented).
112 int * _numberOfGaussPoint ;
116 Array of size _numberOfGeometricType
117 which contains number of geometric
119 (to get corresponding CellModel).
122 //int * _geometricTypeNumber;
126 If true, we consider all entities of type _entity.
133 Index array of size _numberOfGeometricType wich contains
134 for each geometric type, the number of elements of this type.
137 int * _numberOfElements;
141 Sum of each _numberOfElements component.
144 int _totalNumberOfElements;
146 // the two following arrays are defined only if _isOnAllElts is false :
150 array of size _numberOfType+1 wich contains for
151 each geometric type, index in _number._value
152 (if _all is true, we must ask _mesh to get
153 information). _typeIndex[i+1]-_typeIndex[i]
154 represents count of entities of ith geometric
155 type. _typeIndex[_numberOfType] contains total
156 entities count. If _numberOf[i]=0,
157 _typeIndex[i+1]=_typeIndex[i]
158 defined only if _isOnAllElts is false
165 Array of size _index[_numberOfType]-1 wich contain number of
166 entities of each geometric type. We use global numbering.\n
167 Defined only if _isOnAllElts is false.
170 MEDSKYLINEARRAY * _number;
174 SUPPORT(MESH* Mesh, string Name="", medEntityMesh Entity=MED_CELL);
175 SUPPORT(const SUPPORT & m);
177 friend ostream & operator<<(ostream &os,const SUPPORT &my);
179 // function to set all value when SUPPORT was created by MedMedDriver without all MESH information !!! Change with new API !
182 inline void setName(string Name);
183 inline void setDescription(string Description);
184 inline void setMesh(MESH *Mesh);
185 inline void setAll(bool All);
186 inline void setEntity(medEntityMesh Entity);
187 inline void setNumberOfGeometricType(int NumberOfGeometricType);
188 inline void setGeometricType(const medGeometryElement *GeometricType);
189 inline void setNumberOfGaussPoint(const int *NumberOfGaussPoint);
190 // inline void setGeometricTypeNumber(int *GeometricTypeNumber);
191 inline void setNumberOfElements(const int *NumberOfElements);
192 inline void setTotalNumberOfElements(int TotalNumberOfElements);
193 inline void setNumber(MEDSKYLINEARRAY * Number);
194 inline void setNumber(const int * index, const int* value);
196 inline string getName() const;
197 inline string getDescription() const;
198 inline MESH * getMesh() const;
199 inline medEntityMesh getEntity() const;
201 inline bool isOnAllElements() const;
202 inline int getNumberOfTypes() const;
203 inline const medGeometryElement* getTypes() const ;
204 inline const int * getNumberOfGaussPoint() const throw (MEDEXCEPTION);
205 inline int getNumberOfGaussPoint(medGeometryElement geomElement) const throw (MEDEXCEPTION);
206 //inline int * getGeometricTypeNumber() const;
207 //inline int getTotalNumberOfElement() const;
208 inline int getNumberOfElements(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
209 inline MEDSKYLINEARRAY * getnumber() const throw (MEDEXCEPTION);
210 inline const int * getNumber(medGeometryElement GeometricType) const throw (MEDEXCEPTION);
211 inline const int * getNumberIndex() const throw (MEDEXCEPTION);
213 void blending(SUPPORT * mySupport);
215 void setpartial(string Description, int NumberOfGeometricType,
216 int TotalNumberOfEntity, medGeometryElement *GeometricType,
217 int *NumberOfEntity, int *NumberValue);
219 void getBoundaryElements() throw (MEDEXCEPTION);
221 // _____________________
223 // _____________________
226 If isOnAllElements is false, returns number of elements in the
227 support else returns number of nodes.
229 Example : number of MED_TRIA3 or MED_ALL_ELEMENTS elements
230 in entity of support.
232 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
233 medGeometryElement type.
235 //-----------------------------------------------------------------------------
236 inline int SUPPORT::getNumberOfElements(medGeometryElement GeometricType) const
238 //-----------------------------------------------------------------------------
240 if (GeometricType==MED_ALL_ELEMENTS)
241 return _totalNumberOfElements;
242 for (int i=0;i<_numberOfGeometricType;i++)
243 if (_geometricType[i]==GeometricType)
244 return _numberOfElements[i];
245 throw MEDEXCEPTION("Support::getNumberOfElements : Geometric type not found !") ;
248 //---------------------------------------------------------------------
249 inline MEDSKYLINEARRAY * SUPPORT::getnumber() const
251 //---------------------------------------------------------------------
254 throw MEDEXCEPTION("Support::getnumber : Not defined !") ;
259 If isOnAllElements is false, returns an array which contains
260 all number of given medGeometryElement.
262 Numbering is global, ie numbers are bounded by 1 and
263 MESH::getNumberOfElement(entity,MED_ALL_ELEMENTS) and not by 1 and
264 MESH::getNumberOfElement(entity,geomElement).
266 Note : If SUPPORT is defined on MED_NODE, use MED_NONE
267 medGeometryElement type.
269 //---------------------------------------------------------------------
270 inline const int * SUPPORT::getNumber(medGeometryElement GeometricType) const
272 //---------------------------------------------------------------------
274 const char * LOC = "Support::getNumber : " ;
276 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined, support is on all entity !")) ;
277 if (GeometricType==MED_ALL_ELEMENTS)
278 return _number->getValue() ;
279 for (int i=0;i<_numberOfGeometricType;i++)
280 if (_geometricType[i]==GeometricType)
281 return _number->getI(i+1) ;
282 throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"GeometricType not found !")) ;
286 If isOnAllElements is false, returns index of element number.
287 Use it with getNumber(MED_ALL_ELEMENTS).
289 Note : See getConnectivityIndex for details.
291 //-------------------------------------------
292 inline const int * SUPPORT::getNumberIndex() const
293 //-------------------------------------------
297 throw MEDEXCEPTION("Support::getNumberIndex : Not defined, support is on all entity !") ;
298 return _number->getIndex() ;
302 //-------------------------------------------------
303 inline const int * SUPPORT::getNumberOfGaussPoint() const
305 //-------------------------------------------------
307 if (_numberOfGaussPoint!=NULL)
308 return _numberOfGaussPoint ;
310 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
314 Returns number of Gauss points for this medGeometryElement.
317 - Not defined if SUPPORT is on MED_NODE.
318 - Not defined for MED_ALL_ELEMENTS medGeometryElement type.
320 //-----------------------------------------------------------------------------
321 inline int SUPPORT::getNumberOfGaussPoint(medGeometryElement geomElement) const
323 //-----------------------------------------------------------------------------
325 if (_numberOfGaussPoint!=NULL) {
326 for (int i=0;i<_numberOfGeometricType;i++)
327 if (_geometricType[i]==geomElement)
328 return _numberOfGaussPoint[i] ;
329 throw MEDEXCEPTION("Support::getGlobalNumber : GeometricType not found !") ;
331 throw MEDEXCEPTION("Support::getNumberOfGaussPoint : Not defined !") ;
333 // inline int SUPPORT::getNumberLength() const
334 // throw (MEDEXCEPTION)
337 // throw MEDEXCEPTION("Support::getNumberLength : Not defined, support is on all entity !") ;
338 // return _number->getLength() ;
341 /*! set the attribute _name to Name */
342 //--------------------------------------
343 inline void SUPPORT::setName(string Name)
344 //--------------------------------------
349 /*! set the attribute _description to Description */
350 //--------------------------------------------------
351 inline void SUPPORT::setDescription(string Description)
352 //--------------------------------------------------
354 _description=Description;
357 /*! set the reference _mesh to Mesh */
358 //--------------------------------------
359 inline void SUPPORT::setMesh(MESH *Mesh)
360 //--------------------------------------
365 /*! set the attribute _isOnAllElts to All */
366 //------------------------------------------
367 inline void SUPPORT::setAll(bool All)
368 //------------------------------------------
373 /*! set the attribute _entity to Entity */
374 //------------------------------------------
375 inline void SUPPORT::setEntity(medEntityMesh Entity)
378 // if ( Entity == MED_NODE) {
379 // _numberOfGeometricType=1 ;
380 // if (_geometricType == (medGeometryElement *) NULL)
381 // _geometricType=new medGeometryElement[1] ;
384 // // delete previous ???
385 // delete [] _geometricType;
386 // _geometricType=new medGeometryElement[1] ;
388 // _geometricType[0]=MED_NONE ;
392 /*! set the attribute _numberOfGeometricType to NumberOfGeometricType */
393 //---------------------------------------------------------------------
394 inline void SUPPORT::setNumberOfGeometricType(int NumberOfGeometricType)
395 //---------------------------------------------------------------------
397 _numberOfGeometricType=NumberOfGeometricType;
398 if (_geometricType!=NULL) {
399 delete[] _geometricType ;
400 _geometricType = NULL ;
402 if (_numberOfElements!=NULL) {
403 delete[] _numberOfElements ;
404 _numberOfElements = NULL ;
406 if (_numberOfGaussPoint!=NULL) {
407 delete[] _numberOfGaussPoint ;
408 _numberOfGaussPoint = NULL ;
412 /*! set the attribute _geometricType to geometricType */
413 //---------------------------------------------------------------------
414 inline void SUPPORT::setGeometricType(const medGeometryElement *GeometricType)
415 //---------------------------------------------------------------------
417 if (NULL == _geometricType)
418 _geometricType=new medGeometryElement[_numberOfGeometricType];
419 for (int i=0;i<_numberOfGeometricType;i++)
420 _geometricType[i] = GeometricType[i];
421 // _geometricType=GeometricType;
424 /*! set the attribute _numberOfGaussPoint to NumberOfGaussPoint */
425 //-----------------------------------------------------------------
426 inline void SUPPORT::setNumberOfGaussPoint(const int *NumberOfGaussPoint)
427 //-----------------------------------------------------------------
429 if (NULL == _numberOfGaussPoint)
430 _numberOfGaussPoint=new int[_numberOfGeometricType];
431 for (int i=0;i<_numberOfGeometricType;i++)
432 _numberOfGaussPoint[i] = NumberOfGaussPoint[i];
433 // _numberOfGaussPoint = NumberOfGaussPoint ;
436 /*! set the attribute _geometricTypeNumber to GeometricTypeNumber */
437 //-------------------------------------------------------------------
438 //inline void SUPPORT::setGeometricTypeNumber(int *GeometricTypeNumber)
439 //-------------------------------------------------------------------
441 // _geometricTypeNumber=GeometricTypeNumber;
445 Set the attribute _numberOfElements to NumberOfElements and
446 calculate the total number of elements.
448 //----------------------------------------------------------
449 inline void SUPPORT::setNumberOfElements(const int *NumberOfElements)
450 //----------------------------------------------------------
452 if (NULL == _numberOfElements)
453 _numberOfElements=new int[_numberOfGeometricType];
454 memcpy(_numberOfElements,NumberOfElements,sizeof(int)*_numberOfGeometricType);
455 _totalNumberOfElements = 0 ;
456 for (int i=0;i<_numberOfGeometricType;i++)
457 _totalNumberOfElements+=_numberOfElements[i];
460 /*! set the attribute _totalNumberOfElements to TotalNumberOfElements */
461 //--------------------------------------------------------------------
462 inline void SUPPORT::setTotalNumberOfElements(int TotalNumberOfElements)
463 //--------------------------------------------------------------------
465 _totalNumberOfElements=TotalNumberOfElements;
468 /*! set the attribute _number to Number */
469 //---------------------------------------------------
470 inline void SUPPORT::setNumber(MEDSKYLINEARRAY * Number)
471 //---------------------------------------------------
473 if (_number != NULL) delete _number ;
477 /*! set the attribute _number with index and value arrays */
478 //---------------------------------------------------
479 inline void SUPPORT::setNumber(const int * index, const int* value)
480 //---------------------------------------------------
482 if (_number != NULL) delete _number ;
483 _number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value);
486 /*! returns the name of the support. */
487 //------------------------------------
488 inline string SUPPORT::getName() const
489 //------------------------------------
495 /*! returns the description of the support. */
496 //--------------------------------------------
497 inline string SUPPORT::getDescription() const
498 //--------------------------------------------
503 /*! returns a reference to the mesh */
504 //------------------------------------
505 inline MESH * SUPPORT::getMesh() const
506 //------------------------------------
512 Returns true if all elements of this entity are
513 concerned, false otherwise.
514 If true, you must use mesh reference (getMesh) to get more information.
516 //------------------------------------------
517 inline bool SUPPORT::isOnAllElements() const
518 //------------------------------------------
524 Returns number of geometric Types
525 defines in the support
527 //------------------------------------------
528 inline int SUPPORT::getNumberOfTypes() const
529 //------------------------------------------
531 // if ((_isOnAllElts)&(_entity != MED_NODE))
532 // return _mesh->getNumberOfTypes(_entity) ;
534 return _numberOfGeometricType ;
538 Returns the medEntityMesh's type used by the support.
539 Note : A support deals only with one entity's type
540 (for example : MED_FACE or MED_NODE)
542 //---------------------------------------------
543 inline medEntityMesh SUPPORT::getEntity() const
544 //---------------------------------------------
550 If isOnAllElements is false, returns an array of <medGeometryElement>
551 types used by the support.
553 <medEntityMesh> is given by getEntity.
555 //---------------------------------------------------
556 inline const medGeometryElement * SUPPORT::getTypes() const
557 //---------------------------------------------------
559 // if ((_isOnAllElts)&(_entity != MED_NODE))
560 // return _mesh->getTypes(_entity) ;
562 return _geometricType;
565 //---------------------------------------------------
566 //inline int * SUPPORT::getGeometricTypeNumber() const
567 //---------------------------------------------------
569 // const char * LOC = "SUPPORT::getGeometricTypeNumber() : ";
571 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined (is on all elements) !"));
572 // if (_geometricTypeNumber==NULL)
573 // throw MEDEXCEPTION(LOCALIZED(STRING(LOC)<<"Not defined !"));
574 // return _geometricTypeNumber;
578 #endif /* SUPPORT_HXX */