0
$\begingroup$

MeshCoordinates function yields more nodal coordinates than expected. Can I extract the coordinates of vertices only. Here is an example of a square region with a course mesh to explain the problem. I would like the code get me the following coordinates:{{0., 0.}, {0., 0.5}, {0., 1.}, {0.5, 0.}, {0.5, 0.5}, {0.5, 1.}, {1.,0.}, {1., 0.5}, {1., 1.}}.

Needs["NDSolve`FEM`"]
d = Rectangle[{0, 0}, {1, 1}];
mesh = ToElementMesh[d2, MaxCellMeasure -> 0.5];
mesh["Wireframe"]
MeshCoordinates[mesh2][[1, 1]]
$\endgroup$
1
  • $\begingroup$ d2,mesh2 should be d,meshin your code I think. mesh = ToElementMesh[d, MaxCellMeasure -> 1 ]; give the coordinates you wish to get. $\endgroup$ Commented Mar 9, 2022 at 11:24

1 Answer 1

1
$\begingroup$

The function MeshCoordinates works for MeshRegion. ToElementMesh, however, returns an ElementMesh. For an ElementMesh you can extract the coordinates in the following manner:

Needs["NDSolve`FEM`"]
d = Rectangle[{0, 0}, {1, 1}];
mesh = ToElementMesh[d2, MaxCellMeasure -> 0.5];
mesh["Wireframe"]
mesh["Coordinates"]

If you want a first order mesh use:

mesh = ToElementMesh[d2, MaxCellMeasure -> 0.5,"MeshOrder"->1];

Also, I encourage you to look at the documentation of ToElementMesh and ElementMesh for more information.

$\endgroup$
1
  • $\begingroup$ V. clear. Many thanks. $\endgroup$ Commented Mar 10, 2022 at 11:17

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.