How to make a 3D Cylinder Mesh?

I want to generate a cylindrical shape in FEniCS, but have been unable to find documentation or example codes that would allow me to make this. Previous code does not work in the newer versions of FEniCS. I am running FEniCS through docker. I don’t have any code to show because I am a complete newbie and don’t really know where else to ask for help.

Thanks!

Hi
Consider this:

from dolfin import *
from mshr import *

#Making a cylindrical geometry
cylinder = Cylinder(Point(0, 0, -1), Point(0, 0, 1), 0.5, 0.5)
geometry = cylinder

# Making Mesh (40 corresponds to the mesh density)
mesh = generate_mesh(geometry, 40)

# Save the mesh
File("cylinder.pvd") << mesh

Here is the mesh:

gg

1 Like

Hi Leo! Thank you! This worked on my computer! Any idea on how to make shapes contract on FEniCS? I want to compress and stretch the cylinder. Any help would be greatly appreciated!

You can adjust the dimensions like:

cylinder = Cylinder('coordinate of center of the top circle', 'coordinate of center of the bottom circle', 'radius of the circle at the top', 'radius of the circle at the bottom')

Then you can compress and stretch it. For more information please have a look at this

1 Like

please
What is the way to obey the image or to see it. When I type plot mesh, an error occurs. Is there a way to see the image?

Dear @mohamad,
If you dont:

  1. post the code you are running
  2. post the error message you are receiving

(Both with proper markdown encapsulation),
It is very hard for anyone to give you any guidance.

the code and error

This has been Fixed in later versions of dolfin: 3D plot using native FEniCS - #2 by dokken