-
Notifications
You must be signed in to change notification settings - Fork 90
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
Petsc interface generalisation #1889
Conversation
Rather than assuming that a certain subsect of guard cells should be included in a PETSc vector, it now computes which ones should be included using an OperatorStencil. This required some fairly significant refactoring so that the vector and matrix constructors now must take an indexer object as an argument. The indexer stores the information on which guard cells should be included and on the sparsity pattern of a matrix.
These routines (`localSizeXX` and `globalStartIndexXX`) now depend on the OperatorStencil being used and thus would not return a single value for a given mesh. The necessary calculations are now performed in the GlobalIndexer class.
This just represents which cells are used to perform the operation, rather than the weighting on those cells. This can be used when constructing matrix representations of the operation to work out the layout of non-zero matrix elements. This is useful for preallocating memory in PETSc matrices.
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 good! I like the new way of getting the "thin" regions.
More methods on the PetscVector/Matrix could be made const
. I'd try to make all of them const
at first and them remove const
until it works.
Please you could apply clang-format to these changes too?
Thanks for the comments. Some of these are duplicates of those on #1803, which I am in the process of addressing right now and will place on this branch once ready. |
@ZedThree I'm not sure if many more methods on the vector and matrix classes should be made A question on style/convention when it comes to these issues: is it every appropriate to apply |
You're right that's there's not much more on the vector/matrix classes that could be Indeed, a
Element operator()(const ind_type& row, const ind_type& column);
BoutReal operator()(const ind_type& row, const ind_type& column) const; where the latter just gets the value directly. You could return a I think |
Yes, unfortunately Currently I have methods to convert from an Yes, I'd already spotted that |
I believe the latest push should address all of your comments. I think it should pass the CI too, although we'll find out in an hour or so. |
Just to be clear on the Also Neither of these are blocking changes and can be fixed later, I just wanted to clarify my earlier points! * except via a timing side-channel, and we don't care about that here. |
There are some issues with the OpenMP builds which I am currently addressing. More concerning are the failures with the |
The clang build has some warnings about inconsistent or missing OpenMP I guess you've got sorted, but probably due to the gtest |
I've fixed those issues but the errors with the clang run still persist. What is even stranger is that one of the OpenMP runs still breaks: the one built with CMake. The autoconf build works just fine, despite apparently using the same build-options as the CMake one. I have no idea what could be causing that problem. |
This results in unnecessary computations and risks invalidating existing pointers to the vector data containing this data. This didn't appear to be an issue with GCC but did cause problems when compiling with clang.
The problem in the |
I don't fully understand what the issue was, but it appears the constructor/destructor pair was not being called properly for PetscLib. This resulted in PETSc not being properly initialised for later tests. Whatever the exact details, the problem arose in IndexerTest/TestGetRegionBndry and seems to have been related to a for-loop with the iterator being a reference to a GlobalIndexer object. Switching to using pointers got rid of the problem.
I don't fully understand what the issue was with the CMake/OpenMP case. However, it seems that IndexerTest/TestGetRegionBndry was not properly cleaning up after itself, resulting in PETSc not being properly initialised in future tests. The problem seems to have been related to a for-loop with the iterator being a reference to GlobalIndexer objects. Switching to using pointers got rid of the problem (when running locally, at least). |
@ZedThree |
Thanks @cmacmackin ! I suspect the issue with that test was something to do with making a copy of the |
I already did this for pull request #1889 but it seems those changes got reverted on a merge.
As described in #1873, this generalises the PETSc interface so it can be used on a wider variety of problems. This PR contains two significant changes:
These changes will eventually be merged as part of #1803, but as work is ongoing to apply the PETSc interface to other parts of the code I thought it would be best to get them merged into
next
ASAP.