Mesh generation from a geometry

Hi,

Regarding the documentation it seems not possible to generate a mesh from a geometry model, as the geo gmsh file, directly in freefem ?

PS : A geometry model is composed with :

  • a list of vertices
  • list of edges
  • list of domains
  • a domain is defined by a list of boundaries
  • a boundary is defined by a list of oriented edges

In 2d you can do:

{
 // build from bamg geometrie

  { // build the geom file
    ofstream ff("g.mesh");
    int n = 8;
    real h = 0.1;
    ff <<"MeshVersionFormatted 0\n";
    ff <<"AngleOfCornerBound 46\n";
    ff <<"Dimension 2 \n";
    ff << "Vertices "<< n <<  endl;
    for (int i=0;i<n;i++)
      ff << cos(i*pi*2./n) << " " << sin(i*pi*2./n) << " 1\n"; 

    ff << "Edges "<< n<< endl;
    for (int i=0;i<n;i++)
      ff << i+1 << " " << (i+1)%n +1 << " 1\n";

    ff << "hVertices"<< endl;
    for (int i=0;i<n;i++)
      ff << h << endl;
  }

  mesh Th=buildmesh("g.mesh",nbvx=100000);
  plot(Th,wait=1);
}

Thanks,

It seems that medit mesh file can’t handle geometries with holes cause that file format was firstly designed as a mesh file format.
For instance how to define a geometry composed of two concentric circles :

{
// build from bamg geometrie

{ // build the geom file
ofstream ff(“g.mesh”);
int n = 8;
real h = 0.1;
ff <<“MeshVersionFormatted 0\n”;
ff <<“AngleOfCornerBound 46\n”;
ff <<“Dimension 2 \n”;

ff << "Vertices "<< 2*n <<  endl;
for (int i=0;i<n;i++)
  ff << cos(i*pi*2./n) << " " << sin(i*pi*2./n) << " 1\n";
for (int i=0;i<n;i++)
  ff << 0.5*cos(i*pi*2./n) << " " << 0.5*sin(i*pi*2./n) << " 1\n"; 	  

ff << "Edges "<< 2*n<< endl;
for (int i=0;i<n;i++)
  ff << i+1 << " " << (i+1)%(n) +1 << " "<<i+1 <<" \n";

for (int i=0;i<n;i++)
  ff << (i+1)%+n +1+n << " " << (i+1+n) <<" "<< i+1+n<<" \n";  
  
ff << "hVertices"<< endl;
for (int i=0;i<2*n;i++)
  ff << h << endl;

}

mesh Th=buildmesh(“g.mesh”,nbvx=100000);
plot(Th,wait=1);
}