|
|
# Mesh Generation
|
|
|
|
|
|
## Download
|
|
|
- QGIS :
|
|
|
- https://www.qgis.org/fr/site/forusers/download.html
|
|
|
- topography (Open Street map) :
|
|
|
- http://openstreetmapdata.com/data/coastlines
|
|
|
- bathymetry (ETOPO) :
|
|
|
- https://maps.ngdc.noaa.gov/viewers/wcs-client/
|
|
|
- select subregion
|
|
|
- https://www.ngdc.noaa.gov/mgg/global/
|
|
|
|
|
|
## QGIS
|
|
|
|
|
|
- Open QGIS
|
|
|
- Save new project
|
|
|
- Import topography (and bathymetry) data (click and drag)
|
|
|
- Select entity with a rectangle ![rect-select](/uploads/8c06c33278e317a7e745366a8fd42edd/rect-select.png) + "Ctrl+C"
|
|
|
- Create new shapefile layer ![shape-layer](/uploads/d8716ff5f35a04247f607c47b1711988/shape-layer.png) (with type 'line')
|
|
|
- layer -> create new Shapefile layer
|
|
|
- Select new layer
|
|
|
- Open the "edit mode" ![edit](/uploads/8812573e53ef13f95dc3bee0824cdb6a/edit.png) + "Ctrl+V"
|
|
|
- Add one (or more) entity ![entity](/uploads/da2647c08fc1eb25ba052f2c8c7ff28d/entity.png) in order to close the domain
|
|
|
- Click left to add lines, click right to stop (choose an ID)
|
|
|
- (Save your changes !)
|
|
|
- In edit mode, open table of attributes ![image](/uploads/accc84d339bf26eb1855ec1c757963d5/attr-field.png)
|
|
|
- Add a column ![new-column](/uploads/2c28abb33ca2fe51ea97c3f1017b6293/new-column.png), name it "entity" of type "integer"
|
|
|
- Give value "1" by default
|
|
|
- Select line(s) ![select](/uploads/b95d581d39ba6b59289abe757b32be22/select.png) and change entity. Give as many different integers as necessary to produce the mesh and run the model (but not too many).
|
|
|
- Hint : write the numbers on a paper sheet with their meaning (1 : coast).
|
|
|
- Save all and close QGIS
|
|
|
|
|
|
## Python script
|
|
|
|
|
|
Import SLIM preprocessing module
|
|
|
|
|
|
```python
|
|
|
import slimPre
|
|
|
```
|
|
|
|
|
|
Give Earth radius
|
|
|
|
|
|
```python
|
|
|
R=6341e3
|
|
|
```
|
|
|
|
|
|
Get distance to tags "1" and "4" of a shapefile "coast.shp" (lines filled with points every 1000 meters)
|
|
|
|
|
|
```python
|
|
|
distCoast = slimPre.distance_shp("./coast.shp", 1000, [1,4])
|
|
|
```
|
|
|
|
|
|
Get bathymetry data
|
|
|
|
|
|
```python
|
|
|
bath = slimPre.geo_tiff('./etopo.tif')
|
|
|
```
|
|
|
|
|
|
Define a "mesh size map"
|
|
|
|
|
|
Here the resolution ranges from 1 to 10 km, depending on distance to coast. The mesh size should also depend on the bathymetry.
|
|
|
|
|
|
```python
|
|
|
def fsize(x, y, z) :
|
|
|
d = distCoast.evaluate_geocentric(x,y,z)
|
|
|
l0 = 1000
|
|
|
l1 = 10000
|
|
|
d0 = 8000
|
|
|
d1 = 50000
|
|
|
if d < d0 :
|
|
|
s1 = l0
|
|
|
elif d < d1 :
|
|
|
f = (d-d0)/(d1-d0)
|
|
|
s1 = l0*(1-f) + l1 * f
|
|
|
else :
|
|
|
s1 = l1
|
|
|
return s1/R
|
|
|
```
|
|
|
|
|
|
Define a dictionary of the "tags map"
|
|
|
|
|
|
```python
|
|
|
physicals = {1:"coast", 2:"atlantic", 3:"mexico", 4:"island"}
|
|
|
```
|
|
|
|
|
|
Generate the mesh with the following arguments :
|
|
|
|
|
|
- shapefile delimiting the domain
|
|
|
- longitude of a point inside the domain
|
|
|
- latitude of a point inside the domain
|
|
|
- name of the "mesh size map" function
|
|
|
- minimum of the mesh size
|
|
|
- name of the output mesh
|
|
|
- projection system
|
|
|
- name of the dictionariy with the "tags map"
|
|
|
|
|
|
```python
|
|
|
slimPre.mesh_shp(["./coast.shp"], -78 , 23, fsize, 1000/R,
|
|
|
"bahamas.msh", "+proj=utm +ellps=WGS84 +zone=17 +north", physicals)
|
|
|
```
|
|
|
|
|
|
Exit properly
|
|
|
|
|
|
```python
|
|
|
slimPre.exit(0)
|
|
|
```
|
|
|
|