Dear all,
I just started working with FEniCS for my master thesis. The project is about the flow simulation inside the left ventricle of the heart. Therefore, I have a moving geometry which I collected from Magnetic Resonance Imaging. Now, I am trying to use FEniCS to simulate the flow in the moving domain.
At each time step I would like to load the new mesh (which is already interpolated from the first one, all the meshes are topologically consistent, same connectivity elements), find the velocity from the mesh displacement, use this velocity inside the convective term of the weak formulation, and use it as DirichletBC on the left ventricular wall. I tried something like that, but it does not work and I do not know what I have to change:
mesh_1 = Mesh("LV_Fenics/LV_00_vol.xml")
V = VectorFunctionSpace(mesh_1,"CG",3)
# Extract dofs
dms = [V.sub(i).dofmap().dofs() for i in range(3)]
u_mesh = Function(V)
while t < T + DOLFIN_EPS:
# Load next geometry
mesh_2 = Mesh("LV_Fenics/LV_0"+str(i)+"_vol.xml")
# Compute mesh velocity
u_mesh_new = Function(V)
# Get the coordinates in dof order
dof_coor_1 = V.dofmap().tabulate_all_coordinates(mesh_1)
# Coordinates of dofs
coor_x_1 = dof_coor_1[dms[0]]
coor_y_1 = dof_coor_1[dms[1]]
coor_z_1 = dof_coor_1[dms[2]]
dof_coor_2 = V.dofmap().tabulate_all_coordinates(mesh_2)
coor_x_2 = dof_coor_2[dms[0]]
coor_y_2 = dof_coor_2[dms[1]]
coor_z_2 = dof_coor_2[dms[2]]
u_mesh_new.vector()[dms[0]] = (coor_x_2-coor_x_1)/dt
u_mesh_new.vector()[dms[1]] = (coor_y_2-coor_y_1)/dt
u_mesh_new.vector()[dms[2]] = (coor_z_2-coor_z_1)/dt
u_mesh.assign(u_mesh_new)
I perform this point at each iteration in time. The mesh velocity is present inside the weak formulation in the convective term:
# Tentative velocity
U = 0.5*(u0 + u)
F1 = rho*(1/k)*inner(u-u0, v)*dx \
+ rho*inner(grad(u0)*(u0), v)*dx \
+ inner(sigma(U, p0), epsilon(v))*dx \
+ inner(p0*n, v)*ds \
- mu*inner(grad(U).T*n, v)*ds \
- inner(f, v)*dx
a1 = lhs(F1)
L1 = rhs(F1)
As last point, I have to use the mesh velocity u_mesh as dirichlet boundary condition on the boundary mesh. Do you have any suggetions on this?
In advance many thanks for your help!