# generate_mesh: mesh generation via matlab for 2D objects
  - Triangular linear elements are generated to describe the mesh.

### File structure
A script *foo.m* generates two files: 
 - *foo.txt*    : contains
   - number of vertices
   - dimension in space (=2)
   - number of elements
   - number of vertices per element (=3)
   - list of vertex coordinates: x<sub>k</sub>, y<sub>k</sub>
   - list of vertex indices defining the elements: idx<sub>i,1</sub>, idx<sub>i,2</sub>, idx<sub>i,3</sub>
   - **indices start with 1 (Fortran)**
 - *foo_sd.txt* : 
   - number of elements
   - subdomain index an element belongs to
   - **indices start with 1 (Fortran)**
 
### current code structure
 - *ascii_write_mesh.m*              : function that writes a mesh file for input in other codes
 - *ascii_write_subdomains.m*        : function that writes the subdomain number for each element into a file
 - *generate_rectangle_subdomains.m* : function that generates (n x k) subdomains by combining squares
 - *square_4.m*                      : generates mesh and subdomain files for a square separated into subdomains
 - *rec_kk.m*                        : generates mesh and subdomain files for kk subdomains
 - *chip_2materials.m*               : generates mesh and subdomain files for chip geometry with 2 subdomains 

