Define pressure as a function of fewer variables

Hi,
I need to solve a velocity-pressure equation, where we know that the pressure only depends on one variable. Right now I have:

mesh = UnitSquareMesh(30, 30)
V= VectorElement(“Lagrange”, mesh.ufl_cell(), degree = 2, dim = 2)
P = FiniteElement(“Lagrange”, mesh.ufl_cell(), degree = 1)
TH = V * P
VP = FunctionSpace(mesh, TH)

But I would like to have something like
mesh = UnitSquareMesh(30, 30)
mesh_p = UnitIntervalMesh(30)
V= VectorElement(“Lagrange”, mesh.ufl_cell(), degree = 2, dim = 2)
P = FiniteElement(“Lagrange”, mesh_p.ufl_cell(), degree = 1)
TH = V * P
VP = FunctionSpace(mesh, TH),

and then to define a up function on VP and solve for up. Of course this does not work as I get “Sub elements must live on the same cell.”, as P is defined only on mesh_p. Which makes sense, but how could I make fenics understand that P should be defined on the whole 2D space, it is just that along the second variable it is constant? So, it is one-dimensional in dependence, but defined in 2D using the same value from 1D as a constant.

Thanks so much for any ideas.

A somewhat brute-force approach might be to leave p defined over the full mesh, but constrain \partial_{x_2}p to be zero. The simplest approach would be to add a penalty term to the residual, i.e.,

\cdots + \beta\int_\Omega(\partial_{x_2}p)(\partial_{x_2}q)\,d\mathbf{x} = 0\text{ ,}

where \beta is some large number. You could also add an additional Lagrange multiplier to the formulation to enforce this constraint, i.e., something like

\cdots + \int_\Omega\lambda\partial_{x_2}q\,d\mathbf{x} - \int_\Omega\rho\partial_{x_2}p\,d\mathbf{x} = 0\text{ ,}

where \lambda is the Lagrange multiplier (discretized with a DG element and included as a component in the mixed space) and \rho is its corresponding test function.

1 Like

Thank you. Adding p.dx(1) * q.dx(1) * dx has made a real difference.

Hi Nora,
you might want to have a look at our library multiphenics https://github.com/mathLab/multiphenics for this, see e.g. tutorial 3.
Also have a look at the related resources mentioned in the README, most notably the mixed dimensional branch in DOLFIN.

Cheers,
Francesco

Thank you Francesco!