4 * Created on: 23 janv. 2012
9 #include "CdmathException.hxx"
12 //----------------------------------------------------------------------
14 //----------------------------------------------------------------------
19 _groupNames=std::vector<std::string>(0);
24 //----------------------------------------------------------------------
26 //----------------------------------------------------------------------
30 //----------------------------------------------------------------------
31 Node::Node( const Node& node )
32 //----------------------------------------------------------------------
34 _point = node.getPoint() ;
35 _cellsId = node.getCellsId() ;
36 _facesId = node.getFacesId() ;
37 _numberOfCells = node.getNumberOfCells() ;
38 _numberOfFaces = node.getNumberOfFaces() ;
39 _numberOfEdges = node.getNumberOfEdges() ;
40 _groupNames=node.getGroupNames();
41 _region=node.getRegion();
42 _isBorder=node.isBorder();
45 //----------------------------------------------------------------------
46 Node::Node( const int numberOfCells, const int numberOfFaces, const int numberOfEdges, const Point p)
47 //----------------------------------------------------------------------
51 _numberOfCells = numberOfCells ;
52 _numberOfFaces = numberOfFaces ;
53 _numberOfEdges = numberOfEdges ;
54 _cellsId = std::vector< int >(_numberOfCells,0);
55 _facesId = std::vector< int >(_numberOfFaces,0);
56 _neighbourNodesId = std::vector< int >(_numberOfEdges,0);
57 _groupNames=std::vector<std::string>(0);
62 //----------------------------------------------------------------------
64 Node::getCellsId( void ) const
65 //----------------------------------------------------------------------
70 //----------------------------------------------------------------------
72 Node::getFacesId( void ) const
73 //----------------------------------------------------------------------
78 //----------------------------------------------------------------------
80 Node::getNeighbourNodesId( void ) const
81 //----------------------------------------------------------------------
83 return _neighbourNodesId ;
86 //----------------------------------------------------------------------
88 Node::getNumberOfCells( void ) const
89 //----------------------------------------------------------------------
91 return _numberOfCells ;
94 //----------------------------------------------------------------------
96 Node::getNumberOfFaces( void ) const
97 //----------------------------------------------------------------------
99 return _numberOfFaces ;
102 //----------------------------------------------------------------------
104 Node::getNumberOfEdges( void ) const
105 //----------------------------------------------------------------------
107 return _numberOfEdges ;
110 //----------------------------------------------------------------------
112 Node::getPoint( void ) const
113 //----------------------------------------------------------------------
118 //----------------------------------------------------------------------
120 Node::x( void ) const
121 //----------------------------------------------------------------------
126 //----------------------------------------------------------------------
128 Node::y( void ) const
129 //----------------------------------------------------------------------
134 //----------------------------------------------------------------------
136 Node::z( void ) const
137 //----------------------------------------------------------------------
142 std::vector<std::string>
143 Node::getGroupNames(void) const
149 Node::getGroupName(int igroup) const
151 if (igroup<_groupNames.size())
152 return _groupNames[igroup];
155 std::cout<<"Error Node::getGroupName(int igroup), group number "<<igroup+1<<" requested"<<std::endl;
156 std::cout<<"Node belongs to "<< _groupNames.size() <<" groups"<<std::endl;
157 throw CdmathException("Node has no group with number igroup");
162 Node::setGroupName(const std::string groupName)
164 _groupNames.insert(_groupNames.begin(),groupName);
169 Node::isBorder(void) const
171 if (_region==0 | _isBorder)
178 Node::getRegion(void) const
183 //----------------------------------------------------------------------
185 Node::addFaceId (const int numFace, const int faceId, bool isBorder )
186 //----------------------------------------------------------------------
188 _facesId[numFace] = faceId ;
191 if(std::find(_groupNames.begin(), _groupNames.end(), "Boundary") == _groupNames.end())//No group named Boundary
192 _groupNames.insert(_groupNames.begin(),"Boundary");
197 //----------------------------------------------------------------------
199 Node::addCellId (const int numCell, const int cellId )
200 //----------------------------------------------------------------------
202 _cellsId[numCell] = cellId ;
205 //----------------------------------------------------------------------
207 Node::addNeighbourNodeId (const int numNode, const int nodeId )
208 //----------------------------------------------------------------------
210 _neighbourNodesId[numNode] = nodeId ;
213 //----------------------------------------------------------------------
215 Node::distance( const Node& n ) const
216 //----------------------------------------------------------------------
218 double distance=_point.distance(n.getPoint());
222 //----------------------------------------------------------------------
224 //----------------------------------------------------------------------
225 Node::getFaceId(int localId) const
226 //----------------------------------------------------------------------
228 if(localId<_numberOfFaces)
229 return _facesId[localId];
232 std::cout<< "Local id requested : "<< localId<<", total number of faces= "<<_numberOfFaces<<std::endl;
233 throw CdmathException("Node::getFaceId : incorrect face local id");
237 //----------------------------------------------------------------------
239 //----------------------------------------------------------------------
240 Node::getNeighbourNodeId(int localId) const
241 //----------------------------------------------------------------------
243 if(localId<_numberOfEdges)
244 return _neighbourNodesId[localId];
247 std::cout<< "Local id requested : "<< localId<<", total number of edges= "<<_numberOfEdges<<std::endl;
248 throw CdmathException("Node::getNeighbourNodeId : incorrect node local id");
253 Node::operator= ( const Node& node )
254 //----------------------------------------------------------------------
256 _point = node.getPoint() ;
257 _cellsId = node.getCellsId() ;
258 _facesId = node.getFacesId() ;
259 _neighbourNodesId = node.getNeighbourNodesId() ;
260 _numberOfCells = node.getNumberOfCells() ;
261 _numberOfFaces = node.getNumberOfFaces() ;
262 _numberOfEdges = node.getNumberOfEdges() ;
263 _groupNames = node.getGroupNames();
264 _isBorder=node.isBorder();