Why the solution of ft01 example break down on finer meshes?

Hi everyone,

I am new to FEniCS and currently I am trying to learn the basics on available examples.
When I was playing with the ft01 example (Poisson equation with Dirichlet conditions) I realized that when the number of mesh cells is increased even slightly from the default number, the solution is breaking down.

For n = 10 (number of cells in a horizontal and vertical direction) I received correct output:
n_10
but for higher numers, for example n = 15 the output is rather different and obviously not correct:
n_15

I have no idea why this strange behaviour occurs. Therefore the question is: Did I make an error when modifying the original code to run it in the Jupyter Lab or is something wrong with my installation of FEniCS?

The code I am running looks like this:

    from __future__ import print_function
    from fenics import *
    import numpy as np
    import matplotlib.pyplot as plt

    def boundary(x, on_boundary):
        return on_boundary

    # Create mesh and define function space
    n = 15
    mesh = UnitSquareMesh(n, n)
    V = FunctionSpace(mesh, 'CG', 1)

    # Define boundary condition
    u_D = Expression('1 + x[0]*x[0] + 2*x[1]*x[1]', degree=2)

    bc = DirichletBC(V, u_D, boundary)

    # Define variational problem
    u = TrialFunction(V)
    v = TestFunction(V)
    f = Constant(-6.0)
    a = dot(grad(u), grad(v))*dx
    L = f*v*dx

    # Compute solution
    u = Function(V)
    solve(a == L, u, bc)

    # Plot solution and mesh
    plt.colorbar(plot(u))
    plt.rcParams["figure.figsize"] = (5, 5)

The version of FEniCS: 2018.1.0
Installation: through Anaconda on Ubuntu on Windows. I run the code in Jupyter Lab.

Running your attached example (Removing the figsize command, and plotting the mesh on top of the solution field in docker do not reproduce the error docker run -ti -v $(pwd):/home/fenics/shared -w /home/fenics/shared/ --rm quay.io/fenicsproject/stable:2018.1.0
u

Thanks for your answer,
I initially tried to avoid Docker because I’m more familiar with Ubuntu on Windows. But I instaled Docker, run the code on the container and it works just fine there. So I guess that something is definitely wrong with my installation of FEniCS on Ubuntu on Windows. However, Docker is actually a lot simpler to use than I initially thought, so I will just stay there :slight_smile: