Message Boards Message Boards

0
|
2129 Views
|
0 Replies
|
0 Total Likes
View groups...
Share
Share this post:

ToElementMesh does not recognize MeshRefinementFunction in 1D

Posted 4 years ago

When creating a 1D mesh for solving a PDE using the new FiniteElement method of NDSolve in Mathematica 12.1, I stumbled across the following problem that (at least to my understanding) seems to be a bug:

When one creates a Mesh for an Interval (say, [-1,1]) this can be done via DiscretizeRegion[Interval[{-1, 1}]] or via MeshRegion[ToElementMesh[Interval[{-1, 1}]]] both returning equivalent results (apart from different standard mesh sizes).

However, if I want to include a mesh refinement function, for which I take as a minimum working example just a simple length constraint (which could of course also be obtained by setting MaxCellMeasure but this is not what I want eventually), I get the following:

In[]:= ToElementMesh[Interval[{-1, 1}], MeshRefinementFunction -> Function[{vert, len}, len > 0.01]]
ToElementMesh::mrff: The MeshRefinementFunction Function[{vert,len},len>0.01] is not valid and will be ignored. The function does not return either True or False.
Out[]= ElementMesh[{{-1., 1.}}, {LineElement["<" 20 ">"]}]

With DiscretizeRegion[Interval[{-1, 1}], MeshRefinementFunction -> Function[{vert, len}, len > 0.01]] this works as expected, i.e. returns a properly refined MeshRegion object with 320 elements. In 2D (as in the documentation) this works for both versions (ToElementMesh and DiscretizeRegion) as expected. Finally, I want to mention that the error does not depend on the actual code of the MeshRefinementFunction used. To my understanding, this is a bug. My question is now, if someone could confirm that this is a bug or if I completely misunderstood the documentation. Thanks!

As a workaround, in 1D it is not too difficult to generate a manual list of points that are then passed on to ToElementMesh[].

POSTED BY: René Sedmik
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract