Contraction and Expansion of a Cylinder

Hello,

I am working on a project where I need to add a fiber direction to a cylinder and then contract and stretch it. I am not sure how to begin implementing this. I have a cylinder and a mesh, but I have tried displacement code that I used for a unit cube, but it doesn’t work on a cylinder. Any help would be greatly appreciated!

Thanks!

Hey! I have a similar problem, I’m trying to find the eigenvectors of a free oscillating cylinder. I also used the displacement - demo, and i get some results, although I don’t know if they are right… What doesn’t work with your program? And how did you generate the mesh?
greetings :slightly_smiling_face:

Hi,

I am using FenicsMechanics, and this is a working code for cylinder inflation. Although I have not implemented fiber directions, but I believe that would be easy.

=========================================================
code for cylinder inflation

import sys
import dolfin as dlf
sys.path.append("…/fenicsmechanics-master")

import fenicsmechanics as fm
import math
import os
import numpy as np

mat_dict = {
‘type’: ‘elastic’,
‘const_eqn’: ‘neo_hookean’,
‘incompressible’: True,
‘density’: 0.0,
‘kappa’: 10e9, # Pa
‘mu’: 4.0e3 # Pa
}

mesh_file, boundaries = fm.get_mesh_file_names(“quartercylinder” , ret_facets = True,
ext=“xml”)
mesh = dlf.Mesh(mesh_file)
print("Number of elements in the mesh: ",mesh.num_cells())
print("Number of nodes in the mesh: ",mesh.num_vertices())

inner_radius = 1.0
boundaries = dlf.MeshFunction(“size_t”, mesh, 2)
boundaries.set_all(0)
x0_face = dlf.CompiledSubDomain(“near(x[0], 0.0) && on_boundary”) # when x=0 left face
y0_face = dlf.CompiledSubDomain(“near(x[1], 0.0) && on_boundary”)
z0_face = dlf.CompiledSubDomain(“near(x[2], 0.0) && on_boundary”)

class InnerFace(dlf.SubDomain):
def inside(self, x, on_boundary):
return (np.sqrt(x[0]*x[0]+x[1]x[1]) - (1.01inner_radius) ) < dlf.DOLFIN_EPS
and on_boundary
inner_face = InnerFace()

x0_face.mark(boundaries, 1)
y0_face.mark(boundaries, 2)
z0_face.mark(boundaries, 3)
inner_face.mark(boundaries, 4)
dlf.File(’./quartercylinder/quartercylinder-mesh.xml’) << mesh
dlf.File(’./quartercylinder/quartercylinder-boundaries.xml’) << boundaries

mesh_dict = {
‘mesh_file’: mesh,
‘boundaries’: boundaries
}

formulation_dict = {
‘time’: {
‘dt’: 0.1,
‘interval’: [0., 1.]
},
‘element’: ‘p2-p1’,
‘domain’: ‘lagrangian’,
‘bcs’:{
‘dirichlet’: {
‘displacement’: [0.0,0.0,0.0],
‘regions’: [1,2,3], # Integer ID for left face
‘components’: [‘x’,‘y’,‘z’]
},
‘neumann’: {
‘values’: [‘1000.0*t’],
‘regions’: [4],
‘types’: [‘pressure’]
}
}
}

config = {
‘material’: mat_dict,
‘mesh’: mesh_dict,
‘formulation’: formulation_dict
}

problem = fm.SolidMechanicsProblem(config)

solver = fm.SolidMechanicsSolver(problem, fname_disp=’./quartercylinder/disp.pvd’)
solver.set_parameters(linear_solver=“mumps”)
solver.full_solve()
print(“Done”)