7
$\begingroup$

I am trying to solve the one-dimensional wave equation with a frequency dependent source function over three intervals with varying velocity. I need to refine the mesh over the low velocity regions when the wavelength becomes shorter. The documentation for DiscretizeRegion shows how to do this for the left half of a linear region using step functions, but this MeshRefinementFunction does not work for ToElementMesh.

DiscretizeRegion[RegionUnion[Line[{{0}, {1.8}}], Line[{{1.8}, {2.2}}], 
Line[{{2.2}, {4}}]], MeshRefinementFunction -> Function[{v, Len}, If[Max[v] 
>= 2, Len > 0.003, Len > 0.5]]]

Can you help?

Thanks, Ken

$\endgroup$

2 Answers 2

6
$\begingroup$

You can use

ToElementMesh[
 DiscretizeRegion[
  RegionUnion[Line[{{0}, {1.8}}], Line[{{1.8}, {2.2}}], 
   Line[{{2.2}, {4}}]], 
  MeshRefinementFunction -> 
   Function[{v, Len}, If[Max[v] >= 2, Len > 0.003, Len > 0.5]]]]

Another approach you could take is to create a boundary mesh and then use RegionMarkers:

bmesh = ToBoundaryMesh["Coordinates" -> {{0}, {1.8}, {2.2}, {4}}, 
   "BoundaryElements" -> {PointElement[{{1}, {2}, {3}, {4}}, {1, 1, 3,
        3}]}, "PointElements" -> {PointElement[{{1}, {2}, {3}, {4}}, \
{1, 1, 3, 3}]}];

m = ToElementMesh[bmesh, 
  "RegionMarker" -> {{{0.9}, 1, 0.01}, {{2}, 2, 0.1}, {{3}, 3, 0.001}}]
m["Wireframe"]

See the ToElementMesh ref page or the ElementMesh generation tutorial

Also note that there are two tutorials that might be of interest: one is on the wave equation in acoustics and one on the Helmholtz equation for the frequency domain in Acoustics. The fact that the tutorials are about Acoustics is not that important since many things are still applicable. Also, have a look for the acoustics models in product with examples.

$\endgroup$
0
1
$\begingroup$

Thanks for the help. I used the boundary mesh approach with this code:

    bmesh = ToBoundaryMesh["Coordinates" -> {{0}, {1.9}, {2.1}, {4}}, 
    "BoundaryElements" -> {PointElement[{{1}, {2}, {3}, {4}}, {1, 1, 3, 3}]}, 
    "PointElements" -> {PointElement[{{1}, {2}, {3}, {4}}, {1, 1, 3, 3}]}];

    m2 = ToElementMesh[bmesh,"RegionMarker" -> {{{0.9}, 1, 0.2}, {{2}, 2, 0.05}, 
    {{3}, 3, 0.1}}]

Then I used NDSolve and got a much better result for the frequency range I was using

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.