# Zero boundary condition on the test space

**URL:** <https://community.freefem.org/t/zero-boundary-condition-on-the-test-space/3702>\
**Category:** General Discussion\
**Created:** [January 22, 2025, 10:07am UTC](https://community.freefem.org/t/zero-boundary-condition-on-the-test-space/3702 "2025-01-22T10:07:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hthtb22](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/hthtb22/32/2839_2.png) [@hthtb22](https://community.freefem.org/u/hthtb22)\
**Post date:** [January 22, 2025, 10:07am UTC](https://community.freefem.org/t/zero-boundary-condition-on-the-test-space/3702/1 "2025-01-22T10:07:52Z")

</div>

I try to implement the variational form where both trial and test function have zero boundary condition, i.e, u,v \in H^1\_0(\Omega)

```auto
varf mainmatrix (u,v) = 
 ...
+ on(1,2,3,4, u=0, v=0) ;

```

The error: We expected an unknown u=… of the problem

Is there discrete H^1\_0 space in FreeFem++ or alternative way to write?

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [January 22, 2025, 1:02pm UTC](https://community.freefem.org/t/zero-boundary-condition-on-the-test-space/3702/2 "2025-01-22T13:02:44Z")

</div>

You have to write just u=0 !

---

<div class="post-metadata">

**Author:** ![hthtb22](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/hthtb22/32/2839_2.png) [@hthtb22](https://community.freefem.org/u/hthtb22)\
**Post date:** [January 22, 2025, 1:40pm UTC](https://community.freefem.org/t/zero-boundary-condition-on-the-test-space/3702/3 "2025-01-22T13:40:21Z")

</div>

But, it is not the same with u=0 only

On my continuous setting u,v \in H^1\_0  
With trial space in u \in H^1\_0 you can simply set +(…, u=0).  
But with test space v \in H^1\_0 you can not do the same.

Or did you said that if you impose 0 on BC of u, it automatically impose on BC of v?

* * *

In details,  
u,v \in H^1\_0(\Omega) and sigma,psi \in H^1(\Omega). How can I impose H^1\_0 on v?. (Note that if I choose v \in H^1(\Omega) I get the wrong solution)

```auto
fespace Vh(Omega, P1);
Vh u, v, sigma,psi;
varf mainmatrix ([u,sigma], [v,psi]) = 
 int2d(Omega) ((dy(u) + sigma) * (dy(v)+psi ))
+?;

```

---

<div class="post-metadata">

**Author:** ![fb77](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/fb77/32/3796_2.png) [@fb77](https://community.freefem.org/u/fb77)\
**Post date:** [January 22, 2025, 4:21pm UTC](https://community.freefem.org/t/zero-boundary-condition-on-the-test-space/3702/4 "2025-01-22T16:21:38Z")

</div>

Writing `+on(1,2,3,4,u=0);` does not “exactly” impose v=0, but it is equivalent to that (up to some small error), it is done by penalty.  
If you set `tgv=-1` then it really sets u=0 and v=0 on the boundary.
