-
Notifications
You must be signed in to change notification settings - Fork 160
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
Fix coarsening for R space #3814
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import pytest | ||
import numpy | ||
import warnings | ||
from firedrake import * | ||
from firedrake.mg.ufl_utils import coarsen | ||
from firedrake.utils import complex_mode | ||
|
@@ -131,3 +132,25 @@ def test_transfer_manager_dat_version_cache(action, transfer_op, spaces): | |
|
||
else: | ||
raise ValueError(f"Unrecognized action {action}") | ||
|
||
|
||
@pytest.mark.parametrize("family, degree", [("CG", 1), ("R", 0)]) | ||
def test_cached_transfer(family, degree): | ||
# Test that we can properly reuse transfers within solve | ||
sp = {"mat_type": "matfree", | ||
"pc_type": "mg", | ||
"mg_coarse_pc_type": "none", | ||
"mg_levels_pc_type": "none"} | ||
|
||
base = UnitSquareMesh(1, 1) | ||
hierarchy = MeshHierarchy(base, 3) | ||
mesh = hierarchy[-1] | ||
|
||
V = FunctionSpace(mesh, family, degree) | ||
u = Function(V) | ||
F = inner(u - 1, TestFunction(V)) * dx | ||
|
||
# This test will fail if we raise this warning | ||
with warnings.catch_warnings(): | ||
warnings.filterwarnings("error", "Creating new TransferManager", RuntimeWarning) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks very fragile. If we decided not to emit this warning any more, or even changed the content of the warning message, then this would always pass regardless of whether or not we were actually reusing transfer managers. Is a better way to do this not to somehow retrieve the transfer managers from whatever mesh/DM they are attached to and check that they are the same? |
||
solve(F == 0, u, solver_parameters=sp) |
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.
Not sure whether Right or Left is the correct thing here. But it does not really matter if the sizes are the same.