Skip to content
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

PreconditionRelaxation: automatically determine omega #16742

Merged
merged 1 commit into from Mar 13, 2024

Conversation

peterrum
Copy link
Member

@peterrum peterrum commented Mar 9, 2024

by reusing the infrastructure used by PreconditionChebyshev

Copy link
Member

@blaisb blaisb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nothing to report on my side. This will be very useful for people using the matrix free architecture

Copy link
Member

@kronbichler kronbichler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR introduces a relatively large amount of copy-paste. I would prefer if we could try to unify more code by base classes or free functions, to reduce the duplicated code? That said, it does not necessarily have to happen now in this PR, if it happens in the near future.

@@ -2756,7 +2756,7 @@ AffineConstraints<number>::copy_from(
lines.clear();
lines.reserve(other.lines.size());

for (const auto l : other.lines)
for (const auto &l : other.lines)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unrelated, or does it have to do with the other code in the PR, e.g. the test? (I don't think we need to be overly formal and open another PR, I'll approve it with this).

include/deal.II/lac/precondition.h Show resolved Hide resolved
Comment on lines 552 to 567

/**
* Constraints to be used for the operator given. This variable is used to
* zero out the correct entries when creating an initial guess.
*/
AffineConstraints<double> constraints;

/**
* Stores the preconditioner object that the Chebyshev is wrapped around.
*/
EigenvalueAlgorithm eigenvalue_algorithm;

/**
* Preconditioner.
*/
std::shared_ptr<PreconditionerType> preconditioner;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the comments given here are the same as in the Chebyshev class (this looks like copy-paste), would it make sense to introduce a base class and let PreconditionChebyshev::AdditionalData inhert from that class? I fear that having the same members and same documentation two times will lead to divergence with hard-to-understand concepts in the future. Inheritance should also be completely backwards compatible.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have introduced a base class. PreconditionRelaxation::AdditionalData now adds relaxation and n_iterations and PreconditionChebyshev::AdditionalData degree and polynomial_type. What do you think?

Comment on lines +2864 to +2838
PreconditionRelaxation<MatrixType, PreconditionerType>::estimate_eigenvalues(
const VectorType &src) const
{
Assert(eigenvalues_are_initialized == false, ExcInternalError());

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also here it appears as if we have redundancy and copy-paste from the other code. Could you try to unify more?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relevant lines of codes are already shared via the internal function internal::estimate_eigenvalues. PreconditionRelaxation and PreconditionChebyshev need to do some additional/different steps since 1) PreconditionRelaxation does not store the vectors and 2) the estimated eigenvalues are used differently. What would you move additionally to the internal function?

Copy link
Member

@kronbichler kronbichler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the changes, I think with these changes we have a minimal overlap, this is good to go except for a few documentation fixes as listed below.

include/deal.II/lac/precondition.h Outdated Show resolved Hide resolved
include/deal.II/lac/precondition.h Outdated Show resolved Hide resolved
include/deal.II/lac/precondition.h Outdated Show resolved Hide resolved
include/deal.II/lac/precondition.h Outdated Show resolved Hide resolved
protected:
/**
* Pointer to the matrix object.
*/
SmartPointer<const MatrixType, PreconditionRelaxation<MatrixType>> A;

/**
* Relaxation parameter.
* Stores the additional data passed to the initialize function, obtained
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Stores the additional data passed to the initialize function, obtained
* Store the additional data passed to the initialize function, obtained

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left this how it was since there multiple places in the documentation which use stores the same way.

include/deal.II/lac/precondition.h Outdated Show resolved Hide resolved
include/deal.II/lac/precondition.h Outdated Show resolved Hide resolved
@peterrum
Copy link
Member Author

@kronbichler Thank you for the comments to improve the docu. I have applied the changes. Let me know whether it is fine now. I will squash the comments after that.

@kronbichler kronbichler merged commit f20f8d3 into dealii:master Mar 13, 2024
16 checks passed
blaisb pushed a commit to chaos-polymtl/lethe that referenced this pull request Mar 15, 2024
Description of the problem
The eigenvalue estimation for the smoother of the multigrid preconditioners was done through a PreconditionChebyshev.

Description of the solution
Due to recent changes in deal.II (dealii/dealii#16742), now we are able to do it using the PreconditionRelaxation directly. This allows us to remove the estimate omega function since it is done internally by the smoother if the relaxation parameter is set to 1. This allows also to remove the degree parameter that was only used in the case of Chebyshev.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants