From: Jens O. <oe...@st...> - 2003-10-27 15:50:12
|
Hi, I've written a direct current modelling program for geophysical purposes with libmesh. Till now every thing seems to work quit proper. So far so good. But now to my problem, which is quit simple so I think, but I could not solve it. I have data associated to each node. Now I would like to create a vector of nodes, in which the nodes marked as a electrode position are stored (the marker is -99). To solve this I've done the following: const Mesh& const_mesh = mesh; std::vector<Number> node_data; std::vector<Node> ElectrPos; unsigned int ElectrCount=1; unsigned int n_nodes = mesh.n_nodes(); for (unsigned int n_cnt=0; n_cnt<n_nodes; n_cnt++) { const Node& curr_node = const_mesh.node(n_cnt); const Node* curr_node_ptr = const_mesh.node_ptr(n_cnt); if (mesh.data.has_data (curr_node_ptr)) { node_data = mesh.data.get_data (curr_node_ptr); if (node_data[0]==-99) { ElectrPos.resize(ElectrCount); ElectrPos.push_back(curr_node); ElectrCount++; } } } The problem is, that it's not possible to resize the vector ElectrPos. The compiler complains: /usr/include/c++/3.3/bits/stl_vector.h: In member function `void std::vector<_Tp, _Alloc>::resize(unsigned int) [with _Tp = Node, _Alloc = std::allocator<Node>]': InOut.C:163: instantiated from here /usr/include/c++/3.3/bits/stl_vector.h:452: error: no matching function for call to `Node::Node()' /home/oeser/DA/libmesh/include/node.h:150: error: candidates are: Node::Node(const Point&, unsigned int = DofObject::invalid_id) /home/oeser/DA/libmesh/include/node.h:139: error: Node::Node(const Node&) /home/oeser/DA/libmesh/include/node.h:130: error: Node::Node(double, double, double, unsigned int) If I change ElectrPos.resize(ElectrCount) to ElectrPos.resize(curr_node) as the compiler mentioned (with absence of understanding why I should do this), the compiler complains: InOut.C:163: error: no matching function for call to `std::vector<Node, std::allocator<Node> >::resize(const Node&)' /usr/include/c++/3.3/bits/stl_vector.h:434: error: candidates are: void std::vector<_Tp, _Alloc>::resize(unsigned int, const _Tp&) [with _Tp = Node, _Alloc = std::allocator<Node>] /usr/include/c++/3.3/bits/stl_vector.h:452: error: void std::vector<_Tp, _Alloc>::resize(unsigned int) [with _Tp = Node, _Alloc = std::allocator<Node>] What's going on, where is the problem? Because I'm currently new to OOP and C++ I could not solve the problem. But I hope you can give me some hints or a other way to solve the problem. I think I need to store the reference, because I need to call DofObject::dof_number for these nodes. Best regards. Jens. -- |