This may be an stupid question. I was trying to understand the inner workings of Fenics (as I have the feeling that learning by examples I’m all the time bothering you asking for code) and I wrote the following code to plot the basis functions:
from dolfinx.mesh import create_unit_interval
from dolfinx.fem import FunctionSpace, Function
from mpi4py import MPI
D = create_unit_interval( comm = MPI.COMM_WORLD, nx = 10)
H = FunctionSpace( D, ( 'Lagrange', 1 ) )
f = Function(H)
import matplotlib.pyplot as plt
import numpy as np
def plot_function( f, a, b ):
N = 101
x = np.linspace( a, b, N)
p = np.array([ (x_,0,0) for x_ in x ])
cells = x // 0.1
y = f.eval(p,cells)
plt.plot(p[:,0], y)
plt.show()
Now if i call:
f.x.array[1] = 1
plot_function( f, 0, 1 )
the kernel crashes, whereas if I call:
f.x.array[1] = 1
plot_function( f, 0.001, 0.999 )
I get this nice plot:
Is it expected for the kernel to crash?
Thank you very much!