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) ;
97 med_int* getReverseNodalConnectivity () ;
98 med_int* getReverseNodalConnectivityIndex () ;
99 med_int* getReverseDescendingConnectivity () ;
100 med_int* getReverseDescendingConnectivityIndex () ;
102 /*! does nothing if already exists, else
103 evaluates _neighbourhood from _descending */
104 void calculateNeighbourhood(CONNECTIVITY &myConnectivity) ;
108 friend class MED_MESH_RDONLY_DRIVER;
109 friend class MED_MESH_WRONLY_DRIVER;
111 CONNECTIVITY(medEntityMesh Entity=MED_CELL);
112 CONNECTIVITY(int numberOfTypes, medEntityMesh Entity=MED_CELL);
113 CONNECTIVITY(CONNECTIVITY & m);
116 inline bool existConnectivity (medConnectivity connectivityType, medEntityMesh Entity) const ;
117 void calculateConnectivity (medConnectivity connectivityType, medEntityMesh Entity) ;
118 void updateFamily(vector<FAMILY*> myFamilies) ;
120 inline medEntityMesh getEntity () const;
121 inline med_int getNumberOfTypes (medEntityMesh Entity) const;
122 inline medGeometryElement * getGeometricTypes (medEntityMesh Entity) const;
123 medGeometryElement getElementType(medEntityMesh Entity,int Number) const ;
124 inline int * getGlobalNumberingIndex (medEntityMesh Entity) const ;
126 med_int * getConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity,
127 medGeometryElement Type) ;
128 med_int * getConnectivityIndex (medConnectivity ConnectivityType,medEntityMesh Entity) ;
130 CELLMODEL & getType (medGeometryElement Type) const;
131 CELLMODEL * getCellsTypes (medEntityMesh Entity) const;
133 med_int getNumberOfNodesInType (medGeometryElement Type) const;
134 med_int getNumberOfSubCellInType (medGeometryElement Type) const;
135 med_int getNumberOf (medEntityMesh Entity, medGeometryElement Type) const;
136 med_int* getValue (medConnectivity TypeConnectivity, medGeometryElement Type) ;
137 med_int* getValueIndex (medConnectivity TypeConnectivity) ;
139 inline med_int* getReverseConnectivity (medConnectivity ConnectivityType, medEntityMesh Entity=MED_CELL) ;
140 inline med_int* getReverseConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity=MED_CELL) ;
142 med_int* getNeighbourhood() const;
145 /*----------------------*/
146 /* Methodes Inline */
147 /*----------------------*/
149 /*! Returns the medEntityMesh */
150 inline medEntityMesh CONNECTIVITY::getEntity() const
155 /*! Returns the number of different <medGeometryElement> types existing in the specified entity.
157 Note : Not implemented for MED_ALL_ENTITIES. */
158 inline med_int CONNECTIVITY::getNumberOfTypes(medEntityMesh Entity) const
160 MESSAGE("CONNECTIVITY::getNumberOfTypes : Entity = "<<Entity<<", _entity = "<<_entity);
162 return _numberOfTypes;
163 else if (_constituent!=NULL)
164 return _constituent->getNumberOfTypes(Entity) ;
166 return 0 ; // because it is the right information (no need exception !
167 //throw MEDEXCEPTION("Entity not defined !") ;
170 /*! Returns an array of all <med geometry elements> types existing in the mesh for the given medEntityMesh.
172 Note : Not implemented for MED_ALL_ENTITIES. */
173 inline medGeometryElement* CONNECTIVITY::getGeometricTypes(medEntityMesh Entity) const
176 return _geometricTypes;
177 else if (_constituent!=NULL)
178 return _constituent->getGeometricTypes(Entity) ;
180 throw MEDEXCEPTION("Entity not defined !") ;
184 inline int * CONNECTIVITY::getGlobalNumberingIndex(medEntityMesh Entity) const
188 else if (_constituent!=NULL)
189 return _constituent->getGlobalNumberingIndex(Entity) ;
191 throw MEDEXCEPTION("Entity not defined !") ;
194 /*! Returns true if a connectivity exists on elements of type "Entity" */
195 inline bool CONNECTIVITY::existConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity) const
197 if (_entity==Entity) {
198 MESSAGE("existConnectivity : _entity==Entity="<<Entity);
199 if ((ConnectivityType==MED_NODAL)&(_nodal!=(MEDSKYLINEARRAY*)NULL))
201 if ((ConnectivityType==MED_DESCENDING)&(_descending!=(MEDSKYLINEARRAY*)NULL))
203 } else if (_constituent!=NULL)
204 return _constituent->existConnectivity(ConnectivityType,Entity) ;
209 Return an array which contain CELLMODEL foreach element type present in connectivity for given medEntityMesh (similar as getGeometricTypes)
211 Throw an execption if the given entity is not defined or if the array is not defined.
213 inline CELLMODEL * CONNECTIVITY::getCellsTypes(medEntityMesh Entity) const
215 if (Entity == _entity)
219 throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : CELLMODEL array is not defined !");
221 if (_constituent != NULL)
222 return _constituent->getCellsTypes(Entity) ;
224 throw MEDEXCEPTION("CONNECTIVITY::getCellsTypes(medEntityMesh) : Not found Entity !");
227 inline med_int* CONNECTIVITY::getReverseConnectivity(medConnectivity ConnectivityType, medEntityMesh Entity)
230 if (ConnectivityType==MED_NODAL)
231 return getReverseNodalConnectivity() ;
232 else if (ConnectivityType==MED_DESCENDING)
233 return getReverseDescendingConnectivity() ;
235 throw MEDEXCEPTION("MESH::getReverseConnectivity : connectivity mode not supported !");
238 if (NULL==_constituent)
239 calculateDescendingConnectivity() ;
240 return _constituent->getReverseConnectivity(ConnectivityType,Entity) ;
243 inline med_int* CONNECTIVITY::getReverseConnectivityIndex(medConnectivity ConnectivityType, medEntityMesh Entity)
246 if (ConnectivityType==MED_NODAL)
247 return getReverseNodalConnectivityIndex() ;
248 else if (ConnectivityType==MED_DESCENDING)
249 return getReverseDescendingConnectivityIndex() ;
251 throw MEDEXCEPTION("MESH::getReverseConnectivityIndex : connectivity mode not supported !");
254 if (NULL==_constituent)
255 calculateDescendingConnectivity() ;
256 return _constituent->getReverseConnectivityIndex(ConnectivityType,Entity) ;
259 #endif /* CONNECTIVITY_HXX */