# Simplify boundary conditions

**URL:** <https://community.freefem.org/t/simplify-boundary-conditions/3722>\
**Category:** General Discussion\
**Created:** [February 1, 2025, 6:37am UTC](https://community.freefem.org/t/simplify-boundary-conditions/3722 "2025-02-01T06:37:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [February 1, 2025, 2:06pm UTC](https://community.freefem.org/t/simplify-boundary-conditions/3722/2 "2025-02-01T14:06:44Z")

</div>

Hello,  
You have to define a multi-border as in [Input Border Data from an External File in FreeFEM++ - #3 by fb77](https://community.freefem.org/t/input-border-data-from-an-external-file-in-freefem/3713/3)

The principle is to define  
`border a(t=0.,1.;i){ x=(1.-t)*bdrydatx(i)+t*bdrydatx(i+1); y=(1.-t)*bdrydaty(i)+t*bdrydaty(i+1);label=1;}`

In this definition, `i` stands for an integer varying from `0` to `n-1`, where `n` is to be given when you plot or build the mesh by calling `a()`.

Then you write  
`mesh Th=buildmesh(a(discr));`  
where `discr` is an array containing the number of segments that you want when you split each border element.  
Then the above `n` is the length of `discr`.

Example (here `n=3`):

```auto
real[int] bdrydatx=[1,3,2,1];
real[int] bdrydaty=[0,1,4,0];
int[int] discr=[1,2,2];
border a(t=0.,1.;i){ x=(1.-t)*bdrydatx(i)+t*bdrydatx(i+1); y=(1.-t)*bdrydaty(i)+t*bdrydaty(i+1);label=1;}
mesh Th=buildmesh(a(discr));
plot(Th);

```

It gives

 ![multiborder](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/e/e807edcbb98aaf019386da56e5dce22d684ad2b2.png)  
The lower border is split in 1 piece, the two other borders are split in 2 pieces because `discr=[1,2,2]`.  
You can use several multi-borders of this type in a command like  
`mesh Th=buildmesh(a1(discr1)+a2(discr2));`

---

_[View the full topic](https://community.freefem.org/t/simplify-boundary-conditions/3722)._
