4

I want to make the mesh created by ToElementMesh has a node at my specified position. For example, in the following code, I discretize a disk to element meshes with ToElementMesh, and I want to a point, say (0.2,0.3), is coincident with a node. I have no idea on how to do it. Now I use the following code

domain = Disk[];
loc = {0.2, 0.3}
mesh = ToElementMesh[domain,
   MeshRefinementFunction -> 
    Function[{vertices, area}, Block[{x, y}, {x, y} = Mean[vertices];
      If[Norm@({x, y} - loc) < 0.2, area > 0.002, area > 1]]]
   ];

I use MeshRefinementFunction to make the elements near the target point dense and find the nearest node. I think it is not a good and elegant idea.

Is there any simple and built-in options for it, and how can I obtain the node number of it?

Ice0cean
  • 813
  • 4
  • 11

1 Answers1

6

You can use "IncludePoints" likes so:

domain = Disk[];
loc = {0.2, 0.3};
mesh = ToElementMesh[domain, "IncludePoints" -> {loc}];
Nearest[mesh["Coordinates"] -> {"Index", "Element", "Distance"}, loc]
(* {{49, {0.2, 0.3}, 0.}} *)

In my case, the 49th coordinate equals loc.

Tim Laska
  • 16,346
  • 1
  • 34
  • 58