### Save post-processed answer in pvd

184

views

0

Hi there

After solving a differential equation I get an scalar field p, to calculate velocities in x and y direction I have the relationships

$vx=\frac{w^3}{12\mu}\frac{\partial p}{\partial x};vy=\frac{w^3}{12\mu}\frac{\partial p}{\partial y}$

I'm using this code and it is plotting a reasonable result

but if I want to save the variable in a pvd file with file << dpx is giving me a TypeError

Could you please help me with the propper way to transform dpx dpy and dp so they can be saved in a pvd file?

Thank you very much!!!

After solving a differential equation I get an scalar field p, to calculate velocities in x and y direction I have the relationships

$vx=\frac{w^3}{12\mu}\frac{\partial p}{\partial x};vy=\frac{w^3}{12\mu}\frac{\partial p}{\partial y}$

`v``x`=`w`^{3}12`μ`∂`p`∂`x`;`v``y`=`w`^{3}12`μ`∂`p`∂`y`I'm using this code and it is plotting a reasonable result

```
dpx = Dx(p,0)
dpy = Dx(p,1)
dp = (w**3/(12*mu))*sqrt(dpx**2+dpy**2)
plot(dpx)
```

but if I want to save the variable in a pvd file with file << dpx is giving me a TypeError

Could you please help me with the propper way to transform dpx dpy and dp so they can be saved in a pvd file?

Thank you very much!!!

Community: FEniCS Project

### 1 Answer

2

You need to project

`dpx = Dx(p,0)`

in some function space. Try something like:```
dpx = project(Dx(p,0), V) # Here V is the function space
File("foo.pvd") << dpx
```

Thank you very much!!!

written
10 months ago by
Ruben Gonzalez

Please login to add an answer/comment or follow this question.