11
$\begingroup$

I try to generate a mesh over a region, which has a wavy boundary at its bottom and needs very fine mesh around the bottom.

However, the generated mesh boundary is not as smooth as the specified one. The region is enter image description here The generated mesh is enter image description here If we zone-in we will find the bottom boundary is not enter image description here

The bottom looks very bad.

I further try to generate the boundary first. Here is what I found. enter image description here

The boundary is not generated correctly.

Anyone know how to generate the correct meshed boundary?


I have got the answer from http://community.wolfram.com/groups/-/m/t/1221340?sortMsg=Votes:

Adding a range of {{x,-0.6,0.6},{y,0,0.3}} in defining the region.

The minimum work code is as follows.

Needs["NDSolve`FEM`"];

width = 1;
heigth = 0.25;
radius = 10; 
ydatum = 0.006;
Aw = 2 10^-3;
λw = 0.1;
ℛ = 
  ImplicitRegion[
   Abs[x] <= width/2 && y <= heigth + ydatum && 
    y >= x^2/(2 radius) + Aw (1 - Cos[(2 π x)/λw]) + 
      ydatum, {{x,-0.6,0.6},{y,0,0.3}}];
RegionPlot[ℛ, FrameTicks -> None, PlotPoints -> 20000,
  AspectRatio -> Automatic, ImageSize -> Large, 
 PlotRange -> {{-0.48, 0.48}, {0.005, 0.256}}]

bmesh = ToBoundaryMesh[ℛ, 
  "BoundaryMeshGenerator" -> "Continuation", AccuracyGoal -> 2]
bmesh["Wireframe"]

meshrefine = 
  Function[{vertices, area}, 
   Block[{x, y}, {x, y} = Mean[vertices]; 
    If[ydatum < y < ydatum + 0.01, area > 2.1*10^-7, area > 0.001]]];
mesh1 = ToElementMesh[ℛ, "MeshOrder" -> 1, 
  MeshRefinementFunction -> meshrefine]

mesh1["Wireframe"]

Show[mesh1["Wireframe"], 
 PlotRange -> {{-0.025, 0.025}, {0.005, 0.02}}, ImageSize -> 800]
$\endgroup$
  • 3
    $\begingroup$ Weird. I do not know why this happens. In my opinion, this is not the expected behavior and you should consider filing a bug report at Wolfram support. For the moment, I can get it working by adding the option MaxCellMeasure -> 0.0002 to the call to ToElementMesh: This adds only a few thousand triangles but the boundary seems to be discretized accurately. $\endgroup$ – Henrik Schumacher Nov 12 '17 at 7:48
  • $\begingroup$ Thank you. The option MaxCellMeasure -> 0.0002 works for me. Maybe because the mesh size has a large gradient in my original case? $\endgroup$ – Wilhelm Nov 12 '17 at 18:54
  • $\begingroup$ You're welcome. I also thought so. Maybe using a smoother MeshRefinementFunction will also help. $\endgroup$ – Henrik Schumacher Nov 12 '17 at 19:32
  • $\begingroup$ Could you please clarify how to using a smoother MeshRefinementFunction? The same problem happens if I increase the amplitude of the wavy boundary, although I played around with changing the value of MaxCellMeasure. See the updated post. $\endgroup$ – Wilhelm Nov 12 '17 at 21:25
  • 4
    $\begingroup$ The MeshRefinementFunction you use has discontinuities in y = ydatum + 0.01 and y = ydatum This causes that several triangles that are adjacent to each other are treated completely different. If I were a meshing algorithm, I wouldn't like to get such inputs/ $\endgroup$ – Henrik Schumacher Nov 12 '17 at 22:02
9
$\begingroup$

If you use a better refinement function things works as expected:

reg = ImplicitRegion[
   Abs[x] <= width/2 && y <= heigth + ydatum && 
    y >= x^2/(2 radius) + Aw (1 - Cos[(2 π x)/λw]) + 
      ydatum, {x, y}];
mesh1 = ToElementMesh[reg, "MeshOrder" -> 1,
   MeshRefinementFunction -> 
    Function[{vertices, area}, 
     area > 0.0005 Mean[vertices[[All, 2]]]]];
mesh1["Wireframe"]

enter image description here

$\endgroup$
  • $\begingroup$ Thank you. I'm not quite understand how the refine mesh function works. For example, what does Mean[vertices[[All, 2]]] mean? There is a computation balance in my case since I need to cut down the computation time. Hence I need a very fine meh at the bottom, but not at the rest part, e.g., say the mesh size (MaxCellMeasure->{"Length"->0.001/3}) at the bottom is about 0.001/3, but the mesh size at the rest part can be larger. At the same time, I want to generate the mesh as a gradient change of mesh size as you did (instead of a abrupt change of mesh size in my post). $\endgroup$ – Wilhelm Nov 14 '17 at 16:56
  • $\begingroup$ @Wilhelm have a look at the documentation. Look for MeshRefinementFunction and in the options of ToElementMesh to see examples. $\endgroup$ – user21 Nov 14 '17 at 22:54
  • $\begingroup$ Thank you @user21. $\endgroup$ – Wilhelm Nov 19 '17 at 2:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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