← Back to team overview

dolfin team mailing list archive

Re: saving and loading function

 



Kent Andre wrote:
Is it no longer possible to save and load functions ? The following example shows the problem:

the script save_func.py:

from dolfin import *

mesh = UnitSquare(12,12)
V = FunctionSpace(mesh, "CG", 1)

d = Constant(mesh, 1)

d_proj = project(d, V)

file = File("d.xml")
file << d_proj


the script load_func.py
from dolfin import *
mesh = UnitSquare(12,12)
V = FunctionSpace(mesh, "CG", 1)

d = Function(V)
file = File("d.xml")
file >> d Running these two gives:
  File
"/home/kent-and/local/src/dolfin-dev/local/lib/python2.5/site-packages/dolfin/cpp.py", line 6968, in __rshift__
    return _cpp.File___rshift__(*args)
RuntimeError: *** Error: Unable to assign to function, not in the same
function space.


I assume that the reason is that I run these script in separate
sessions.

Try something like

  from dolfin import *

  d = Function()
  file = File("d.xml")
  file >> d

  mesh = d.function_space().mesh()
  V    = d.function_pace()

Garth


_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@xxxxxxxxxx
http://www.fenics.org/mailman/listinfo/dolfin-dev




Follow ups

References