I do not have the bandwidth to parse 700 lines of code to debug your code.
I copy-pasted the file: https://raw.githubusercontent.com/chennachaos/MagnetoMechanicalFEniCS/main/hard_magnetic_constant_bfield_quadrature.py
which yielded a DivisionByZero
error when trying to compile/generate code for the residual of your non-linear problem:
/usr/lib/python3/dist-packages/ffc/quadrature/quadraturerepresentation.py:58: QuadratureRepresentationDeprecationWarning:
*** ===================================================== ***
*** FFC: quadrature representation is deprecated! It will ***
*** likely be removed in 2018.2.0 release. Use uflacs ***
*** representation instead. ***
*** ===================================================== ***
issue_deprecation_warning()
Division by zero.
Traceback (most recent call last):
File "/root/shared/mwe.py", line 558, in <module>
CoupledProblem = NonlinearVariationalProblem(L, w, bcs, J=a)
File "/usr/lib/python3/dist-packages/dolfin/fem/problem.py", line 157, in __init__
F = Form(F, form_compiler_parameters=form_compiler_parameters)
File "/usr/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/python3/dist-packages/dolfin/jit/jit.py", line 47, in mpi_jit
return local_jit(*args, **kwargs)
File "/usr/lib/python3/dist-packages/dolfin/jit/jit.py", line 97, 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 190, in compile_ufl_objects
ir = compute_ir(analysis, prefix, parameters, jit)
File "/usr/lib/python3/dist-packages/ffc/representation.py", line 182, in compute_ir
irs = [_compute_integral_ir(fd, form_id, prefix, element_numbers, classnames, parameters, jit)
File "/usr/lib/python3/dist-packages/ffc/representation.py", line 182, in <listcomp>
irs = [_compute_integral_ir(fd, form_id, prefix, element_numbers, classnames, parameters, jit)
File "/usr/lib/python3/dist-packages/ffc/representation.py", line 455, in _compute_integral_ir
ir = r.compute_integral_ir(itg_data,
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturerepresentation.py", line 104, in compute_integral_ir
ir["trans_integrals"] = _transform_integrals_by_type(ir, transformer,
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturerepresentation.py", line 182, in _transform_integrals_by_type
terms = _transform_integrals(transformer, integrals_dict, integral_type)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturerepresentation.py", line 229, in _transform_integrals
terms = transformer.generate_terms(integral.integrand(), integral_type)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 807, in generate_terms
terms = self.visit(integrand)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 593, in index_sum
ops.append(self.visit(summand))
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 593, in index_sum
ops.append(self.visit(summand))
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 558, in indexed
code = self.visit(indexed_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 762, in component_tensor
code = self.visit(component_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 558, in indexed
code = self.visit(indexed_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 762, in component_tensor
code = self.visit(component_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 593, in index_sum
ops.append(self.visit(summand))
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 558, in indexed
code = self.visit(indexed_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 762, in component_tensor
code = self.visit(component_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 558, in indexed
code = self.visit(indexed_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 762, in component_tensor
code = self.visit(component_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 593, in index_sum
ops.append(self.visit(summand))
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 593, in index_sum
ops.append(self.visit(summand))
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 558, in indexed
code = self.visit(indexed_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 762, in component_tensor
code = self.visit(component_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 558, in indexed
code = self.visit(indexed_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 103, in visit
r = h(o)
File "/usr/lib/python3/dist-packages/ffc/quadrature/quadraturetransformerbase.py", line 762, in component_tensor
code = self.visit(component_expr)
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in <listcomp>
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ufl_legacy/algorithms/transformer.py", line 99, in visit
r = h(o, *[self.visit(op) for op in o.ufl_operands])
File "/usr/lib/python3/dist-packages/ffc/quadrature/optimisedquadraturetransformer.py", line 147, in division
code[key] = create_fraction(val, denominator)
File "/usr/lib/python3/dist-packages/ffc/quadrature/symbolics.py", line 102, in create_fraction
fraction = Fraction(num, denom)
File "/usr/lib/python3/dist-packages/ffc/quadrature/fraction.py", line 56, in __init__
error("Division by zero.")
File "<string>", line 1, in <lambda>
File "/usr/lib/python3/dist-packages/ufl_legacy/log.py", line 158, in error
raise self._exception_type(self._format_raw(*message))
Exception: Division by zero.
which to indicates some mistake in the variational formulation.
It would be helpful if you supply new error messages and traces, and the reduce examples accordingly. Working from the trace above one can boil it down to being an issue with:
T_visc = J**(-2/3)*(Gneq_1*F*(A1 - (1/3)*inner(Cdis, A1)*inv(Cdis)) )
Simply having that term as the only thing that is returned from Piola
yields the DivisonByZero error.
In general, I wouldn’t advice anyone starting to use legacy DOLFIN, especially with complex variational forms, as the code generation can become extremely expensive wrt time and memory.