modified inside function to generate submesh
8 weeks ago by
I would like to generate a sub mesh using sub domains. Subdomain is defined by a circle with unit radius. I want all the elements which is crossing the circle boundary to be included in the subdomain. The following code creates a submesh but if anyone of the nodes of an element is outside the circle, that element is not included. I think this related to the inside() function. Can we modify this function so that what I need is done? Where can I find this function in Ubuntu folders to check? Or, any other suggestions?
Note: I donot want to use tolerance which is sensitive to mesh size.
Here is the code:
from fenics import * # Generate mesh mesh = RectangleMesh(Point(-1.1,-1.1), Point(1.1,1.1), 32, 32,'crossed') # Define subdomains class innerbound(SubDomain): def inside(self, x, on_boundary): return (sqrt(x*x + x*x)<1.0) sub_domains=MeshFunction('size_t', mesh, mesh.topology().dim() - 1) sub_domains.set_all(0) ibound=innerbound() ibound.mark(sub_domains,1) # Generate submesh smesh=SubMesh(mesh,ibound)
Here is the subdomain generated by this function which does not include all the elements crossing the white circle:
Community: FEniCS Project
8 weeks ago by
set_of_crossed_cells = all_cells - strictly_interior_cells - strictly_exterior_cells
You already know how to mark
strictly_exterior_cellsis its simple modification.
Please login to add an answer/comment or follow this question.