1 #ifndef CONNECTIVITY_HXX
2 #define CONNECTIVITY_HXX
7 #include "MEDMEM_Exception.hxx"
8 #include "MEDMEM_define.hxx"
10 using namespace MED_EN;
12 class MEDSKYLINEARRAY;
17 this class deals with all type of connectivity
18 this a recursive class in order to store
21 class CONNECTIVITY // recursive class
29 /*! contains MED_CELL MED_FACE or MED_EDGE */
30 medEntityMesh _entity ;
31 /*! contains MED_NODAL or MED_DESCEND */
32 medConnectivity _typeConnectivity ;
33 /*! count of differents cells types
35 med_int _numberOfTypes ;
36 /*! array of all med_geometric_type used by MESH. */
37 medGeometryElement* _geometricTypes ;
39 /*! map indexed by med_geometric_type
40 which contains the different
41 'CellModel' used by MESH. */
43 /*! contains the dimension of the entity */
44 med_int _entityDimension ;
46 /*! needed by calculateReverseNodalConnectivity */
47 med_int _numberOfNodes ;
49 /*! array of size _numberOfTypes+1 which
50 gives for each cell type the first
51 cell number in _nodal or _descending
52 array (depends on _typeConnectivity)
53 To get cells count for one type, we
54 must minus _count[i+1] and _count[i]
55 ( 0 <= i < _numberOfTypes ).
56 Note that _count[_numberOfTypes] returns
57 total cells count + 1 */
60 /*! pointer on an array which stores the nodal connectivity */
61 MEDSKYLINEARRAY* _nodal ;
62 /*! pointer on an array which stores the descending connectivity */
63 MEDSKYLINEARRAY* _descending ;
64 /*! pointer on an array which stores the resverse nodal connectivity */
65 MEDSKYLINEARRAY* _reverseNodalConnectivity ;
66 /*! pointer on an array which stores the reverse descending connectivity */
67 MEDSKYLINEARRAY* _reverseDescendingConnectivity ;
68 /*! if face or edge, list of 2 cells or
69 2 faces it belongs to.
70 If 2nd number equals 0, we have a
71 boundary entity. We could use
72 MEDSKYLINEARRAY, but we suppose we have
73 always only 2 (or 1) entities. */
74 MEDSKYLINEARRAY* _neighbourhood ;
75 /*! connectivity of sub cell if
76 descendant connectivity is calculated */
77 CONNECTIVITY * _constituent ;
84 /*! does nothing if already exists, else
85 evaluates _nodal from _descending */
86 void calculateNodalConnectivity() ;
87 /*! does nothing if already exists, else
88 evaluates from _nodal */
89 void calculateReverseNodalConnectivity() ;
90 /*! does nothing if already exists, else
91 evaluates _descending from _nodal */
92 void calculateDescendingConnectivity() ;
93 /*! does nothing if already exists, else
94 evaluates from _descending */
95 // void calculateReverseDescendingConnectivity(CONNECTIVITY *myConnectivity) ;
96 /*! does nothing if already exists, else
97 evaluates _neighbourhood from _descending */
98 void calculateNeighbourhood(CONNECTIVITY &myConnectivity) ;
102 friend class MED_MESH_RDONLY_DRIVER;
103 friend class MED_MESH_WRONLY_DRIVER;
105 CONNECTIVITY(medEntityMesh Entity=MED_CELL);
106 CONNECTIVITY(int numberOfTypes, medEntityMesh Entity=MED_CELL);
109 inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const ;
110 void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity) ;
111 void updateFamily(vector<FAMILY*> myFamilies) ;
113 inline medEntityMesh getEntity () const;
114 inline med_int getNumberOfTypes (medEntityMesh Entity) const;
115 inline medGeometryElement * getGeometricTypes (medEntityMesh Entity) const;
116 medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
117 inline int * getGlobalNumberingIndex (medEntityMesh Entity) const ;
119 med_int * getConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity,
120 medGeometryElement Type) ;
121 med_int * getConnectivityIndex (medConnectivity ConnectivityType,medEntityMesh Entity) ;
123 CELLMODEL & getType (medGeometryElement Type) const;
124 CELLMODEL * getCellsTypes (medEntityMesh Entity) const;
126 med_int getNumberOfNodesInType (medGeometryElement Type) const;
127 med_int getNumberOfSubCellInType (medGeometryElement Type) const;
128 med_int getNumberOf (medEntityMesh Entity, medGeometryElement Type) const;
129 med_int* getValue (medConnectivity TypeConnectivity, medGeometryElement Type) ;
130 med_int* getValueIndex (medConnectivity TypeConnectivity) ;
131 med_int* getReverseNodalConnectivity () ;
132 med_int* getReverseNodalConnectivityIndex () ;
133 med_int* getReverseDescendingConnectivity () ;
134 med_int* getReverseDescendingConnectivityIndex () ;
135 med_int* getNeighbourhood() const;
138 /*----------------------*/
139 /* Methodes Inline */
140 /*----------------------*/
142 /*! Returns the medEntityMesh */
143 inline medEntityMesh CONNECTIVITY::getEntity() const
148 /*! Returns the number of different <medGeometryElement> types existing in the specified entity.
150 Note : Not implemented for MED_ALL_ENTITIES. */
151 inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const
153 MESSAGE("CONNECTIVITY::getNumberOfTypes : Entity = "<<Entity<<", _entity = "<<_entity);
155 return _numberOfTypes;
156 else if (_constituent!=NULL)
157 return _constituent->getNumberOfTypes(Entity) ;
159 return 0 ; // because it is the right information (no need exception !
160 //throw MEDEXCEPTION("Entity not defined !") ;
163 /*! Returns an array of all <med geometry elements> types existing in the mesh for the given medEntityMesh.
165 Note : Not implemented for MED_ALL_ENTITIES. */
166 inline medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const
169 return _geometricTypes;
170 else if (_constituent!=NULL)
171 return _constituent->getGeometricTypes(Entity) ;
173 throw MEDEXCEPTION("Entity not defined !") ;
177 inline int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const
181 else if (_constituent!=NULL)
182 return _constituent->getGlobalNumberingIndex(Entity) ;
184 throw MEDEXCEPTION("Entity not defined !") ;
187 /*! Returns true if a connectivity exists on elements of type "Entity" */
188 inline bool CONNECTIVITY::existConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) const
190 if (_entity==Entity) {
191 MESSAGE("existConnectivity : _entity==Entity="<<Entity);
192 if ((ConnectivityType==MED_NODAL)&(_nodal!=(MEDSKYLINEARRAY*)NULL))
194 if ((ConnectivityType==MED_DESCENDING)&(_descending!=(MEDSKYLINEARRAY*)NULL))
196 } else if (_constituent!=NULL)
197 return _constituent->existConnectivity(ConnectivityType,Entity) ;
202 Return an array which contain CELLMODEL foreach element type present in connectivity for given medEntityMesh (similar as getGeometricTypes)
204 Throw an execption if the given entity is not defined or if the array is not defined.
206 inline CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
208 if (Entity == _entity)
212 throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : CELLMODEL array is not defined !");
214 if (_constituent != NULL)
215 return _constituent->getCellsTypes(Entity) ;
217 throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : Not found Entity !");
220 #endif /* CONNECTIVITY_HXX */