# Options to impose Dirichlet BC with "ON"

**URL:** https://community.freefem.org/t/options-to-impose-dirichlet-bc-with-on/1399
**Category:** General Discussion
**Created:** [December 21, 2021, 4:17am UTC](https://community.freefem.org/t/options-to-impose-dirichlet-bc-with-on/1399 "2021-12-21T04:17:01Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)
#### Post date: [December 21, 2021, 4:17am UTC](https://community.freefem.org/t/options-to-impose-dirichlet-bc-with-on/1399/1 "2021-12-21T04:17:02Z")

</div>

Hello all,

@prj, @frederichecht, where I could find all the options to impose dirichlet boundary conditions with “on” like this: on(1, u=g, tgv=xx) with xx=-1; -2; -10 ; …

Thank you for your help,

Best regards,

Loïc,

---

<div class="post-metadata">

### Author: ![prj](https://avatars.discourse-cdn.com/v4/letter/p/ecae2f/32.png) [@prj](https://community.freefem.org/u/prj)
#### Post date: [December 21, 2021, 4:58pm UTC](https://community.freefem.org/t/options-to-impose-dirichlet-bc-with-on/1399/2 "2021-12-21T16:58:36Z")

</div>

It’s all there: [FreeFem-sources/HashMatrix.cpp at develop · FreeFem/FreeFem-sources · GitHub](https://github.com/FreeFem/FreeFem-sources/blob/develop/src/femlib/HashMatrix.cpp#L1190).

---

<div class="post-metadata">

### Author: ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)
#### Post date: [December 22, 2021, 2:08pm UTC](https://community.freefem.org/t/options-to-impose-dirichlet-bc-with-on/1399/3 "2021-12-22T14:08:07Z")

</div>

Thank you for your answer!

---

<div class="post-metadata">

### Author: ![frederichecht](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/frederichecht/32/15_2.png) [@frederichecht](https://community.freefem.org/u/frederichecht)
#### Post date: [December 23, 2021, 2:48pm UTC](https://community.freefem.org/t/options-to-impose-dirichlet-bc-with-on/1399/4 "2021-12-23T14:48:00Z")

</div>

I will add a small example in tutorial to see

```auto
	load "msh3"
	meshL Th = segment(2);
	real [int] vtgv = [-20,-10,-2,-1,0, tgv]; 
	varf va(u,v)= int1d(Th)(u*v*24.)+on(1,2,u=0);// mul by 12 to have integer coef ..
	// label : 1 on first DoF O 
	// 2 on last DoF 2 
	// tgv : -20 put to zero of row and colnum of Dof with label 1 or 2 
	fespace Vh(Th,P1);
	for [i,tgvi:vtgv]
	{
		matrix A= va(Vh,Vh,tgv=tgvi);
		real[int,int] F(3,3);
		F=0.;  
		for [i,j,aij:A]
		  F(i,j) = aij;
		cout << " tgv = " << tgvi << " matrix= " << F << "\n\n\n";
	}

```

the output is :

```auto
  -- FESpace: Nb of Nodes 3 Nb of DoF 3
 tgv = -20 matrix= 3 3	
	   0 0 0
	   0 8 0
	   0 0 0
	

 tgv = -10 matrix= 3 3	
	   0 0 0
	   2 8 2
	   0 0 0
	

 tgv = -2 matrix= 3 3	
	   1 0 0
	   0 8 0
	   0 0 1
	

 tgv = -1 matrix= 3 3	
	   1 0 0
	   2 8 2
	   0 0 1
	

 tgv = 0 matrix= 3 3	
	   0 2 0
	   2 8 2
	   0 2 0
	

 tgv = 1e+30 matrix= 3 3	
	 1e+30 2 0
	   2 8 2
	   0 2 1e+30
	

times: compile 0.007039s, execution 0.000266s, mpirank:0

```

---

<div class="post-metadata">

### Author: ![Loic](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Loic](https://community.freefem.org/u/Loic)
#### Post date: [December 26, 2021, 2:25pm UTC](https://community.freefem.org/t/options-to-impose-dirichlet-bc-with-on/1399/5 "2021-12-26T14:25:56Z")

</div>

Thank you for this explanation !
