← Back to team overview

dolfin team mailing list archive

Re: [Question #123668]: reading nodal data from XML file

 

Question #123668 on DOLFIN changed:
https://answers.launchpad.net/dolfin/+question/123668

    Status: Open => Answered

Anders Logg proposed the following answer:
On Wed, Sep 01, 2010 at 05:17:25PM -0000, Siva Shankar Rudraraju wrote:
> New question #123668 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/123668
>
> I am interested in having some restart capability in my script. Essentially, I need to be able to load my last converged nodal displacement solution from an XML file, and use this as the initial solution state for future load increments..... this is required as my multifield problem at times diverges, and I don't want to start again from the first load increment.
>
> demo.py in pde/advection-diffusion/ has:
> V = VectorFunctionSpace(mesh, "CG", 2)
> velocity = Function(V, "../velocity.xml.gz");
>
> But I would prefer the following:
> V = VectorFunctionSpace(mesh, "CG", 2)
>
> And at every restart point:
> input= File("../velocity.xml.gz");
> input >> V;
>
> but this returns:
> TypeError: in method 'File___rshift__', argument 2 of type 'dolfin::FunctionPlotData &'
>
> So is there a way to initialize a scalar/vector nodal field from a XML file?
>
> --shiva

You need to read/write the vector, not the function or the mesh:

# First
f = File("vector.xml")
f << u.vector()

# Then
f >> u.vector()

--
Anders

-- 
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.