New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate DG into non-nested MG #15209
Conversation
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
@peterrum I think I included all requested changes :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First set of comments. Thank you for working on this!
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
217a811
to
48cf619
Compare
@fdrmrc This should be ready. Maby you can have a look and test it :) Regarding an extension to multiple components: Probably only these lines have to be changed @peterrum Thanks for the help :) |
4b900e4
to
053e54b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice feature of 9.5 :)
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jh66637 Thank you for the very nice work! These modifications are also a big step towards supporting multiple components in the non-nested MG implementation needed by @fdrmrc !
Let's wait for the review of another person, since I have been partly involved in the development. Please note there might be still some changes coming depending on the requirements of multi-component systems.
7db23ed
to
e2eec85
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a complicated algorithm and I would like to ask if I understood the overall idea correctly:
- We are primarily discussing the case of a
prolongate
operation that goes into a DG space. - The main problem with a DG space is that several elements might request the evaluation at the same point. Rather than removing duplicates among the points as in the
FE_Q
case (as implemented via Add two level transfer operator between non-nested levels #15141), we need to take into account all values, as they in fact might be different on different sides for a discontinuous basis. This is done by constructing an auxiliary continuous finite element space, which has the same support points as the underlying DG space, which is underlying theRemotePointEvaluation
process.
So in some sense, this could be seen as a performance optimization to reduce the work to the points actually needing the information.
Is this understanding correct? If no, could you please help me understand where in the above chain my misunderstanding is? Use the comments below as guidance where my misunderstanding could come from.
If my understanding is correct, I am confused why we need the complicated code. The point I want to understand is what would happen with FE_DGQArbitraryNodes<dim>(QGauss<1>(degree+1))
. As I explain more thoroughly in one of my comments, also the usual FE_DGQ
could be interpreted as an arbitrary-nodes interpolation. As the grids will in general not be matching, I see no reason why we would stick to FE_DGQ
and not the more "accurate" one with Gauss quadrature points. This question evolved during the ~3 hours when reviewing this PR, spurred by offline discussions with @peterrum and the special cases you need for degree 0: In a sense, the degree 0 case is the prototypical FE_DGQArbitraryNodes(QGauss<1>(degree+1))
element, with unique points on the grid. My question would then be if, for all kinds of FE_DGQ*
elements, we should not always interpolate into some arbitrary support points that are rich enough first, and only later switch into the actual basis representation?
And finally, I would be wondering if/how we would want to proceed if we wanted to make some consistent projection from one grid to the other, say, by integration on cut sub-entities of the mesh where each entity has polynomial solutions from both sides as generated by CGAL intersections. Where would one put that in this framework?
I realize my request may sound overly picky and my questions might entirely miss the intent you have, but in fact I highly appreciate the work you've been doing, this is excellent work and helpful in a variety of contexts.
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
Assert(dof_handler.get_fe().degree == dof_handler_sp.get_fe().degree, | ||
ExcMessage("DoFhandlers need the same degree.")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need some additional requirements on the two spaces? Like the number of dofs_per_cell
on the base element being the same? Just because two FE spaces have the same degree does not mean they are compatible one-to-one. As far as I can see in the code below, you only check the degree of the finite element before you create the dof_handler_sp
, without ever looking at the unknowns. What would happen if I used this with FE_DGP
, https://dealii.org/developer/doxygen/deal.II/classFE__DGP.html?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out the missing Asserts
.
I added Asserts
to ensure the function can only be used with FE_DGQ
and FE_Q
. I also added an Assert
to ensure the same n_dofs_per_cell
which is indeed needed for now (and has to be deleted later when the function is extended such that it can be used to identify DoF indices for the same support point in the context of multiple components).
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
const auto global_dof_idx = | ||
needs_conversion ? dof_indices[to_hierarchic[i]] : | ||
dof_indices[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This assumes sp_indices.size() == dof_indices.size()
and the same position of support points, right? And that the dof_handler
actually have an underlying FiniteElement
with support points? I think we need to make additional assertions that the finite element spaces satisfy the underlying assumptions of this algorithm. This is an extension of the comment above, and to test what I mean, I suggest to consider the case of FE_DGQLegendre
, https://dealii.org/developer/doxygen/deal.II/classFE__DGQLegendre.html and see if that one also works.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will update the asserts tomorrow, I want to take the time to test this as suggested.
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
if (degree == 0) | ||
dof_handler_sp->distribute_dofs(FE_DGQ<dim, spacedim>(degree)); | ||
else | ||
dof_handler_sp->distribute_dofs(FE_Q<dim, spacedim>(degree)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand why this is necessary, given the comment of FE_DGQ<dim>(0)
you make above. There are also DG elements with unique support points, or in fact they could all be considered as having unique support points. My reasoning goes like this: The DG polynomial space is equivalent to the Lagrange basis in the Gaussian quadrature points, which are all located strictly inside the reference element. The reason why you do the averaging above (which took me a long time to understand, it is complicated) is that you assume the Gauss-Lobatto support points, which is however an arbitrary choice in a DG method. By construction, a DG element does not impose continuitiy in any way, so whether or not two support points coincide can be considered by chance but not systematic. I do not want to dispute that there are cases where achieving continuity in the interpolation between grids makes sense, but I would like to see some theoretic justification. I do really appreciate the effort you put into making the matching of unknowns work, but as I told to @peterrum offline, my question is what you would like to happen if I pass in FE_DGQArbitraryNodes<dim>(QGauss<1>(degree + 1));
. I summarize my point in the general introductory comment to this review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I completely agree and dependent on which direction we agree to move I will change this 👍
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
include/deal.II/multigrid/mg_transfer_global_coarsening.templates.h
Outdated
Show resolved
Hide resolved
As a note, several of the above theoretical questions do not need to be addressed immediately and can be considered part of the more general issue #15148, right now I would be happy with some clarifications to see the overall direction more clearly. |
@kronbichler Thank you for reviewing, I know the PR is quite lengthy and I highly appreciate it. I will try to answer your questions. If something remains unclear, please let me know. Before answering all the questions you left above, in detail, I would also like to discuss the main picture. This is because I see your point and would like to know in which direction we are targeting. During the development of the code, I actually only thought about The motivation is as follows: In case of continuous FEM it is possible to remove the duplicate DoF indices and directly access the DoF values in the vector. If we want to directly access the DoF values from a given vector for DG (instead of using additional evaluations) we have to scan for duplicate DoF indices corresponding to the same support point. The latter holds only true if support points are not strictly located inside elements. Interpolating into arbitrary support points first and switching to the basis representation afterward always requires the evaluation of shape functions instead of directly accessing components of a vector, and using the non-nested version on a nested (globally coarsened grid) would yield different results compared to directly applying the nested version. Apart from this, it has the advantage that it is possible to skip the scanning for indices at support points. I hope this clarifies the intent. I don't know in which direction we want to move here. One suggestion would be to keep the code as a fast path for the special case with Regarding where to place consistent projection using |
I let @fdrmrc comment on this topic, since he is currently working on this. But I think we agreed on an approach where one can configure the two-level transfer operator via an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @jh66637 for the extensive explanation. I am not sure either about the direction to take, I think your point is valid in terms of support points and "optimization" possibilities.
I think we would still get the same result, because the prolongation operation that gets implemented is an embedding for nested meshes: No matter what the basis representation on the fine scale is, it will always be able to exactly represent the coarse scale. And in fact, any Anyway, I suggest to proceed with the present PR, do the small tidy-up and address possible algorithmic strategies later. |
I also think the present version could be used as a fast path for
As written, what we were thinking about was indeed an I am working on I haven't thought about the |
2fab8a0
to
82d9273
Compare
This PR aims to integrate DG into the non-nested MG implementation and is a split off of #15148.
@peterrum @fdrmrc