Hi I want to save the solution u, the velocity field, of naiver stokes equation to a txt file. Here is my code
#solve the equation
solve(a==L, wf, bc)
…
#get u
u_copy, p_copy = wf.split(True)
…
#get coordinate
dof_coordinates = QSpace.tabulate_dof_coordinates()
dof_coordinates.resize((n, d))
dof_x = dof_coordinates[:, 0]
dof_y = dof_coordinates[:, 1]
…
#attempt to write u to a txt file
f = open(‘u.txt’, ‘a’)
f.write(str(dof_x) + ‘\n’ + str(dof_y) + ‘\n’ + str(np.reshape(u_copy.vector().get_local(),(-1,2)))+ ‘\n\n’)
f.close()
However only the fist 3 and last 3 elements are saved in the txt file
[19.609375 19.6875 19.53125 … 0. 0. 0.078125]
[ 0. 0. 0. … 20. 19.921875 20. ]
[[ 6.32249327e-31 0.00000000e+00]
[ 0.00000000e+00 -1.26223532e-31]
[ 0.00000000e+00 -1.56487699e-30]
…
[ 0.00000000e+00 -9.61048819e-32]
[-8.09088108e-32 0.00000000e+00]
[ 0.00000000e+00 0.00000000e+00]]
I wonder how I can save all the solution. Also I am not sure if I am reshaping u correctly.
Thanks!