5
$\begingroup$

I want to create an element mesh from an arc $x=Rcos(\varphi), y=Rsin(\varphi)$, with $R=100, \varphi \in [0,\pi/4]$ which looks like this:

Graphics[Circle[{0, 0}, 100, {0, Pi/4}]]

enter image description here

I want to discretize the region with 8 elements, so I tried something like this:

ToElementMesh[
    "Coordinates" -> Table[{100 Cos[phi], 100 Sin[phi]}, {phi, 0, Pi/4, 1/8 Pi/4}],
    "MeshElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 8}, {8, 9}}]}
]

This results in:

ToElementMesh: The element dimension of LineElement[{{1,2},{2,3},{3,4},{4,5},{5,6},{6,7},{7,8},{8,9}}] is not consistent with other elements that are of dimension 2.
ToElementMesh: A mesh could not be generated.

I used this example for 1D from the docs as a template (this is the only example of 1D element meshes from the docs):

ToElementMesh[
    "Coordinates" -> Partition[Range[0., 1., 1/9], 1], 
    "MeshElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 5}, {5, 6}, {6, 7}, {7, 8}, {8, 9}, {9, 10}}]}
]

The problem seems to be that the dimension of the "Coordinates" is {9,2} instead of {9,1}, but I haven't been able to figure out how to deal with this. Can this be done with ToElementMesh or is there another way to do this?

EDIT: This does what I wanted:

MeshRegion[
    Table[{100 Cos[phi], 100 Sin[phi]}, {phi, 0, Pi/4, 1/8 Pi/4}], 
    Line[{1, 2, 3, 4, 5, 6, 7, 8, 9}]
]

enter image description here

$\endgroup$
2
  • $\begingroup$ Have you seen MeshRegion and DiscretizeGraphics? $\endgroup$ Jun 22, 2020 at 7:29
  • $\begingroup$ @HenrikSchumacher Thanks for the tip, tried that now and DiscretizeGraphics does the trick! $\endgroup$
    – inot12
    Jun 22, 2020 at 7:33

1 Answer 1

4
$\begingroup$

When you use ToElementMesh the result will always be a mesh of the full region. What you want to do in this case is to generate a boundary mesh were the embedding dimension is not the same as the region dimension:

Needs["NDSolve`FEM`"]
ToBoundaryMesh[
 "Coordinates" -> 
  Table[{100 Cos[phi], 100 Sin[phi]}, {phi, 0, Pi/4, 1/8 Pi/4}], 
 "BoundaryElements" -> {LineElement[{{1, 2}, {2, 3}, {3, 4}, {4, 
      5}, {5, 6}, {6, 7}, {7, 8}, {8, 9}}]}]

(* ElementMesh[{{70.7107, 100.}, {0., 70.7107}}, Automatic] *)
$\endgroup$
2
  • $\begingroup$ Thank you for the explanation, this works. $\endgroup$
    – inot12
    Jun 22, 2020 at 8:08
  • $\begingroup$ @inot12, you are welcome. $\endgroup$
    – user21
    Jun 22, 2020 at 8:11

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.