-
-
Notifications
You must be signed in to change notification settings - Fork 169
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
Use combined W matrix for primary and secondary data in IQN #2010
base: develop
Are you sure you want to change the base?
Conversation
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.
Looks promising!
I guess the SVD changes could go to a separate refactoring PR.
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 to see how these changes reduce code duplication 👍
Still a bit of work to do, especially for parallel runs I guess, see below.
Requires a changelog as we now have support of secondary data for IMVJ
virtual std::vector<int> getDataIDs() const | ||
{ | ||
return _dataIDs; | ||
return _primaryDataIDs; | ||
} |
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.
Let's change the name of this function as well.
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.
For the whole acceleration method? Other under-relaxation methods also use this function
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.
For Aitken, we in principle also have the primary vs secondary story.
size_t unknowns = _dimOffsets[utils::IntraComm::getRank() + 1] - _dimOffsets[utils::IntraComm::getRank()]; | ||
PRECICE_ASSERT(entries == unknowns, entries, unknowns); | ||
// size_t unknowns = _dimOffsets[utils::IntraComm::getRank() + 1] - _dimOffsets[utils::IntraComm::getRank()]; | ||
// PRECICE_ASSERT(entries == unknowns, entries, unknowns); //? |
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 tricky point. Should _dimOffsets
include secondary data or not? Probably makes a difference for IMVJ. Let's try to also add a test with secondary data that runs in parallel.
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.
Since it's used to initialize the size of Wtil
, I would say that the _dimOffsets
should include the secondary data. But I'm a little confused with this function now:
precice/src/acceleration/BaseQNAcceleration.cpp
Lines 626 to 632 in 8458db5
int BaseQNAcceleration::getLSSystemRows() | |
{ | |
if (utils::IntraComm::isParallel()) { | |
return _dimOffsets.back(); | |
} | |
return _primaryResiduals.size(); | |
} |
In the extended tests, the parallel tests with IMVJ include also secondary data. They could work with this implementation here(secondary data included in the
_dimOffsets
). This assert should be modified a bit then.
PRECICE_ASSERT(_oldPrimaryResiduals.size() == _oldPrimaryXTilde.size(), _oldPrimaryResiduals.size(), _oldPrimaryXTilde.size()); | ||
PRECICE_ASSERT(_primaryValues.size() == _oldPrimaryXTilde.size(), _primaryValues.size(), _oldPrimaryXTilde.size()); | ||
PRECICE_ASSERT(_oldPrimaryValues.size() == _oldPrimaryXTilde.size(), _oldPrimaryValues.size(), _oldPrimaryXTilde.size()); | ||
PRECICE_ASSERT(_primaryResiduals.size() == _oldPrimaryXTilde.size(), _primaryResiduals.size(), _oldPrimaryXTilde.size()); | ||
|
||
// assume data structures associated with the LS system can be updated easily. | ||
|
||
// scale data values (and secondary data values) |
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.
Is this comment correct? I don't think that there is any scaling in there.
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.
Only concatenate happens until the next comment
_residuals *= _initialRelaxation; | ||
_residuals += _oldValues; | ||
_values = _residuals; | ||
_values = _oldValues + _residuals; |
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.
Is this correct? Now _residuals
has a different value.
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.
From the test results I didn't see difference. If you mean that the _residuals
is not updated here, I see that the _residuals
would be calculated from _values
and _oldValues
by updating differences and is not stored like _values
, so the step here still 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.
If you mean that the _residuals is not updated here
Exactly.
If such a change is unrelated to this PR, I would always do it separately as a refactoring. Otherwise, we might get side effects.
From the test results I didn't see difference
Remember that tests are never perfect.
@@ -136,7 +136,6 @@ class ParallelMatrixOperations { | |||
|
|||
PRECICE_ASSERT(_needCyclicComm); | |||
PRECICE_ASSERT(leftMatrix.cols() == q, leftMatrix.cols(), q); | |||
PRECICE_ASSERT(leftMatrix.rows() == rightMatrix.cols(), leftMatrix.rows(), rightMatrix.cols()); |
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.
Removing this doesn't feel good.
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.
In the comment it says that For multiplication W_til * Z = J, p = r = n_global, q = m
, which is not the case now. I'm not so sure why this assertion is necessary for the operation unless these two variables are mixed used. Need to check.
PRECICE_WARN_IF(M.cols() < (int) _weights.size(), "Matrix and weights size mismatch, only part of the preconditioning weights will be used."); | ||
PRECICE_WARN_IF(M.cols() > (int) _weights.size(), "Matrix and weights size mismatch, only part of the matrix will be preconditioned."); |
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.
Let's find a better solution here. Such warnings will confuse 99% of users.
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.
Could we add unit tests to cover these 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.
I still think it would be better to do these changes in a separate PR before this one. And add unit tests for the new functionality.
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.
How about do one PR for SVD and one preconditioning and one for IQN itself
Main changes of this PR
The secondary data is handled together with primary data in the
W
matrix both in IQN-ILS and IQN-IMVJ method.Motivation and additional information
Relating to #1996
To do
secondaryDataIDs
and_values
with only primary data are still needed; -> Yes, for computingV
, warn zero update ofV
;Wtil
should still be done, currently commented out;Author's checklist
pre-commit
hook to prevent dirty commits and usedpre-commit run --all
to format old commits.Reviewers' checklist