diff --git a/ImageIterator.py b/ImageIterator.py index 08dd004efe5cf9bd61341f3ed2eeb04d4c4193c2..749e726feaa09f78cb76c7b69410f31293eab150 100644 --- a/ImageIterator.py +++ b/ImageIterator.py @@ -34,6 +34,7 @@ class ImageIterator(): self.working_folder = parameters["working_folder"] if ("working_folder" in parameters) else "." self.working_basename = parameters["working_basename"] if ("working_basename" in parameters) else "sol" + self.initialize_U_from_file = parameters["initialize_U_from_file"] if ("initialize_U_from_file" in parameters) else False self.initialize_DU_with_DUold = parameters["initialize_DU_with_DUold"] if ("initialize_DU_with_DUold" in parameters) else False @@ -94,7 +95,12 @@ class ImageIterator(): k_frame_old = k_frame+1 #self.printer.print_var("k_frame_old",k_frame_old,-1) - if (self.initialize_DU_with_DUold): + if (self.initialize_U_from_file): + xdmf_filename = self.initialize_U_from_file+"_"+str(k_frame).zfill(2)+".xdmf" + xdmf_file = dolfin.XDMFFile(xdmf_filename) + xdmf_file.read(self.problem.U, "U") + xdmf_file.close() + elif (self.initialize_DU_with_DUold): self.problem.U.vector().axpy(1., self.problem.DUold.vector()) self.problem.call_before_solve( diff --git a/fedic2.py b/fedic2.py index ac4143cb0e71c72ebc5268ee5f0d62b5ed897595..cc79220336b92d1f7cfc927e73e8e274c30281a0 100644 --- a/fedic2.py +++ b/fedic2.py @@ -41,6 +41,7 @@ def fedic2( residual_type="Iref", # Iref, Iold, Iref-then-Iold relax_type="gss", # constant, aitken, gss relax_init=1.0, + initialize_U_from_file=0, initialize_DU_with_DUold=0, tol_res=None, tol_res_rel=None, @@ -59,6 +60,8 @@ def fedic2( "residual_type must be \"Iref\". Aborting." assert (relax_init == 1.),\ "relax_init must be 1. Aborting." + assert (not ((initialize_U_from_file) and (initialize_DU_with_DUold))),\ + "Cannot initialize U from file and DU with DUold together. Aborting." assert (tol_res is None),\ "tol_res is deprecated. Aborting." assert (tol_im is None),\ @@ -135,6 +138,7 @@ def fedic2( parameters={ "working_folder":working_folder, "working_basename":working_basename, - "initialize_DU_with_DUold":initialize_DU_with_DUold}) + "initialize_DU_with_DUold":initialize_DU_with_DUold, + "initialize_U_from_file":initialize_U_from_file}) image_iterator.iterate()