Message Boards Message Boards

How to customize complex solution regions for NDSolve like the example in Mathematica?

Posted 5 days ago

The example of mathematica for solving PDE on a irregular region

Hello, everyone!
I have came across an interesting example of solving PDE on a customize complex solution regions like the alphabet region of "Wolfram" in the Official Example (see the picture or the website https://www.wolfram.com/mathematica/new-in-10/symbolic-geometry/solve-partial-differential-equations-over-regions.html
. I am wondering that how can I define this kind of region, since I want to try this example using different alphabet like "EIAS"? I cannot find any functions or codes to realize this example.

I am using Mathematica 14 now.
Thanks very much.

POSTED BY: HAO XU
5 Replies

Perhaps something like this:

reg = BoundaryDiscretizeGraphics[
  First@ImportString[
    ExportString[Style["HAO XU", 64], "PDF"],
    {"PDF", "PageGraphics"}],
  MaxCellMeasure -> 0.5] (* adapt MaxCellMeasure as desired *)

If you want letters in a certain font, change the Style[]:

Style["HAO XU", 64, FontFamily -> "Times", FontSlant -> Italic]
Style["数学", 48]

And so forth.

POSTED BY: Michael Rogers

Here's a silly toy:

Needs["NDSolve`FEM`"];
reg = BoundaryDiscretizeGraphics[
   First@ImportString[
     ExportString[Style["钨", 64, FontFamily -> "Songti SC"], "PDF"],
     {"PDF", "PageGraphics"}],
   MaxCellMeasure -> 0.05];
usol = NDSolveValue[{Laplacian[u[x, y], {x, y}] == -2, 
    DirichletCondition[u[x, y] == 0, True]}, u, {x, y} \[Element] reg];
Animate[
 ElementMeshPlot3D[
  ElementMeshInterpolation[usol["ElementMesh"], 
   a  usol["ValuesOnGrid"]]
  , ColorFunction -> Function[{u}, Blend[{Black, Red}, u/2.]], 
  ColorFunctionScaling -> False, PlotRange -> {All, All, {0, 4}}
 ], 
 {a, 0, 1},
 AnimationDirection -> ForwardBackward, 
 AnimationRate -> 0.2]

Chinese character for tungsten, animated to turn from black to red

Google translate tells me this is the Chinese character for the Latin wolframium.

POSTED BY: Michael Rogers

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. Posting code Images doesn't help other members to copy your code. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

You can also embed notebook or attach notebook.

enter image description here

POSTED BY: Moderation Team
Posted 4 days ago

Wow! That is so fantastic! Your code is so concise and effective. It can also run successfully on my computer。Thanks a ton for sharing this!

POSTED BY: HAO XU
Posted 4 days ago

Thank you very much! Your examples are concise and understandable, and are even applicable to the Chinese context, which pleasantly surprised me. Thanks again for your help!

POSTED BY: HAO XU
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract