3
$\begingroup$

Based on this simple example of a triangle mesh

Needs["NDSolve`FEM`"]
mesh = ToElementMesh[Rectangle[] , "MaxCellMeasure" -> .05 ,"MeshElementType" ->"TriangleElement", "MeshOrder" -> 1]
mesh["Wireframe"]

enter image description here

I would like to ask the following question:

How can I force mathematica to create a triangle mesh with at least two elements at each corner?

Thanks!

$\endgroup$
6
  • $\begingroup$ I think I may not be understanding your question. Could you clarify (perhaps with a graphical example) what you mean by two triangle elements in each corner? Do you mean that the vertex of the enclosing square should be a vertex for two triangles, instead of one as it is above? $\endgroup$
    – MarcoB
    Dec 6, 2022 at 14:09
  • $\begingroup$ Sorry for need of clarification. The simpliest mesh I'm looking for would consist of rectangle +two diagonals. $\endgroup$ Dec 6, 2022 at 15:14
  • $\begingroup$ I am not sure why TWO diagonals would be the simplest. Surely the simplest triangulation would only have ONE diagonal, i.e. dividing the rectangle into two triangles? That can be accomplished with a large enough value of MaxCellMeasure, e.g. MaxCellMeasure -> 1. I could not find any value for MaxCellMeasure that would give four triangles (i.e. both diagonals). $\endgroup$
    – MarcoB
    Dec 6, 2022 at 16:49
  • $\begingroup$ I can get the TWO diagonal version using TriangulateMesh[Rectangle[], MaxCellMeasure -> 0.3] if that helps $\endgroup$
    – MarcoB
    Dec 6, 2022 at 17:00
  • $\begingroup$ @MarcoB two diagonal version fullfills all four corner conditions $\endgroup$ Dec 6, 2022 at 19:59

2 Answers 2

2
$\begingroup$

I was able to get the desired outcome using the build in TriangulateMesh:

TriangulateMesh[Rectangle[], MaxCellMeasure -> 0.3]

a mesh of four triangles, from the square cut by both diagonals

The best I could get with the FEM machinery is only one diagonal:

Needs["NDSolve`FEM`"]

ToElementMesh[
  Rectangle[], "MaxCellMeasure" -> 1,
  "MeshElementType" -> "TriangleElement", "MeshOrder" -> 1
 ]["Wireframe"]

rectangle bisected by only one diagonal

$\endgroup$
1
  • $\begingroup$ Thanks for your helpful answer. Still I would like to give a mesh constraint "Every meshpoint has at least 3 neighbors" $\endgroup$ Dec 7, 2022 at 8:46
1
$\begingroup$

You could try including more points near the corners. E.g.:

Needs["NDSolve`FEM`"]
mesh = ToElementMesh[Rectangle[], "MaxCellMeasure" -> .02, 
  "MeshElementType" -> "TriangleElement", "MeshOrder" -> 1, 
  "IncludePoints" -> {{0.1, 0.1}, {0.9, 0.9}}]
mesh["Wireframe"]

enter image description here

$\endgroup$
2
  • $\begingroup$ Tahnks for this simple approach. But it depends sensitively on value of MaxCellMeasure. I tried "MaxCellMeasure" -> .04 which gives unexpacted result $\endgroup$ Dec 6, 2022 at 15:33
  • $\begingroup$ You could try to add additional points on the border near the corners. $\endgroup$ Dec 7, 2022 at 8:48

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.