... | ... | @@ -5,9 +5,36 @@ The acoustic wave equation describes the propagation of an wave through a materi |
|
|
equation assumes that all movements are only small perturbations over the background flow
|
|
|
field. They can be obtained by linearizing the more general Euler equations over this back-
|
|
|
ground field. This clearly cannot work for complex flows, e.g. for supersonic “booms”.
|
|
|
We describe our material by the parameters $K_0$ , which is the so-called bulk-modulus and by
|
|
|
the density $\rho_0$ . We solve here for velocity $v$ and pressure $p$ in one dimension
|
|
|
We describe our material by the parameters $`K_0`$ , which is the so-called bulk-modulus and by
|
|
|
the density $`\rho_0`$ . We solve here for velocity $`v`$ and pressure $`p`$ in one dimension
|
|
|
|
|
|
```math
|
|
|
\partial_t \begin{pmatrix}
|
|
|
v_x\\v_y\\p
|
|
|
\end{pmatrix}
|
|
|
+ \nabla F
|
|
|
\begin{pmatrix}
|
|
|
v_x\\v_y\\p
|
|
|
\end{pmatrix} = 0,
|
|
|
```
|
|
|
where $`v_x, v_y`$ denote the velocity in $x$- and $y$-direction respectively.
|
|
|
|
|
|
Further, the flux is given by:
|
|
|
```math
|
|
|
F = \left[
|
|
|
\begin{pmatrix}
|
|
|
0 & 0 & \frac{1}{\rho_0}\\
|
|
|
0 & 0 & 0 \\
|
|
|
K_0 & 0 & 0
|
|
|
\end{pmatrix} ,
|
|
|
\begin{pmatrix}
|
|
|
0 & 0 & 0\\
|
|
|
0 & 0 & \frac{1}{\rho_0}\\
|
|
|
0 & K_0 & 0
|
|
|
\end{pmatrix} \right],
|
|
|
```
|
|
|
|
|
|
These equations are telling us that the change in time of the velocity is proportional to the gradient of pressure.
|
|
|
|
|
|
# Step 1: Setting up a specification file
|
|
|
The first step to writing an ExaHyPE application users is a specification file. The specification file is passed to the ExaHyPE toolkit, which creates glue code, empty application-specific classes and optionally application and architecture tailored core routines. In the next step these application specific classes will be filled with the PDE terms.
|
... | ... | @@ -26,7 +53,7 @@ exahype-project ##Name |
|
|
|
|
|
/*Configure the domain*/
|
|
|
computational-domain
|
|
|
dimension const = 2
|
|
|
dimension const = ##dimensions
|
|
|
width = ##domain width
|
|
|
offset = ##offset
|
|
|
end-time = ##final time
|
... | ... | @@ -84,15 +111,15 @@ In this file all place holders are marked by ## and need to be filled to get a w |
|
|
|
|
|
For now let's go through the place holders one by one and fill them in:
|
|
|
|
|
|
## `exahype-project`##Name
|
|
|
## `exahype-project ##Name`
|
|
|
* The name of the project. Choose something short to name your project, e.g. Acoustic.
|
|
|
|
|
|
```javascript
|
|
|
exahype-project
|
|
|
exahype-project Acoustic
|
|
|
```
|
|
|
## `output-directory const`
|
|
|
* Defines where the the code body will be generated relative to the root directory
|
|
|
* In our case we use *./ApplicationExamples/Acoustic*
|
|
|
* In our case we use ./ApplicationExamples/Acoustic
|
|
|
|
|
|
```javascript
|
|
|
output-directory const = ./ApplicationExamples/Acoustic
|
... | ... | @@ -100,39 +127,39 @@ output-directory const = ./ApplicationExamples/Acoustic |
|
|
|
|
|
## `computational-domain`
|
|
|
* Here we define the number of dimensions, the simulated domain and the physical end time of the application
|
|
|
* The acoustic equations can be defined in two or three dimensions, we want to do our simulation on the cube $`[-0.5,0.5]^3`$ and for one second:
|
|
|
* The acoustic equations can be defined in two or three dimensions. We want to work in 2 dimensions to start with. Let's define our simulation on the cube $`[-0.5,0.5]^2`$ and for one second. Thus, our domain is of size 1.0 and needs to be offset by -0.5 in each direction.
|
|
|
|
|
|
```javascript
|
|
|
computational-domain
|
|
|
dimension const = 3
|
|
|
width = 1.0, 1.0, 1.0
|
|
|
offset = -0.5, -0.5, -0.5
|
|
|
dimension const = 2
|
|
|
width = 1.0, 1.0
|
|
|
offset = -0.5, -0.5
|
|
|
end-time = 1.0
|
|
|
end computational-domain
|
|
|
```
|
|
|
|
|
|
## `solver ADER-DG` ...
|
|
|
* This region defines the characteristics of the simulated PDE and the used solver.
|
|
|
* `variables const` By lokking at the formula you see that the SWE consist of 3 quantities $'h,hu,hv'$ which we will denote with h and a vector p of length 2.
|
|
|
* `order const` The polynomial degreee of the high order representation. We'll use order 3.
|
|
|
* This region defines the characteristics both of the simulated PDE and of the used solver.
|
|
|
* `variables const` By looking at the equation we are solving you see that the acoustic wave equation consists of 2 quantities the vector-valued velocity $`v`$ and pressure $`p`$.
|
|
|
* `order const` The polynomial degree of the high order representation. We'll use order 3 for now.
|
|
|
* `maximum-mesh-size` The maximum size of a single cell. ExaHyPE always has to hold a power of 3 cells in one dimension<sup>1</sup>. By setting this value you define an lower limit for the number of cells which is the rounded up to the next power of 3. For our example setting `maximum-mesh-size` to 0.05 gives us a theoretical number of 20 cells in one dimension. The next power of three is 27, so our mesh will end up with 27 cells in each dimension and a mesh size of $`\frac{1}{27}`$.
|
|
|
* `type const` Here you can choose between a linear or nonlinear PDE. SWE are nonlinear (as the flux is).
|
|
|
* `terms const` The type of terms that occur in the PDE system. SWE only hold a flux.
|
|
|
* `type const` Here you can choose between a linear or nonlinear PDE. The acoustic wave equation is a linear PDE so we set linear here.
|
|
|
* `terms const` The type of terms that occur in the PDE system. For the acoustic wave equation will only require a flux. We could also add source terms, non-conservative products or material matrices to the application.
|
|
|
|
|
|
```javascript
|
|
|
solver ADER-DG SWE_ADERDG
|
|
|
variables const = h:1,p:2
|
|
|
variables const = v:2,p:1
|
|
|
order const = 3
|
|
|
/* 27 points: 0.05, 9 points: 0.15 */
|
|
|
maximum-mesh-size = 0.05
|
|
|
time-stepping = globalfixed
|
|
|
type const = nonlinear
|
|
|
type const = linear
|
|
|
terms const = flux
|
|
|
optimisation const = generic
|
|
|
language const = C
|
|
|
end solver
|
|
|
```
|
|
|
<sup>1</sup> The explanation for this takes too long at this point, but believe me there is a reason.
|
|
|
<sup>1</sup> The ExaHyPE core relies on the [Peano framework](http://www.peano-framework.org/index.php/peano-v-3/) for its dynamically adaptive Cartesian meshes. This framework creates tree-structured cartesian meshes by subdividing the element into threes.
|
|
|
|
|
|
## Adding a plotter
|
|
|
* In this example we add a simple vtk output plotter which is sufficient for our needs.
|
... | ... | @@ -140,26 +167,38 @@ output-directory const = ./ApplicationExamples/Acoustic |
|
|
|
|
|
```javascript
|
|
|
plot vtk::Cartesian::vertices::ascii VtkWriter
|
|
|
variables const = 3
|
|
|
variables const = 2
|
|
|
time = 0.0
|
|
|
repeat = 1e-2
|
|
|
output = ./swe
|
|
|
output = ./acoustic
|
|
|
end plot
|
|
|
```
|
|
|
* This results in a writer plotting all 3 variables every 0.02 seconds starting at time 0. The files will have a prefix swe and be placed in the project directory.
|
|
|
* This results in a writer plotting both variables every 0.02 seconds starting at time 0. The files will have a prefix acoustic and be placed in the project directory. If you add a path it will place them into a directory instead. In this case make sure the directory exists before running the code.
|
|
|
|
|
|
# Run the Toolkit
|
|
|
# Step 2: Run the Toolkit
|
|
|
To generate the code body apply the toolkit to the specification file we just created. Go back to the ExaHyPE root directory and hit :
|
|
|
|
|
|
```sh
|
|
|
./Toolkit/toolkit.sh ApplicationExamples/SWE_Test/SWE_ADERDG.exahype
|
|
|
./Toolkit/toolkit.sh ApplicationExamples/Acoustic/acoustic.exahype
|
|
|
```
|
|
|
The Toolit will end with `setup build environment ... ok` if it terminated successful, else you'll receive a detailed error message.
|
|
|
|
|
|
Go back to ApplicationExamples/SWE_Test/ you should see several automatically generated files:
|
|
|
Go back to ApplicationExamples/Acoustic/ you should see several automatically generated files:
|
|
|
|
|
|
```sh
|
|
|
ls SWE_Test
|
|
|
> AbstractSWE_ADERDG.cpp AbstractSWE_ADERDG.h KernelCalls.cpp Makefile README_generated.md SWE_ADERDG.cpp SWE_ADERDG.h SWE_ADERDG_Variables.h VtkWriter.cpp VtkWriter.h
|
|
|
ls Acoustic
|
|
|
>
|
|
|
|
|
|
```
|
|
|
|
|
|
# Step 3: Write the PDE terms to complete the user solver
|
|
|
|
|
|
|
|
|
|
|
|
# Optional: Material Parameters
|
|
|
This equation becomes much more interesting, if we add material parameters that can vary in space.
|
|
|
|
|
|
* That means, that we need to use $`\rho_0(x,y,z)`$ instead of just one constant $`\rho_0`$.
|
|
|
* They are not allowed to vary in time. Once we have chosen a material, the material stays the same.
|
|
|
* In ExaHyPE there is the possibility to add parameters directly in the specification file.
|
|
|
|