Saving P2 element solution

I was working on a project where for the initial part, we were working on P1 element freespace, and saving the solution of our equation with


But later we had to shift to P2 elements, so naturally i changed the code by changing P1 to P2 everywhere in the code and changing order = 2 , while using savesol.
But in this approach, there is no output being saved in the sol file.
Do anyone have any idea on where i am making a mistake and how do i fix it to save the solution file

The simple way is one save the mesh with save mesh instruction and sane the array of dof in a file “Toto” as an array

After to reread in freefem

Read the mesh file with readmesh instruction
Then def the finite element space Vh

Ifstream fin(“Toto”);
fin >> U;

I am new to this software, how does saving the mesh play any role in saving the solution ( with P2 elements) to the equation and how do I implement saving the array of dof part

Screenshot 2023-06-23 at 7.26.14 PM


Have you looked at this Savesol readsol for P2 FE fields? - #3 by plouraboue?

Admittedly, there’s no use of savesol, but it does allow you to save a solution and then read it later.

Yes I did. savesol can not handle P2 FE fields. Only P1. For P2 you have to write manually as suggested by Frederic. Chears, Franck

1 Like

Thank you, I will try implementing this and share the updates

Hi , i tried this, my read code is plotting the mesh ( saved in mesh.msh) instead of the solution that my i saved in the save.txt

or am i doing something wrong in saving