# 3: Meshing

## Mesh Settings

Meshing is one of the key components to obtaining accurate results. The elements that are used to construct a mesh must take into account a number of aspects to be able to discretize stress gradients accurately within the model. The following parameters are typically used to determine the required element size which we commonly refer to as box:

1. Frequency of Interest
• Typical variable name - freqint
• Set to the centre of the frequency band that you are interested in
2. Slowest wave velocity in the model
• Typical variable name - vel
• Generally set to the lowest shear wave velocity in the model
3. Shortest wavelength in the model
• Typical variable name - wavelength
• Calculation of the shortest wavelength based on vel and freqint
4. Number of element to discretise a wavelength
• Typical variable name - nepw
• Minimum value of 15 elements per wavelength is recommended
5. Size of an element
• Typical variable name - box
• Calculated from the wavelength divided by number of elements per wavelength
```c frequency and meshsymb freqint =  1e6                  /* frequency of interest symb freqdamp =  \$freqint             /* set damping frequency to frequency of interestsymb vel =  1500                     /* minimum material velocity in model
symb wavelength =  \$vel /  \$freqint  /* calculate smallest wavelength to disctretisesymb nepw =  15                      /* number of elements per wavelength symb box =  \$wavelength /  \$nepw     /* calculate element size for meshing```

The freqdamp variable is not used as part of the meshing process but, it is usually set here with the value of freqint to align the damping characteristics of the materials over the correct frequency band of interest.

Note: more elements per wavelength can be used to increase accuracy or minimise numerical dispersion*, however, this MUST be traded off against additional computational time. For example, in a 3D model, doubling the amount of elements per wavelength with multiply the model size by a factor of 8. Therefore, the effect of diminishing returns must be considered. Unless it is absolutely necessary, a small increase in accuracy is not necessarily worth the x10-20 increase in simulation time

*Numerical Dispersion is inherent in all numerical codes and is a small cumulative error that is caused due to sampling a wave in space and time. The non-physical phenomenon causes different frequencies to travel a different velocities; changing the shape of the wave with in turn can lead to amplitude (time domain) and phase (frequency domain) errors.

## Keypoint Generation and Grid Setup

### #keycord:

Keypoints are critical points in space that will be used to accurately map out the dimensions of your geometry. Using the variables created in the Model Inputs section, we can use the #keycord command to generate these keypoints along the X and Y axis:

`c create x-y-z keypoints to accurately model dimensiossymb #keycord x 1 0.0 \$stst_size \$defect_size \$stst_sizesymb #get { idx } rootmax x   /* store last keypoint indice in variable 'idx'            symb #keycord y 1 0.0 \$defect_size2 \$stst_size symb #get { jdx } rootmax y   /* store last keypoint indice in variable 'jdx'`

The #keycord command is very simple to set up:

1. Access the command through symb command
2. The first input argument is the direction which the keypoint will be generated: x,y or z (3D models)
3. The indice value which the keypoint will start from :1
4. The absolute value which the first defined keypoint
5. The dimensions to define folllowin keypoints: variables created

What the code will yield:

Tip: we always record the last indice value using the #get rootmax option. Note that #get operations use braces { } instead of regular brackets ( )

It is useful to have quick access the last node/keypoint on the grid to use in additional commands and for debug purposes.

### #keyindx:

Following on from the XYZ keypoints, we need to determine how many elements are required to represent the distances along the XY direction which for the computatinal grid shall also be known as the IJ direction. We can use the dedicated symb command, #keyindx to do so:

`c create i-j-k keypoints symb #keyindx i 1 \$idx 1 \$box 1  /* calculate number of nodes required in i directionsymb #keyindx j 1 \$jdx 1 \$box 1  /* calculate number of nodes required in j direction          symb indgrd = \$i\$idx             /* last node number in i directionsymb jndgrd = \$j\$jdx             /* last node number in j direction`
1. Access the command through symb command
2. the first input argument is the direction which the keypoint will be generated - i, j or k(3D models)
3. the first keypoint indice value - 1
4. the last keypoint indice value - \$idx \$jdx or \$kdx
5. keypoint incremental value - 1
• This value allows keypoints to be skipped for the number of elements between keypoints calculation (i.e. 1 = (x1-x2-x3-x4-x5) or 2 = (x1-x3-x5) etc.)
6. maximum size of element - \$box
7. minimum spacing between keypoints - 1
• Places at least one element by default in between keypoints to prevent errors
• If value = 4, a minimum of 4 elements will always be created in between keypoints

Note: we recommend that element aspect ratio should not exceed 4:1 for stability and accuracy reasons so be careful when you are setting minimum spacing value to a higher integer value

### GRID and GEOM command:

`c create gridgrid \$indgrd \$jndgrd     /* generate grid of nodes and apply axisymmetric condition to model gridc map physical geometry to grid of nodesgeom keypnt>\$idx \$jdx    /* tie in all xy keypoints (physical dimensions) to ij keypoints(nodes)`

The grid command is very simple: it will generate a grid of evenly spaced nodes/elements based on the integer values input and allows the grid to be axially rotated to create axisymmetric models.

The geom command ties in the physical distances to the nodal spacing, and where there is a keypoint, a node must lie at that precise location. This means that your mesh will look more like this:

This is one of the reasons why we set up models using keypoints: so that the important aspects of our geometry are at the exact required size.

1. Using the symb command, create 6 variables for the mesh settings:
1. freqint - 1 MHz
2. freqdamp - 1 MHz
3. vel - 1500 m/s
4. wavelength - vel / freqint
5. nepw - 15 elements per wavelength
6. box - wavelength / nepw
2. Create keypoints in the along the X and Y direction using the #keycord command
3. Store the last indice value in both X and Y direction using the symb #get {...} rootmax option
4. Create keypoints in the along the I and J direction using the #keyindx command
5. Using the symb command, create 2 variables to store the last IJ nodes:
1. indgrd - \$i\$idx
2. jndgrd - \$j\$jdx
6. Insert in grid command to create grid of nodes and apply axisymmetric Y condition (axiy)
7. Insert in geom keypnt to tie in XY keypoints to IJ keypoints

Progress to tutorial section: Materials

## Tutorial Code

```c frequency and meshsymb freqint =  1e6                  /* frequency of interest symb freqdamp =  \$freqint             /* set damping frequency to frequency of interestsymb vel =  1500                     /* minimum material velocity in model
symb wavelength =  \$vel /  \$freqint  /* calculate smallest wavelength to disctretisesymb nepw =  15                      /* number of elements per wavelength symb box =  \$wavelength /  \$nepw     /* calculate element size for meshingc create x-y-z keypoints to accurately model dimensiossymb #keycord x 1 0.0 \$stst_size \$defect_size \$stst_sizesymb #get { idx } rootmax x   /* store last keypoint indice in variable 'idx'            symb #keycord y 1 0.0 \$defect_size2 \$stst_sizesymb #get { jdx } rootmax y   /* store last keypoint indice in variable 'jdx'c create i-j-k keypoints symb #keyindx i 1 \$idx 1 \$box 1  /* calculate number of nodes required in i directionsymb #keyindx j 1 \$jdx 1 \$box 1  /* calculate number of nodes required in j direction          symb indgrd = \$i\$idx             /* last node number in i directionsymb jndgrd = \$j\$jdx             /* last node number in j direction
c create gridgrid \$indgrd \$jndgrd      /* generate grid of nodes and apply axisymmetric condition to model gridc map physical geometry to grid of nodesgeom keypnt \$idx \$jdx        /* tie in all xy keypoints (physical dimensions) to ij keypoints(nodes)

```
0 out of 0 found this helpful