4 Fixed typos
source | link

The OP's example exhibits some numerical problems about which the fastidious ToElementMesh and even some System functions complainscomplain. Since the OP is dealing with the System` Region* functions to produce graphics, I'll assume the warnings can be ignored as long as the functions do not fail. There are two things that lead to problems in the OP's example. (1) The RegionPlot is so fine that somehow it generates parts that lead to error messages. (2) The transformation reverses the orientation and in some cases the order-2 "triangles" (which are really hexagons from a Graphics point of view) self-intersect due to the curvature of the images of the lines under the transformation.

(*  ElementMesh[{{1., 100.}, {0.83334, 9.99999}}, {TriangleElement["<" 12707 ">"]}]
   *)

Despite the error, we can still use the ElementMesh to get the desired MeshRegion.

tmesh = MeshRegion@dmesh;
Show[tmesh, Frame -> True, AspectRatio -> 1/2]
(* output similar to above *)

The OP's example exhibits some numerical problems about which the fastidious ToElementMesh even some System functions complains. Since the OP is dealing with the System` Region* functions, I'll assume the warnings can be ignored as long as the functions do not fail. There are two things that lead to problems in the OP's example. (1) The RegionPlot is so fine that somehow it generates parts that lead to error messages. (2) The transformation reverses the orientation and in some cases the order-2 "triangles" (which are really hexagons from a Graphics point of view) self-intersect due to the curvature of the images of the lines under the transformation.

ElementMesh[{{1., 100.}, {0.83334, 9.99999}}, {TriangleElement["<" 12707 ">"]}]
 
tmesh = MeshRegion@dmesh;
Show[tmesh, Frame -> True, AspectRatio -> 1/2]
(* output similar to above *)

The OP's example exhibits some numerical problems about which the fastidious ToElementMesh and even some System functions complain. Since the OP is dealing with the System` Region* functions to produce graphics, I'll assume the warnings can be ignored as long as the functions do not fail. There are two things that lead to problems in the OP's example. (1) The RegionPlot is so fine that somehow it generates parts that lead to error messages. (2) The transformation reverses the orientation and in some cases the order-2 "triangles" (which are really hexagons from a Graphics point of view) self-intersect due to the curvature of the images of the lines under the transformation.

(*  ElementMesh[{{1., 100.}, {0.83334, 9.99999}}, {TriangleElement["<" 12707 ">"]}]  *)

Despite the error, we can still use the ElementMesh to get the desired MeshRegion.

tmesh = MeshRegion@dmesh;
Show[tmesh, Frame -> True, AspectRatio -> 1/2]
(* output similar to above *)
3 Responded to comment
source | link

The OP's updated example

The OP's example exhibits some numerical problems about which the fastidious ToElementMesh even some System functions complains. Since the OP is dealing with the System` Region* functions, I'll assume the warnings can be ignored as long as the functions do not fail. There are two things that lead to problems in the OP's example. (1) The RegionPlot is so fine that somehow it generates parts that lead to error messages. (2) The transformation reverses the orientation and in some cases the order-2 "triangles" (which are really hexagons from a Graphics point of view) self-intersect due to the curvature of the images of the lines under the transformation.

A simpler approach here is to work with the boundary of the region and manually transform the coordinates. We can also use a linear ElementMesh since the interest seems to be graphics and not PDEs.

ϕ = (10 y^(1/2))/x > 1 && (10 y^(1/2))/x < 1.2;
reg = DiscretizeGraphics@ RegionPlot[ϕ, {x, 1, 100}, {y, 1, 100}, PlotPoints -> 100];
breg = BoundaryMesh[reg];

BoundaryMesh::brepl: There are components in [reg] having dimension lower than the embedding dimension 2 that will not be included in the boundary representation. >>

Needs["NDSolve`FEM`"];
bmesh = ToBoundaryMesh[
   "Coordinates" -> Function[{x, y}, {y, x/y}] @@@ MeshCoordinates[breg],
   "BoundaryElements" -> {LineElement @@ Thread[MeshCells[breg, 1], Line]}
   ];
emesh = ToElementMesh[bmesh, "MeshOrder" -> 1, 
   MaxCellMeasure -> {"Area" -> Infinity}];

tmesh = MeshRegion[emesh];
Show[tmesh, AspectRatio -> 1/2, Frame -> True]

Mathematica graphics

My original example

Without a supplied example, let's use this:

Needs["NDSolve`FEM`"]

emesh = ToElementMesh[reg];ToElementMesh[reg, "MeshOrder" -> 1];  (* order 1 added in update *)

xfn = Function[{x, y}, x - y^2/2];
yfn = Function[{x, y}, y - x^2/2];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}];

treg = MeshRegion@dmesh

Side note on OP's example and ElementMeshDeformation

It turns out that if we apply the original approach to the boundary mesh breg, ToElementMesh complains but produces an ElementMesh that can be translated to a MeshRegion without difficulty. (The problem is that the ordering of the vertices of the triangles is wrong.)

emesh = ToElementMesh[breg, "MeshOrder" -> 1];

xfn = Function[{x, y}, y - x];
yfn = Function[{x, y}, x/y - y];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}]

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

ElementMesh[{{1., 100.}, {0.83334, 9.99999}}, {TriangleElement["<" 12707 ">"]}]

tmesh = MeshRegion@dmesh;
Show[tmesh, Frame -> True, AspectRatio -> 1/2]
(* output similar to above *)

Without a supplied example, let's use this:

Needs["NDSolve`FEM`"]

emesh = ToElementMesh[reg];

xfn = Function[{x, y}, x - y^2/2];
yfn = Function[{x, y}, y - x^2/2];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}];

treg = MeshRegion@dmesh

The OP's updated example

The OP's example exhibits some numerical problems about which the fastidious ToElementMesh even some System functions complains. Since the OP is dealing with the System` Region* functions, I'll assume the warnings can be ignored as long as the functions do not fail. There are two things that lead to problems in the OP's example. (1) The RegionPlot is so fine that somehow it generates parts that lead to error messages. (2) The transformation reverses the orientation and in some cases the order-2 "triangles" (which are really hexagons from a Graphics point of view) self-intersect due to the curvature of the images of the lines under the transformation.

A simpler approach here is to work with the boundary of the region and manually transform the coordinates. We can also use a linear ElementMesh since the interest seems to be graphics and not PDEs.

ϕ = (10 y^(1/2))/x > 1 && (10 y^(1/2))/x < 1.2;
reg = DiscretizeGraphics@ RegionPlot[ϕ, {x, 1, 100}, {y, 1, 100}, PlotPoints -> 100];
breg = BoundaryMesh[reg];

BoundaryMesh::brepl: There are components in [reg] having dimension lower than the embedding dimension 2 that will not be included in the boundary representation. >>

Needs["NDSolve`FEM`"];
bmesh = ToBoundaryMesh[
   "Coordinates" -> Function[{x, y}, {y, x/y}] @@@ MeshCoordinates[breg],
   "BoundaryElements" -> {LineElement @@ Thread[MeshCells[breg, 1], Line]}
   ];
emesh = ToElementMesh[bmesh, "MeshOrder" -> 1, 
   MaxCellMeasure -> {"Area" -> Infinity}];

tmesh = MeshRegion[emesh];
Show[tmesh, AspectRatio -> 1/2, Frame -> True]

Mathematica graphics

My original example

Without a supplied example, let's use this:

Needs["NDSolve`FEM`"]

emesh = ToElementMesh[reg, "MeshOrder" -> 1];  (* order 1 added in update *)

xfn = Function[{x, y}, x - y^2/2];
yfn = Function[{x, y}, y - x^2/2];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}];

treg = MeshRegion@dmesh

Side note on OP's example and ElementMeshDeformation

It turns out that if we apply the original approach to the boundary mesh breg, ToElementMesh complains but produces an ElementMesh that can be translated to a MeshRegion without difficulty. (The problem is that the ordering of the vertices of the triangles is wrong.)

emesh = ToElementMesh[breg, "MeshOrder" -> 1];

xfn = Function[{x, y}, y - x];
yfn = Function[{x, y}, x/y - y];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}]

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

ElementMesh[{{1., 100.}, {0.83334, 9.99999}}, {TriangleElement["<" 12707 ">"]}]

tmesh = MeshRegion@dmesh;
Show[tmesh, Frame -> True, AspectRatio -> 1/2]
(* output similar to above *)
2 Fixed typos
source | link

Without a supplied example, let's use this:

reg = DiscretizeGraphics@ RegionPlot[(x^2 + y^2)^2 - 12 x y <= 1, {x, -2, 2}, {y, -2, 2}]

Mathematica graphics

I get a different error, suggesting that TransformedRegion is not implemented for mesh regions (well, sort of suggesting something like it).

TransformedRegion[reg, xfn = Function[{x, y}, {x - y^2/2, y - x^2/2}]];

TransformedRegion::rnimpl: The function TransformedRegion is not implemented for  (reg) . >>

Such functionality is built into the FEM utilities, though.

Needs["NDSolve`FEM`"]

emesh = ToElementMesh[reg];

xfn = Function[{x, y}, x - y^2/2];
yfn = Function[{x, y}, y - x^2/2];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}];

treg = MeshRegion@dmesh

Mathematica graphics

Notes: (1) Since we're transforming a mesh region, the polygonal boundary will be transformed into a polygonal boundary. ToElementMesh may subdivide an original boundary segment and the subdividing points will be mapped onto the image of the segment; they will not be mapped on to the boundary of the original region defined by the equation. (2) A transformation that is nonot 1-1 or reverses orientation will generate an error.

Without a supplied example, let's use this:

reg = DiscretizeGraphics@ RegionPlot[(x^2 + y^2)^2 - 12 x y <= 1, {x, -2, 2}, {y, -2, 2}]

Mathematica graphics

I get a different error, suggesting that TransformedRegion is not implemented for mesh regions (well, sort of suggesting something like it).

TransformedRegion[reg, xfn = Function[{x, y}, {x - y^2/2, y - x^2/2}]];

TransformedRegion::rnimpl: The function TransformedRegion is not implemented for  . >>

Such functionality is built into the FEM utilities, though.

Needs["NDSolve`FEM`"]

emesh = ToElementMesh[reg];

xfn = Function[{x, y}, x - y^2/2];
yfn = Function[{x, y}, y - x^2/2];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}];

treg = MeshRegion@dmesh

Mathematica graphics

Notes: (1) Since we're transforming a mesh region, the polygonal boundary will be transformed into a polygonal boundary. ToElementMesh may subdivide an original boundary segment and the subdividing points will be mapped onto the image of the segment; they will not be mapped on to the boundary of the original region defined by the equation. (2) A transformation that is no 1-1 will generate an error.

Without a supplied example, let's use this:

reg = DiscretizeGraphics@ RegionPlot[(x^2 + y^2)^2 - 12 x y <= 1, {x, -2, 2}, {y, -2, 2}]

Mathematica graphics

I get a different error, suggesting that TransformedRegion is not implemented for mesh regions (well, sort of suggesting something like it).

TransformedRegion[reg, Function[{x, y}, {x - y^2/2, y - x^2/2}]];

TransformedRegion::rnimpl: The function TransformedRegion is not implemented for (reg) . >>

Such functionality is built into the FEM utilities, though.

Needs["NDSolve`FEM`"]

emesh = ToElementMesh[reg];

xfn = Function[{x, y}, x - y^2/2];
yfn = Function[{x, y}, y - x^2/2];
xifn = ElementMeshInterpolation[{emesh}, xfn @@@ emesh["Coordinates"]];
yifn = ElementMeshInterpolation[{emesh}, yfn @@@ emesh["Coordinates"]];
dmesh = ElementMeshDeformation[emesh, {xifn, yifn}];

treg = MeshRegion@dmesh

Mathematica graphics

Notes: (1) Since we're transforming a mesh region, the polygonal boundary will be transformed into a polygonal boundary. ToElementMesh may subdivide an original boundary segment and the subdividing points will be mapped onto the image of the segment; they will not be mapped on to the boundary of the original region defined by the equation. (2) A transformation that is not 1-1 or reverses orientation will generate an error.

1
source | link