Copy variables between different meshes with PETSc

Dear Tak,
You can use the newly implemented routine transfer to help you go between one distributed solution to another. If you want the transfer PETSc Mat, you can use the transferMat function, see this new example PtAP-2d-PETSc.edp.
Here is the function used in your code, and the resulting screenshots.

load "PETSc"
macro dimension()2// EOM
include "macro_ddm.idp"

meshN Sh1=square(30,30,[x,y]);
meshN Sh2=square(50,50,[x,y]);

buildDmesh(Sh1)
buildDmesh(Sh2)

fespace Ph1(Sh1, P2);
Ph1 u=sin(4*x)+cos(5*y);

fespace Ph2(Sh2, P2);
Ph2 v;
// v=u;

macro defPlot(u)u//
transfer(Sh1, P2, u, Sh2, P2, v);
plotMPI(Sh1, u, P2, defPlot, real, cmm = "u")
plotMPI(Sh2, v, P2, defPlot, real, cmm = "v")

1 Like