Dear Lawrence,

Thanks, I really appreciate it. Hope it is the last one. The solver doesn't converge. If I run same mesh and same script in FEniCS (with the changes you suggested, that is the boundary conditions), the linear solver converges immediately (0.13 s).
In Firedrake I have the following error:

Traceback (most recent call last):
  File "Elasticity2D_Firedrake.py", line 163, in <module>
    solve(lhs_varf == rhs_varf, sol, bcs=[bc1,bc2])
  File "/home/simone/firedrake/src/firedrake/firedrake/solving.py", line 125, in solve
    _solve_varproblem(*args, **kwargs)
  File "/home/simone/firedrake/src/firedrake/firedrake/solving.py", line 153, in _solve_varproblem
    solver.solve()
  File "/home/simone/firedrake/src/firedrake/firedrake/variational_solver.py", line 267, in solve
    solving_utils.check_snes_convergence(self.snes)
  File "/home/simone/firedrake/src/firedrake/firedrake/solving_utils.py", line 44, in check_snes_convergence
    %s""" % (snes.getIterationNumber(), msg))
firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations.
Reason:
   Inner linear solve failed to converge after 10000 iterations with reason: DIVERGED_MAX_IT


Thank you so much!

Best regards,
Simone

On Tue, Jun 25, 2019 at 9:28 AM Lawrence Mitchell <wence@gmx.li> wrote:

> On 25 Jun 2019, at 15:25, Simone Puel <spuel@utexas.edu> wrote:
>
> Dear Lawrence,
>
> Thanks so much! I have done as you suggested and now I have a different error:
>
> Traceback (most recent call last):
>   File "Elasticity2D_Firedrake.py", line 163, in <module>
>     solve(lhs_varf == rhs_varf, sol, bcs=[bc1,bc2])
>   File "/home/simone/firedrake/src/firedrake/firedrake/solving.py", line 125, in solve
>     _solve_varproblem(*args, **kwargs)
>   File "/home/simone/firedrake/src/firedrake/firedrake/solving.py", line 153, in _solve_varproblem
>     solver.solve()
>   File "/home/simone/firedrake/src/firedrake/firedrake/variational_solver.py", line 249, in solve
>     dbc.apply(self._problem.u)
>   File "</home/simone/firedrake/lib/python3.6/site-packages/decorator.py:decorator-gen-48>", line 2, in apply
>   File "/home/simone/firedrake/src/PyOP2/pyop2/profiling.py", line 60, in wrapper
>     return f(*args, **kwargs)
>   File "/home/simone/firedrake/src/firedrake/firedrake/bcs.py", line 432, in apply
>     r.assign(self.function_arg, subset=self.node_set)
>   File "</home/simone/firedrake/lib/python3.6/site-packages/decorator.py:decorator-gen-40>", line 2, in assign
>   File "/home/simone/firedrake/src/firedrake/firedrake/utils.py", line 61, in wrapper
>     return f(*args, **kwargs)
>   File "/home/simone/firedrake/src/firedrake/firedrake/function.py", line 377, in assign
>     assemble_expressions.Assign(self, expr), subset)
>   File "</home/simone/firedrake/lib/python3.6/site-packages/decorator.py:decorator-gen-45>", line 2, in evaluate_expression
>   File "/home/simone/firedrake/src/firedrake/firedrake/utils.py", line 58, in wrapper
>     return f(*args, **kwargs)
>   File "/home/simone/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 507, in evaluate_expression
>     e, args, _ = ExpressionWalker().walk(tree)
>   File "/home/simone/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 346, in walk
>     return (self.visit(expr),
>   File "/home/simone/firedrake/src/ufl/ufl/algorithms/transformer.py", line 114, in visit
>     r = h(o)
>   File "/home/simone/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 413, in operator
>     operands = [operands[0], self.visit(operands[1])]
>   File "/home/simone/firedrake/src/ufl/ufl/algorithms/transformer.py", line 114, in visit
>     r = h(o)
>   File "/home/simone/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 417, in operator
>     operands = list(map(self.visit, o.ufl_operands))
>   File "/home/simone/firedrake/src/ufl/ufl/algorithms/transformer.py", line 114, in visit
>     r = h(o)
>   File "/home/simone/firedrake/src/firedrake/firedrake/assemble_expressions.py", line 383, in coefficient
>     raise ValueError("Constant has mismatched shape for expression function space")
> ValueError: Constant has mismatched shape for expression function space
>
>
> I kept the function spaces as the original:
> BDM = VectorFunctionSpace(mesh, "BDM", 1)
> DGv = VectorFunctionSpace(mesh, "DG", 0)
> DGs = FunctionSpace(mesh, "DG", 0)
>
> Vh = BDM * DGv * DGs
>
> Is this error due to the boundary conditions that I prescribed?
> u0 = Constant((0.0, 0.0))                                                                           # zero displacement left, right and bottom
> zero_stress = as_vector([Constant((0., 0.)), Constant((0., 0.))])                    # zero stress at top
>
> Thank you so much for your help, I really appreciate it.
>

I think so. You probably want

zero_stress = as_tensor([[0, 0], [0, 0]])

or:

zero_stress = Constant([[0, 0], [0, 0]])

Thanks,

Lawrence


--
Simone Puel
Ph.D. student in Geological Sciences at the University of Texas at Austin
Jackson School of Geosciences & Institute for Geophysics (UTIG)
JGB 5.332 & ROC 2.116L
+1 (737)-230-6811