# Finite element mesh generation with specified coordinates [closed]

I am trying to use Mathematica's FEM capabilities, but I want to generate my own QuadElement mesh. (The key word in here is trying.)

Needs["NDSolveFEM"]
nx = ny = 5;
coordinates =
Flatten[ Table[{-Cos[(π/nx) i], -Cos[(π/ny) j]}, {i, 0, nx, 1}, {j, 0, ny, 1}], 1];
ToElementMesh[Rectangle[{-1, -1}, {1, 1}],
"Coordinates" -> coordinates,

I am getting the error messages:

Unknown option Coordinates for ToElementMesh
Unknown option MeshElementsType for ToElementMesh

But both options are described in the Mathematica documentation.

Where is my mistake? Or worse, where are my mistakes? :)

### Edit

While changing the code from "MeshElements" to "MeshElementType", I forget the "s" at the end and wrote "MeshElementsType".

## closed as off-topic by Pinti, MarcoB, Alex Trounev, JungHwan Min, Bill WattsFeb 2 at 3:27

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Pinti, MarcoB, Alex Trounev, JungHwan Min, Bill Watts
If this question can be reworded to fit the rules in the help center, please edit the question.

• I suggest that you read documentation (about possible syntax) for ToElementMesh carefully. You are mixing function syntax with region (Rectangle) and syntax with rules ("Coordinates"->... and "MeshElements"->...). – Pinti Jan 30 at 15:13
• Also, it's "MeshElementType" not "MeshElementsType". Mind the "s". – Henrik Schumacher Jan 30 at 15:14

If you want to prescribe the points, you have to generate the mesh yourself. With the function getGridQuads below, you may try this:

nx = ny = 5;
R = ToElementMesh[
"Coordinates" -> Tuples[-Cos[Subdivide[0., Pi , nx - 1]], 2],
]

Code dump:

Compile[{{m, _Integer}, {n, _Integer}, {xclosed, True | False}, {yclosed, True | False}},
Block[{a1, a2, a3, a4, b1, b2, quads, qq, mm, nn},
b1 = Boole[xclosed];
b2 = Boole[yclosed];
mm = m - b1;
nn = n - b2;

qq = Table[
a1 = mm (j - 1) + i;
a2 = mm (j - 1) + i + 1;
a3 = mm j + i;
a4 = mm j + i + 1;
{a1, a2, a4, a3},
{i, 1, mm - 1}];

If[xclosed,
Join[qq,
a1 = mm (j - 1) + mm;
a2 = mm (j - 1) + 1;
a3 = mm (j) + 1;
a4 = mm (j) + mm;
{{a1, a2, a3, a4}}
],
qq
]
,
{j, 1, nn - 1}], 1];

If[yclosed,
qq = Table[
a1 = mm (nn - 1) + i;
a2 = mm (nn - 1) + i + 1;
a3 = i;
a4 = i + 1;
{a1, a2, a4, a3},
{i, 1, mm - 1}];
If[xclosed,
a1 = mm nn;
a2 = mm (nn - 1) + 1;
a3 = mm;
a4 = 1;
qq = Join[qq, {{a1, a2, a4, a3}}]
];