From: Roy Stogner <roystgnr@ic...>  20090211 13:20:48

On Wed, 11 Feb 2009, yunfei zhu wrote: > I use the following code to access the displacement of a special node at > each time step. > First, specified by the node_number: > const Node& node = mesh.node(node_number); This is probably what's going wrong: the node number changes after refinement. > Then get the dof number of a variable on this node: > const unsigned int node_dof_u = node.dof_number(0, u_var, 0); And so does the dof number. > Then I could access the solution by: > (*nonlinear_system.solution)(node_dof_u). > > But I don't think it's a good way to access the solution, That's true  it will break on nonvertex nodes on nonLagrange elements. > because when I read in a mesh by > > mesh.read("mesh.xda"), then refine the mesh by > mesh_refinement.uniformly_refine(1), the solution it writes > > out is not the one I want. I thought maybe it is because the > solution would not be ordered by the dof number of node after > refinement. After refinement, the node with number node_number is still given by node = mesh.node(node_number), the first dof index there is still given by node_dof_u = node.dof_number, the solution there is still given by solution(node_dof_u)... but because the indexing is changed by refinement, your old node_number and node_dof_u have nothing to do with the new mesh. You'll need to save some invariant property of the node before refinement (it's position shouldn't change, for example) and look up it's new node number by searching for that.  Roy 