4 * Created on: 23 janv. 2012
9 #include "CdmathException.hxx"
13 //----------------------------------------------------------------------
15 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 Cell::Cell( int numberOfNodes, int numberOfFaces, double measure, const Point p )
24 //----------------------------------------------------------------------
27 _numberOfNodes = numberOfNodes ;
28 _numberOfFaces = numberOfFaces ;
29 _nodesId = std::vector< int >(_numberOfNodes,0);
30 _facesId = std::vector< int >(_numberOfFaces,0);
31 _normalVectors = Vector(3*_numberOfFaces);
35 //----------------------------------------------------------------------
37 //----------------------------------------------------------------------
41 //----------------------------------------------------------------------
42 Cell::Cell( const Cell& cell )
43 //----------------------------------------------------------------------
45 _point = cell.getBarryCenter() ;
46 _numberOfNodes = cell.getNumberOfNodes();
47 _numberOfFaces = cell.getNumberOfFaces() ;
48 _measure = cell.getMeasure() ;
49 _nodesId=cell.getNodesId();
50 _facesId=cell.getFacesId();
51 _normalVectors=cell.getNormalVectors();
54 //----------------------------------------------------------------------
56 //----------------------------------------------------------------------
58 Cell::getNodesId ( void ) const
59 //----------------------------------------------------------------------
64 //----------------------------------------------------------------------
66 Cell::getMeasure ( void ) const
67 //----------------------------------------------------------------------
72 //----------------------------------------------------------------------
74 Cell::getFacesId ( void ) const
75 //----------------------------------------------------------------------
80 //----------------------------------------------------------------------
82 Cell::getNumberOfNodes ( void ) const
83 //----------------------------------------------------------------------
85 return _numberOfNodes ;
88 //----------------------------------------------------------------------
90 Cell::getBarryCenter( void ) const
91 //----------------------------------------------------------------------
96 //----------------------------------------------------------------------
99 //----------------------------------------------------------------------
104 //----------------------------------------------------------------------
106 Cell::y( void ) const
107 //----------------------------------------------------------------------
112 //----------------------------------------------------------------------
114 Cell::z( void ) const
115 //----------------------------------------------------------------------
120 //----------------------------------------------------------------------
122 Cell::getNumberOfFaces ( void ) const
123 //----------------------------------------------------------------------
125 return _numberOfFaces ;
128 //----------------------------------------------------------------------
130 Cell::addFaceId (int numFace, int faceId )
131 //----------------------------------------------------------------------
133 _facesId[numFace] = faceId ;
136 //----------------------------------------------------------------------
138 Cell::addNormalVector (int numNormalVector, double x, double y, double z)
139 //----------------------------------------------------------------------
141 _normalVectors(3*numNormalVector) = x ;
142 _normalVectors(3*numNormalVector+1) = y ;
143 _normalVectors(3*numNormalVector+2) = z ;
146 //----------------------------------------------------------------------
148 Cell::getNormalVector( int numNormalVector, int numComposant ) const
149 //----------------------------------------------------------------------
152 return _normalVectors(3*numNormalVector);
153 else if (numComposant==1)
154 return _normalVectors(3*numNormalVector+1);
155 else if (numComposant==2)
156 return _normalVectors(3*numNormalVector+2);
158 throw CdmathException("Cell::getNormalVector, numComposant should be 0, 1 or 2");
161 //----------------------------------------------------------------------
163 Cell::getNormalVectors (void) const
164 //----------------------------------------------------------------------
166 return _normalVectors;
169 //----------------------------------------------------------------------
171 Cell::addNodeId (int numNode, int nodeId )
172 //----------------------------------------------------------------------
174 _nodesId[numNode] = nodeId ;
177 //----------------------------------------------------------------------
179 Cell::operator= ( const Cell& cell )
180 //----------------------------------------------------------------------
182 _point = cell.getBarryCenter() ;
183 _numberOfNodes = cell.getNumberOfNodes() ;
184 _numberOfFaces = cell.getNumberOfFaces() ;
185 _measure = cell.getMeasure() ;
187 _nodesId = cell.getNodesId();
188 _facesId = cell.getFacesId();
189 _normalVectors=cell.getNormalVectors();
193 //----------------------------------------------------------------------
195 Cell::getFaceId(int localId) const
196 //----------------------------------------------------------------------
198 if(localId<_numberOfFaces)
199 return _facesId[localId];
202 std::cout<< "Local id requested : "<< localId<<", total number of faces= "<<_numberOfFaces<<std::endl;
203 throw CdmathException("Cell::getfaceId : incorrect face local id");
207 //----------------------------------------------------------------------
209 Cell::getNodeId(int localId) const
210 //----------------------------------------------------------------------
212 if(localId<_numberOfNodes)
213 return _nodesId[localId];
216 std::cout<< "Local id requested : "<< localId<<", total number of nodes= "<<_numberOfNodes<<std::endl;
217 throw CdmathException("Cell::getNodeId : incorrect node local id");