Mesh refinement

8 months ago by
Hello everybody,

I am working with a 2D mesh where I have defined some subdomains in order to assign the loads and different values of material properties to region of the mesh.
I would like to learn how to refine the mesh in a specific subdomain but I cannot find any tutorial or instruction.
Could you please help me?

Thank you


Community: FEniCS Project

1 Answer

8 months ago by

The following works for me

#refine_criteria:how much distance from the point you want your mesh to be fine
# origin = Point(x,y)# the point you want to refin your mesh around it

cell_markers = CellFunction("bool", coarse_mesh)
	origin = Point(0,0)
	for cell in cells(coarse_mesh):
		p = cell.midpoint()
		if p.distance(origin) < refine_criteria:
			cell_markers[cell] = True
	fine_mesh = refine(coarse_mesh, cell_markers)
Thank you very much!!

written 8 months ago by Diego  

I have BoxMesh and my code runs fine until I refine the mesh. When I try you piece of code about by itself, it works and I get what I want. When I add it to my code after I define my BoxMesh, I get an error saying CellFunctionSizet object is not callable. Any idea what that happens?
written 11 weeks ago by Ashraf El Gaaly  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »