Dear ladies and gentlemen,
When I run this content of the official tutorial, I get the following error: https://notebooks.gesis.org/binder/Jupiter/user/jorgensd-dolfinx-tutorial-ta2rzfcq/lab/tree/chapter1/fundamentals_ code.ipynb:
from dolfinx.fem.petsc import LinearProblem
problem = LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
uh = problem.solve()
---------------------------------------------------------------------------
ArityMismatch Traceback (most recent call last)
Cell In[9], line 2
1 from dolfinx.fem.petsc import LinearProblem
----> 2 problem = LinearProblem(a, L, bcs=[bc], petsc_options={"ksp_type": "preonly", "pc_type": "lu"})
3 uh = problem.solve()
File /usr/local/dolfinx-complex/lib/python3.10/dist-packages/dolfinx/fem/petsc.py:588, in LinearProblem.__init__(self, a, L, bcs, u, petsc_options, form_compiler_options, jit_options)
556 def __init__(self, a: ufl.Form, L: ufl.Form, bcs: typing.List[DirichletBC] = [],
557 u: typing.Optional[_Function] = None,
558 petsc_options: typing.Optional[dict] = None,
559 form_compiler_options: typing.Optional[dict] = None,
560 jit_options: typing.Optional[dict] = None):
561 """Initialize solver for a linear variational problem.
562
563 Args:
(...)
586 "pc_factor_mat_solver_type": "mumps"})
587 """
--> 588 self._a = _create_form(a, form_compiler_options=form_compiler_options, jit_options=jit_options)
589 self._A = create_matrix(self._a)
590 self._L = _create_form(L, form_compiler_options=form_compiler_options, jit_options=jit_options)
File /usr/local/dolfinx-complex/lib/python3.10/dist-packages/dolfinx/fem/forms.py:188, in form(form, dtype, form_compiler_options, jit_options)
185 return list(map(lambda sub_form: _create_form(sub_form), form))
186 return form
--> 188 return _create_form(form)
File /usr/local/dolfinx-complex/lib/python3.10/dist-packages/dolfinx/fem/forms.py:183, in form.<locals>._create_form(form)
180 """Recursively convert ufl.Forms to dolfinx.fem.Form, otherwise
181 return form argument"""
182 if isinstance(form, ufl.Form):
--> 183 return _form(form)
184 elif isinstance(form, collections.abc.Iterable):
185 return list(map(lambda sub_form: _create_form(sub_form), form))
File /usr/local/dolfinx-complex/lib/python3.10/dist-packages/dolfinx/fem/forms.py:141, in form.<locals>._form(form)
139 if mesh is None:
140 raise RuntimeError("Expecting to find a Mesh in the form.")
--> 141 ufcx_form, module, code = jit.ffcx_jit(mesh.comm, form,
142 form_compiler_options=form_compiler_options,
143 jit_options=jit_options)
145 # For each argument in form extract its function space
146 V = [arg.ufl_function_space()._cpp_object for arg in form.arguments()]
File /usr/local/dolfinx-complex/lib/python3.10/dist-packages/dolfinx/jit.py:56, in mpi_jit_decorator.<locals>.mpi_jit(comm, *args, **kwargs)
51 @functools.wraps(local_jit)
52 def mpi_jit(comm, *args, **kwargs):
53
54 # Just call JIT compiler when running in serial
55 if comm.size == 1:
---> 56 return local_jit(*args, **kwargs)
58 # Default status (0 == ok, 1 == fail)
59 status = 0
File /usr/local/dolfinx-complex/lib/python3.10/dist-packages/dolfinx/jit.py:204, in ffcx_jit(ufl_object, form_compiler_options, jit_options)
202 # Switch on type and compile, returning cffi object
203 if isinstance(ufl_object, ufl.Form):
--> 204 r = ffcx.codegeneration.jit.compile_forms([ufl_object], options=p_ffcx, **p_jit)
205 elif isinstance(ufl_object, ufl.FiniteElementBase):
206 r = ffcx.codegeneration.jit.compile_elements([ufl_object], options=p_ffcx, **p_jit)
File /usr/local/lib/python3.10/dist-packages/ffcx/codegeneration/jit.py:190, in compile_forms(forms, options, cache_dir, timeout, cffi_extra_compile_args, cffi_verbose, cffi_debug, cffi_libraries)
187 for name in form_names:
188 decl += form_template.format(name=name)
--> 190 impl = _compile_objects(decl, forms, form_names, module_name, p, cache_dir,
191 cffi_extra_compile_args, cffi_verbose, cffi_debug, cffi_libraries)
192 except Exception as e:
193 try:
194 # remove c file so that it will not timeout next time
File /usr/local/lib/python3.10/dist-packages/ffcx/codegeneration/jit.py:260, in _compile_objects(decl, ufl_objects, object_names, module_name, options, cache_dir, cffi_extra_compile_args, cffi_verbose, cffi_debug, cffi_libraries)
256 import ffcx.compiler
258 # JIT uses module_name as prefix, which is needed to make names of all struct/function
259 # unique across modules
--> 260 _, code_body = ffcx.compiler.compile_ufl_objects(ufl_objects, prefix=module_name, options=options)
262 ffibuilder = cffi.FFI()
263 ffibuilder.set_source(module_name, code_body, include_dirs=[ffcx.codegeneration.get_include_path()],
264 extra_compile_args=cffi_extra_compile_args, libraries=cffi_libraries)
File /usr/local/lib/python3.10/dist-packages/ffcx/compiler.py:97, in compile_ufl_objects(ufl_objects, object_names, prefix, options, visualise)
95 # Stage 1: analysis
96 cpu_time = time()
---> 97 analysis = analyze_ufl_objects(ufl_objects, options)
98 _print_timing(1, time() - cpu_time)
100 # Stage 2: intermediate representation
File /usr/local/lib/python3.10/dist-packages/ffcx/analysis.py:88, in analyze_ufl_objects(ufl_objects, options)
85 else:
86 raise TypeError("UFL objects not recognised.")
---> 88 form_data = tuple(_analyze_form(form, options) for form in forms)
89 for data in form_data:
90 elements += [convert_element(e) for e in data.unique_sub_elements]
File /usr/local/lib/python3.10/dist-packages/ffcx/analysis.py:88, in <genexpr>(.0)
85 else:
86 raise TypeError("UFL objects not recognised.")
---> 88 form_data = tuple(_analyze_form(form, options) for form in forms)
89 for data in form_data:
90 elements += [convert_element(e) for e in data.unique_sub_elements]
File /usr/local/lib/python3.10/dist-packages/ffcx/analysis.py:163, in _analyze_form(form, options)
160 complex_mode = "_Complex" in options["scalar_type"]
162 # Compute form metadata
--> 163 form_data = ufl.algorithms.compute_form_data(
164 form,
165 do_apply_function_pullbacks=True,
166 do_apply_integral_scaling=True,
167 do_apply_geometry_lowering=True,
168 preserve_geometry_types=(ufl.classes.Jacobian,),
169 do_apply_restrictions=True,
170 do_append_everywhere_integrals=False, # do not add dx integrals to dx(i) in UFL
171 complex_mode=complex_mode)
173 # If form contains a quadrature element, use the custom quadrature scheme
174 custom_q = None
File /usr/local/lib/python3.10/dist-packages/ufl/algorithms/compute_form_data.py:415, in compute_form_data(form, do_apply_function_pullbacks, do_apply_integral_scaling, do_apply_geometry_lowering, preserve_geometry_types, do_apply_default_restrictions, do_apply_restrictions, do_estimate_degrees, do_append_everywhere_integrals, complex_mode)
412 preprocessed_form = reconstruct_form_from_integral_data(self.integral_data)
414 # TODO: Test how fast this is
--> 415 check_form_arity(preprocessed_form, self.original_form.arguments(), complex_mode)
417 # TODO: This member is used by unit tests, change the tests to
418 # remove this!
419 self.preprocessed_form = preprocessed_form
File /usr/local/lib/python3.10/dist-packages/ufl/algorithms/check_arities.py:198, in check_form_arity(form, arguments, complex_mode)
196 """Check the arity of a form."""
197 for itg in form.integrals():
--> 198 check_integrand_arity(itg.integrand(), arguments, complex_mode)
File /usr/local/lib/python3.10/dist-packages/ufl/algorithms/check_arities.py:190, in check_integrand_arity(expr, arguments, complex_mode)
188 for arg, conj in arg_tuples:
189 if arg.number() == 0 and not conj:
--> 190 raise ArityMismatch("Failure to conjugate test function in complex Form")
191 elif arg.number() > 0 and conj:
192 raise ArityMismatch(f"Argument {arg} is spuriously conjugated in complex Form")
ArityMismatch: Failure to conjugate test function in complex Form
Not only this piece of content, but also other sample codes, I will get more or less errors, and then I can’t run the results.
I installed fenics through docker. I am not very good at finite element, and I have encountered many difficulties in the installation. I want to ask for help. Is it because my installation is incorrect, or if someone encountered the same problem and finally solved it?