# Help with creating a baffle

**URL:** <https://community.freefem.org/t/help-with-creating-a-baffle/2981>\
**Category:** General Discussion\
**Created:** [February 21, 2024, 2:05pm UTC](https://community.freefem.org/t/help-with-creating-a-baffle/2981 "2024-02-21T14:05:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![RNlao](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/rnlao/32/2070_2.png) [@RNlao](https://community.freefem.org/u/RNlao)\
**Post date:** [February 21, 2024, 2:05pm UTC](https://community.freefem.org/t/help-with-creating-a-baffle/2981/1 "2024-02-21T14:05:49Z")

</div>

I want to introduce a flat plate without thickness into a grid, essentially means inserting a line or surface that fluid cannot cross.This is akin to defining a boundary condition. The sketch is below.  
 ![image](https://canada1.discourse-cdn.com/flex030/uploads/freefem/original/2X/0/0f99828fa3f33c9ba213482f60fb42a3178a6b10.png)

The red line is the baffle. How can I create this baffle?

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [February 21, 2024, 8:07pm UTC](https://community.freefem.org/t/help-with-creating-a-baffle/2981/2 "2024-02-21T20:07:35Z")

</div>

Add an inner boundary to your mesh. The idea is like this:

```auto
real Rout = 5.0;
int Npts = 40; int NptsIn=20;
border circle1(t=0,2*pi){x=Rout*cos(t); y=Rout*sin(t); label=0;};
border inner(t=0,1){x=0.5*Rout*(t-0.5); y=0.0; label=1;};
mesh Th=buildmesh(circle1(Npts)+inner(NptsIn)) ;
plot(Th,wait=true); //to see the mesh

```

---

<div class="post-metadata">

**Author:** ![RNlao](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/rnlao/32/2070_2.png) [@RNlao](https://community.freefem.org/u/RNlao)\
**Post date:** [February 23, 2024, 2:37am UTC](https://community.freefem.org/t/help-with-creating-a-baffle/2981/3 "2024-02-23T02:37:08Z")

</div>

Thank you for your answer. I ran your program successfully. But something wrong happened with my code.

```auto
real xinlet = -40;
real xoutlet = 80;
real yside = 40;
real length=5;    
real width=1;    
real n=.5;                 
border cylinder1(t=0,1){ x=-2.5+length*t;y=-0.5;label=2;}
border cylinder2(t=0,1){ x=-2.5+length*t;y=0.5;label=2;}
border cylinder3(t=0,1){ x=-2.5;y=-0.5+width*t;label=2;}
border cylinder4(t=0,1){ x=2.5;y=-0.5+width*t;label=2;}
border inlet(t=-1,1){ x=xinlet;y=yside*t;label=1;}
border baffle(t=0,1){ x=-2.5;y=0.1*t;label=2;}
border outlet(t=-1,1){ x=xoutlet;y=yside*t;label=3;}
border latsup(t=0,1){ x=xoutlet-(xoutlet-xinlet)*t;y=yside;label=3;} 
border latbot(t=0,1){ x=xoutlet-(xoutlet-xinlet)*t;y=-yside;label=3;}
mesh th=buildmesh(inlet(-2*yside*n)+outlet(2*yside*n)+latsup((xoutlet-xinlet)*n)+latbot(-(xoutlet-xinlet)*n)+cylinder1(-50)+cylinder2(50)+cylinder3(10)+cylinder4(-10)+baffle(10));
plot(th,wait=true);

```

The error message is below

```auto
Missing edge 24 v0 = 0[-2.5,0] v1= 1[-2.5,0.1] 0 0x0
 There are 1 lost edges 
 The boundary is crossing maybe! 
 Fatal error in the mesh generator 10
  current line = 11
Meshing error: Bamg
 number : 10, 
 catch Err bamg 
Meshing error: Bamg
 number : 10, 
 err code 5 , mpirank 0

```

---

<div class="post-metadata">

**Author:** ![julienG](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/julieng/32/222_2.png) [@julienG](https://community.freefem.org/u/julienG)\
**Post date:** [February 23, 2024, 3:16am UTC](https://community.freefem.org/t/help-with-creating-a-baffle/2981/4 "2024-02-23T03:16:37Z")

</div>

your `baffle` overlaps with the boundary `cylinder3`. Maybe this:

> border baffle(t=0,1){ x=-2.5+dd;y=0.1\*t+0.5;label=2;}

Also, to help you design meshes, you can plot your boundaries, for example like this:

> plot( cylinder1(50) + cylinder2(-50) + cylinder3(-10) +cylinder4(10)  
> +baffle(10) );

then you easily see the problems

---

<div class="post-metadata">

**Author:** ![RNlao](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/rnlao/32/2070_2.png) [@RNlao](https://community.freefem.org/u/RNlao)\
**Post date:** [February 23, 2024, 3:21am UTC](https://community.freefem.org/t/help-with-creating-a-baffle/2981/5 "2024-02-23T03:21:49Z")

</div>

It ran successfully. I make a stupid mistake. Thank you for your prompt reply. 🥰
