Hello,
I have a function atrue (constant by elements) :
Va = FunctionSpace(mesh, ‘DG’, 0)
atrue = Function(Va)
and I want to plot it on a mesh !!
plot
plt.figure()
plot(atrue, title=“True parameter field”, mode=“warp”)
plt.show()
But it does not work.
Thanks
1 Like
nate
October 8, 2019, 1:47pm
2
Output the function to file (e.g. XDMFFile
) and visualise with an application such as paraview . Or take a look at the fantastic vtkplotter
which has support for dolfin functions through vtkplotter.dolfin.plot
1 Like
from a similar example:
from dolfin import *
from vtkplotter.dolfin import plot
def f(coordinate):
if coordinate[0]>0.5: return 1
return 0
mesh = UnitSquareMesh(50, 50)
V = FunctionSpace(mesh, "DG", 0)
g = Function(V)
coords = V.tabulate_dof_coordinates()
for i in range(V.dim()):
g.vector()[i] = f(coords[i])
plot(g, style='paraview', lw=0)
check here for more examples.