You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
In MeshHierarchy, users can specify how many refinement_levelsand how many refinements_per_level they want. If refinements_per_level is not 1, 2, or 4 (or probably any power of 2), then restrict and prolong raise a KeyError (it seems because there's a mismatch with the number of dofs).
Steps to Reproduce
This minimal example
from firedrake import *
mesh = UnitSquareMesh(2,2)
for n in range(1, 6):
print("\nrefinements_per_level = ", n)
# refinement_levels=1, refinements_per_level=n
mh = MeshHierarchy(mesh, 1, n)
# Coarse space
V_coarse = FunctionSpace(mh[0], "CG", 2)
V_coarse_dual = V_coarse.dual()
# Fine space
element = V_coarse.ufl_element()
V_fine = FunctionSpace(mh[-1], element)
V_fine_dual = V_fine.dual()
# restrict cofunction from V_fine_dual to V_coarse_dual
F_fine = Cofunction(V_fine_dual)
F_coarse = Cofunction(V_coarse_dual)
try:
restrict(F_fine, F_coarse)
print("restrict works")
except Exception as e:
print("restrict does not work, the error is:")
print(e)
# prolong function from V_coarse into V_fine
u_coarse = Function(V_coarse)
u_fine = Function(V_fine)
try:
prolong(u_coarse, u_fine)
print("prolong works")
except Exception as e:
print("prolong does not work, the error is:")
print(e)
outputs
refinements_per_level = 1
restrict works
prolong works
refinements_per_level = 2
restrict works
prolong works
refinements_per_level = 3
restrict does not work, the error is:
Fraction(54043195528445951, 54043195528445952)
prolong does not work, the error is:
Fraction(6004799503160661, 18014398509481984)
refinements_per_level = 4
restrict works
prolong works
refinements_per_level = 5
restrict does not work, the error is:
Fraction(90071992547409921, 90071992547409920)
prolong does not work, the error is:
Fraction(3602879701896397, 18014398509481984)
Expected behavior
From the documentation, this should work with any integer value.
Error message
here is one of the backtraces:
Traceback (most recent call last):
File "/Users/alberto/Documents/FIREDRAKE/firedrake/src/firedrake/firedrake/mg/kernels.py", line 224, in prolong_kernel
return cache[key]
~~~~~^^^^^
KeyError: ('prolong', (0, (0,), (1,), (2,)), (1, (3,), (4,), (5,)), (2, ()), (0, (0,), (1,), (2,)), (1, (), (), ()), (2, ()))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/alberto/Documents/FIREDRAKE/fireshape/examples/levelset/multigridfail.py", line 32, in <module>
prolong(u_coarse, u_fine)
File "petsc4py/PETSc/Log.pyx", line 188, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "petsc4py/PETSc/Log.pyx", line 189, in petsc4py.PETSc.Log.EventDecorator.decorator.wrapped_func
File "/Users/alberto/Documents/FIREDRAKE/firedrake/src/firedrake/firedrake/mg/interface.py", line 75, in prolong
kernel = kernels.prolong_kernel(coarse)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/alberto/Documents/FIREDRAKE/firedrake/src/firedrake/firedrake/mg/kernels.py", line 282, in prolong_kernel
"ncandidate": hierarchy.fine_to_coarse_cells[levelf].shape[1],
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
KeyError: Fraction(6004799503160661, 18014398509481984)
Describe the bug
In MeshHierarchy, users can specify how many
refinement_levels
and how manyrefinements_per_level
they want. Ifrefinements_per_level
is not 1, 2, or 4 (or probably any power of 2), then restrict and prolong raise aKeyError
(it seems because there's a mismatch with the number of dofs).Steps to Reproduce
This minimal example
outputs
Expected behavior
From the documentation, this should work with any integer value.
Error message
here is one of the backtraces:
Environment:
The text was updated successfully, but these errors were encountered: