Skip to content
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

Error assembling forms involving vector R0 functions #1456

Open
jrmaddison opened this issue Jun 18, 2019 · 2 comments
Open

Error assembling forms involving vector R0 functions #1456

jrmaddison opened this issue Jun 18, 2019 · 2 comments

Comments

@jrmaddison
Copy link
Contributor

For example:

from firedrake import *

mesh = UnitSquareMesh(10, 10)
vspace = VectorFunctionSpace(mesh, "R", 0)
test, trial = TestFunction(vspace), TrialFunction(vspace)

M = assemble(inner(test, trial) * dx)

leads to the error

UFL:ERROR Replacement expressions must have the same shape as what they replace.
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    M = assemble(inner(test, trial) * dx)
  File "[..]/firedrake/src/firedrake/firedrake/assemble.py", line 105, in assemble
    loops = tuple(loops)
  File "[..]/firedrake/src/firedrake/firedrake/assemble.py", line 228, in _assemble
    kernels = tsfc_interface.compile_form(f, "form", parameters=form_compiler_parameters, inverse=inverse)
  File "[..]/firedrake/src/firedrake/firedrake/tsfc_interface.py", line 206, in compile_form
    f = _real_mangle(f)
  File "[..]/firedrake/src/firedrake/firedrake/tsfc_interface.py", line 233, in _real_mangle
    return ufl.replace(form, replacements)
  File "[..]/firedrake/src/ufl/ufl/algorithms/replace.py", line 69, in replace
    return map_integrand_dags(Replacer(mapping2), e)
  File "[..]/firedrake/src/ufl/ufl/algorithms/replace.py", line 38, in __init__
    error("Replacement expressions must have the same shape as what they replace.")
  File "[..]/firedrake/src/ufl/ufl/log.py", line 172, in error
    raise self._exception_type(self._format_raw(*message))
ufl.log.UFLException: Replacement expressions must have the same shape as what they replace.
@wence-
Copy link
Contributor

wence- commented Jun 18, 2019

There are two issues here:

  1. _real_mangle assumes scalar RealFunctionSpace (one could fix that by just making a vector of 1 of appropriate shape)

  2. I don't think the rest of the code will work.

@jrmaddison
Copy link
Contributor Author

Some related examples:

from firedrake import *

mesh = UnitIntervalMesh(10)

vspace = VectorFunctionSpace(mesh, "R", degree=0, dim=2)
v_F = Function(vspace, name="v_F")
v_F.assign(Constant((1.0, 1.0)))

print(assemble(dot(v_F, Constant((1.0, 1.0))) * dx))

and:

from firedrake import *

mesh = UnitIntervalMesh(10)

tspace = TensorFunctionSpace(mesh, "R", degree=0, shape=(2, 2))
t_F = Function(tspace, name="t_F")
t_F.assign(Constant(((1.0, 1.0), (1.0, 1.0))))

print(assemble(inner(t_F, Constant(((1.0, 1.0), (1.0, 1.0)))) * dx)) 

lead to LoopyError s (long error messages). Switching "R" to "DG" yields the correct results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants