Skip to content

Commit

Permalink
Introduce partitioned heat equation scenario using waveform relaxation (
Browse files Browse the repository at this point in the history
#30)

* `heat.py` is modified such that waveform relaxation is used.
* Adapter and preCICE configuration files are modified correspondingly.
  • Loading branch information
BenjaminRodenberg authored Jun 18, 2019
1 parent 4d8226a commit 116bac4
Show file tree
Hide file tree
Showing 21 changed files with 527 additions and 67 deletions.
2 changes: 1 addition & 1 deletion HT/partitioned-heat/fenics-fenics/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
venv
.idea
*.pyc
out
out*
*.log
*events.json
33 changes: 33 additions & 0 deletions HT/partitioned-heat/fenics-fenics/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
# Tutorial for a partitioned heat equation using FEniCS

This tutorial is described in the [preCICE wiki](https://github.com/precice/precice/wiki/Tutorial-for-solving-the-heat-equation-in-a-partitioned-fashion-using-FEniCS).

## Waveform relaxation (experimental)

This branch of the tutorial uses the fenics-adapter waveform bindings. If you want to run this tutorial, you have to install the version of the FEniCS-adapter that can be found on [this branch](https://github.com/precice/fenics-adapter/tree/WaveformBindingsDraft). Further information on waveform relaxation in the FEniCS-adapter can be found in issue https://github.com/precice/fenics-adapter/issues/16 and milestone https://github.com/precice/fenics-adapter/milestone/2.

### Setup description and how to run the examples

For all setups linear interpolation in time is used for each (micro-)timestep. The commands for running the example cases are given.

**WR11:** this case uses no subcycling such that `dt_neumann = dt_dirichlet = T_window` (dt for each solver equals window size).

* ` python3 heat.py -d`
* ` python3 heat.py -n`

**WR12:** this case uses subcycling such that `2*dt_neumann = dt_dirichlet = T_window`.

* ` python3 heat.py -d -wr 1 2`
* ` python3 heat.py -n -wr 1 2`

**WR22:** this case uses subcycling such that `2*dt_neumann = 2*dt_dirichlet = T_window`.

* ` python3 heat.py -d -wr 2 1`
* ` python3 heat.py -n -wr 2 1`

### running the experiments

In the folder `experiments` you can find experiments with different timestep size and waveform configuration. If you traverse down the folder structure, you will find preCICE and adapter config files for running the experiments. All the output will be generated in that folder.

Example for running:

`cd experiments/WR12/dT0.1`
`python3 ../../../heat.py -d -wr 1 2 -dT 0.1`
`python3 ../../../heat.py -n -wr 1 2 -dT 0.1`
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"coupling_mesh_name": "DirichletNodes",
"write_data_name": "Flux",
"read_data_name": "Temperature"
},
"waveform": {
"n_substeps": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@
"coupling_mesh_name": "NeumannNodes",
"write_data_name": "Temperature",
"read_data_name": "Flux"
},
"waveform": {
"n_substeps": 1
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@

<precice-configuration>

<log enabled="1">
<sink filter="%Severity% > debug" />
</log>


<solver-interface dimensions="2">

<!-- Data fields that are exchanged between the solvers -->
<data:scalar name="Temperature"/>
<data:scalar name="Flux"/>
<data:scalar name="Temperature1"/>
<data:scalar name="Flux1"/>

<!-- A common mesh that uses these data fields -->
<mesh name="DirichletNodes">
<use-data name="Temperature"/>
<use-data name="Flux"/>
<use-data name="Temperature1"/>
<use-data name="Flux1"/>
</mesh>

<mesh name="NeumannNodes">
<use-data name="Temperature"/>
<use-data name="Flux"/>
<use-data name="Temperature1"/>
<use-data name="Flux1"/>
</mesh>

<!-- Represents each solver using preCICE. In a coupled simulation, two participants have to be
Expand All @@ -29,40 +26,40 @@

<participant name="HeatDirichlet">
<!-- Makes the named mesh available to the participant. Mesh is provided by the solver directly. -->
<use-mesh name="DirichletNodes" provide="yes"/>
<use-mesh name="NeumannNodes" from="HeatNeumann"/>
<use-mesh name="DirichletNodes" provide="yes" />
<use-mesh name="NeumannNodes" from="HeatNeumann" />
<!-- Define input/output of the solver. -->
<write-data name="Flux" mesh="DirichletNodes"/>
<read-data name="Temperature" mesh="DirichletNodes"/>
<write-data name="Flux1" mesh="DirichletNodes"/>
<read-data name="Temperature1" mesh="DirichletNodes"/>
<mapping:nearest-projection direction="write" from="DirichletNodes" to="NeumannNodes" constraint="consistent" timing="initial"/>
<mapping:nearest-projection direction="read" from="NeumannNodes" to="DirichletNodes" constraint="consistent" timing="initial"/>
</participant>

<participant name="HeatNeumann">
<use-mesh name="NeumannNodes" provide="yes"/>
<write-data name="Temperature" mesh="NeumannNodes"/>
<read-data name="Flux" mesh="NeumannNodes"/>
<write-data name="Temperature1" mesh="NeumannNodes"/>
<read-data name="Flux1" mesh="NeumannNodes"/>
</participant>

<!-- Communication method, use TCP sockets, Change network to "ib0" on SuperMUC -->
<m2n:sockets distribution-type="gather-scatter" from="HeatDirichlet" to="HeatNeumann" network="lo"/>

<coupling-scheme:serial-implicit>
<participants first="HeatDirichlet" second="HeatNeumann"/>
<max-time value="1"/>
<max-time value="10"/>
<timestep-length value=".1" valid-digits="8"/>
<max-iterations value="100"/>
<exchange data="Flux" mesh="NeumannNodes" from="HeatDirichlet" to="HeatNeumann" />
<exchange data="Temperature" mesh="NeumannNodes" from="HeatNeumann" to="HeatDirichlet" initialize="true"/>
<relative-convergence-measure data="Flux" mesh="NeumannNodes" limit="1e-5"/>
<relative-convergence-measure data="Temperature" mesh="NeumannNodes" limit="1e-5"/>
<exchange data="Flux1" mesh="NeumannNodes" from="HeatDirichlet" to="HeatNeumann" />
<exchange data="Temperature1" mesh="NeumannNodes" from="HeatNeumann" to="HeatDirichlet" initialize="true"/>
<relative-convergence-measure data="Flux1" mesh="NeumannNodes" limit="1e-12"/>
<relative-convergence-measure data="Temperature1" mesh="NeumannNodes" limit="1e-12"/>
<extrapolation-order value="0"/>
<post-processing:IQN-ILS>
<!--PostProc always done on the second participant-->
<data name="Temperature" mesh="NeumannNodes"/>
<initial-relaxation value="0.01"/>
<max-used-iterations value="3"/>
<timesteps-reused value="1"/>
<data name="Temperature1" mesh="NeumannNodes"/>
<initial-relaxation value="1.0"/>
<max-used-iterations value="50"/>
<timesteps-reused value="0"/>
<filter type="QR2" limit="1e-3"/>
</post-processing:IQN-ILS>
</coupling-scheme:serial-implicit>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"solver_name": "HeatDirichlet",
"config_file_name": "precice-config.xml",
"interface": {
"coupling_mesh_name": "DirichletNodes",
"write_data_name": "Flux",
"read_data_name": "Temperature"
},
"waveform": {
"n_substeps": 1
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"solver_name": "HeatNeumann",
"config_file_name": "precice-config.xml",
"interface": {
"coupling_mesh_name": "NeumannNodes",
"write_data_name": "Temperature",
"read_data_name": "Flux"
},
"waveform": {
"n_substeps": 2
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?xml version="1.0"?>

<precice-configuration>

<solver-interface dimensions="2">

<!-- Data fields that are exchanged between the solvers -->
<data:scalar name="Temperature1"/>
<data:scalar name="Temperature2"/>
<data:scalar name="Flux1"/>

<!-- A common mesh that uses these data fields -->
<mesh name="DirichletNodes">
<use-data name="Temperature1"/>
<use-data name="Temperature2"/>
<use-data name="Flux1"/>
</mesh>

<mesh name="NeumannNodes">
<use-data name="Temperature1"/>
<use-data name="Temperature2"/>
<use-data name="Flux1"/>
</mesh>

<!-- Represents each solver using preCICE. In a coupled simulation, two participants have to be
defined. The name of the participant has to match the name given on construction of the
precice::SolverInterface object used by the participant. -->

<participant name="HeatDirichlet">
<!-- Makes the named mesh available to the participant. Mesh is provided by the solver directly. -->
<use-mesh name="DirichletNodes" provide="yes" />
<use-mesh name="NeumannNodes" from="HeatNeumann" />
<!-- Define input/output of the solver. -->
<write-data name="Flux1" mesh="DirichletNodes"/>
<read-data name="Temperature1" mesh="DirichletNodes"/>
<read-data name="Temperature2" mesh="DirichletNodes"/>
<mapping:nearest-projection direction="write" from="DirichletNodes" to="NeumannNodes" constraint="consistent" timing="initial"/>
<mapping:nearest-projection direction="read" from="NeumannNodes" to="DirichletNodes" constraint="consistent" timing="initial"/>
</participant>

<participant name="HeatNeumann">
<use-mesh name="NeumannNodes" provide="yes"/>
<write-data name="Temperature1" mesh="NeumannNodes"/>
<write-data name="Temperature2" mesh="NeumannNodes"/>
<read-data name="Flux1" mesh="NeumannNodes"/>
</participant>

<!-- Communication method, use TCP sockets, Change network to "ib0" on SuperMUC -->
<m2n:sockets distribution-type="gather-scatter" from="HeatDirichlet" to="HeatNeumann" network="lo"/>

<coupling-scheme:serial-implicit>
<participants first="HeatDirichlet" second="HeatNeumann"/>
<max-time value="10"/>
<timestep-length value=".1" valid-digits="8"/>
<max-iterations value="100"/>
<exchange data="Flux1" mesh="NeumannNodes" from="HeatDirichlet" to="HeatNeumann" />
<exchange data="Temperature1" mesh="NeumannNodes" from="HeatNeumann" to="HeatDirichlet" initialize="true"/>
<exchange data="Temperature2" mesh="NeumannNodes" from="HeatNeumann" to="HeatDirichlet" initialize="true"/>
<relative-convergence-measure data="Flux1" mesh="NeumannNodes" limit="1e-12"/>
<relative-convergence-measure data="Temperature1" mesh="NeumannNodes" limit="1e-12"/>
<relative-convergence-measure data="Temperature2" mesh="NeumannNodes" limit="1e-12"/>
<extrapolation-order value="0"/>
<post-processing:IQN-ILS>
<!--PostProc always done on the second participant-->
<data name="Temperature1" mesh="NeumannNodes"/>
<data name="Temperature2" mesh="NeumannNodes"/>
<initial-relaxation value="1.0"/>
<max-used-iterations value="50"/>
<timesteps-reused value="0"/>
<filter type="QR2" limit="1e-3"/>
</post-processing:IQN-ILS>
</coupling-scheme:serial-implicit>

</solver-interface>
</precice-configuration>
Loading

0 comments on commit 116bac4

Please sign in to comment.