5
$\begingroup$

I am trying to generate 1D mesh points on x axis, shown below:

Needs["NDSolve`FEM`"]
eC = 100(*Element Count*);
xMesh = ToGradedMesh[{{Line[{{0}, {3}}], <|"Alignment" -> "Right", 
      "ElementCount" -> eC|>}, {Line[{{3}, {4}}], <|
      "Alignment" -> "Left", 
      "ElementCount" -> eC|>}, {Line[{{4}, {5}}], <|
      "Alignment" -> "Right", "ElementCount" -> eC, 
      "GradingRatio" -> 1.2|>}, {Line[{{5}, {7}}], <|
      "Alignment" -> "Left", "ElementCount" -> eC, 
      "GradingRatio" -> 1.2|>}}];
MeshRegion[xMesh]

The code worked fine when my element count eC is 10. However, when I try to increase the element count eC to 100, the following error arises:

enter image description here

For more context, I want the mesh points to concentrate in certain regions (x=3, and x=5). Therefore, I used GradingRatio to tune the non-uniformity of their distributions. I realized that the error above also tends to occur when the GradingRatio value increases.

$\endgroup$

1 Answer 1

8
$\begingroup$

The exact reasoning behind this is somewhat complicated. But I'll show a way to modify this; even when I do not advise to do it. Let's look at a simpler example:

Needs["NDSolve`FEM`"]
eC = 80;(* workds *)
eC = 81(*fails*);
xMesh = ToGradedMesh[{
   {Line[{{4}, {5}}], <|"Alignment" -> "Right", "ElementCount" -> eC, 
     "GradingRatio" -> 1.2|>}}]

This fails to generate a mesh. using 80 elements will work. Once you have called ToGradedMesh once you have access to an internal variable

NDSolve`FEM`ToGradedMeshDump`$elementTolerance // N
(* 1.*10^-8 *)

If you relax this safety factor a bit, to say:

NDSolve`FEM`ToGradedMeshDump`$elementTolerance = 10^-6;

Then this will work:

eC = 100;
xMesh = ToGradedMesh[{
   {Line[{{4}, {5}}], <|"Alignment" -> "Right", "ElementCount" -> eC, 
     "GradingRatio" -> 1.2|>}}]
$\endgroup$

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.