Start from last step

Hi;

I am wondering if is there any way to Run FreeFem from a saved checkpoint?

Thanks

You can write a script like this

include "getARGV.idp" ;

int Index   = getARGV("-index" , 0);

mesh Th;            // define the mesh (empty)
fespace Vh(Th, P1); // define the finite element space

// Build or load mesh
if( !Index ){   // Build mesh for the first time
  Th = square(20,20);
  savemesh(Th,"Mesh.msh");
 }
 else{         // Otherwise read the mesh 
   Th=readmesh("Mesh.msh"); 
 }

Vh X1; // The FE-function

// Guess or load the functions
if( !Index ){   // Initial guess
  X1 = cos(x*2.0*pi)*sin(y*2.0*pi);
 }
 else{         // Otherwise read the data 
   ifstream input("iter="+(Index-1)+".fem");  
   input >> X1[] ;    
 }

// Do something her, I shift
real shift = 0.1*Index;
X1 = X1( (x+shift) - ((x+shift)<1. ? 0. : 1.) ,y);

// View and save
plot(X1,cmm="iter = "+Index,wait=1,fill=1,value=1);

{ ofstream output("iter="+Index+".fem");  
  output << X1[] ;    };

Then you run your first iteration
> FreeFem++ your_script.edp -index 0
then your second iteration
> FreeFem++ your_script.edp -index 1
etc…

hope this helps

1 Like