### Table des matières

## Meshgen : A mesh generator for cartesian grid

Meshgen is a modest mesh generator for cartesian grid. The principle is very simple :

- Each direction {x,y,z} (or {r,$\theta$,z} in cylindrical geometry) is represented by a line.
- Each line can be splitted in several parts over which a distribution law is applied in order to build the discretization nodes.
- Following the CFD code used, these nodes have different definitions :
- For Chorus, they are the cell centers.
- For Sunfluidh, they are the cell-face locations ($x_i, y_i, z_i$ see the page "Overview ...", section "stagerred grid" for more details).

- Several distribution laws are available :
- Geometric functions
- Hyperbolic tangent functions
- Cosine function

### Compilation procedure

**For Sorbonne universite class, this step is automatically made by the install procedure.**

After downloading the Meshgen project from the server forge by means of svn (svn co –username your_login https://forge.limsi.fr/svn/MESHGEN/TRUNK)

- go to the directory MESHGEN/TRUNK/SOURCES
- Run the command make: The executable file meshgen.x is created.

### Meshgen settings

The grid parameters are set in the input data file “data_meshgen.dat”. A simple example of a 2D grid is given * here*:

### Data set description

In the data file, each block of data is attributed to a direction (I,J or K).

Each direction can be split in several parts (segments) on which a specific distribution law is applied in order to place the discrete nodes.

Each distribution law is defined by means of namelists that are described at the end of this page.

For illustrating how that works, let consider a domain length $L$ (in an arbitrary direction) split in $2$ parts with lengths $L_1$ and $L_2$, respectively (see the figure below). Discrete coordinates are distributed with a given law (by considering here $N_1=6$ for the first segment, $N_2=8$ for the second one).

The origin coordinate is not included in the procedure. It is added by the code.

The coordinate located at the upper end of the segment belongs to this segment, not to the following one.

The available distribution functions are (click on function name to get details):

- Regular function (Function_name= REGULAR)
- Hyperbolic tangent function "one side" (Function_Name= TANH_ONE_SIDE)
- Hyperbolic tangent function "two sides" (Function_Name= TANH_TWO_SIDES)
- Gauss-Lobatto distribution (Function_Name= GAUSS_LOBATTO)
- Geometric series "type 1" (Function_Name= GEOMETRIC_SERIE_1)
- Geometric series "type 2" (Function_Name= GEOMETRIC_SERIE_2)

These functions get some parameters :

**Number_of_Cells**: Number of cells over the segment (for all functions).**Length**: Length of the segment (for all functions).**Left_Cell_Size**: Reference size of the cell placed at the left tip of the segment (for all functions except the regular function and geometric series “Type 1”)**Right_Cell_Size**: Reference size of the cell placed at the right tip of the segment (for hyperbolic function “two sides” only)**Reverse_Ordering**: Reverse the ordering of the distribution if set to .true.**End_of_Block_Data**: logical set to .true. to specify the end of a data structure (by default it set to .false. by the program)

*A template is provided here*.

&METRIC_UNIT Type_of_Metric= 0 /

- Type_of_Metric= 0 specifies a usual metric
- Type_of_Metric= 1 specifies an angular metric. The unit is the degree.

The block of data must be closed with the special namelist

&MESH_FUNCTION_DATA End_of_Data_Block = .true./

### Generate the grid with Meshgen

After setting the data set in the file “data_meshgen.dat”, run the command “meshgen.x”.

Few questions are asked :

- Choice of CFD code : OLORIN or SUNFLUIDH (1) CHORUS (2) —> choose the correct option
- MPI domain decomposition (1) or not (0) —> choose the correct option (if unsure, answer 0)

For the case of MPI domain decomposition, further information is required to perform the appropriate domain decomposition

- number of domain decomposition per direction
- In I-direction —> write the value
- In J-direction —> write the value
- In K-direction —> write the value

### Output files

The grid data are recorded in the appropriate files that depend on the code previously selected:

- For Chorus, maille_yyyyy.dat : data are recorded in binary format. “yyyyy” is the number of the associated subdomain.
- For sunfluidh :
, maillx.d, mailly.d, maillz.d (one file per direction): data are recorded in ASCII format and ordered in two colums, the first one is the cell-index, the second one is the coordinate of the upper face of the cell.Be careful, by default the first index starts at 2. The first coordinate is directly provided by the code.**For sequential computation**, maillx_yyyyy.d, mailly_yyyyy.d and maillz_yyyyy.d (one file per direction): data are recorded in ASCII format and ordered in two colums, the first one is the cell-index, the second one is the coordinate of the upper face of the cell.**For domain decomposition (MPI parallelization)**

### Check the grid

For checking the grid features, a specific file named “report_meshgen.d” is created in which relevant data about the grid characteristics can be read.

Three other files named “check_mesh_I.d”, “check_mesh_J.d” and “check_mesh_K.d” are created. They are similar to “maillx.d”, “mailly.d” and “maillz.d” (see above). A 3rd column of data is associated to the cell size.