Problem with Update of compound GridFunction after SetActiveDofs

Hello everybody,

I updated NGSolve a few days ago and now I’m getting a strange error running a file that worked before.

In this example, I have a time-dependent finite element space (the Dofs of the space depend on a time-dependent region defined by a level set function) and a function defined on a compound FESpace. At the beginning of each time step, I define the DOFs I need and update the FESpace, the compound FESpace, and the gridfunction (solution of my system) on the compound FES.

That works for a few time steps and then I get an error when updating the Gridfunction. The time-step when the error occurs and the error message vary when one changes some parameters (order, which DOFs to use, and even if one imports everything from ngsolve or only the used functions and objects). The error messages I got (in different settings) were:

free(): corrupted unsorted chunks
corrupted size vs. prev_size
double free or corruption (out)
Aborted (core dumped)

I added a MWE to show the behavior. It’s shown in the file, that we do not have a problem of updating a gridfunction defined on the ‘not compounded’ FES. In addition, if one does not change the gridfunction (just comment out the last line of the MWE), no error occurs.

Can anyone help me tackling this problem?

Thanks a lot! Best wishes,
Paul

UpdateProblem_MWE.py (1.8 KB)

the problem is caused be the recent change of making GridFunction(nested=True) the default. It is fixed in the coming nightly.

With the current version, you can use the workaround and set

gfu = GridFunction(mesh, ..., nested=False)

to obtain the old behaviour.

Joachim

Thank you for your fast reply!

That easy workaround helps a lot and works fine.

Best wishes,
Paul