I write a code that generates the following mesh. I would like to find out the elements that completely lie within a certain circular region inside this meshed area. How do I do that?
The code that I wrote is shown below:
w=100; (* Box width *)
h=100; (* Box height *)
xmin = 0;
ymin = 0;
xmax = xmin + w;
ymax = ymin + h;
d = 10;(* Mesh Size *)
<< NDSolve`FEM`
(* Create the coordinates *)
coords = {};(* Nodal Coordinate Matrix *)
nx = w/d + 1;(* Number of nodes in the x-direction *)
ny = h/d + 1;(* Number of nodes in the y-direction *)
For[i = 0,
i <= nx - 1, i++,
For[j = 0, j <= ny - 1, j++,
coords = Append[coords, {xmin + i*d, ymin + j*d}];
]
]
(* Create Element Connectivity Matrix to generate triangular elements *)
elMat = {};(* Element Connectivity Matrix *)
For[i = 1,
i <= ny - 1, i++,
For[j = 1, j <= nx - 1, j++,
elMat =
Append[elMat, {(i - 1)*ny + j, (i - 1)*ny + j + 1, i*ny + j}];
elMat = Append[elMat, {i*ny + j, i*ny + j + 1, (i - 1)*ny + j + 1}]
]
]
(* Create Mesh *)
mesh = ToElementMesh["Coordinates" -> coords,
"MeshElements" -> {TriangleElement[elMat]}];
mesh["Wireframe"]