<div dir="ltr"><div><div><div><div><div><div>Hi all,<br><br></div>I am in the process of writing an implicit solver for a set of PDEs (namely MHD equations), in FORTRAN. When setting the non-linear function to solve via Newton-Krylov, I use a "user defined context", namely the thing denoted by "ctx" on the doc page about SNESFunction :<br> <br><a href="http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESFunction.html#SNESFunction">http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/SNES/SNESFunction.html#SNESFunction</a><br><br></div>In practice ctx is a user defined type which contains everything I need in the local routine which sets the function on the local part of the grid, FormFunctionLocal. That is, some local/global geometrical information on the grid, the physical parameter, and possibly any other thing. <br><br></div>In my case it so happens that due to the scheme I have chosen, when I compute my function, I need the full solution of the problem at the last two time steps (which are in Vec format). So my ctx contains two Vec elements. Since I will work in 3D and intend to use a lot of points in the future, I am concerned about memory problems which could occur.<br><br></div>Is there a limit to the size occupied by ctx ? Would this be better if instead I was declaring global variables in a module and using this module inside FormFunctionLocal ? Is this allowed ?<br><br></div>Best regards<br><br></div>Timothee NICOLAS<br></div>