Problem with mesh in .xdmf format

Hi everyone,

I have built and tested my code using UnitSquareMesh( ) available in Fenics library and it is working properly. However, I need to work with more complex domains. So, I have chosen gmsh software for this purpose. I have saved the mesh in format .msh and convert it to .xdmf file or converting it directly from .geo to .xdmf .

When I use the mesh input with *.xdmf files, two error message shows up according to the tests that I have made:

*** Error:   Unable to solve nonlinear system with NewtonSolver.
*** Reason:  Newton solver did not converge because maximum number of iterations reached.
*** Where:   This error was encountered inside NewtonSolver.cpp.
*** Process: 0

Or this other error message :

HDF5-DIAG: Error detected in HDF5 (1.10.4) MPI-process 0:
  #000: ../../../src/H5F.c line 444 in H5Fcreate(): unable to create file
    major: File accessibilty
    minor: Unable to open file
  #001: ../../../src/H5Fint.c line 1364 in H5F__create(): unable to open file
    major: File accessibilty
    minor: Unable to open file
  #002: ../../../src/H5Fint.c line 1615 in H5F_open(): unable to lock the file
    major: File accessibilty
    minor: Unable to open file
  #003: ../../../src/H5FD.c line 1640 in H5FD_lock(): driver lock request failed
    major: Virtual File Layer
    minor: Can't update object
  #004: ../../../src/H5FDsec2.c line 941 in H5FD_sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    major: File accessibilty
    minor: Bad file ID accessed
HDF5-DIAG: Error detected in HDF5 (1.10.4) MPI-process 0:
  #000: ../../../src/H5F.c line 444 in H5Fcreate(): unable to create file
    major: File accessibilty
    minor: Unable to open file
  #001: ../../../src/H5Fint.c line 1364 in H5F__create(): unable to open file
    major: File accessibilty
    minor: Unable to open file
  #002: ../../../src/H5Fint.c line 1615 in H5F_open(): unable to lock the file
    major: File accessibilty
    minor: Unable to open file
  #003: ../../../src/H5FD.c line 1640 in H5FD_lock(): driver lock request failed
    major: Virtual File Layer
    minor: Can't update object
  #004: ../../../src/H5FDsec2.c line 941 in H5FD_sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    major: File accessibilty
    minor: Bad file ID accessed
HDF5-DIAG: Error detected in HDF5 (1.10.4) MPI-process 0:
  #000: ../../../src/H5F.c line 444 in H5Fcreate(): unable to create file
    major: File accessibilty
    minor: Unable to open file
  #001: ../../../src/H5Fint.c line 1364 in H5F__create(): unable to open file
    major: File accessibilty
    minor: Unable to open file
  #002: ../../../src/H5Fint.c line 1615 in H5F_open(): unable to lock the file
    major: File accessibilty
    minor: Unable to open file
  #003: ../../../src/H5FD.c line 1640 in H5FD_lock(): driver lock request failed
    major: Virtual File Layer
    minor: Can't update object
  #004: ../../../src/H5FDsec2.c line 941 in H5FD_sec2_lock(): unable to lock file, errno = 11, error message = 'Resource temporarily unavailable'
    major: File accessibilty
    minor: Bad file ID accessed

I am proving the code with UnitSquareMesh( ) code (working) just for checking if necessary, the code with xdmf input (not working), and the code used to convert from .geo file to .xdmf.

Any suggestions would be very helpful.

xdmf Mesh:

def lmbdainv(s, mu_rel, no, nw):
    return 1.0 / ((1.0 / mu_rel) * s ** nw + (1.0 - s) ** no)


# Fractional flow function
def F(s, mu_rel, no, nw):
    return s ** nw / (s ** nw + mu_rel * (1.0 - s) ** no)


def tensor_jump(v, n):
    return ufl.outer(v, n)("+") + ufl.outer(v, n)("-")


class PiecewiseConstant(UserExpression):
    def __init__(self, values, markers, **kwargs):
        self._values = values
        self._markers = markers
        super().__init__(**kwargs)

    def eval_cell(self, values, x, cell):
        values[0] = self._values[self._markers[cell.index]]

    def value_shape(self):
        return tuple()


### Relative viscosity of water w.r.t. crude oil
Kinv = Constant(1 / (1e-6))
# Time step
dt = Constant(0.01)

mu = 1
mu_b = 1
phi = Constant(0.4)
pin = 6000
pout = 5000
sbar = Constant(1)

t = 0.0
T = 1000 * float(dt)


mesh = Mesh()
with XDMFFile("mesh.xdmf") as infile:
    infile.read(mesh)

mvc = MeshValueCollection("size_t", mesh, 2)
with XDMFFile("domains.xdmf") as infile:
    infile.read(mvc)
Markers = cpp.mesh.MeshFunctionSizet(mesh, mvc)

mvc1 = MeshValueCollection("size_t", mesh, 1)
with XDMFFile("boundaries.xdmf") as infile:
    infile.read(mvc1)
boundaries = cpp.mesh.MeshFunctionSizet(mesh, mvc1)

order = 1
BDM = FiniteElement("BDM", mesh.ufl_cell(), order)
DG = FiniteElement("DG", mesh.ufl_cell(), order - 1)
# DG1 = FiniteElement("DG", mesh.ufl_cell(), order)
Element = MixedElement([BDM, DG, DG])
mixed_space = FunctionSpace(mesh, Element)
n = FacetNormal(mesh)


# Function spaces and functions
V = TestFunction(mixed_space)
dU = TrialFunction(mixed_space)
U = Function(mixed_space)
U0 = Function(mixed_space)

v, q, r = split(V)
u, p, s = split(U)
u0, p0, s0 = split(U0)

s_mid = 0.5 * (s0 + s)

# ============= DEFINITION OF SPATIALLY-VARYING PARAMETERS =====================
marker_inner = 1
marker_outer = 0

no_outer = 2
nw_outer = 2
no_inner = 1
nw_inner = 1

no = {marker_inner: no_inner, marker_outer: no_outer}
nw = {marker_inner: nw_inner, marker_outer: nw_outer}

VVV = FunctionSpace(mesh, "DG", 0)

noo = PiecewiseConstant(no, Markers)
noo_proj = project(noo, VVV)
nww = PiecewiseConstant(nw, Markers)
nww_proj = project(nww, VVV)

# =========== END DEFINITION OF SPATIALLY-VARYING PARAMETERS ===================

ds = Measure("ds", domain=mesh, subdomain_data=boundaries)
dx = Measure("dx", domain=mesh, subdomain_data=Markers)


bc2 = DirichletBC(mixed_space.sub(0), Constant((0.0, 0.0)), boundaries, 2)

bc4 = DirichletBC(mixed_space.sub(0), Constant((0.0, 0.0)), boundaries, 4)

bcs = [bc2, bc4]  # velocity BC

alpha = 35
h = CellDiameter(mesh)
h2 = ufl.Min(h("+"), h("-"))

stab = (
    mu * (alpha / h2) * inner(tensor_jump(u, n), tensor_jump(v, n)) * dS
    - mu * inner(avg(grad(u)), tensor_jump(v, n)) * dS
    - mu * inner(avg(grad(v)), tensor_jump(u, n)) * dS
)

L1 = (
    mu_b * inner(grad(u), grad(v)) * dx(1)
    + inner(v, lmbdainv(s_mid, mu, no_outer, nw_outer) * Kinv * u) * dx(0)
    - div(v) * p * dx
    + pin * dot(v, n) * ds(1)
    + pout * dot(v, n) * ds(3)
    + stab
)

L2 = q * div(u) * dx(0) + q * div(u) * dx(1)

un = 0.5 * (inner(u0, n) + abs(inner(u0, n)))
un_h = 0.5 * (inner(u0, n) - abs(inner(u0, n)))

stabilisation = (
    dt("+")
    * inner(
        jump(r),
        un("+") * F(s_mid, mu, noo_proj, nww_proj)("+")
        - un("-") * F(s_mid, mu, noo_proj, nww_proj)("-"),
    )
    * dS
)

L3 = (
    phi * r * (s - s0) * dx(0)
    + r * (s - s0) * dx(1)
    - dt * inner(grad(r), F(s_mid, mu, no_outer, nw_outer) * u) * dx(0)
    - dt * inner(grad(r), F(s_mid, mu, no_outer, nw_outer) * u) * dx(1)
    + dt * r * F(s_mid, mu, no_outer, nw_outer) * un * ds
    + stabilisation
    + dt * r * un_h * sbar * ds(1)
)

# Total L
L = L1 + L2 + L3

J = derivative(L, U, dU)

problem = NonlinearVariationalProblem(L, U, bcs=bcs, J=J)
solver = NonlinearVariationalSolver(problem)

solver.parameters["newton_solver"]["relative_tolerance"] = 1e-6
solver.parameters["newton_solver"]["absolute_tolerance"] = 1e-6
solver.parameters["newton_solver"]["maximum_iterations"] = 10

u_file = XDMFFile("dir2" + "/velocity.xdmf")
p_file = XDMFFile("dir2" + "/pressure.xdmf")
s_file = XDMFFile("dir2" + "/saturation.xdmf")


while t < T:
    t += float(dt)
    U0.assign(U)
    solver.solve()
    u, p, s = U.split()
    p_file.write(p, t)
    s_file.write(s, t)
    u_file.write(u, t)

UnitSquareMesh( ) code:

# Total mobility
def lmbdainv(s, mu_rel, no, nw):
    return 1.0 / ((1.0 / mu_rel) * s ** nw + (1.0 - s) ** no)


# Fractional flow function
def F(s, mu_rel, no, nw):
    return s ** nw / (s ** nw + mu_rel * (1.0 - s) ** no)


def tensor_jump(v, n):
    return ufl.outer(v, n)("+") + ufl.outer(v, n)("-")


class PiecewiseConstant(UserExpression):
    def __init__(self, values, markers, **kwargs):
        self._values = values
        self._markers = markers
        super().__init__(**kwargs)

    def eval_cell(self, values, x, cell):
        values[0] = self._values[self._markers[cell.index]]

    def value_shape(self):
        return tuple()


class Obstacle(SubDomain):
    def inside(self, x, on_boundary):
        return between(x[1], (0.3, 0.7)) and between(x[0], (0.1, 0.5))


# Relative viscosity of water w.r.t. crude oil

Kinv = Constant(1 / (1e-6))
# Time step
dt = Constant(0.01)

mu = 1
mu_b = 1
phi = Constant(0.4)
pin = 6000
pout = 5000
sbar = Constant(1)

t = 0.0
T = 100 * float(dt)

mesh = UnitSquareMesh(90, 90)
n = FacetNormal(mesh)

order = 1
BDM = FiniteElement("BDM", mesh.ufl_cell(), order)
DG = FiniteElement("DG", mesh.ufl_cell(), order - 1)
Element = MixedElement([BDM, DG, DG])
mixed_space = FunctionSpace(mesh, Element)

# Function spaces and functions
V = TestFunction(mixed_space)
dU = TrialFunction(mixed_space)
U = Function(mixed_space)
U0 = Function(mixed_space)

v, q, r = split(V)
u, p, s = split(U)
u0, p0, s0 = split(U0)

s_mid = 0.5 * (s0 + s)

# ============= DEFINITION OF SPATIALLY-VARYING PARAMETERS =====================
marker_inner = 1
marker_outer = 0

no_outer = 2
nw_outer = 2
no_inner = 1
nw_inner = 1

obstacle = Obstacle()
domains = MeshFunction("size_t", mesh, mesh.topology().dim())
domains.set_all(marker_outer)
obstacle.mark(domains, marker_inner)


no = {marker_inner: no_inner, marker_outer: no_outer}
nw = {marker_inner: nw_inner, marker_outer: nw_outer}

VVV = FunctionSpace(mesh, "DG", 0)

noo = PiecewiseConstant(no, domains)
noo_proj = project(noo, VVV)
nww = PiecewiseConstant(nw, domains)
nww_proj = project(nww, VVV)

# =========== END DEFINITION OF SPATIALLY-VARYING PARAMETERS ===================
boundaries = MeshFunction("size_t", mesh, mesh.topology().dim() - 1)
left = AutoSubDomain(lambda x: near(x[0], 0.0))
right = AutoSubDomain(lambda x: near(x[0], 1.0))
bottom = AutoSubDomain(lambda x: near(x[1], 0.0))
top = AutoSubDomain(lambda x: near(x[1], 1.0))

# Define boundary markers
left.mark(boundaries, 1)
top.mark(boundaries, 2)
right.mark(boundaries, 3)
bottom.mark(boundaries, 4)

ds = Measure("ds", domain=mesh, subdomain_data=boundaries)
dx = Measure("dx", domain=mesh, subdomain_data=domains)


bc2 = DirichletBC(mixed_space.sub(0), Constant((0.0, 0.0)), boundaries, 2)
# # bc3 = DirichletBC(VQ.sub(0), Constant((0.0, 0.0)), boundaries, 3)
bc4 = DirichletBC(mixed_space.sub(0), Constant((0.0, 0.0)), boundaries, 4)

bcs = [bc2, bc4]  # velocity BC

alpha = 35
h = CellDiameter(mesh)
h2 = ufl.Min(h("+"), h("-"))

stab = (
    mu * (alpha / h2) * inner(tensor_jump(u, n), tensor_jump(v, n)) * dS
    - mu * inner(avg(grad(u)), tensor_jump(v, n)) * dS
    - mu * inner(avg(grad(v)), tensor_jump(u, n)) * dS
)

L1 = (
    mu_b * inner(grad(u), grad(v)) * dx(1)
    + inner(v, lmbdainv(s_mid, mu, no_outer, nw_outer) * Kinv * u) * dx(0)
    - div(v) * p * dx
    + pin * dot(v, n) * ds(1)
    + pout * dot(v, n) * ds(3)
    + stab
)

L2 = q * div(u) * dx(0) + q * div(u) * dx(1)

un = 0.5 * (inner(u0, n) + abs(inner(u0, n)))
un_h = 0.5 * (inner(u0, n) - abs(inner(u0, n)))

stabilisation = (
    dt("+")
    * inner(
        jump(r),
        un("+") * F(s_mid, mu, noo_proj, nww_proj)("+")
        - un("-") * F(s_mid, mu, noo_proj, nww_proj)("-"),
    )
    * dS
)


L3 = (
    phi * r * (s - s0) * dx(0)
    + r * (s - s0) * dx(1)
    - dt * inner(grad(r), F(s_mid, mu, no_outer, nw_outer) * u) * dx(0)
    - dt * inner(grad(r), F(s_mid, mu, no_outer, nw_outer) * u) * dx(1)
    + dt * r * F(s_mid, mu, no_outer, nw_outer) * un * ds
    + stabilisation
    + dt * r * un_h * sbar * ds(1)
)


# Total L
L = L1 + L2 + L3

J = derivative(L, U, dU)

problem = NonlinearVariationalProblem(L, U, bcs=bcs, J=J)
solver = NonlinearVariationalSolver(problem)

u_file = XDMFFile("dir2" + "/velocity.xdmf")
p_file = XDMFFile("dir2" + "/pressure.xdmf")
s_file = XDMFFile("dir2" + "/saturation.xdmf")


while t < T:
    t += float(dt)
    U0.assign(U)
    solver.solve()
    u, p, s = U.split()
    p_file.write(p, t)
    s_file.write(s, t)
    u_file.write(u, t)

Convert from .geo to .xdmf

import os
from dolfin import *
import meshio


file_in = "holesuCT"
file_out = "holesuCT"

os.system("gmsh " + file_in + ".geo -2 -o " + file_out + ".msh")
os.system("meshio-convert " + file_out + ".msh " + file_out + ".xdmf")

msh = meshio.read("holesuCT.msh")
tri_data = msh.cell_data_dict["gmsh:physical"]["triangle"]
line_data = msh.cell_data_dict["gmsh:physical"]["line"]

meshio.write(
    "mesh.xdmf",
    meshio.Mesh(
        points=msh.points[:, :2], cells={"triangle": msh.cells_dict["triangle"]}
    ),
)

meshio.write(
    "boundaries.xdmf",
    meshio.Mesh(
        points=msh.points,
        cells={"line": msh.cells_dict["line"]},
        cell_data={"bnd_marker": [msh.cell_data_dict["gmsh:physical"]["line"]]},
    ),
)

meshio.write(
    "domains.xdmf",
    meshio.Mesh(
        points=msh.points,
        cells={"triangle": msh.cells_dict["triangle"]},
        cell_data={"dom_marker": [msh.get_cell_data("gmsh:physical", "triangle")]},
    ),
)

Hi,

I’m not sure what you want to do with mesh.xdmf and domains.xdmf as you typically need one mesh for the entire domain and the other mesh for the boundary part (boundaries.xdmf in your case)

Have you looked this tutorial how to conver .msh into .xdmf ??

Dear @Kei_Yamamoto ,

I need the " domains.xdmf " because in this problem I have different properties along the domain. So, I need to mark the different domains. For example, like the figure bellow. Here I need to calculate the function def F(s, mu_rel, no, nw) using no = nw = 2 in blue domain and no = nw = 1 in red one.
Moreover, I will construct much more complex domains than this one. So, this is the reason that I am using gmsh.

16_vuggs

Sorry about not mentioning this figure previously.

best regards
Thiago Konopka

The domains can be saved in the saved file as the mesh, as both of them relate to cells.

Secondly, you have not supplied the code for generating the mesh, and thus it is very hard to give you any further guidance.

Dear @dokken,

I did not know that I could use just one file for mesh and domain. I base this choice on other examples in this forum.

The .geo file bellow represents a very simple case like the figure bellow:

Note: this .geo code is generated from an image processing code for complex geometries with multiple subdomains like the red square.

Best regards
Thiago Konopka

vugg_forum

// mesh size description

cl_1   =  0.1;
cl_2   =  0.05;

// boundary points
Point(1) = {0, 0, 0, cl_1};
Point(2) = {1.000, 0, 0, cl_1};
Point(3) = {1.000, 1.000, 0, cl_1};
Point(4) = {0, 1.000, 0, cl_1};


// lines that connect boundary
Line(1) = {1, 2};
Line(2) = {3, 2};
Line(3) = {4, 3};
Line(4) = {1, 4};

  // Mesh Parameters
  Mesh.CharacteristicLengthExtendFromBoundary = 0;
  Mesh.CharacteristicLengthMax = 0.01;
 
  // Define Segment coordinates

// Hole 2

X2 = {0.300, 0.304, 0.308, 0.312, 0.316, 0.320, 0.324, 0.328, 0.332, 0.336, 0.340, 0.344, 0.348, 0.351, 0.355, 0.359, 0.363, 0.367, 0.371, 0.375, 0.379, 0.383, 0.387, 0.391, 0.395, 0.399, 0.403, 0.407, 0.411, 0.415, 0.419, 0.423, 0.427, 0.431, 0.435, 0.439, 0.443, 0.447, 0.450, 0.454, 0.458, 0.462, 0.466, 0.470, 0.474, 0.478, 0.482, 0.486, 0.490, 0.494, 0.498, 0.502, 0.506, 0.510, 0.514, 0.518, 0.522, 0.526, 0.530, 0.534, 0.538, 0.542, 0.546, 0.550, 0.553, 0.557, 0.561, 0.565, 0.569, 0.573, 0.577, 0.581, 0.585, 0.589, 0.593, 0.597, 0.601, 0.605, 0.609, 0.613, 0.617, 0.621, 0.625, 0.629, 0.633, 0.637, 0.641, 0.645, 0.649, 0.652, 0.656, 0.660, 0.664, 0.668, 0.672, 0.676, 0.680, 0.684, 0.688, 0.692, 0.696, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.696, 0.692, 0.688, 0.684, 0.680, 0.676, 0.672, 0.668, 0.664, 0.660, 0.656, 0.652, 0.649, 0.645, 0.641, 0.637, 0.633, 0.629, 0.625, 0.621, 0.617, 0.613, 0.609, 0.605, 0.601, 0.597, 0.593, 0.589, 0.585, 0.581, 0.577, 0.573, 0.569, 0.565, 0.561, 0.557, 0.553, 0.550, 0.546, 0.542, 0.538, 0.534, 0.530, 0.526, 0.522, 0.518, 0.514, 0.510, 0.506, 0.502, 0.498, 0.494, 0.490, 0.486, 0.482, 0.478, 0.474, 0.470, 0.466, 0.462, 0.458, 0.454, 0.450, 0.447, 0.443, 0.439, 0.435, 0.431, 0.427, 0.423, 0.419, 0.415, 0.411, 0.407, 0.403, 0.399, 0.395, 0.391, 0.387, 0.383, 0.379, 0.375, 0.371, 0.367, 0.363, 0.359, 0.355, 0.351, 0.348, 0.344, 0.340, 0.336, 0.332, 0.328, 0.324, 0.320, 0.316, 0.312, 0.308, 0.304, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300}; 
Y2 = {0.3, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.300, 0.304, 0.308, 0.312, 0.316, 0.320, 0.324, 0.328, 0.332, 0.336, 0.340, 0.344, 0.348, 0.351, 0.355, 0.359, 0.363, 0.367, 0.371, 0.375, 0.379, 0.383, 0.387, 0.391, 0.395, 0.399, 0.403, 0.407, 0.411, 0.415, 0.419, 0.423, 0.427, 0.431, 0.435, 0.439, 0.443, 0.447, 0.450, 0.454, 0.458, 0.462, 0.466, 0.470, 0.474, 0.478, 0.482, 0.486, 0.490, 0.494, 0.498, 0.502, 0.506, 0.510, 0.514, 0.518, 0.522, 0.526, 0.530, 0.534, 0.538, 0.542, 0.546, 0.550, 0.553, 0.557, 0.561, 0.565, 0.569, 0.573, 0.577, 0.581, 0.585, 0.589, 0.593, 0.597, 0.601, 0.605, 0.609, 0.613, 0.617, 0.621, 0.625, 0.629, 0.633, 0.637, 0.641, 0.645, 0.649, 0.652, 0.656, 0.660, 0.664, 0.668, 0.672, 0.676, 0.680, 0.684, 0.688, 0.692, 0.696, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.700, 0.696, 0.692, 0.688, 0.684, 0.680, 0.676, 0.672, 0.668, 0.664, 0.660, 0.656, 0.652, 0.649, 0.645, 0.641, 0.637, 0.633, 0.629, 0.625, 0.621, 0.617, 0.613, 0.609, 0.605, 0.601, 0.597, 0.593, 0.589, 0.585, 0.581, 0.577, 0.573, 0.569, 0.565, 0.561, 0.557, 0.553, 0.550, 0.546, 0.542, 0.538, 0.534, 0.530, 0.526, 0.522, 0.518, 0.514, 0.510, 0.506, 0.502, 0.498, 0.494, 0.490, 0.486, 0.482, 0.478, 0.474, 0.470, 0.466, 0.462, 0.458, 0.454, 0.450, 0.447, 0.443, 0.439, 0.435, 0.431, 0.427, 0.423, 0.419, 0.415, 0.411, 0.407, 0.403, 0.399, 0.395, 0.391, 0.387, 0.383, 0.379, 0.375, 0.371, 0.367, 0.363, 0.359, 0.355, 0.351, 0.348, 0.344, 0.340, 0.336, 0.332, 0.328, 0.324, 0.320, 0.316, 0.312, 0.308, 0.304, 0.300};

// Define spline surface

LN = 90;

nR = #X2[ ];
p0  =  newp;
p   =  p0;
For i In {0:nR-1}
Point(newp)  =    {X2[i], Y2[i], 0, cl_2};
EndFor
p2  =  newp-1;
BSpline(90)   =  {p:p2,p};
Line Loop(91) = {90};
Plane Surface(92) = {91};


// Define all surfaces
Line Loop(5) = {1, -2, -3, -4};

Physical Line(1) = {4};
Physical Line(2) = {3};
Physical Line(3) = {2};
Physical Line(4) = {1};

Plane Surface(93) ={5,91};
Physical Surface(0) = {93};
Physical Surface(1) ={92};

I reverted the post to contain the original question.
Solution was to change the initial guess:

Adding a non-zero initial guess to your non-linear problem seems to help:

U.vector()[:] = 0.00001

prior to

makes the solution converge

It is working @dokken,

Thank you