-
-
Notifications
You must be signed in to change notification settings - Fork 228
Fix interpolation onto submesh with maps requiring dof transformations #4038
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
base: main
Are you sure you want to change the base?
Conversation
|
Should there be changes in the core code too? I only see a new test in the PR. |
Yes, just waiting for the CI to fail before I push the fix. |
…of transformation
Fix pushed. |
garth-wells
left a comment
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.
Great to have this fixed. Suggested change of order for the if statement.
|
Looking further up in the function, we have auto mesh = u1.function_space()->mesh();
...
auto cell_map0 = mesh->topology()->index_map(mesh->topology()->dim());This looks a bit wrong (in a way related to what this PR fixes). We have I'd suggest changing auto mesh = u1.function_space()->mesh();to auto mesh1 = u1.function_space()->mesh();and checking for This would also make the fix in this PR clearer with: if ((mesh1 == u0.function_space()->mesh()) and (element1 == element0 or *element1 == *element0)) |
Clarification pushed. auto mesh1 = u1.function_space()->mesh();
assert(mesh1);
assert(cells0.size() == cells1.size());
auto cell_map1 = mesh1->topology()->index_map(mesh1->topology()->dim());
assert(cell_map1);
std::size_t num_cells1 = cell_map1->size_local() + cell_map1->num_ghosts();
if (u1.function_space() == u0.function_space()
and cells0.size() == num_cells1)which in theory could be wrong, as auto mismatch = std::mismatch(cells0.begin(),cells0.end(), cells1.begin());
if (u1.function_space() == u0.function_space()
and cells0.size() == num_cells1 and mismatch.first()==cells0.end())Stand alone example of proper check (tested in godbolt): #include<vector>
#include<algorithm>
#include<cstdint>
#include<iostream>
#include<iterator>
#include<ranges>
int main ()
{
std::vector<std::int32_t> a = {0,1,2,3,5,4};
std::vector<std::int32_t> c = {0,1,2,4,4,5};
[[maybe_unused]] auto [first, last] = std::mismatch(a.begin(), a.end(), c.begin());
[[maybe_unused]] auto [first_iota, last_iota] = std::mismatch(a.begin(), a.end(), std::ranges::iota_view{0, (int)a.size()}.begin());
std::cout << std::distance(a.begin(), first) << "\n";
std::cout << std::distance(a.begin(), first_iota) << "\n";
return 1;
}which returns 3
4 |
|
@garth-wells I've added a progressive check that tests if: A check to test this has been added to the code. |
Two bug fixes:
Interpolation onto submesh with same element type
Currently, interpolation from space A to space B doesn't use permutation info if element_A == element_B.
However, this is not correct when working with submeshes, as the cell_permutation_data might be different between the meshes.
The initial issue was discovered by @afasil9 when working on TEAM30 (https://github.com/Wells-Group/TEAM30/).
This pull request add a test that fails on 2,3 and 4 processors on main and a fix to interpolate.
Interpolation onto same function space (and mesh), with subset of cells
If the number of cells (
cells0.size()) passed intou.interpolate(v, cells0=cells0)matches the number of cells on the process (including ghosts), we currently assume that
cells0=np.arange(num_cells_on_process), which is not True, as cells0 can contain duplicate cells.This is fixed by adding a progressive set of checks to determine if this is True.