Someone can tell me which command can be used to create a ring in FEniCS? Thanks
Hi, if you meant how can we generate a mesh in the ring shape you can use -
In 2d, using this code -
from dolfin import *
from mshr import *
domain= Circle(Point(0., 0.), 2) - Circle(Point(0., 0.), 1)
mesh = generate_mesh(domain, 20)
plot(mesh);
like this -
In 3d, using this code -
from dolfin import *
from mshr import *
cylinder1 = Cylinder(Point(0., 0., 0), Point(0., 0., 1), 10, 10)
cylinder2 = Cylinder(Point(0., 0., 0), Point(0., 0., 1), 5, 5)
domain = cylinder1 - cylinder2
mesh = generate_mesh(domain, 40)
File("ring_3d.pvd") << mesh
plot(mesh);
I used paraview to visualize the mesh in 3d like this -
But there is a caveat here, the mshr
library that I’m using is currently not maintained so consider using Gmsh for making the geometries. Here are some good tutorials to get you started - Mesh generation and conversion with PYGMSH and Meshio and Using the GMSH Python API to generate complex meshes.
I hope this helps.
Thank you so much!
I want to create a ring in the rectangle. I have tried your command. But in the rectangle i can not see this ring.
I show you a photo about this model.
Is the orange space with red and green cross empty ?
No, its not empty. The orange part is a specific material
Okay, I suggest you to kindly go through this post How to use gmsh tags to assign material properties? which is probably what you are looking for.
EDIT: You can also use boundary conditions to define different material properties like in this tutorial -
Defining subdomains for different materials.