Hello all
I am trying to visualise the basis functions used in different choices of elements. So far I am successfull producing plots of them when the element degree is 1 as follows.
from dolfinx import fem, mesh
from mpi4py import MPI
import matplotlib.pyplot as plt
domain = mesh.create_unit_interval(MPI.COMM_SELF, 4)
V = fem.FunctionSpace(domain, ('CG',1))
v = fem.Function(V)
v.x.array[4] = 1
plt.plot(v.x.array)
Here the 4 in v.x;array[4] is a chosen index between the values of the local range (V.dofmap.index_map.local_range
).
For 2D meshes I do the visualisation with pyvista
.
For this example (with Lagrange elements of degree 1), I artificially set the value of the function at a node to 1. I was wondering if there is some quicker/more elegant way to do this and if there is something possible for higher order degree elements, e.g. Lagrange elements with degree 2 ((āCGā, 2) in the functionspace) or higher.
I am happy with any advice and/or pointers on how to do this.
Many thanks in advance!