Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project!

## [Libmesh-users] Inferring SparsityPattern for DG discretization

 [Libmesh-users] Inferring SparsityPattern for DG discretization From: Vijay S. Mahadevan - 2008-11-07 16:35:59 ```Hi, I'm not sure if this is a stupid question but I'm not entirely sure as to how you would find the nonzeros per row in a DG discretization. This is not obvious to me since in say an advection system, the flux at the boundaries couple the dofs in one cell to the next. And hence, the dof_map does not have any idea about this discretization or coupling of variables. In the continuous FEM case, the dof_map does provide the connectivity correctly since the mesh_nodes are the dofs in the discretization. Any ideas as to how I can possibly access the location of nonzeros per row by just looking at the final assembled matrix ? I saw that there is a update_sparsity_pattern routine in SparseMatrix but this is not overloaded in PetscMatrix. I guess I am looking for something like the sparsity_pattern object, or am I way off on my interpretation of what this means ? Thank you very much for any help in advance. Vijay ```

 [Libmesh-users] Inferring SparsityPattern for DG discretization From: Vijay S. Mahadevan - 2008-11-07 16:35:59 ```Hi, I'm not sure if this is a stupid question but I'm not entirely sure as to how you would find the nonzeros per row in a DG discretization. This is not obvious to me since in say an advection system, the flux at the boundaries couple the dofs in one cell to the next. And hence, the dof_map does not have any idea about this discretization or coupling of variables. In the continuous FEM case, the dof_map does provide the connectivity correctly since the mesh_nodes are the dofs in the discretization. Any ideas as to how I can possibly access the location of nonzeros per row by just looking at the final assembled matrix ? I saw that there is a update_sparsity_pattern routine in SparseMatrix but this is not overloaded in PetscMatrix. I guess I am looking for something like the sparsity_pattern object, or am I way off on my interpretation of what this means ? Thank you very much for any help in advance. Vijay ```
 Re: [Libmesh-users] Inferring SparsityPattern for DG discretization From: Benjamin Kirk - 2008-11-07 17:31:17 ```> I'm not sure if this is a stupid question but I'm not entirely sure as > to how you would find the nonzeros per row in a DG discretization. > This is not obvious to me since in say an advection system, the flux > at the boundaries couple the dofs in one cell to the next. And hence, > the dof_map does not have any idea about this discretization or > coupling of variables. In the continuous FEM case, the dof_map does > provide the connectivity correctly since the mesh_nodes are the dofs > in the discretization. In DG discretizations the degrees of freedom in any given element are typically coupled to all the degrees of freedom in its face-neighbors. > Any ideas as to how I can possibly access the location of nonzeros per > row by just looking at the final assembled matrix ? I saw that there > is a update_sparsity_pattern routine in SparseMatrix but this is not > overloaded in PetscMatrix. I guess I am looking for something like the > sparsity_pattern object, or am I way off on my interpretation of what > this means ? The DofMap will add all face neighbor degrees of freedom to an element's coupled dofs if (1) all the variables in the system are discontinuous, or (2) the command line option '--implicit_neighbor_dofs' is specified. The role of the sparsity pattern is to define the graph structure of the system matrix. So, the DofMap builds this graph, and then passess it off to any associated matrices. It is then destroyed because it takes a fair bit of memory and, in theory, should not be needed after the matrices are reinitialized with the proper structure. In the case of PETSc it does not actually need the graph of the matrix - the number of on- and off-processor nonzeros per row will suffice. Of course, internal to the DofMap the sparsity pattern is computed anyway to get this information. If you look in the laspack and trilinos matrix implementations you will see where the sparsity pattern is actually used. Hope this helps, -Ben ```
 Re: [Libmesh-users] Inferring SparsityPattern for DG discretization From: Vijay S. Mahadevan - 2008-11-07 17:43:14 ```Ben, Thanks for the prompt reply. A clarification regarding what you said: > The DofMap will add all face neighbor degrees of freedom to an element's > coupled dofs if > > (1) all the variables in the system are discontinuous, or > (2) the command line option '--implicit_neighbor_dofs' is specified. In my system, all variables use disconitnuous basis. And now I tried to run the code with --implicit_neighbor_dofs in command line. But I still get only the local element dofs and not the neighboring element dofs when I populate dofs with the call "dof_map.dof_indices(...)". Is this what is to be expected or did I try something else than what you suggested ? I just need DofMap to tell me which other dof my current dofs are coupled to. From what I understand, your reply answers that but somehow I do not see the same in my code. Am i missing something ? Vijay On Fri, Nov 7, 2008 at 11:31 AM, Benjamin Kirk wrote: > >> I'm not sure if this is a stupid question but I'm not entirely sure as >> to how you would find the nonzeros per row in a DG discretization. >> This is not obvious to me since in say an advection system, the flux >> at the boundaries couple the dofs in one cell to the next. And hence, >> the dof_map does not have any idea about this discretization or >> coupling of variables. In the continuous FEM case, the dof_map does >> provide the connectivity correctly since the mesh_nodes are the dofs >> in the discretization. > > In DG discretizations the degrees of freedom in any given element are > typically coupled to all the degrees of freedom in its face-neighbors. > >> Any ideas as to how I can possibly access the location of nonzeros per >> row by just looking at the final assembled matrix ? I saw that there >> is a update_sparsity_pattern routine in SparseMatrix but this is not >> overloaded in PetscMatrix. I guess I am looking for something like the >> sparsity_pattern object, or am I way off on my interpretation of what >> this means ? > > The DofMap will add all face neighbor degrees of freedom to an element's > coupled dofs if > > (1) all the variables in the system are discontinuous, or > (2) the command line option '--implicit_neighbor_dofs' is specified. > > The role of the sparsity pattern is to define the graph structure of the > system matrix. So, the DofMap builds this graph, and then passess it off to > any associated matrices. It is then destroyed because it takes a fair bit > of memory and, in theory, should not be needed after the matrices are > reinitialized with the proper structure. > > In the case of PETSc it does not actually need the graph of the matrix - the > number of on- and off-processor nonzeros per row will suffice. Of course, > internal to the DofMap the sparsity pattern is computed anyway to get this > information. > > If you look in the laspack and trilinos matrix implementations you will see > where the sparsity pattern is actually used. > > Hope this helps, > > -Ben > > > ```
 Re: [Libmesh-users] Inferring SparsityPattern for DG discretization From: Benjamin Kirk - 2008-11-07 17:50:27 ```> A clarification regarding what you said: > >> The DofMap will add all face neighbor degrees of freedom to an element's >> coupled dofs if >> >> (1) all the variables in the system are discontinuous, or >> (2) the command line option '--implicit_neighbor_dofs' is specified. > > In my system, all variables use disconitnuous basis. And now I tried > to run the code with --implicit_neighbor_dofs in command line. But I > still get only the local element dofs and not the neighboring element > dofs when I populate dofs with the call "dof_map.dof_indices(...)". Oh, I see what you want. In your case the sparsity pattern is built up properly using the neighbor degrees of freedom, but DofMap::dof_indices(...) will always return only the degrees of freedom an element needs to compute the solution in that element... > Is this what is to be expected or did I try something else than what > you suggested ? I just need DofMap to tell me which other dof my > current dofs are coupled to. From what I understand, your reply > answers that but somehow I do not see the same in my code. Am i > missing something ? So, in your case, when you are computing the face contribution between 'elem' and 'neighbor', you need DofMap::dof_indices(elem,...) and DofMap::dof_indices(neighbor,...). This is consistent with the fact that you will need two FiniteElement objects, one on the local element and one for the neighbor. The total list of Dofs coupled to a given element will be the union of DofMap::dof_indices(elem,...) DofMap::dof_indices(neighbor_0,...) ... DofMap::dof_indices(neighbor_N,...) Does that help? -Ben ```
 Re: [Libmesh-users] Inferring SparsityPattern for DG discretization From: Vijay S. Mahadevan - 2008-11-07 18:13:45 ```That makes a lot more sense. I can loop over the elements depending on the flux type I use for my discretization and infer the coupled dofs I need. Thanks for the help Ben ! On Fri, Nov 7, 2008 at 11:50 AM, Benjamin Kirk wrote: >> A clarification regarding what you said: >> >>> The DofMap will add all face neighbor degrees of freedom to an element's >>> coupled dofs if >>> >>> (1) all the variables in the system are discontinuous, or >>> (2) the command line option '--implicit_neighbor_dofs' is specified. >> >> In my system, all variables use disconitnuous basis. And now I tried >> to run the code with --implicit_neighbor_dofs in command line. But I >> still get only the local element dofs and not the neighboring element >> dofs when I populate dofs with the call "dof_map.dof_indices(...)". > > Oh, I see what you want. In your case the sparsity pattern is built up > properly using the neighbor degrees of freedom, but DofMap::dof_indices(...) > will always return only the degrees of freedom an element needs to compute > the solution in that element... > >> Is this what is to be expected or did I try something else than what >> you suggested ? I just need DofMap to tell me which other dof my >> current dofs are coupled to. From what I understand, your reply >> answers that but somehow I do not see the same in my code. Am i >> missing something ? > > So, in your case, when you are computing the face contribution between > 'elem' and 'neighbor', you need DofMap::dof_indices(elem,...) and > DofMap::dof_indices(neighbor,...). This is consistent with the fact that > you will need two FiniteElement objects, one on the local element and one > for the neighbor. > > The total list of Dofs coupled to a given element will be the union of > > DofMap::dof_indices(elem,...) > DofMap::dof_indices(neighbor_0,...) > ... > DofMap::dof_indices(neighbor_N,...) > > Does that help? > > -Ben > > ```