... | ... | @@ -25,12 +25,12 @@ The first step is to create a new shapefile (for example, `coast.shp`) with the |
|
|
- Enter the *edit mode* ![edit](/uploads/3c3afe1f36fc4ac58743b3e3aa930d95/edit.png) and paste the entities with *Ctrl+V*
|
|
|
- *Seamsh* requires lines to have a "physical" attribute. To add this attribute to coastlines, open table of attributes ![attr-field](/uploads/831cb5ac88fed104372113c22ab27484/attr-field.png)
|
|
|
- Add a column ![new-column](/uploads/cf8897fd6cfb6d7b272f4ed244cc8889/new-column.png), name it `physical` of type `string` (with size 20 or more depending on how inspired you feel)
|
|
|
- Give value `'coast'` by default to coast lines. Select *physical* (top left list), type 'coast' and select *Update All*.
|
|
|
- Give value `'coast'` by default to coastlines. Select *physical* (top left list), type 'coast' and select *Update All*.
|
|
|
- You can view and edit the attributes of a given line by clicking on it with the tool ![select](/uploads/e7ade47750c57be4bea219f949a479ef/select.png)
|
|
|
- If needed, you can give different physical attributes to different coast lines by selecting them with ![rect-select](/uploads/d75be8d994e117ce9419c35c4bafc155/rect-select.png) and then updating their physical attribute using *Update selected* in ![attr-field](/uploads/831cb5ac88fed104372113c22ab27484/attr-field.png).
|
|
|
- If needed, you can give different physical attributes to different coastlines by selecting them with ![rect-select](/uploads/d75be8d994e117ce9419c35c4bafc155/rect-select.png) and then updating their physical attribute using *Update selected* in ![attr-field](/uploads/831cb5ac88fed104372113c22ab27484/attr-field.png).
|
|
|
- Add one (or more) lines ![entity](/uploads/6a86ca4b9f0504f9580c2538021acb2a/entity.png) in order to close the domain (Left-click to start adding the points of a line, right-click to end the line). Give the physical attribute of you choice to the added lines ('open' for instance) than click on *OK*.
|
|
|
- Exit the *edit mode* and save the layer
|
|
|
- Save the project (If you are using a virtual machine, put it in the *slim-vm* shared directory.)
|
|
|
- Save the project.
|
|
|
|
|
|
## Python scripts
|
|
|
|
... | ... | @@ -38,14 +38,15 @@ In order to generate the mesh, a Python script `mesh_example.py` is available on |
|
|
|
|
|
### `params.py`
|
|
|
|
|
|
In this file, the following variables are defined
|
|
|
`param.py` is the central file containing the user-defined variables/parameters needed by all other scripts. In this file, the following variables are defined
|
|
|
```python
|
|
|
shape_file = "coast_physical_v4.shp" # shape file containing coast lines
|
|
|
shape_file = "coast_physical_v4.shp" # shape file containing coastlines
|
|
|
reef_file = "reefs_v4_physical.shp" # shape file with reefs (or other feature of interest)
|
|
|
use_bath = False # True if mesh resolution depends on bathymetry otherwise False
|
|
|
use_bath_grad = False # True if mesh resolution depends on bathymetry gradient otherwise False
|
|
|
mesh_file = "florida_coarse.msh" # name of generated mesh
|
|
|
```
|
|
|
`shape_file` is the path to the file generated in the previous step. In case you want to refine your mesh near features such as coral reefs, the path to the shape file containing these features can be assigned to the variable `reef_file`.
|
|
|
`shape_file` is the path to the shape file generated in the previous step (make sure that the generated .cpg, .dbf, .prj and .shx files are in the same folder). In case you want to refine your mesh near features such as coral reefs, the path to the shape file containing these features can be assigned to the variable `reef_file`(make sure to add a `physical` attribute to the lines/polygons of this file with QGIS).
|
|
|
|
|
|
In case you want to use bathymetry data to define the element size of your mesh (`use_bath = True` or `use_bath_grad = True`, you will need to download it using the `download_forcings.py` script by launching
|
|
|
```bash
|
... | ... | @@ -55,11 +56,11 @@ or |
|
|
```bash
|
|
|
python3 download_forcings.py
|
|
|
```
|
|
|
At this stage, it is not necessary to run `download_forcings.py` in its integrity, you can interrupt it by typing `Ctrl`+`c` as soon as the bathymetry is downloaded.
|
|
|
At this stage, it is not necessary to run `download_forcings.py` in its integrity, you can interrupt it with `Ctrl`+`c` as soon as the bathymetry has been imported.
|
|
|
|
|
|
### `mesh_example.py`
|
|
|
|
|
|
In this section, we will briefly explain the different lines of the script. First, we load the different modules needed by the script and define the meshing domain (you don't need to edit this part)
|
|
|
In this section, we will briefly explain the different lines of the meshing script. First, we load the different modules needed by the script and define the meshing domain (you should not edit this part)
|
|
|
|
|
|
```python
|
|
|
import seamsh
|
... | ... | @@ -88,14 +89,14 @@ Then shape files are added to the domain |
|
|
domain.add_boundary_curves_shp(param.shape_file, "physical", CurveType.POLYLINE)
|
|
|
domain_reefs.add_interior_curves_shp(param.reef_file, "physical", CurveType.POLYLINE)
|
|
|
```
|
|
|
In case, you don't need the variable `reef_file`, the second line can be commented.
|
|
|
In case, you don't need the variable `reef_file`, the second line can be commented (with `#`).
|
|
|
|
|
|
The mesh size will can depend on three parameters:
|
|
|
The mesh size can depend on three parameters:
|
|
|
1. distance to coast/special features
|
|
|
2. bathymetry
|
|
|
3. bathymetry gradient
|
|
|
|
|
|
The distances to coastlines (and coral reefs/special features) are defined in the following lines (you might need to modify these lines depending on the physical attributes of your shape file).
|
|
|
The distances to coastlines (and coral reefs/special features) with given physical attributes are defined in the following lines (you might need to modify these lines depending on the physical attributes of your shape file).
|
|
|
```python
|
|
|
# 3. Define distances to features for mesh resolutions
|
|
|
dist_fl = seamsh.field.Distance(domain, 100, ["coast"])
|
... | ... | @@ -189,7 +190,8 @@ where `(-81.78, 23.95)` must be modified to be coordinates of a point inside you |
|
|
```python
|
|
|
# 7. Start meshing
|
|
|
seamsh.gmsh.mesh(coarse, param.mesh_file, mesh_size, version=2)
|
|
|
|
|
|
```
|
|
|
|
|
|
![mesh_bathymetry](/uploads/68c837d705cedc80d5a789b7715b9d5b/bahamas_tuto_bath.png) |
|
|
\ No newline at end of file |
|
|
You can then visualize the generated mesh using [Gmsh](https://gmsh.info/).
|
|
|
|
|
|
![florida_coarse](uploads/8d295485acba9f6c101375af5ac2858d/florida_coarse.png) |
|
|
\ No newline at end of file |