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
MGLevelGlobalTransfer/MGTransferMatrixFree: allow user to init vectors #11871
Conversation
325af78
to
dea03f4
Compare
I have not looked into the code yet, but this is a good help. We should keep an eye on whether or not this can be combined with the code currently used for a similar purpose dealii/include/deal.II/multigrid/mg_transfer_matrix_free.h Lines 102 to 106 in 179a496
|
@kronbichler I guess you know what the intention is for the new lamda function: the class My question is the following: if I fill One minor question: why did you use |
Yes, the intention is to get the same result - the setup of the transfer class should check if the partitioner it needs is compatible with the one provided externally, which means that the MG transfer should only need ghosts which are already in the user-provided partitioner. In case it needs more indices, which happens sooner or later as we progress to coarser levels (in my experience, all levels but the finest one), it needs to keep a second set of local vectors and partitioners, which we then copy back and forth into. But since the problem sizes for all but the largest level are already ~8x smaller (in 3D and h-mg or p-mg with bisection), the copy for the small sizes is more tolerable as the largest one. So we could use that approach in my opinion, but I think we still need to give it some thought as to which variant we prefer. I lean towards preferring your approach with lambdas, as the user does not need to collect things and can merely use the given level argument. Also, I have not checked yet if it obviates the |
@kronbichler Thanks for the details! I will investigate this in the next days and will take a look if I can integrate the same optimizations in the global-coarsening approach. Furthermore, I could image to move the lambda to the |
dea03f4
to
011b9d3
Compare
if (external_partitioners.size() > 0) | ||
this->initialize_dof_vector = | ||
[&external_partitioners]( | ||
const unsigned int level, | ||
LinearAlgebra::distributed::Vector<Number> &vec) { | ||
vec.reinit(external_partitioners[level]); | ||
}; |
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.
@kronbichler I have rebased this PR and have converted the vector of partitioners internally to a lambda function. What do you think. As far as I see it, the approach with adjust_ghost_range_if_necessary()
is broken, since Multigrid
will reset the partitioners in each cycle and I don't see a way to fix this. We might also want to consider to update step-59.
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 you mean that it calls adjust_ghost_range_if_necessary
exactly once per level in each multigrid iteration (as the vector is reset upon copy_to_mg
)? Either way, as discussed in the post below, I think we should improve the initialization of all vectors to avoid these kind of operations.
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 you mean that it calls adjust_ghost_range_if_necessary exactly once per level in each multigrid iteration (as the vector is reset upon copy_to_mg)?
Yes. That is the case.
I have given this some more thought. I think experience has shown that we need a better way to initialize the vectors that we use inside the multigrid algorithm. However, let us discuss where the right place for this action, as I am not sure if the transfer classes are the right place:
|
9172498
to
dea03f4
Compare
dea03f4
to
706a2c5
Compare
Have you all given this issue some more thought? |
@kronbichler I have made the modification. Could you take a look at the last commit; it is not optimal, since I need somehow access to the partitioner, I need to create a temporal vector... |
eb4d4d5
to
f77bd55
Compare
doc/news/changes/minor/20210309Munch
Outdated
@@ -0,0 +1,7 @@ | |||
New: The classes MGTransferMatrixFree::build() now also |
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.
New: The classes MGTransferMatrixFree::build() now also | |
New: The class MGTransferMatrixFree::build() now also |
doc/news/changes/minor/20210309Munch
Outdated
New: The classes MGTransferMatrixFree::build() now also | ||
accepts an optional function for initializing the internal level vectors. | ||
This is useful if one uses the the transfer operators in the context of | ||
smoothers that are build around MatrixFree objects. |
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.
smoothers that are build around MatrixFree objects. | |
smoothers that are built around MatrixFree objects. |
f77bd55
to
ad09d6f
Compare
@kronbichler I have fixed both typos! |
/rebuild |
Similar to:
dealii/include/deal.II/multigrid/mg_transfer_global_coarsening.h
Lines 353 to 356 in 15440af
Not completely finished. I'll continue tomorrow. Hopefully, this is the start of the end of
adjust_ghost_range_if_necessary()
and the derivedMGTransferMatrixFree
operators that only extendcopy_to_mg()
.