I am using Fenics to extract the FEM matrices and to plot the finite element solution. I am using another language to solve the resulting time dependent system.
The domain of the PDE is a complicated shape with different portions of the boundary subject to various boundary conditions.
I am doing a simple experiment in which I supply the nodal values of the FEM solution, i.e.
unodalVals = 10*np.ones(1357)
Then converting it to a vector object via
u.vector().set_local(unodalVals)
And subsequently plotting the FEM solution in my domain with a complicated shape.
plot(u)
However, below is a snippet of how the plot looks like:
Hi nate, thanks for getting back. Are you saying that the dimension of the nodal values I provided, 1357, is not enough? The resulting matrices I get from assemble in fenics have this dimension so I am not sure what you mean…
Another issue is that the inputs to FunctionSpace are xml.gz files.
Yes, that’s fair. Here’s a minimal working example. I really appreciate your help looking into this:
Here’s my code:
import numpy as np
import dolfin as df
import fenics as fe
import matplotlib.pyplot as plt
mesh_file = 'ref3_mesh_fenics.xml.gz'
gamma_numbers_file = 'ref3_gamma_numbers_fenics.xml.gz'
# set matrix reordering off
df.parameters['reorder_dofs_serial'] = False
# read mesh file and mesh function for gamma numbers
mesh = df.Mesh(mesh_file)
gamma_numbers = df.MeshFunction('size_t', mesh, gamma_numbers_file)
# define function space linear lagrange elements P1
V = df.FunctionSpace(mesh, 'Lagrange', 1)
u = df.Function(V)
unodalVals = 10*np.ones(1357)
u.vector().set_local(unodalVals)
fe.plot(u)
plt.show()
The files included above can be downloaded from this link
Yes, I just realized it now. Thank you so much. It turns out that the error is that I mismatched the file with the number of nodes. I should have used the file in the other directory for the 1357 degrees of freedom. This is really a stupid mistake from my end. Thanks for your patience!