Discontinuous Function Space Assembly

3 months ago by

I am trying to assemble certain expressions, but I get an ArityMismatch error. Here is a short snippet of code that reproduces this type of error:
from dolfin import *
from mshr import *

kappa = 1e-9
rho_f = Constant(3000)
g_const = 0.0
g = Constant((0.0,g_const))

# Mesh definition
X_MIN = 0.0
X_MAX = 1.0
Y_MIN = 0.0
Y_MAX = 3.0

mresolution = 100
mesh = RectangleMesh(Point(X_MIN,Y_MIN),Point(X_MAX,Y_MAX),mresolution, mresolution)

def q(p):
    return -kappa*(grad(p)-rho_f*g)

def test():
    # Test to see where the error in FEniCS assembly occurs (ArityMismatch).
    degree = 1
    element_equil = VectorElement('DG',mesh.ufl_cell(), degree)
    element_pressure = FiniteElement('DG',mesh.ufl_cell(), degree)
    element = MixedElement([element_equil,element_pressure])
    V = FunctionSpace(mesh, element)
    W = FunctionSpace(mesh, element_equil)
    Q = FunctionSpace(mesh, element_pressure)
    v = Function(V)
    (u, p) = split(v)
    (v1, v2) = TestFunctions(V)
    n = FacetNormal(mesh)
    # This works.
    print('First success.')
    # But this doesn't work.
    print('Second success.')

I get this error message:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***     fenics-support@googlegroups.com
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
*** -------------------------------------------------------------------------
*** Error:   Unable to perform just-in-time compilation of form.
*** Reason:  ffc.jit failed with message:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/dolfin/compilemodules/jit.py", line 142, in jit
    result = ffc.jit(ufl_object, parameters=p)
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 218, in jit
    module = jit_build(ufl_object, module_name, parameters)
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 134, in jit_build
  File "/usr/lib/python3/dist-packages/dijitso/jit.py", line 167, in jit
    header, source, dependencies = generate(jitable, name, signature, params["generator"])
  File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 67, in jit_generate
    prefix=module_name, parameters=parameters, jit=True)
  File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 143, in compile_form
    prefix, parameters, jit)
  File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 185, in compile_ufl_objects
    analysis = analyze_ufl_objects(ufl_objects, kind, parameters)
  File "/usr/lib/python3/dist-packages/ffc/analysis.py", line 94, in analyze_ufl_objects
    for form in forms)
  File "/usr/lib/python3/dist-packages/ffc/analysis.py", line 94, in <genexpr>
    for form in forms)
  File "/usr/lib/python3/dist-packages/ffc/analysis.py", line 178, in _analyze_form
  File "/usr/lib/python3/dist-packages/ufl/algorithms/compute_form_data.py", line 388, in compute_form_data
    check_form_arity(preprocessed_form, self.original_form.arguments())  # Currently testing how fast this is
  File "/usr/lib/python3/dist-packages/ufl/algorithms/check_arities.py", line 152, in check_form_arity
    check_integrand_arity(itg.integrand(), arguments)
  File "/usr/lib/python3/dist-packages/ufl/algorithms/check_arities.py", line 145, in check_integrand_arity
    args = map_expr_dag(rules, expr, compress=False)
  File "/usr/lib/python3/dist-packages/ufl/corealg/map_dag.py", line 37, in map_expr_dag
    result, = map_expr_dags(function, [expression], compress=compress)
  File "/usr/lib/python3/dist-packages/ufl/corealg/map_dag.py", line 86, in map_expr_dags
    r = handlers[v._ufl_typecode_](v, *[vcache[u] for u in v.ufl_operands])
  File "/usr/lib/python3/dist-packages/ufl/algorithms/check_arities.py", line 42, in sum
    raise ArityMismatch("Adding expressions with non-matching form arguments {0} vs {1}.".format(a, b))
ufl.algorithms.check_arities.ArityMismatch: Adding expressions with non-matching form arguments (Argument(FunctionSpace(Mesh(VectorElement(FiniteElement('Lagrange', triangle, 1), dim=2), 2), MixedElement(VectorElement(FiniteElement('Discontinuous Lagrange', triangle, 1), dim=2), FiniteElement('Discontinuous Lagrange', triangle, 1))), 0, None),) vs ().
*** Where:   This error was encountered inside jit.py.
*** Process: 0
*** DOLFIN version: 2017.2.0
*** Git changeset:  unknown
*** -------------------------------------------------------------------------​

Any thoughts?
Community: FEniCS Project
the code works if I comment out

What is the purpose of that term if g is a constant equal to zero?

written 3 months ago by Eleonora Piersanti  
Thank you. The value of g can be different - it's basically a placeholder in this code.
written 3 months ago by Saro  

1 Answer

3 months ago by
If you substitute the definition of \(q(v_2)\) into the second integrand, then use the linearity of the average and dot-with-\(\mathbf{n}\) operations, you can re-write the integral as something like
-kappa*avg(dot(grad(v2),n))*jump(p)*dS + kappa*avg(dot(rho_f*g,n))*jump(p)*dS​
In this case, you can see that the first form has a free argument (the test function, \(v_2\), giving it an arity of one), and would be assembled to a vector (with one entry for each finite element basis function), while the second form just integrates a scalar-valued function with no free arguments, and would assemble to a single scalar value (arity zero).  The vector and scalar cannot be added together, causing the error.
Thank you for the explanation.
written 3 months ago by Saro  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »