This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Dump solution to vtk file

0 votes

Dear all

I have a problem about dumping solution to a vtk file. I would appreciate if you can help me out.
In the following code, I want to dump the solution for S to a vtk file. u and d are the solutions of different equations on Vector function Spaces at time steps (t). At the end I want to calculate the function S and dump the solution (scalar field) to a vtk file.

V_u = VectorFunctionSpace(mesh, "Lagrange", 1)
V_d = VectorFunctionSpace(mesh, "Lagrange", 1)

u = Function (V_u)
d = Function (V_d)

def e(u)
     return sym(grad(u))

def S(u,d)
    return e(u)[0,0]*(1 + d[0,1])


.....

file_S = File("s.pvd")
file _S<< S, t
asked Oct 17, 2014 by Navid Mozaffari FEniCS Novice (510 points)

What is your particular problem/question? And there is a typo in the last line of your code excerpt...

Hi Jan

Exactly, I do not know, how to compute S in the form that is defined (based on the calculated vector fields u and d) to be dumped to the vtk file. That typo is my question ! !

Hi Navid, I really have troubles to understand what you want to do and where you get stuck. Maybe you can provide the PDE you want to solve. Also, you should split up your questions like 1. How can I solve this equation? 2. How do I write a solution to a vkt file?

Hi Jan

I am so sorry if it is confusing. Actually, I don't have problem to solve those PDEs (u is the solution of one in a vector form and d is the solution of another one in a vector form). After finding the solutions (u and d), I want to compute S values over all cells (as it is defined in the code, based on obtained values of u and d) and then dump it to the vtk file. I have problem to dump this solution (i.e. S values ) which is scalar to the file.

...