Out of Bound problem after refining a 3D mesh

Hello Freefem community:

I’ve had recently problems when I apply local refinement in a 3D mesh using tetgreconstruction. The for loop in which the mesh is refined, is located inside of a while loop. Once the mesh is refined, the commands within the while loop are executed. However, a problem appears. It seems that the fespace function it is not updated accordingly with the number of nodes of the refined mesh and when the loop index i reaches the number of elements of the initial mesh(143180) the program fails. and gives in return the following output:

Out of bound 0 <=143283 < 143180 array type = P2KNIdE
current line = 321
Exec error : Out of bound in operator

I tried to update the fespace functions once the mesh is refined. However, I still get the same error message.

Attached to this message the .edp file and the .mesh file is found.

Any suggestion would be greatly appreciated.
Best Regards
Jacob
Reaction diffusion_2_11.edp (11.7 KB)
Model 1__3d.mesh (7.1 MB)

Are you interpolating the fespace function onto the new mesh?

1 Like

Hello Chris

Thank you for the answer. No, I didn’t considered to interpolate the fe space function. After some searching i came across to the interpolate function. Now it seems that the problem due to the bound of the fespace it solved.

matrix Interpol = interpolate(Xh,Vh);
Cen1=Interpol*Cen;

In which the Ce1 is the variable defined in Xh(P0) space, and Cen is defined in Vh(P1). Cen is calculated previously using the reaction diffusion equations.

However, when the program enters the next iteration, after refining the mesh another time, it appears another error message, precisely at the execution of the aforementioned command.

Assertion fail : (B->ChecknbColumn(y.N()))
line :270, in file ./…/femlib/RNM.hpp
Assertion fail : (B->ChecknbColumn(y.N()))
line :270, in file ./…/femlib/RNM.hpp
err code 6 , mpirank 0

Best Regards
Jacob

Do not create an interpolation matrix to do this. Instead redefine the same mesh and interpolate the FE functions on the new mesh directly using the syntax ‘unew = uold;’ See the examples for ‘adaptmesh’ here.

1 Like

Hello Chris,

Thank you very much for your reply. Sorry, during the last weeks, i wasn’t available. According to your last post, and seeing the example of the documentation, I have equalized the variables in the form:

u=u;
v=v;

It seems that the problem regarding to the number of elements is finally solved. However, from the following iteration, after solving again the reaction-diffusion equations, the solution give nul values in the form:

– Solve :
min nan max nan
min nan max nan

According to the example of the documentation, it seems that the solution is interpolated by using a function, which depends only on the coordinates and is defined at the beginning of the code. However, in my case, the solution is updated by solving the aforementioned equations.

I hope this shead some light to the solution.

Best Regards
Jacob

Without further insight it’s hard to pinpoint the issue, but I would suggest playing around a bit with the various parameters in adaptmesh. In particular, make sure you have nbvx set large enough to accommodate the other adaptation parameters.

Also, make sure you aren’t mixing linear algebra objects from before and after your adaptation, as they will have different dimensions.

Hello Chris,

In my case i use mshmet and tetgreconstruction, since it is a 3d model. The only parameter related to the mesh size that i found is sizeofvolume, which is normally set to hhh/3, being h the metric of the mesh defined with mshmet. Attached you can find a simplified case, in which the execution reproduces the same results that i had mentioned in the earlier post.
Reaction_diffusion_test.edp (3.7 KB)

Best Regards
Jacob
Model 1_2.mesh (3.3 MB)

Hi Jacob,

when referring to dimensions I was referring to the sizes of the matrices and vectors associated with the operators, which change with mesh size. Make sure you update their sizes after refinement using vec.resize(NEWDIMENSION), for example.