Skip to content

Commit 70c64ea

Browse files
davidscnMakisHuekerman
authored
Tweak aste tutorial documentation (#293)
* Fix cleaning tool * Port docs to new names * Overhaul script comments * Extend documentation Co-authored-by: Gerasimos Chourdakis <[email protected]> Co-authored-by: Benjamin Uekermann <[email protected]>
1 parent 700c5e2 commit 70c64ea

File tree

5 files changed

+72
-38
lines changed

5 files changed

+72
-38
lines changed

aste-turbine/README.md

+51-17
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,63 @@
11
---
2-
title: ASTE (Artificial Solver Testing Environment) Turbine Tutorial
2+
title: ASTE (artificial solver testing environment) wind turbine blade tutorial
33
permalink: tutorials-aste-turbine.html
4-
keywords: ASTE, Testing, Turbine
5-
summary: This tutorial is an example case for ASTE, showcasing basic features and usage of ASTE.
4+
keywords: ASTE, mapping, data mapping, mapping configuration, turbine
5+
summary: This tutorial is an example case for ASTE, where we investigate different preCICE mappings using ASTE.
66
---
77

88
{% include note.html content="Get the [case files of this tutorial](https://github.com/precice/tutorials/tree/master/aste-turbine). Read how in the [tutorials introduction](https://precice.org/tutorials.html)." %}
99

10+
If you are completely new to ASTE have a look at our [ASTE documentation](https://precice.org/tooling-aste.html). This tutorial shows how to setup a mapping between two (artificial) meshes using preCICE and ASTE in parallel. The executed mapping can be investigated in terms of accuracy as well as runtime.
11+
1012
## Setup
1113

12-
This case is a simple usage scenario for ASTE. Some features demonstrated by this tutorial:
14+
Our example consists of a wind turbine blade geometry, which was triangulated using different refinement levels. The mesh files are stored in [this GitLab repository](https://gitlab.lrz.de/precice/precice2-ref-paper-setup) and correspond to the mesh files used for the mapping tests of our [version 2 reference paper](https://doi.org/10.12688/openreseurope.14445.1). The mesh files are automatically downloaded when the `run.sh` script is executed. In this example setup, we map the mesh `0.01.vtk` (left side of the figure) to the mesh `0.006.vtk` (right side of the figure).
15+
16+
![Turbine setup](images/tutorials-aste-setup.png)
17+
18+
## Running the tutorial
19+
20+
All necessary steps in order to run the mapping setup are summarized in the `run.sh` script. Have a look at the comments in the run script in order to understand what is happening. In particular, the script executes the following steps:
21+
22+
1. Download the mesh files and extract them in the `meshes` directory. This step is only executed when running the script for the first time. For our example, we only use two of the downloaded meshes. The tutorial can easily be modified to employ different meshes.
23+
2. Generate input data for our mapping problem. As described in the [ASTE documentation](https://precice.org/tooling-aste.html#precice-aste-evaluate), the python script `precice-aste-evaluate` evaluates a test function and stores the results on a mesh. Here, we select Franke's function, evaluate it on the input mesh `0.01.vtk`, and store the results on a mesh called `input_mesh.vtu`. Use `precice-aste-evaluate --list-functions` to get a complete list of available test functions and their definitions.
24+
3. Partition meshes. We want to execute the mapping in parallel. To this end, we need to partition our mesh files so that each rank receives its own mesh file. The python script `precice-aste-partition` partitions a given mesh in a specified number of pieces (here two for the input mesh and two for the output mesh).
25+
4. Execute the actual mapping. We start two instances of `precice-aste-run`, which is the ASTE core module interfacing with preCICE, to emulate two participants. Here, we map the data from the coarse input mesh to the fine output mesh. We store the mesh and data per rank in files `mapped/mapped...` with data called `InterpolatedData`.
26+
5. Join scattered mesh files. The python script `precice-aste-join` joins the results into one large mesh file `result.vtu`.
27+
6. Investigate accuracy of mapping configuration. We use `precice-aste-evaluate` again. This time, we use the `--diff` flag in order to compute the error between our test function and the mapped data. We store the difference data (`Error`) on the result mesh (`result.vtu`) as well, which allows us to visualize the error distribution, e.g., using `ParaView`. `precice-aste-evaluate` also prints several global error measures to the console:
28+
29+
```bash
30+
---[ASTE-Evaluate] INFO : Vertex count 9588
31+
---[ASTE-Evaluate] INFO : Relative l2 error 0.002402706834866804
32+
---[ASTE-Evaluate] INFO : Maximum absolute error per vertex 0.009659755828445804
33+
---[ASTE-Evaluate] INFO : Maximum signed error per vertex 0.00888725146042224
34+
---[ASTE-Evaluate] INFO : Minimum absolute error per vertex 0.0
35+
---[ASTE-Evaluate] INFO : Minimum signed error per vertex -0.009659755828445804
36+
---[ASTE-Evaluate] INFO : Median absolute error per vertex 0.0011544478395176805
37+
---[ASTE-Evaluate] INFO : 99th percentile of absolute error per vertex 0.007066025673252374
38+
---[ASTE-Evaluate] INFO : 95th percentile of absolute error per vertex 0.005206080046631978
39+
---[ASTE-Evaluate] INFO : 90th percentile of absolute error per vertex 0.004253350142177374
40+
```
41+
42+
This information is additionally stored in a JSON file `result.stats.json` for potential further processing.
1343

14-
* Mapping from a fine grid (`0.009.vtk`) to a coarse grid (`0.01.vtk`).
15-
* Usage of ASTE partitioner.
16-
* Usage of ASTE mesh joiner.
17-
* Usage of ASTE calculator for calculating a function on a given mesh.
18-
* Usage of ASTE.
44+
{% note %}
45+
The error measures used here are only useful for consistent mapping configurations, i.e., `constraint="consistent"`.
46+
{% endnote %}
1947

20-
## Running ASTE
48+
This tutorial is meant as a starting point to investigate mapping setups. The provided configuration uses a `nearest-neighbor` mapping, but there are other mapping configurations available (commented out) in the `precice-config.xml` file. Example: using the last configuration (`rbf-compact-polynomial-c6` with a dense matrix decomposition) leads to the following error measures:
2149

22-
Run the `run.sh` script. It performs the following steps:
50+
```bash
51+
---[ASTE-Evaluate] INFO : Vertex count 3458
52+
---[ASTE-Evaluate] INFO : Relative l2 error 9.588343106540401e-08
53+
---[ASTE-Evaluate] INFO : Maximum absolute error per vertex 1.7229951972397295e-06
54+
---[ASTE-Evaluate] INFO : Maximum signed error per vertex 1.7229951972397295e-06
55+
---[ASTE-Evaluate] INFO : Minimum absolute error per vertex 3.5638159090467525e-14
56+
---[ASTE-Evaluate] INFO : Minimum signed error per vertex -1.6968422637542169e-06
57+
---[ASTE-Evaluate] INFO : Median absolute error per vertex 6.217611314696114e-09
58+
---[ASTE-Evaluate] INFO : 99th percentile of absolute error per vertex 3.548732313379818e-07
59+
---[ASTE-Evaluate] INFO : 95th percentile of absolute error per vertex 1.6012309731194814e-07
60+
---[ASTE-Evaluate] INFO : 90th percentile of absolute error per vertex 8.077894064206796e-08
61+
```
2362

24-
* Downloads the meshes from preCICE repository.
25-
* Using `vtk_calculator.py` script, calculates function `eggholder` on a finer grid.
26-
* Using `partition_mesh.py` script, partitions the coarse and fine mesh into 2 domains.
27-
* Using `preciceMap` executable, maps the data from the fine grid to the coarse grid.
28-
* Using `join_mesh.py`script, joins the result meshes into a final mesh.
29-
* Using ``vtk_calculator.py` script, calculates difference between mapped and original function on coarse grid.
63+
which are clearly better than the ones we got with `nearest-neighbor` mapping above. However, this comes at the cost of a much higher runtime ().
Loading

aste-turbine/precice-config.xml

+2-4
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@
3535

3636
<mapping:nearest-neighbor constraint="consistent" direction="read" from="A-Mesh" to="B-Mesh" />
3737
<!-- <mapping:nearest-projection constraint="consistent" direction="read" from="A-Mesh" to="B-Mesh" /> -->
38-
<!-- <mapping:rbf-gaussian shape-parameter="4" constraint="consistent" direction="read" from="A-Mesh" to="B-Mesh" x-dead="false" y-dead="false" z-dead="false" /> -->
39-
<!-- <mapping:rbf-gaussian shape-parameter="5600" solver-rtol="1e-9" constraint="consistent" direction="read" from="A-Mesh" to="B-Mesh" x-dead="true" y-dead="false" z-dead="false" polynomial="separate" preallocation="tree"/> -->
40-
<!-- <mapping:rbf-volume-splines solver-rtol="1e-9" constraint="consistent" direction="read" from="A-Mesh" to="B-Mesh" x-dead="false" y-dead="false" z-dead="false" /> -->
41-
<!-- <export:vtk every-n-time-windows="1" directory="vtkB/" normals="0"/> -->
38+
<!-- <mapping:rbf-compact-polynomial-c6 support-radius="0.1" use-qr-decomposition="false" constraint="consistent" direction="read" from="A-Mesh" to="B-Mesh" /> -->
39+
<!-- <mapping:rbf-compact-polynomial-c6 support-radius="0.1" use-qr-decomposition="true" constraint="consistent" direction="read" from="A-Mesh" to="B-Mesh" /> -->
4240
</participant>
4341

4442
<coupling-scheme:parallel-explicit>

aste-turbine/run.sh

+17-16
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,30 @@ set -e -x
66
# Download the meshes
77
test -f meshes.tar.gz || wget https://gitlab.lrz.de/precice/precice2-ref-paper-setup/-/raw/main/meshes/meshes.tar.gz
88

9+
mkdir -p meshes
10+
911
# Extract the meshes
10-
test -f 0.009.vtk -a 0.01.vtk ||tar -xf meshes.tar.gz
12+
test -f meshes/0.006.vtk -a meshes/0.01.vtk || tar -xvf meshes.tar.gz --directory meshes
1113

12-
# Calculate on fine mesh
13-
vtk_calculator.py -m 0.009.vtk -f "eggholder3d" -d "EggHolder"
14+
# Generate input data for the mapping problem using the predefined Franke's function function
15+
precice-aste-evaluate -m meshes/0.01.vtk -f "franke3d" -d "Franke" -o input_mesh.vtu
1416

1517
# Decompose both meshes to two procesors
16-
# Choose resolution 0.009 mesh as fine mesh
17-
partition_mesh.py -m 0.009.vtk -n 2 -o fine_mesh --dir fine_mesh --algorithm topology
18-
# Choose resolution 0.01 mesh as coarse mesh
19-
partition_mesh.py -m 0.01.vtk -n 2 -o coarse_mesh --dir coarse_mesh --algorithm topology
18+
# Choose resolution 0.01 mesh as coarse mesh and partition the mesh using a uniform algorithm
19+
precice-aste-partition -m input_mesh.vtu -n 2 -o coarse_mesh --dir coarse_mesh --algorithm uniform
20+
# Choose resolution 0.006 mesh as coarse mesh and partition the mesh using a meshfree algorithm
21+
precice-aste-partition -m meshes/0.006.vtk -n 2 -o fine_mesh --dir fine_mesh --algorithm meshfree
2022

21-
# The result directory of preciceMap needs to exist beforehand
23+
# Create results directory of precice-aste-run
2224
mkdir -p mapped
2325

24-
# Map from the finer mesh to coarser mesh
25-
mpirun -n 2 preciceMap -v -p A --mesh fine_mesh/fine_mesh --data "EggHolder" &
26-
mpirun -n 2 preciceMap -v -p B --mesh coarse_mesh/coarse_mesh --output mapped/mapped --data "InterpolatedData"
26+
# Map from coarse mesh to fine mesh, start two ASTE instances, one for each participant
27+
mpirun -n 2 precice-aste-run -p A --mesh coarse_mesh/coarse_mesh --data "Franke" &
28+
mpirun -n 2 precice-aste-run -p B --mesh fine_mesh/fine_mesh --output mapped/mapped --data "InterpolatedData"
2729

28-
# Join the output files together to result.vtk,
29-
# Recovery cannot be used since GlobalID's are not exist in mapped mesh
30-
join_mesh.py -m mapped/mapped -o result.vtk --recovery coarse_mesh/coarse_mesh_recovery.json
30+
# Join the output files together to result.vtu
31+
precice-aste-join -m mapped/mapped -o result.vtu --recovery fine_mesh/fine_mesh_recovery.json
3132

3233
# Measure the difference between the original function and the mapped values
33-
# Save into data array called difference
34-
vtk_calculator.py -m result.vtk -f "eggholder3d" -d difference --diffdata "InterpolatedData" --diff --stats
34+
# Save into data array called Error
35+
precice-aste-evaluate -m result.vtu -f "franke3d" -d "Error" --diffdata "InterpolatedData" --diff --stats

tools/clean-tutorial-base.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ set -e -u
77
clean_tutorial .
88
clean_aste
99
clean_precice_logs .
10-
rm -fv *.log
10+
rm -fv ./*.log
11+
rm -fv ./*.vtu
1112

0 commit comments

Comments
 (0)