# Free-Slip Boundary Condition in Fluid Flow

**URL:** <https://fenicsproject.discourse.group/t/free-slip-boundary-condition-in-fluid-flow/10096>\
**Category:** General\
**Created:** [January 4, 2023, 7:46pm UTC](https://fenicsproject.discourse.group/t/free-slip-boundary-condition-in-fluid-flow/10096 "2023-01-04T19:46:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![femur](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/femur/32/4558_2.png) [@femur](https://fenicsproject.discourse.group/u/femur)\
**Post date:** [January 4, 2023, 7:46pm UTC](https://fenicsproject.discourse.group/t/free-slip-boundary-condition-in-fluid-flow/10096/1 "2023-01-04T19:46:50Z")

</div>

In close alignment to [Component-wise Dirichlet BC — FEniCSx tutorial](https://jsdokken.com/dolfinx-tutorial/chapter3/component_bc.html) by J.S. Dokken, I would like to do the same with Raviart-Thomas elements.  
Consider this example, where the displacement in x-direction at the right boundary is set to zero:

```auto
import numpy as np
from dolfinx import fem, mesh
from mpi4py import MPI
from ufl import FiniteElement
from petsc4py.PETSc import ScalarType

msh = mesh.create_unit_square(MPI.COMM_WORLD, 10, 10)
V = fem.FunctionSpace(msh, FiniteElement("RT", msh.ufl_cell(), 1))

boundary_facets = mesh.locate_entities_boundary(msh, msh.topology.dim-1, lambda x: np.isclose(x[0], 1))
boundary_dofs_x = fem.locate_dofs_topological(V.sub(0), msh.topology.dim-1, boundary_facets)

bc = fem.dirichletbc(ScalarType(0), boundary_dofs_x, V.sub(0))

```

However this produces the error:

```auto
File "/usr/local/dolfinx-real/lib/python3.10/dist-packages/dolfinx/fem/function.py", line 501, in sub
    assert self.ufl_element().num_sub_elements() > i
AssertionError

```

This error does not appear with Lagrange elements.  
Why is that and how can I still apply the same boundary condition strongly (weakly is not an option)?

---

<div class="post-metadata">

**Author:** ![dokken](https://yyz2.discourse-cdn.com/free1/user_avatar/fenicsproject.discourse.group/dokken/32/1560_2.png) [@dokken](https://fenicsproject.discourse.group/u/dokken)\
**Post date:** [January 4, 2023, 8:02pm UTC](https://fenicsproject.discourse.group/t/free-slip-boundary-condition-in-fluid-flow/10096/2 "2023-01-04T20:02:03Z")

</div>

A R-T element has no x-component to constrain. Consider

> **[DefElement](https://defelement.com/elements/examples/triangle-N1div-1.html)**
>
> An encyclopedia of finite element definitions

and for instance the basis functions:

 ![image](https://global.discourse-cdn.com/free1/uploads/fenicsproject1/original/2X/4/4f39e125ecb3a8fa5861c90d77067fa0a5aa1c8b.jpeg)  
Then you see that the basis function is vector valued. I.e. there is only three degrees of freedom, that are scalar valued.

u\_h=\sum\_{i=0}^2 c\_i \mathcal{F}^{\mathrm{div}}\phi\_i(x)  
where \mathcal{F}^{\mathrm{div}} is the contravariant Piola mapping, see for instance: [DefElement](https://defelement.com/ciarlet.html)
