Periodic Boundary Conditions for Mixed Finite Element Spaces

In order to save a reference solution computed on a fine mesh, and later compare it to another run of your code on a rough mesh, you can follow the following sketch

// assumed known mesh Th, fespace Vh, approximate solution u in Vh

// save the mesh to a file "mesh.msh"
savemesh(Th,"mesh.msh");
// save the solution to a file "uref.d"
{
 ofstream fileref("uref.d");
 fileref << u[] << endl;
}

//-------------------------------

//recover a previously saved solution "uref.d" and its mesh "mesh.msh"
mesh Ths=readmesh("mesh.msh");
fespace Vs(Ths,....);//define the fespace exactly as it was defined when the reference solution was saved to a file
Vs us;
{
 ifstream filereadref("uref.d");
 filereadref >> us[] ;
}

// compute the error between u and the reference solution us
// the error is computed on the rough mesh Th (computation on Ths is also possible)
Vh usinterp=us;//interpolate the reference solution us defined on Ths to a function usinterp on Th
real error = sqrt(int2d(Th)((u-usinterp)^2));