void UpdateProblem(Mesh &mesh, FiniteElementSpace &fespace, GridFunction &x, BilinearForm &a, LinearForm &b) { // Update the space: recalculate the number of DOFs and construct a matrix // that will adjust any GridFunctions to the new mesh state. fespace.Update(); // Interpolate the solution on the new mesh by applying the transformation // matrix computed in the finite element space. Multiple GridFunctions could // be updated here. x.Update(); // Free any transformation matrices to save memory. fespace.UpdatesFinished(); // Inform the linear and bilinear forms that the space has changed. a.Update(); b.Update(); }