4
$\begingroup$

I have a hole in an infinite plate and a code that generates a finite element mesh of it. I need more elements concentrated near the hole, because the solution varies more at this region. The issue here is that in Mesh 1 is missing some elements near the hole. The only diference between the codes is that in one i have specified MeshOrder->order, and in the other don't. Why is that?

Mesh 1 code:

Needs["NDSolve`FEM`"]
order = 2;
R = 10;
RF = 200;
mesh = ToElementMesh[
  ImplicitRegion[
   R <= Sqrt[x x + y y] && RF >= Sqrt[x x + y y] , {x, y}], {{0, 
    RF}, {0, RF}}, "MeshOrder" -> order, 
  MeshRefinementFunction -> 
   Function[{vertices, area}, 
    Block[{x, y}, {x, y} = Mean[vertices]; 
     If[(Sqrt[x x + y y] >= R && Sqrt[x x + y y] <= 1.5 R), area > 1, 
      area > 5000]]]]

mesh["Wireframe"]

enter image description here

Mesh 2 code:

mesh = ToElementMesh[
  ImplicitRegion[
   R <= Sqrt[x x + y y] && RF >= Sqrt[x x + y y] , {x, y}], {{0, 
    RF}, {0, RF}}, 
  MeshRefinementFunction -> 
   Function[{vertices, area}, 
    Block[{x, y}, {x, y} = Mean[vertices]; 
     If[(Sqrt[x x + y y] >= R && Sqrt[x x + y y] <= 1.5 R), area > 1, 
      area > 5000]]]]

mesh["Wireframe"]

enter image description here

enter image description here

$\endgroup$
6
  • $\begingroup$ What do you mean by 'discontinuities'? It's not clear what you are asking. $\endgroup$
    – user21
    Commented Apr 28, 2017 at 14:11
  • $\begingroup$ @user21 if you look closely in the figures you will see that in Mesh 1 are missing some elements near the hole. $\endgroup$
    – Stratus
    Commented Apr 28, 2017 at 14:18
  • $\begingroup$ I don't see it - may you can edit you post to contain a zoomed picture that shows what you mean. $\endgroup$
    – user21
    Commented Apr 28, 2017 at 14:19
  • $\begingroup$ @user21 i have added a picture comparing both meshes closely. $\endgroup$
    – Stratus
    Commented Apr 28, 2017 at 14:24
  • $\begingroup$ OK, I see. One last question - why do you specify "MeshOrder" explicitly? Any particular reason? $\endgroup$
    – user21
    Commented Apr 28, 2017 at 14:34

1 Answer 1

1
$\begingroup$

You can avoid the issue you are seeing by generating a first order boundary mesh for the numerical region and then call ToElementMesh on that. The key is to generate a first order boundary mesh - that's what ToElementMesh does in the default usage. Using "MeshOrder"->2 also generates a second order boundary mesh, which seems to interfere with the refinement function.

Needs["NDSolve`FEM`"]
order = 2;
R = 10;
RF = 200;
nr = ToNumericalRegion[
   ImplicitRegion[
    R <= Sqrt[x x + y y] && RF >= Sqrt[x x + y y], {x, y}], {{0, 
     RF}, {0, RF}}];
(* make a first order boundary mesh *)

bmesh = ToBoundaryMesh[nr, "MeshOrder" -> 1];
mesh = ToElementMesh[nr, "MeshOrder" -> order, 
   MeshRefinementFunction -> 
    Function[{vertices, area}, Block[{x, y}, {x, y} = Mean[vertices];
      If[(Sqrt[x x + y y] >= R && Sqrt[x x + y y] <= 1.5 R), area > 1,
        area > 5000]]]];
Show[mesh["Wireframe"], PlotRange -> {{-1, 20}, {-1, 20}}]

enter image description here

$\endgroup$
5
  • $\begingroup$ your code here in my computer still return a mesh missing some elements. $\endgroup$
    – Stratus
    Commented Apr 28, 2017 at 18:12
  • $\begingroup$ What version are you using? This works fine on 11.1. $\endgroup$
    – user21
    Commented Apr 28, 2017 at 18:33
  • $\begingroup$ @ user21 i'm using 11.0 $\endgroup$
    – Stratus
    Commented Apr 28, 2017 at 18:48
  • $\begingroup$ I no longer have 11.0 installed, in fact I am using 11.1.1. Is an upgrade an option? $\endgroup$
    – user21
    Commented Apr 28, 2017 at 18:59
  • $\begingroup$ Did you get a change to upgrade? $\endgroup$
    – user21
    Commented May 2, 2017 at 12:57

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.