[Libmesh-users] Getting the points corresponding to a variable's DOF

 [Libmesh-users] Getting the points corresponding to a variable's DOF From: Andrew Donaldson Davis - 2013-12-12 18:00:06 ```Hi, I am trying to get the spatial points corresponding to the degrees of freedom for a specific variable in a libMesh::System. However, I am having some trouble if the degree of the variable's shape functions is less than the mesh. Here is the code I am using int varNum = 0 set dofIndices; system.local_dof_indices(varNum, dofIndices); const libMesh::MeshBase& mesh =system.get_mesh(); for (auto dofIter = dofIndices.begin(); dofIter != dofIndices.end(); ++dofIter) { libMesh::Point pt = mesh.point(*dofIter); cout << pt << endl; } This works fine if, for example, varNum is order 2 and the mesh is libMesh::QUAD9. However, if varNum is linear (order) and the mesh still libMesh::QUAD9 I am not getting the correct subset of mesh points. It looks like the set dofIndices contains the numbers 1,2,3,...,N, which I believe give the first N points in the mesh. I expected dofIndices not to contain sequential numbers. Shouldn't it skip some on each element (corresponding to the DOFs that aren't used by the basis)? Does anyone know a better way to accomplish this? If it helps: The end-goal of this is to compute a covariance matrix such that each entry corresponds is a function of the distance between two points in the mesh (C_ij = K(x_i,x_j)). Thus, the need for the points at each DOF. Hopefully this question makes sense! I tried to write it as compactly as possible so if anything is confusing please let me know. Thanks for all your help, Andy ```

 [Libmesh-users] Getting the points corresponding to a variable's DOF From: Andrew Donaldson Davis - 2013-12-12 18:00:06 ```Hi, I am trying to get the spatial points corresponding to the degrees of freedom for a specific variable in a libMesh::System. However, I am having some trouble if the degree of the variable's shape functions is less than the mesh. Here is the code I am using int varNum = 0 set dofIndices; system.local_dof_indices(varNum, dofIndices); const libMesh::MeshBase& mesh =system.get_mesh(); for (auto dofIter = dofIndices.begin(); dofIter != dofIndices.end(); ++dofIter) { libMesh::Point pt = mesh.point(*dofIter); cout << pt << endl; } This works fine if, for example, varNum is order 2 and the mesh is libMesh::QUAD9. However, if varNum is linear (order) and the mesh still libMesh::QUAD9 I am not getting the correct subset of mesh points. It looks like the set dofIndices contains the numbers 1,2,3,...,N, which I believe give the first N points in the mesh. I expected dofIndices not to contain sequential numbers. Shouldn't it skip some on each element (corresponding to the DOFs that aren't used by the basis)? Does anyone know a better way to accomplish this? If it helps: The end-goal of this is to compute a covariance matrix such that each entry corresponds is a function of the distance between two points in the mesh (C_ij = K(x_i,x_j)). Thus, the need for the points at each DOF. Hopefully this question makes sense! I tried to write it as compactly as possible so if anything is confusing please let me know. Thanks for all your help, Andy ```
 Re: [Libmesh-users] Getting the points corresponding to a variable's DOF From: John Peterson - 2013-12-12 18:09:28 ```On Thu, Dec 12, 2013 at 10:59 AM, Andrew Donaldson Davis wrote: > Hi, > > I am trying to get the spatial points corresponding to the degrees of > freedom for a specific variable in a libMesh::System. However, I am having > some trouble if the degree of the variable's shape functions is less than > the mesh. Here is the code I am using > > int varNum = 0 > set dofIndices; > system.local_dof_indices(varNum, dofIndices); > > const libMesh::MeshBase& mesh =system.get_mesh(); > > for (auto dofIter = dofIndices.begin(); dofIter != dofIndices.end(); > ++dofIter) { > libMesh::Point pt = mesh.point(*dofIter); > cout << pt << endl; > } > > This works fine if, for example, varNum is order 2 and the mesh is > libMesh::QUAD9. However, if varNum is linear (order) and the mesh still > libMesh::QUAD9 I am not getting the correct subset of mesh points. It > looks like the set dofIndices contains the numbers 1,2,3,...,N, which I > believe give the first N points in the mesh. I expected dofIndices not to > contain sequential numbers. Shouldn't it skip some on each element > (corresponding to the DOFs that aren't used by the basis)? Does anyone > know a better way to accomplish this? I guess it would depend on the node numbering in your mesh? Is it possible that the first N nodes are actually the corner vertices of the QUAD9s and hence correspond to the DOF ids for the linear finite element? Is your mesh created via build_square()? -- John ```
 Re: [Libmesh-users] Getting the points corresponding to a variable's DOF From: John Peterson - 2013-12-12 18:31:58 ```On Thu, Dec 12, 2013 at 11:15 AM, Andrew Davis wrote: > Hi, > > I suppose you are right - it would depend on the node number in the mesh. > So in that case, the set dofIndices contains the correct numbers. However, > if I look at the points (the line cout << pt << endl;) they only come from a > quarter of the domain. > > I am building a mesh via build_square (its a unit box). When the parameter > has linear shape functions the points that are printed come from the domain > [0, 1]x[0, 0.25]. In general, I don't think there's any reason that dof "12" should have any relationship to node "12" in the Mesh... If you want to check that, you can try looping over the Nodes and comparing node->id() and node->dof_number(sys_num, var_num, 0); (The 0 applies to LAGRANGE elements.) -- John ```