# Invalid region for small angles. To Element Mesh. Finite element method

I would like to mesh the region below in order to use it for a calculation by means of NDSolve. Could anyone help me to discretize this region for NDSolve using. Thank you very much.

Needs["NDSolveFEM"];

Rwg=7.0; RLiner=8.0; RRib=8.5; RExt=9.0; Theta1=0.0227; Theta2=0.00916;

Ω=ImplicitRegion[
!(x^2 + y^2>RLiner^2 && x^2 + y^2< RRib^2 && 0<y<x*Tan[Theta2])&&
(y>=0 && x^2 + y^2>=Rwg^2 && x^2 + y^2<=RExt^2 && y<=x Tan[Theta1]),{x, y}];

Show[ RegionPlot[Ω], ImageSize -> 300]

ToElementMesh[Ω,MaxCellMeasure -> 0.0001]["Wireframe"]

• Welcome to the site, you've done well to post your code, and we'd love to help, but we can't really check the code without values for all those constants. Mar 15, 2016 at 15:41
• The constants values are: Rwg=7.0; RLiner=8.0; RRib=8.5; RExt=9.0; Theta1=Pi/4; Theta2=Pi/8; Thank you. I would be very grateful for your reply. Mar 15, 2016 at 15:46
• When I enter this code, I get this result, so I have no error with version 10.3.1. What version are you using? The mesh is extremely fine and I assume memory intensive, what happens if you change it to MaxCellMeasure -> 0.1? Mar 15, 2016 at 15:56
• Antony, please use the edit link right under your question to add those details in the question itself. Mar 15, 2016 at 15:56
• Don't you just hate it when the OP changes the problem! Mar 16, 2016 at 11:34

Look at the boundary mesh generated for the region:

Needs["NDSolveFEM"];
Rwg=7.0;RLiner=8.0;RRib=8.5;RExt=9.0;Theta1=0.0227;Theta2=0.00916;
\[CapitalOmega]=ImplicitRegion[!(x^2+y^2>RLiner^2&&x^2+y^2<RRib^2&&0<y<x*Tan[Theta2])&&(y>=0&&x^2+y^2>=Rwg^2&&x^2+y^2<=RExt^2&&y<=x Tan[Theta1]),{x,y}];
ToBoundaryMesh[\[CapitalOmega]]["Wireframe"] You see there is a line at y==0 which should not be there.

\[CapitalOmega][] /. {x -> 8.4, y -> 0}
True


If you reformulate the region to:

LOWER = -1;
\[CapitalOmega] =
ImplicitRegion[! (x^2 + y^2 > RLiner^2 && x^2 + y^2 < RRib^2 &&
LOWER <= y < x*Tan[Theta2]) && y >= 0 && x^2 + y^2 >= 49. &&
x^2 + y^2 <= 81. && y <= 0.022703899831486306 x, {x, y}]


This example works as expected:

ToElementMesh[\[CapitalOmega]]["Wireframe"] Now, various version of Mathematica use different (default) algorithms to to discretize regions. Even more so DiscretizeRegion and ToElementMesh may use different algorithms in the same version. What I have shown here is version 10.4

• Thanks - this method works for version 10.2 as well so it solves OP's problem. I knew it was a good idea to call in the artillery Mar 17, 2016 at 9:39
• @JasonB, I always thought of myself as being a little more subtle than the artillery ;-) Mar 17, 2016 at 19:00

I believe this is a bug: for some reason changing the conditional y<x Tan[] to y/x<Tan[] makes it work:

Rwg = 7.0; RLiner = 8.0; RRib = 8.5; RExt = 9.0;
Theta1 = 0.0227
Theta2 = 0.0091
\[CapitalOmega] =
ImplicitRegion[! (x^2 + y^2 > RLiner^2 && x^2 + y^2 < RRib^2 &&
0 < y/x < Tan[Theta2]) &&
(y >= 0 && x^2 + y^2 >= Rwg^2 && x^2 + y^2 <= RExt^2 &&
y/x <= Tan[Theta1]), {x, y}];
Show[RegionPlot[\[CapitalOmega]], ImageSize -> 300]
<< NDSolveFEM
ToElementMesh[\[CapitalOmega], MaxCellMeasure -> 0.0001]["Wireframe"]


note the mesh is so dense the wireframe image is just black. here it is with MaxCellMeasure->0.0025 v10.1/Windows. Minimal example of the issue:

 GraphicsRow@Table[
RLiner = 8.; RRib = 8.5;
o2 = ImplicitRegion[
RLiner^2 <= x^2 + y^2 <= RRib^2 && 0 <= y <= x Tan[Theta2], {x,
y}];
Show[{RegionPlot[o2, PlotStyle -> Red] ,
Plot[{x Tan[Theta2]}, {x, 0, 9}]},
PlotRange -> {0, .8}] , {Theta2, {.09, .075}}] • Thank you. But, unfourtunately, running your code I have back "The implicit region is not a valid region to plot". Moreover, the region discretizaed does not corresponds to the region I want actually discretized Mar 16, 2016 at 8:19
• @Antony, what version of Mathematica are you using? Please answer this, as it could have a great effect on which answer is right for you. Also, what about using DiscretizeRegion@Ω? Mar 16, 2016 at 8:51
• @george2079 - I can confirm the bug in your minimal example is there in 10.1 but fixed by 10.2. I can also say that the bug appears to be confined to RegionPlot. If you replace the first argument of your Show command with {Plot[{x Tan[Theta2]}, {x, 0, 9}], DiscretizeRegion@o2} then it seems to work just fine. Mar 16, 2016 at 10:24
• @JasonB: I am using the Mathematica 10.2. I never used DiscretizedRegion@Ω Mar 16, 2016 at 10:29
• @Antony - Excellent, I can confirm that the code in the original post gives me an error in version 10.2 - now I can try to find a workaround. I've never used the FEM capabilities for NDSolve, so I don't really know the difference between an ElementMesh and a MeshRegion Mar 16, 2016 at 10:33

It can sometimes help out if you Reduce your implicit description of the region first.

ToElementMesh[
ImplicitRegion[! (x^2 + y^2 > RLiner^2 && x^2 + y^2 < RRib^2 &&
0 < y < x*Tan[Theta2]) && (y >= 0 && x^2 + y^2 >= Rwg^2 &&
x^2 + y^2 <= RExt^2 && y <= x Tan[Theta1]) // Reduce // Evaluate,
{x, y}], MaxCellMeasure -> 0.0001]["Wireframe"] As has been pointed out, it's a very fine mesh. Here it is with MaxCellMeasure commented out: • the OP changed the angles in the question to ones that cause an error. Interestingly with these new angles, I get the error with the Reduce but it runs fine without: i.stack.imgur.com/QHboS.png Mar 16, 2016 at 10:10

This is all very confusing, different versions of Mathematica seem to react differently to the different region functions involved here. What I'm going to write here is only really applicable to version 10.2, I may put a note at the bottom for other versions.

Here is the region,

With[{Rwg = 7.0, RLiner = 8.0, RRib = 8.5, RExt = 9.0,
Theta1 = 0.0227, Theta2 = 0.00916},
region = ! (x^2 + y^2 > RLiner^2 && x^2 + y^2 < RRib^2 &&
0 < y < x*Tan[Theta2]) && (y >= 0 && x^2 + y^2 >= Rwg^2 &&
x^2 + y^2 <= RExt^2 && y <= x Tan[Theta1]);
]


We try to create an ElementMesh from this region,

Needs["NDSolveFEM"];
ToElementMesh[ImplicitRegion[
region, {x, y}],
MaxCellMeasure -> 0.0001]["Wireframe"]


During evaluation of In:= ToElementMesh::fememins: The mesh elements are not valid. A set of valid mesh element incidents needs to be positive integers and be able to form a complete sequence starting from 1 to the largest incident present. There are missing incidents; a complete sequence cannot be formed. >>

During evaluation of In:= ToElementMesh::femtemnm: A mesh could not be generated. >>

(* $Failed["Wireframe"] *)  We try MichaelE2's trick of simplifying the conditionals, ToElementMesh[ImplicitRegion[ Evaluate@Reduce@region, {x, y}], MaxCellMeasure -> 0.0001]["Wireframe"]  During evaluation of In:= ToElementMesh::fememib: The input has or generated an intersecting boundary and cannot be processed. >> During evaluation of In:= ToElementMesh::femtemnm: A mesh could not be generated. >> (*$Failed["Wireframe"] *)


Still no luck. But if we first create a MeshRegion and then convert it to an ElementMesh, then it does work, even though it still gives some errors.

dregion = DiscretizeRegion[
ImplicitRegion[
Evaluate@Reduce@region, {x, y}],
Method -> "Continuation", PerformanceGoal -> "Quality"];
ToElementMesh[dregion, MaxCellMeasure -> 0.0001]["Wireframe"]
`

DiscretizeRegion::drcm: Method->Continuation not able to resolve all components of dimension less than the embedding dimension 2; these may be omitted from the result. >>

ToElementMesh::femimq: The element mesh has insufficient quality of -20.1137. A quality estimate below 0. may be caused by a wrong ordering of element incidents or self-intersecting elements. >> ## Edit

As shown in this screenshot, I only get this error in version 10.2, not in 10.1 or 10.3 