Skip to main content

Mesh region with Rick Astley

· One min read
Kirill Vasin

A example of creating and using boundary mesh for solving equations on them.

Download original notebook

Smile!

img = (*VB[*)(FrontEndRef["438babff-4e1b-415b-ba6b-edeb3d6f288f"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKmxhbJCUmpaXpmqQaJumaGJom6SYlmiXppqakJhmnmKUZWVikAQCXhRbB"*)(*]VB*);

Apply a filter

MeanShiftFilter[img, 5, 1] // Binarize // ColorNegate
(*VB[*)(FrontEndRef["15a0967d-a941-4e65-a420-fb082f4c1fcb"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKG5omGliamafoJlqaGOqapJqZ6iaaGBnopiUZWBilmSQbpiUnAQB6nhWZ"*)(*]VB*)

Create a mesh region

ξ = ImageMesh[%]
(*VB[*)(temporal$303081)(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKm6aam6dZGiXrmhunWuqamFsm61pYGKfqGqUkpRklG1okJxonAgCDyBXq"*)(*]VB*)

Compute eigenfunctiions of the wave equation

{vals, funs} = NDEigensystem[
   {-Laplacian[u[x, y], {x, y}], 
    DirichletCondition[u[x, y] == 0, True]}, 
   u[x, y], Element[{x, y}, ξ], 6];

Plot different time slots

Grid@
 Partition[
  Table[ContourPlot[funs[[i]], Element[{x, y}, ξ], 
    PlotRange -> All, ImageSize->300, PerformanceGoal->"Speed", PlotLabel -> vals[[i]], 
    PlotTheme -> "Minimal"], {i, Length[vals]}], 3]
(*GB[*){{(*VB[*)(FrontEndRef["d8c846b4-e03d-4933-af0d-5c0c607865b9"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKp1gkW5iYJZnophoYp+iaWBob6yamGaTomiYbJJsZmFuYmSZZAgCE/xV6"*)(*]VB*)(*|*),(*|*)(*VB[*)(FrontEndRef["522b14a5-a144-4f98-93d4-ef618e74613d"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKmxoZJRmaJJrqJhqamOiapFla6Foap5jopqaZGVqkmpuYGRqnAAB4SBUa"*)(*]VB*)(*|*),(*|*)(*VB[*)(FrontEndRef["ad1adb3d-e6aa-408e-9045-805e8be7e425"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJ6YYJqYkGafoppolJuqaGFik6loamJjqWhiYplokpZqnmhiZAgCVWBX/"*)(*]VB*)}(*||*),(*||*){(*VB[*)(FrontEndRef["1f6981c5-081b-49a0-b3ab-6412a3e17980"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKG6aZWVoYJpvqGlgYJumaWCYa6CYZJybpmpkYGiUapxqaW1oYAAB6pxUK"*)(*]VB*)(*|*),(*|*)(*VB[*)(FrontEndRef["98ffe6b3-a454-41e8-a875-98af8e9c6475"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKW1qkpaWaJRnrJpqYmuiaGKZa6CZamJvqWlokplmkWiabmZibAgCH8xWc"*)(*]VB*)(*|*),(*|*)(*VB[*)(FrontEndRef["af9fc913-cfc6-4f29-a194-c65a20e7b129"])(*,*)(*"1:eJxTTMoPSmNkYGAoZgESHvk5KRCeEJBwK8rPK3HNS3GtSE0uLUlMykkNVgEKJ6ZZpiVbGhrrJqclm+mapBlZ6iYaWproJpuZJhoZpJonGRpZAgCRcRXa"*)(*]VB*)}}(*]GB*)