3
$\begingroup$

I would like to create a 1D mesh of the intervall (-pi/2,pi/2) for solving a DE with FEM, with more elements close to +-1 - these elements should be of order 2, since order 1 elements yield too low accuracy.

For the function ToElementMesh the option "MeshRefinementFunction" does not work in 1D, which is why I tried to first use the function Discretize region and convert the result a FEM mesh, this gives the wrong answer though:

Needs["NDSolve`FEM`"];
A = ImplicitRegion[True, {{x, -\[Pi]/2, \[Pi]/2}}];
f = Function[{vertices, area}, 
   area > 0.01 (1 + 10*Abs[(Norm[Mean[vertices]] - 1)])];
B = DiscretizeRegion[A, MeshRefinementFunction -> f]

Z = ToElementMesh[B]
ElementMesh[{{-1.5708, 4.63385}}, {LineElement["<" 159 ">"]}]

The resulting mesh goes from -pi/2 to ~4.6 and not to pi/2 as it should be. Is there any way to get this to work? Thanks in advance.

$\endgroup$
1
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Sep 29 at 13:25
3
$\begingroup$

Hm, smells like a bug. You can use this in the mean time:

MeshOrderAlteration[B["MakeRepresentation"["ElementMesh"]], 2]
$\endgroup$
1
  • $\begingroup$ This gives me just what I needed, thanks a lot! $\endgroup$
    – Eddi
    Sep 30 at 8:49

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.