1
|
123571 Views
|
4 Replies
|
3 Total Likes
View groups...
Share

# How to use NMinimize on a mesh?

Posted 10 years ago
 Hey there, community! I have recently been working with the new FEM-package included in Mathematica 10. I have a 2D mesh and two interpolating functions (call them uif and vif) obtained by solving a differential equation in the mesh using NDSolve. The mesh is similar to the one shown below, only denser. My problem now is that, given values u0 and v0, I need to find the point where uif[x,y] = u0 and vif[x,y] = v0. Now, since uif and vif are defined on the mesh, I would naturally want to do something like this: NMinimize[{Norm[{u0 - uif[x, y], v0 - vif[x, y]}], {x, y} \[Element] mesh}, {x, y}]];  Here "{x,y} [Element] mesh" indicates that the point (x,y) lies inside the mesh. Unfortunately, the above code results in the following error: NMinimize::elemc: "Unable to resolve the domain or region membership condition {x,y} \[Element] <<1>>.  So, is there a way to convert the mesh into a region that I can pass on to NMinimize? Previously I tried defining the region explicitly using unions and differences of disks and rectangles, or implicitly using equations for $x$ and $y$, but due to a number of bugs (or restrictions) with the regions and with the FEM package, this is unfortunately not an option. The mesh is simply-connected and I do have direct access to the boundary mesh if necessary. -Jonatan
4 Replies
Sort By:
Posted 10 years ago
 This will be easier in the next release, but for now something like the following may work: NMinimize[{Norm[{u0 - uif[x, y], v0 - vif[x, y]}], SignedRegionDistance[MeshRegion[mesh]][{x, y}] <= 0}, {x, y}] 
Posted 10 years ago
 Thank you for the quick response! Just tried your solution and it seems to work fine.
Posted 10 years ago
 Sorry for resurrecting an old topic, but I'm curious about what you said. Was the next release you were referring to 10.0.2? If so, what is the easier way you mentioned?The reason I ask is that I'm currently writing a report which will include this code, and it would be great if I could also mention the easier version. Unfortunately I don't have access to 10.0.2 yet, so I can't test it.
Posted 10 years ago
 Yes, 10.0.2 directly accepts constraints such as {x, y} \[Element] meshregion.