4 * Created on: 23 janv. 2012
9 #include "CdmathException.hxx"
15 //----------------------------------------------------------------------
17 //----------------------------------------------------------------------
21 _groupNames=std::vector<std::string>(0);
29 //----------------------------------------------------------------------
30 Face::Face( const Face& face )
31 //----------------------------------------------------------------------
33 _measure = face.getMeasure() ;
34 _region=face.getRegion();
35 _groupNames=face.getGroupNames();
36 _point = face.getBarryCenter();
37 _numberOfCells = face.getNumberOfCells() ;
38 _numberOfNodes = face.getNumberOfNodes() ;
39 _nodesId=face.getNodesId();
40 _cellsId=face.getCellsId();
46 //----------------------------------------------------------------------
47 Face::Face( const int numberOfNodes, const int numberOfCells, const double measure, const Point p, double xN, double yN, double zN )
48 //----------------------------------------------------------------------
51 _numberOfNodes = numberOfNodes ;
52 _numberOfCells = numberOfCells ;
53 _nodesId = std::vector< int >(_numberOfNodes,0);
54 _cellsId = std::vector< int >(_numberOfCells,0);
62 _groupNames=std::vector<std::string>(1,"Boundary");
63 else if(numberOfCells>=2)//On a graph geometry (spaceDim>meshDim), a face is a node and can have more than 2 cell neighbour
64 _groupNames=std::vector<std::string>(0);
67 cout<<"Error, trying to create a face with "<< numberOfCells <<" cell neighbours"<<endl;
68 throw CdmathException("A face must have at least one cell neighbour (MEDCoupling philosophy)");
72 //----------------------------------------------------------------------
74 //----------------------------------------------------------------------
79 Face::getRegion(void) const
85 Face::getXN(void) const
91 Face::getYN(void) const
97 Face::getZN(void) const
102 std::vector<std::string>
103 Face::getGroupNames(void) const
109 Face::getGroupName(int igroup) const
111 if(igroup<_groupNames.size())
112 return _groupNames[igroup];
115 std::cout<<"Error Face::getGroupName(int igroup), group number "<<igroup+1<<" requested"<<std::endl;
116 std::cout<<"Face belongs to "<< _groupNames.size() <<" groups"<<std::endl;
117 throw CdmathException("Face has no group with number igroup");
122 Face::setGroupName(const string groupName)
124 if(std::find(_groupNames.begin(), _groupNames.end(), groupName) == _groupNames.end())//No group named groupName
126 _groupNames.insert(_groupNames.begin(),groupName);
130 cout<<"Warning Face::setGroupName, group name "<< groupName <<" is already present. No duplication"<<endl;
136 if (_region==0 || _numberOfCells==1)
141 //----------------------------------------------------------------------
143 Face::getBarryCenter( void ) const
144 //----------------------------------------------------------------------
149 //----------------------------------------------------------------------
151 Face::x( void ) const
152 //----------------------------------------------------------------------
157 //----------------------------------------------------------------------
159 Face::y( void ) const
160 //----------------------------------------------------------------------
165 //----------------------------------------------------------------------
167 Face::z( void ) const
168 //----------------------------------------------------------------------
173 //----------------------------------------------------------------------
175 Face::getCellsId( void ) const
176 //----------------------------------------------------------------------
181 //----------------------------------------------------------------------
183 Face::getNodesId( void ) const
184 //----------------------------------------------------------------------
189 //----------------------------------------------------------------------
191 Face::getMeasure( void ) const
192 //----------------------------------------------------------------------
197 //----------------------------------------------------------------------
199 Face::getNumberOfCells( void ) const
200 //----------------------------------------------------------------------
202 return _numberOfCells ;
205 //----------------------------------------------------------------------
207 Face::getNumberOfNodes( void ) const
208 //----------------------------------------------------------------------
210 return _numberOfNodes ;
213 //----------------------------------------------------------------------
215 Face::addCellId(const int numCell, const int cellId )
216 //----------------------------------------------------------------------
218 _cellsId[numCell] = cellId ;
220 //----------------------------------------------------------------------
222 Face::addNodeId(const int numNode, const int nodeId )
223 //----------------------------------------------------------------------
225 _nodesId[numNode] = nodeId ;
228 //----------------------------------------------------------------------
230 Face::operator= ( const Face& face )
231 //----------------------------------------------------------------------
233 _measure = face.getMeasure() ;
234 _point = face.getBarryCenter() ;
235 _numberOfCells = face.getNumberOfCells() ;
236 _numberOfNodes = face.getNumberOfNodes() ;
237 _nodesId=face.getNodesId();
238 _cellsId=face.getCellsId();
239 _groupNames=face.getGroupNames();
240 _region=face.getRegion();
246 //------------------------------------------------------------------------
248 Face::getNodeId(int localId) const
249 //------------------------------------------------------------------------
251 if(localId<_numberOfNodes)
252 return _nodesId[localId];
255 std::cout<< "Local id requested : "<< localId<<" total number of nodes= "<<_numberOfNodes<<std::endl;
256 throw CdmathException("Face::getNodeId : incorrect node local id");
259 //------------------------------------------------------------------------
261 Face::getCellId(int localId) const
262 //------------------------------------------------------------------------
264 if(localId<_numberOfCells)
265 return _cellsId[localId];
268 std::cout<< "Local id requested : "<< localId<<" total number of cells= "<<_numberOfCells<<std::endl;
269 throw CdmathException("Face::getCellId : incorrect cell local id");