# Adaptmesh in 1D, for a segment

**URL:** <https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010>\
**Category:** General Discussion\
**Created:** [February 29, 2024, 9:26pm UTC](https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010 "2024-02-29T21:26:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![tess35](https://avatars.discourse-cdn.com/v4/letter/t/ac8455/32.png) [@tess35](https://community.freefem.org/u/tess35)\
**Post date:** [February 29, 2024, 9:26pm UTC](https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010/1 "2024-02-29T21:26:04Z")

</div>

Hi,

Could you remind me how to adaptmesh for 1D mesh ?

Thank

---

<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:** [March 1, 2024, 8:59am UTC](https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010/2 "2024-03-01T08:59:06Z")

</div>

No real way to day. Because it is trivial , Sorry

---

<div class="post-metadata">

**Author:** ![tess35](https://avatars.discourse-cdn.com/v4/letter/t/ac8455/32.png) [@tess35](https://community.freefem.org/u/tess35)\
**Post date:** [March 7, 2024, 1:54pm UTC](https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010/3 "2024-03-07T13:54:56Z")

</div>

I try :

load “msh3”  
meshL Th=segment(1000);  
fespace Vh(Th, P2);  
Vh u, v ;  
solve Poisson ( u, v, solver = LU ) = int1d(Th) ( dx(u)_dx(v) + u_v )- int1d(Th) ( x\*v )+  
on ( 1, 2, u = 0.0 );  
plot([xx,u],wait=1);  
It works.

But not after:  
meshL Th2 = adaptmesh(Th, u , err= 1E-5 )

The version is 4.11 and i have the following error message:  
meshL Th2 = adaptmesh(Th, u , err= 1E-5 ) error operator ( ,   
List of choices N5Fem2D4MeshE N5Fem2D4MeshE

---

<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:** [March 8, 2024, 5:54pm UTC](https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010/4 "2024-03-08T17:54:12Z")

</div>

Yes but they are no code after!

---

<div class="post-metadata">

**Author:** ![tess35](https://avatars.discourse-cdn.com/v4/letter/t/ac8455/32.png) [@tess35](https://community.freefem.org/u/tess35)\
**Post date:** [March 13, 2024, 9:04pm UTC](https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010/5 "2024-03-13T21:04:53Z")

</div>

Ok je suis un peu long à la compréhension.  
Il n’y a pas de fonction en 1D ? ou cela se fait de manière très simple ? ou c’est automatique ?  
Désolé de vous faire revenir sur ce sujet.

---

<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:** [March 14, 2024, 4:04pm UTC](https://community.freefem.org/t/adaptmesh-in-1d-for-a-segment/3010/6 "2024-03-14T16:04:59Z")

</div>

IL n’y a pas le code associe,

but the code is simple for P1 approximation of u

1. compute the metrix by regularization of de u'' in P1 ant than I call it m \sim 1/\varepsilon | u''|  
where \varepsilon is the level of error in norm L^\infty.

Now the problem is to build a mesh such that the length in m are content and equal to 1 the mesh size.

the length of seg [a,b[] = \int\_a^b \sqrt{|m|},  
so if we call M the primitive of \sqrt{|m|}, then the mesh is image by N of regular mesh of mesh size class to 1, and where N is the inverse function of M
