Hello everyone,
I need your help. Indeed I solved a transient problem of soft tissue mechanics on a 3D slab. However, I would like to have the solution on an xy plane of the domain for z=0 and in the middle (z=0.5).
I have used some solutions that I have found on the internet but, I get no result.
I have mainly tested the solutions in the links:
You can try defining an expression that you can interpolate to get rid of your third axis.
Something like this:
#Dummy problem
from fenics import *
import matplotlib.pyplot as plt
# Create mesh and define function space
mesh = UnitCubeMesh(8, 8, 8)
V = FunctionSpace(mesh, 'CG', 1)
# Define boundary condition
u_D = Constant(0)
def boundary(x, on_boundary):
return on_boundary
bc = DirichletBC(V, u_D, boundary)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Constant(100)
a = dot(grad(u), grad(v))*dx
L = f*v*dx
# Compute solution
u = Function(V)
solve(a == L, u, bc)
# Plot solution and mesh
plt.colorbar(plot(u))
plt.title('u')
Define an expression to evaluate u at some value of z:
You can also save the solution as a .pvd or .xdmf file and read it back in paraview. Then you use the slice filter and export the 2D data as a .csv file. Then you can read and manipulate it with pandas.
Yep should work. However this should be downgrading to a very old version of matplotlib. Any chance this is another case where we should PR to dolfin to fix the deprecated syntax?
I know matplotlib is not ideal in this situation.
I’m trying to have 3D visualisations in a jupyter notebook in a Github Codespace for a workshop.
I’ve given a go at vedo but couldn’t get it to work in Codespaces.
Does dolfin_pyvista_adapter work in jupyter notebooks?