In the implementation of 1D Laplace, in file src/Tests/v0_Laplace1D, there is an allocation error in the mesh when the number of elements per side in an even number.
Lines 18 to 21 of the file are as follows:
int dim = 1;
ElemType type = ElemType::Line;
auto* mesh = new StructuredMesh();
mesh->produceCartesian(dim,11,type);
In the last line, if 11 is the number of elements per side the created cartesian mesh will have (the mesh is the line [0,1], divided into as many elements as the number states.
If 11 is changed to any other odd number (13, 19, 21, ....) the code will run as intended. However, if the number of elements is changed to an even number (10, 12, 8, ...) the code will give a malloc error when allocating the arrays in the mesh.
In the implementation of 1D Laplace, in file
src/Tests/v0_Laplace1D
, there is an allocation error in the mesh when the number of elements per side in an even number.Lines 18 to 21 of the file are as follows:
In the last line, if
11
is the number of elements per side the created cartesian mesh will have (the mesh is the line [0,1], divided into as many elements as the number states. If11
is changed to any other odd number (13, 19, 21, ....) the code will run as intended. However, if the number of elements is changed to an even number (10, 12, 8, ...) the code will give amalloc
error when allocating the arrays in the mesh.For
12
, the output is as followsI do not know why this happens. Why is it doing this?