# Showing error while solving an interface problem

Hello everyone

Below I am attaching a minimal example of interface problem in which I am trying to solve
a(u,v) =0 and a(u,v) = a(u_e,v) so that u converges to u_e.

But It shows an error. Can you provide me a reason why this happen ?

u_exS  = Expression(("-cos(pi*x[0])*sin(pi*x[1])","sin(pi*x[0])*cos(pi*x[1])"), degree=5, domain=mesh)
p_exS  = Expression("cos(pi*x[0])*cos(pi*x[1])", degree=5, domain=mesh)
u_exD  = Expression(("-cos(pi*x[0])*sin(pi*x[1])","sin(pi*x[0])*cos(pi*x[1])"), degree=5, domain=mesh)
p_exD  = Expression("cos(pi*x[0])*cos(pi*x[1])", degree=5, domain=mesh)

lam_ex = -p_exD('-')

FvS = 2.0 * nu * inner(epsilon(u_exS), epsilon(vS)) * dx(stokes) + alpha*nu/sqrt(kappa)*dot(u_exS('+'),t('+'))*dot(vS('+'),t('+'))*dS(interf) - p_exS * div(vS) * dx(stokes) +  avg(lam_ex) * dot(vS('+'),n('+')) * dS(interf)


Error

Calling FFC just-in-time (JIT) compiler, this may take some time.
Cannot restrict an expression twice.
Traceback (most recent call last):
File "/home/aparna/stokes-biots/exact.py", line 159, in <module>
FF = block_assemble(rhs)
File "/home/aparna/.local/lib/python3.10/site-packages/multiphenics/fem/block_assemble.py", line 38, in block_assemble
block_form = BlockForm(block_form, form_compiler_parameters=form_compiler_parameters)
File "/home/aparna/.local/lib/python3.10/site-packages/multiphenics/fem/block_form.py", line 38, in BlockForm
return BlockForm1(replaced_block_form, block_function_space, form_compiler_parameters)
File "/home/aparna/.local/lib/python3.10/site-packages/multiphenics/fem/block_form_1.py", line 48, in __init__
replaced_block_form[I] = _create_dolfin_form(
File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/assembling.py", line 60, in _create_dolfin_form
return Form(form,
File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/fem/form.py", line 43, in __init__
ufc_form = ffc_jit(form, form_compiler_parameters=form_compiler_parameters,
File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py", line 50, in mpi_jit
return local_jit(*args, **kwargs)
File "/usr/lib/petsc/lib/python3/dist-packages/dolfin/jit/jit.py", line 100, in ffc_jit
return ffc.jit(ufl_form, parameters=p)
File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 217, in jit
module = jit_build(ufl_object, module_name, parameters)
File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 130, in jit_build
module, signature = dijitso.jit(jitable=ufl_object,
File "/usr/lib/python3/dist-packages/dijitso/jit.py", line 165, in jit
header, source, dependencies = generate(jitable, name, signature, params["generator"])
File "/usr/lib/python3/dist-packages/ffc/jitcompiler.py", line 65, in jit_generate
code_h, code_c, dependent_ufl_objects = compile_object(ufl_object,
File "/usr/lib/python3/dist-packages/ffc/compiler.py", line 142, in compile_form
return compile_ufl_objects(forms, "form", object_names,
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 89, in analyze_ufl_objects
form_datas = tuple(_analyze_form(form, parameters)
File "/usr/lib/python3/dist-packages/ffc/analysis.py", line 89, in <genexpr>
form_datas = tuple(_analyze_form(form, parameters)
File "/usr/lib/python3/dist-packages/ffc/analysis.py", line 169, in _analyze_form
form_data = compute_form_data(form,
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/compute_form_data.py", line 321, in compute_form_data
form = apply_restrictions(form)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/apply_restrictions.py", line 170, in apply_restrictions
return map_integrand_dags(rules, expression,
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/map_integrands.py", line 46, in map_integrand_dags
return map_integrands(lambda expr: map_expr_dag(function, expr, compress),
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/map_integrands.py", line 27, in map_integrands
mapped_integrals = [map_integrands(function, itg, only_integral_type)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/map_integrands.py", line 27, in <listcomp>
mapped_integrals = [map_integrands(function, itg, only_integral_type)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/map_integrands.py", line 35, in map_integrands
return itg.reconstruct(function(itg.integrand()))
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/map_integrands.py", line 46, in <lambda>
return map_integrands(lambda expr: map_expr_dag(function, expr, compress),
File "/usr/lib/python3/dist-packages/ufl_legacy/corealg/map_dag.py", line 36, in map_expr_dag
result, = map_expr_dags(function, [expression], compress=compress,
File "/usr/lib/python3/dist-packages/ufl_legacy/corealg/map_dag.py", line 97, in map_expr_dags
r = handlers[v._ufl_typecode_](v)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/apply_restrictions.py", line 39, in restricted
return map_expr_dag(self._rp[side], o.ufl_operands[0],
File "/usr/lib/python3/dist-packages/ufl_legacy/corealg/map_dag.py", line 36, in map_expr_dag
result, = map_expr_dags(function, [expression], compress=compress,
File "/usr/lib/python3/dist-packages/ufl_legacy/corealg/map_dag.py", line 97, in map_expr_dags
r = handlers[v._ufl_typecode_](v)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/apply_restrictions.py", line 36, in restricted
error("Cannot restrict an expression twice.")
File "/usr/lib/python3/dist-packages/ufl_legacy/log.py", line 158, in error
raise self._exception_type(self._format_raw(*message))
ufl_legacy.log.UFLException: Cannot restrict an expression twice.


this is at least a place where a variable is restricted twice, once in the definition of lam_ex and the other when using avg on it.

Okay sir, Thank you for the response