# Meshing with acute-angled triangles

**URL:** https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392
**Category:** General Discussion
**Created:** [April 13, 2023, 7:54am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392 "2023-04-13T07:54:18Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [April 13, 2023, 7:54am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/1 "2023-04-13T07:54:18Z")

</div>

Hi,  
Is there a command in FreeFem++ to build a meshing with “only acute angles” for all elements?. Let us say the constructed triangles are equilateral as an example. I did not find that in the documentation. Can someone helps me with this please?  
Thanks a lot.

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [April 19, 2023, 6:56am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/2 "2023-04-19T06:56:02Z")

</div>

Hi community again,  
Any comment on this kind of meshing?  
I have tried to use the command “adapt” with the subroutine “thetamax= minimum corner angle in degrees”. But I have not obtained the desired result.  
Your comments are appreciated.

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [April 19, 2023, 12:49pm UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/3 "2023-04-19T12:49:43Z")

</div>

Have you tried adaptmesh with `anisomax = 1.0`?

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [April 19, 2023, 2:23pm UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/4 "2023-04-19T14:23:42Z")

</div>

Thank you Chris for your fast reply.  
I put it as you suggested as follows :

mesh Th=square(2, 2, [x0+(x1-x0)\*x, y0+(y1-y0)\*y]);  
Th = adaptmesh(Th, 1./8., IsMetric=1, anisomax = 1.0, thetamax=60);

However, the mesh is still the same without any change. Is there something else here to be replaced or added?

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [April 25, 2023, 5:50pm UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/5 "2023-04-25T17:50:06Z")

</div>

Hi,  
As I am engrossed with this problem, I am just asking if there is any further replies in this regards. I appreciate that.

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [April 27, 2023, 7:56am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/6 "2023-04-27T07:56:27Z")

</div>

I would encourage you to check out a dedicated free open-source meshing software like GMSH if you are in need of greater control over the mesh. While FreeFEM is very powerful for adaptive meshing, it does not have as many mesh controls as are available in other, more specialized, meshing softwares.

You can easily interface FreeFEM meshes with GMSH using `load "gmsh"`

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [May 3, 2023, 5:23pm UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/7 "2023-05-03T17:23:03Z")

</div>

Many thanks for your help

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [May 14, 2023, 11:16am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/8 "2023-05-14T11:16:58Z")

</div>

Hi again  
I studied Gmsh a bit and successfully exported the Gmsh mesh into freefem++ with mesh format 2. Now, when I run freefem++ I have another problem with the boundary labels of the domain. A message reads " **Your set of boundary condition is incompatible with the mesh label**" shown to me. How to make them compatible in order to make it run correctly.

Here is the rectangle1 Gmsh commands:  
h1 = 0.0625; // Characteristic length of a mesh element  
Point(1) = {0, 0, 0, h1}; // Points construction  
Point(2) = {0.6, 0, 0, h1};  
Point(3) = {0.6, 1, 0, h1};  
Point(4) = {0, 1, 0, h1};  
Line(1) = {1, 2}; // Lines construction between points  
Line(2) = {2, 3};  
Line(3) = {3, 4};  
Line(4) = {4, 1};  
Curve Loop(1) = {1, 2, 3, 4}; // A Boundary  
Plane Surface(1) = {1}; // A Surface consisting of all lines  
Physical Surface(1) = {1}; // Setting a label to the Surface  
Physical Curve(1) = {1}; // Set a physical tag 1 to Curve (=line) 1  
Physical Curve(2) = {2}; // Set a physical tag 2 to Curve (=line) 2  
Physical Curve(3) = {3}; // Set a physical tag 3 to Curve (=line) 3  
Physical Curve(4) = {4}; // Set a physical tag 4 to Curve (=line) 4

Also, a sketch of the freefem code is given:

func g= 12./(x+y+1.0)^2; //DIRICHELET boundary condition  
func c=24; //The function c(x), coefficient of u

// importing two overlapping rectangles  
load “gmsh”  
mesh Th1 = gmshload(“rectangle1.msh”);  
mesh Th2 = gmshload(“rectangle2.msh”);

// plot to see the 2 meshes.  
plot(Th1, Th2, cmm=“Th mesh read from GMSH”, wait=true);

//Finite element spaces  
fespace Vh1(Th1, P1);  
Vh1 uh1, vh1, f1, uold1;

fespace Vh2(Th2, P1);  
Vh2 uh2, vh2, f2, uold2;

uold1=0; uold2=0;  
for (int n=0; n\<=30; n++){  
//solve both problems

```
f1=uold1^2;
solve Schw1(uh1, vh1)
      =int2d(Th1)(dx(uh1)*dx(vh1)+dy(uh1)*dy(vh1))+int2d(Th1)(c*uh1*vh1) 
	   +int2d(Th1)(f1*vh1)-int2d(Th1)(c*uold1*vh1)	  					 
	   +on(1,3,4, uh1=g)+on(2, uh1=max(uold1,uold2));	         					 			  

f2=uold2^2;
solve Schw2(uh2, vh2)
      =int2d(Th2)(dx(uh2)*dx(vh2)+dy(uh2)*dy(vh2))+int2d(Th2)(c*uh2*vh2) 
	   +int2d(Th2)(f2*vh2)-int2d(Th2)(c*uold2*vh2)	   					 
	   +on(1,2,3, uh2=g)+on(4, uh2=max(uold1,uold2));	              				 
uold1=uh1;
uold2=uh2;

```

};  
I appreciate your help.

---

<div class="post-metadata">

### Author: ![aszaboa](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/aszaboa/32/2918_2.png) [@aszaboa](https://community.freefem.org/u/aszaboa)
#### Post date: [May 15, 2023, 7:32am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/9 "2023-05-15T07:32:15Z")

</div>

I am not exactly sure what that message means, but in my experience you can ignore it. You can suppress it with setting `verbosity=0`.

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [May 15, 2023, 11:35am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/11 "2023-05-15T11:35:50Z")

</div>

> [@AbuAzzan](#):
>
> **Your set of boundary condition is incompatible with the mesh label**

As mentioned by @aszaboa, you can ignore this as long as your script is behaving normally. See [this](https://github.com/FreeFem/FreeFem-sources/issues/147) thread for more info.

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [May 15, 2023, 5:52pm UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/12 "2023-05-15T17:52:40Z")

</div>

I solved the problem as long as i updated the gmsh mesh file. Thank you so much for your support.

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [May 17, 2023, 2:05pm UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/13 "2023-05-17T14:05:16Z")

</div>

One more question if possible.  
After exporting the gmsh meshing into freefem environment, is there any **command** available in freefem allowing me to **refine** that mesh once again while keeping the **same characteristics of meshing**.  
Thanks.

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [May 17, 2023, 2:18pm UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/14 "2023-05-17T14:18:15Z")

</div>

Are you referring to [this](https://doc.freefem.org/documentation/mesh-generation.html#the-command-splitmesh)?

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [May 18, 2023, 6:24am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/15 "2023-05-18T06:24:33Z")

</div>

Thanks Chris. I am trying to implement it in my case. The following is my attempt.

load “gmsh”  
mesh Th1 = gmshload(“rectangle1\_case3.msh”);  
mesh Th2 = gmshload(“rectangle2\_case3.msh”);

for (int n=1; n\<=nmsh; n++){  
// The updated mesh sizes  
h1[n]=1./(2.\*n+1);  
h2[n]=1./(4.\*n+1);

Th1 = splitmesh(Th1,h1[n]);  
Th2 = splitmesh(Th2,h2[n]);  
…  
};

However, I have got the following error!

# – Splitmesh 0x10eef5c0 split min: 0 max: 0 mshptg bug in number of points 0 \> 0 == max nb points Error mesh generation in mshptg : err = 1 nb triangles = 0 current line = 73 Assertion fail : (err==0 && nbt !=0) line :2085, in file ../femlib/fem.cpp Assertion fail : (err==0 && nbt !=0) line :2085, in file ../femlib/fem.cpp err code 6 , mpirank 0

I think the problem is with the mesh size functions. Any help to solve it.

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [May 18, 2023, 10:53am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/16 "2023-05-18T10:53:23Z")

</div>

I believe the second argument should be a single integer.

---

<div class="post-metadata">

### Author: ![AbuAzzan](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/abuazzan/32/1645_2.png) [@AbuAzzan](https://community.freefem.org/u/AbuAzzan)
#### Post date: [May 30, 2023, 6:43am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/17 "2023-05-30T06:43:54Z")

</div>

Sorry for the late reply. Do you mean the mesh sizes arguments h1[n] & h2[n]? If they are so, how can I write down them as integers?

Another question, Can I also use the command **adaptmesh** here to refine the meshs and is there any preventative measurements to apply it?

---

<div class="post-metadata">

### Author: ![cmd](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.freefem.org/cmd/32/67_2.png) [@cmd](https://community.freefem.org/u/cmd)
#### Post date: [May 30, 2023, 8:25am UTC](https://community.freefem.org/t/meshing-with-acute-angled-triangles/2392/19 "2023-05-30T08:25:49Z")

</div>

Sorry, I was thinking of the `split` argument in `trunc`. You can find more info about `splitmesh` and `adaptmesh` [here](https://doc.freefem.org/documentation/mesh-generation.html).
