I want to interpolate a function u from one finite element space Vh to another finite element space Wh. Both spaces are based on P2 dicontinuous finite elements. I have used the operator “=” for interpolation. The “=” operator use linear interpolation. Will there be any problem for using this linear interpolation as I am using P2 elements? Or how can I use second order interpolation?
Thanks in advance.
Search the docs for “interpolate” as there is a function by this name that takes
two fespaces and returns a matrix that transforms one set of points into the other.
You could probably do this for a small mesh and verify it is what you expect.
Apparently IIRC you can also write u[i]=w(x,y) where u and w are defined in two different
fespaces. If you want to try these let us know how they work compared to expectations.
Of course, some error will be introduced by using linear interpolation with higher order elements, but this is much more efficient than a higher order interpolation method. Further, even if you used a higher-order method, the (continuous) interpolation would still be imperfect due to the discontinuous nature of your FE space. Depending on the smoothness of your functions and the resolution of your mesh, I expect that the interpolation error from moving the locations of the discontinuities would be more important than the error from linear vs quadratic interpolation.
So, while I can’t definitively say whether there will be any problem with linear interpolation in your specific case, I can say that second order interpolation would not eliminate your problem. I think your best case is to use linear interpolation, as currently implemented in FreeFEM. If you need higher resolution, you can always use
splitmesh to refine the mesh before the interpolation step.
remark, the interpolation operator is link to the element finites,
but for discontinuous finite element you have to be careful if the mesh is no same
because you can have common interpolation points on different element, so the only coordinate of point are not suffisante.
you can play with this for example.
Its easy to get some oscillation with the P2 elements for example and the P1
are linear interpolators. I’ve never used the disocontinuous elements but
have seen the non-monotonic step during mesh adaptation.
load "msh3" load "medit" int nx=10; int nx2=22; int[int] lbe=[100,200]; // begin and end point labels meshL Th1=Sline(nx, [1.0*x],label=lbe); meshL Th2=Sline(nx2, [.5+ .25*(x-.5)],label=lbe); fespace Vh1(Th1,P1); fespace Vh2(Th2,P2); Vh1 u1x=x; Vh1 u1=(x>.5)?1:0; Vh2 u2x=x; Vh2 u2; matrix A=interpolate(Vh2,Vh1); u2=A*u1; cout<<u1x<<endl; cout<<u1<<endl; cout<<" u2 "<<endl; cout<<u2x<<endl; cout<<u2<<endl;