On Fri, Jan 28, 2011 at 02:40:26PM -0000, Melanie Jahny wrote: > New question #143185 on DOLFIN: > https://answers.launchpad.net/dolfin/+question/143185 > > I solve the Navier-Stokes-Brinkman equation with fenics and get the velocity > u and the pressure p as result: > > (u,p) = problem.solve().split() > > At the end of the program, I'd like to write u to a xml-file, but using the > code: > > velocity_file = File( "velocity.xml" ) > velocity_file << u.vector() > > causes the following error: > > velocity_file << u.vector() > RuntimeError: *** Error: You are attempting to access a non-const vector from > a sub-Function. > > Using the code: > > solution = problem.solve() > velocity_file = File( "velocity.xml" ) > velocity_file << solution.vector() > > works, but I'd like to know if I can store only the velocity u in a xml-file. > Thanks for any help!!!
Add the argument deepcopy=True to the split() method and it should work. The reason you get an error is that split() by default returns views of u and p (which means they don't have vectors of degrees of freedom that can be stored to file). Why are you writing vectors in XML format? If it's used for postprocessing, it would be better to store the functions in PVD format (for ParaView). If it's for storing values and reading back later, I suggest using the TimeSeries class, which is easier and more efficient. -- Anders _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : [email protected] Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp

