# Non zero dirichlet boundary condition

**URL:** https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818
**Category:** New to Julia
**Tags:** gridap
**Created:** [June 25, 2023, 7:05pm UTC](https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818 "2023-06-25T19:05:43Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)
#### Post date: [June 25, 2023, 7:05pm UTC](https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818/1 "2023-06-25T19:05:43Z")

</div>

Hi is there any one who knows how can i define non zero dirichlet boundary condition in gridap? not using affine space just introducing bc in weak form and solve linear Au=b  
i know that it should make rows and columns of related bc zero in A but i dont know is there any other way in gridap to make this?

---

<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: [June 25, 2023, 8:45pm UTC](https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818/2 "2023-06-25T20:45:37Z")

</div>

There’s an example of this in the [Gridap Poisson tutorial](https://gridap.github.io/Tutorials/dev/pages/t001_poisson/) (which is the first hit on a google search for “gridap dirichlet”), which shows how to supply an arbitrary function that indicates the value of the solutions on the Dirichlet boundaries.

---

<div class="post-metadata">

### Author: ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)
#### Post date: [June 25, 2023, 9:01pm UTC](https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818/3 "2023-06-25T21:01:33Z")

</div>

yes i have read that tutorial but they applied the displacement bc in trial space and they use traction bc in weak form, in my case i don’t have body force (f) and traction (h) . i just have g on a specified boundary. i want to set both my test and trial space the same and implement g in weak form which i couldn’t find any example of this in tutorials. in all of them they use affine or change the U

---

<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: [June 25, 2023, 9:16pm UTC](https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818/4 "2023-06-25T21:16:33Z")

</div>

> [@mary](#):
>
> i want to […] implement g in weak form

Dirichlet boundary conditions aren’t implemented in the weak form — they are an “essential” boundary condition that is implemented in the function space (which are effectively turned into a source term on the rhs during the assembly).

---

<div class="post-metadata">

### Author: ![mary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mary/32/53139_2.png) [@mary](https://discourse.julialang.org/u/mary)
#### Post date: [June 25, 2023, 9:22pm UTC](https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818/5 "2023-06-25T21:22:01Z")

</div>

as i understand there are some methods to do that like lagrange multipliers, nitsche and penalty method. am i wrong?

---

<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: [June 26, 2023, 12:52am UTC](https://discourse.julialang.org/t/non-zero-dirichlet-boundary-condition/100818/6 "2023-06-26T00:52:39Z")

</div>

Are you thinking of embedded boundaries? [GitHub - gridap/GridapEmbedded.jl: Embedded finite element methods in Julia](https://github.com/gridap/GridapEmbedded.jl) has an example implementing a Nitsche method. (Not much documentation yet for this package, sadly.)
