# Unit tangent vector in Gridap.jl

**URL:** <https://discourse.julialang.org/t/unit-tangent-vector-in-gridap-jl/108181>\
**Category:** Numerics\
**Tags:** finite-element, gridap\
**Created:** [December 30, 2023, 10:22am UTC](https://discourse.julialang.org/t/unit-tangent-vector-in-gridap-jl/108181 "2023-12-30T10:22:25Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![andy45](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@andy45](https://discourse.julialang.org/u/andy45)\
**Post date:** [December 30, 2023, 10:22am UTC](https://discourse.julialang.org/t/unit-tangent-vector-in-gridap-jl/108181/1 "2023-12-30T10:22:25Z")

</div>

Hi. I am trying to solve two-dimensional Stokes-Darcy equations using Gridap.jl. One of the terms in a weak formulation has the form {\int\_{I}\lambda\left(u\cdot\tau\right)\left(v\cdot\tau\right)ds} where \tau is a unit tangent vector to the interface I between two subdomains.  
Is there a way to specify a unit tangent vector in Gridap.jl? Specifically, I am looking for a function similar to `get_normal_vector`.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 30, 2023, 1:21pm UTC](https://discourse.julialang.org/t/unit-tangent-vector-in-gridap-jl/108181/2 "2023-12-30T13:21:08Z")

</div>

Can’t you use \int \lambda (u \times n) \cdot (v \times n) \, ds instead, where n is a unit normal?

---

<div class="post-metadata">

**Author:** ![andy45](https://avatars.discourse-cdn.com/v4/letter/a/50afbb/32.png) [@andy45](https://discourse.julialang.org/u/andy45)\
**Post date:** [December 30, 2023, 1:47pm UTC](https://discourse.julialang.org/t/unit-tangent-vector-in-gridap-jl/108181/3 "2023-12-30T13:47:50Z")

</div>

@stevengj Thank you for your reply. However I am solving a two-dimensional problem so I cannot use the cross product.

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [December 30, 2023, 1:49pm UTC](https://discourse.julialang.org/t/unit-tangent-vector-in-gridap-jl/108181/4 "2023-12-30T13:49:47Z")

</div>

> [@andy45](#):
>
> However I am solving a two-dimensional problem so I cannot use the cross product.

I believe that Gridap [defines the cross product of 2d vectors](https://github.com/gridap/Gridap.jl/blob/10d0b59af543314096360b3d8bcb79445a00dd0f/src/TensorValues/Operations.jl#L455-L457) as just a scalar corresponding to the “z” component, which is exactly what you want here (u \times n is then equivalent to (u \times n) \cdot e\_3 = u \cdot (n \times e\_3) = u \cdot \tau).

The cross product also gives you a way to get a tangent vector if you want it — given a 2d normal vector n = (n\_1, n\_2), a tangent vector is \tau = n \times e\_3 = (n\_2, -n\_1). But it doesn’t seem like you actually need to construct this explicitly.

---

<div class="post-metadata">

**Author:** ![aerappa](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aerappa/32/212281_2.png) [@aerappa](https://discourse.julialang.org/u/aerappa)\
**Post date:** [January 7, 2025, 8:38am UTC](https://discourse.julialang.org/t/unit-tangent-vector-in-gridap-jl/108181/5 "2025-01-07T08:38:16Z")

</div>

Hey, I created a [PR](https://github.com/gridap/Gridap.jl/pull/1071#pullrequestreview-2533166935) to provide a nice interface for exactly what you wanted @andy45 , although @stevengj’s solution still works of course.
