When I created mesh by function with ToElementMesh, some errors occured. The code below is a minimal example. I can't understand why it failed.

coordinates = {{0,0}, {1,0}, {1,1}, {0,1}};
meshinc = TriangleElement[{{1, 2, 4}}];
mesh = ToElementMesh["Coordinates" -> coordinates, "MeshElements" -> {meshinc}]

I think it should have succeeded in creating a triangle element with the vertexs of $(0,0)$, $(1,0)$, $(0,1)$, I know the nodes of the elements should be in the anticlockwise dieection, but it stilled failed. However, it will succeed when

meshinc = TriangleElement[{{1, 2, 3}}]

The code below also failed

mesh = 
   "Coordinates" -> 
     {{0, 0}, {1, 0}, {2, 0}, {0, 1}, {1, 1}, {2, 1}, {0, 2}, {1, 2}, {2, 2}}, 
  "MeshElements" -> {QuadElement[{{1, 2, 5, 4}}]}]

Could you explain my failures and advise me on some principles to use when creating a mesh?

  • $\begingroup$ The reason is given in the error message. See my answer/long comment. $\endgroup$ – Michael E2 Jan 4 '16 at 13:50

The explanation is in the error message (emphasis mine):

ToElementMesh::fememins: The mesh elements are not valid. A set of valid mesh element incidents needs to be positive integers and be able to form a complete sequence starting from 1 to the largest incident present. There are missing incidents; a complete sequence cannot be formed. >>

It helps to give complete information in the question, by the way, including error messages.

| improve this answer | |
  • $\begingroup$ Thanks a lot @Michael E2, I'm using a Chinese version MMA, I think maybe I can switch to English :) $\endgroup$ – Ice0cean Jan 4 '16 at 13:53
  • $\begingroup$ Oh I noted the message provided in Chinese, it looks so strange $\endgroup$ – Ice0cean Jan 4 '16 at 13:59
  • $\begingroup$ @Ice0cean Ah. Do you mean the messages say something different in Chinese? $\endgroup$ – Michael E2 Jan 4 '16 at 13:59
  • $\begingroup$ Yes, even I'm a native Chinese speaker, I can't understand what's the message means, it looks confusing. em, just like some Chinese characters's combination :( Maybe something wrong when translated to Chinese. $\endgroup$ – Ice0cean Jan 4 '16 at 14:06
  • $\begingroup$ @Ice0cean Yes, it must take a lot of work to get all the translations correct. Consider reporting it to WRI, if you can. $\endgroup$ – Michael E2 Jan 4 '16 at 14:13

Not the answer you're looking for? Browse other questions tagged or ask your own question.