### Adding gravity to Poisson equation

169

views

0

Hi there

I have the equation

$0=\nabla\bullet\left(\nabla p-\rho g\right)$0=∇•(∇

Solved in a circular domain in the x, z coordiantes.

How could I subtract the g vector from the $\frac{\partial p}{\partial z}$∂

I've been trying these but I do not know how to define the vector field with the constant z component

Thank you very much for your help
I recommend you add more details about your problem though. Like including the entire snippet of code.

I have the equation

$0=\nabla\bullet\left(\nabla p-\rho g\right)$0=∇•(∇

`p`−`ρ``g`)Solved in a circular domain in the x, z coordiantes.

How could I subtract the g vector from the $\frac{\partial p}{\partial z}$∂

`p`∂`z`term onlyI've been trying these but I do not know how to define the vector field with the constant z component

`F = (Dx(p,0)*Dx(q,0)+(Dx(p,1)-rho*g)Dx(q,0))*dx`

Thank you very much for your help

Community: FEniCS Project

written
5 months ago by
Miguel

### 1 Answer

2

You can write g as a vector expression:

```
from dolfin import *
mesh = UnitSquareMesh(10,10)
V = FunctionSpace(mesh, 'CG', 1)
p = Function(V)
q = TestFunction(V)
g = Expression(("0.0", "10.0"), degree=0)
F = inner(grad(q),(grad(p) - g))*dx
p_ = TrialFunction(V)
J = derivative(F, p, p_)
```

Thank you very much for your help.

There is one thing I do not understand, what is the purpose of these lines?

There is one thing I do not understand, what is the purpose of these lines?

```
p_ = TrialFunction(V)
J = derivative(F, p, p_)
```

written
5 months ago by
Ruben Gonzalez

To get the jacobian/derivative of the linear form F with respect to p. Not sure if you need it, probably not.

written
5 months ago by
Miguel

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