4
$\begingroup$

I am attempting to use a text character as the base of a three-dimensional prism:

$Version

(* 14.0.0 for Microsoft Windows (64-bit) (December 13, 2023) *)

Echo[rtext = BoundaryDiscretizeGraphics[Text["1"], _Text], "dim rtext:", RegionDimension];
Echo[rline = Line[{{0}, {1}}], "dim rline:", RegionDimension];

(*
» dim rtext:  2
» dim rline:  1
*)

RegionProduct[rtext, rline]
DiscretizeRegion@%

(*
Unevaluated RegionProduct[ «graphical ‹1›», Line[{{0},{1}}] ]

Error message: DiscretizeRegion::drf: DiscretizeRegion was unable to discretize the region RegionProduct[,Line[{{0},{1}}]].

Unevaluated DiscretizeRegion[ RegionProduct[ «graphical ‹1›», Line[{{0},{1}}] ] ]
*)

My expectations were:

  • a 2D-boundary of the digit I used in rtext (Polygon or, if the digit shape has "holes", FilledCurve) as the result of BoundaryDiscretizeGraphics (that looks fine);
  • a 1D-line in rline, which also looks fine;
  • a 3D-body, a prism, as the result of RegionProduct, which didn't happen; and
  • a mesh version of the body from DiscretizeRegion, which also didn't happen.

Clearly I am doing something wrong, but I have done nothing but reading docs, googling, searching SE and trying ever weirder ideas for the past two days and am no closer to a solution. Any help would be very welcome.

Thanks,
Felix.

$\endgroup$

1 Answer 1

6
$\begingroup$
  • Replace 1 to 1.
  • Since RegionProduct is already a MeshRegion, so we need not discrete the region again.
rtext = BoundaryDiscretizeGraphics[Text["1"], _Text];
rline = Line[{{0}, {1.}}];
reg = RegionProduct[rtext, rline];
HighlightMesh[reg, Style[2, Directive@{Opacity[.2], LightCyan}]]

enter image description here

  • Test NDSolveFEM, but MeshRegion does not work,I don't know why.
(* $Version > 13 *)
Needs["NDSolve`FEM`"];
rtext = BoundaryDiscretizeGraphics[Text["1"], _Text];
rline = Line[{{0}, {1}}];
mesh1 = ToElementMesh[rtext];
mesh2 = ToElementMesh[rline];
productMesh = ElementMeshRegionProduct[mesh1, mesh2];
productMesh["Wireframe"] // Show // BoundaryDiscretizeGraphics
  • Add the comment by @user21
(*$Version>13*)
Clear[mesh1, mesh2];
Needs["NDSolve`FEM`"];
rtext = BoundaryDiscretizeGraphics[Text["1"], _Text];
rline = Line[{{0}, {1}}];
mesh1 = ToElementMesh[rtext, "MeshOrder" -> 1];
mesh2 = ToElementMesh[rline, "MeshOrder" -> 1];
productMesh = ElementMeshRegionProduct[mesh1, mesh2];
MeshRegion[productMesh]
$\endgroup$
5
  • 2
    $\begingroup$ That's because MeshRegion can not deal with the second order Prism elements. Try this: mesh1 = ToElementMesh[rtext, "MeshOrder" -> 1]; mesh2 = ToElementMesh[rline, "MeshOrder" -> 1]; productMesh = ElementMeshRegionProduct[mesh1, mesh2]; MeshRegion[productMesh] $\endgroup$ Commented Feb 23, 2024 at 8:49
  • $\begingroup$ @user21 Thanks! $\endgroup$ Commented Feb 23, 2024 at 9:43
  • $\begingroup$ @cvgmt Thank you so much! I have no clue why I must use a machine number as the second Line coordinate, or why the 0 can remain an integer. As a (so far) non-FEM-user, I was equally surprised by the connection to FEM and to NDSolve, and I look forward to learning more about it. Thank you! $\endgroup$ Commented Feb 23, 2024 at 9:53
  • 1
    $\begingroup$ @user21 Are second-order prism elements ones with curved boundaries? So much to learn – thank you! $\endgroup$ Commented Feb 23, 2024 at 9:57
  • 1
    $\begingroup$ @FelixKasza, yes, curved edges: In the Details and Options section of PrismElement the is an illustration. $\endgroup$ Commented Feb 23, 2024 at 10:24

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.