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 if(std::find(_groupNames.begin(), _groupNames.end(), groupName) == _groupNames.end())//No group named groupName
166 _groupNames.insert(_groupNames.begin(),groupName);
170 std::cout<<"Warning Node::setGroupName, group name "<< groupName <<" is already present. No duplication"<<std::endl;
174 Node::isBorder(void) const
176 if (_region==0 | _isBorder)
183 Node::getRegion(void) const
188 //----------------------------------------------------------------------
190 Node::addFaceId (const int numFace, const int faceId, bool isBorder )
191 //----------------------------------------------------------------------
193 _facesId[numFace] = faceId ;
196 if(std::find(_groupNames.begin(), _groupNames.end(), "Boundary") == _groupNames.end())//No group named Boundary
197 _groupNames.insert(_groupNames.begin(),"Boundary");
202 //----------------------------------------------------------------------
204 Node::addCellId (const int numCell, const int cellId )
205 //----------------------------------------------------------------------
207 _cellsId[numCell] = cellId ;
210 //----------------------------------------------------------------------
212 Node::addNeighbourNodeId (const int numNode, const int nodeId )
213 //----------------------------------------------------------------------
215 _neighbourNodesId[numNode] = nodeId ;
218 //----------------------------------------------------------------------
220 Node::distance( const Node& n ) const
221 //----------------------------------------------------------------------
223 double distance=_point.distance(n.getPoint());
227 //----------------------------------------------------------------------
229 //----------------------------------------------------------------------
230 Node::getFaceId(int localId) const
231 //----------------------------------------------------------------------
233 if(localId<_numberOfFaces)
234 return _facesId[localId];
237 std::cout<< "Local id requested : "<< localId<<", total number of faces= "<<_numberOfFaces<<std::endl;
238 throw CdmathException("Node::getFaceId : incorrect face local id");
242 //----------------------------------------------------------------------
244 //----------------------------------------------------------------------
245 Node::getNeighbourNodeId(int localId) const
246 //----------------------------------------------------------------------
248 if(localId<_numberOfEdges)
249 return _neighbourNodesId[localId];
252 std::cout<< "Local id requested : "<< localId<<", total number of edges= "<<_numberOfEdges<<std::endl;
253 throw CdmathException("Node::getNeighbourNodeId : incorrect node local id");
258 Node::operator= ( const Node& node )
259 //----------------------------------------------------------------------
261 _point = node.getPoint() ;
262 _cellsId = node.getCellsId() ;
263 _facesId = node.getFacesId() ;
264 _neighbourNodesId = node.getNeighbourNodesId() ;
265 _numberOfCells = node.getNumberOfCells() ;
266 _numberOfFaces = node.getNumberOfFaces() ;
267 _numberOfEdges = node.getNumberOfEdges() ;
268 _groupNames = node.getGroupNames();
269 _isBorder=node.isBorder();