Skip to content

Commit 625e57f

Browse files
uekermankss682
authored andcommitted
Extend step 2 with Python tab
1 parent f6f8709 commit 625e57f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

pages/docs/couple-your-code/couple-your-code-steering-methods.md

+33
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ What do they do?
2424
2525
The following function allows us to query the maximum allowed time step size from preCICE:
2626
27+
28+
<ul id="apiTabs" class="nav nav-tabs">
29+
<li class="active"><a href="#cpp" data-toggle="tab">C++</a></li>
30+
<li><a href="#python" data-toggle="tab">Python</a></li>
31+
</ul>
32+
<div class="tab-content">
33+
<div role="tabpanel" class="tab-pane active" id="cpp" markdown="1">
2734
```cpp
2835
double getMaxTimeStepSize();
2936
```
@@ -53,3 +60,29 @@ while (not simulationDone()){ // time loop
5360
precice.finalize(); // frees data structures and closes communication channels
5461
turnOffSolver();
5562
```
63+
</div>
64+
<div role="tabpanel" class="tab-pane" id="python" markdown="1">
65+
```python
66+
import precice
67+
68+
turn_on_solver() # e.g. setup and partition mesh
69+
70+
precice = precice.Interface(
71+
"FluidSolver", "precice-config.xml", rank, size
72+
)
73+
precice_dt = precice.initialize()
74+
75+
u = initialize_solution()
76+
77+
while t < t_end: # time loop
78+
dt = compute_adaptive_dt()
79+
dt = min(precice_dt, dt) # more about this in Step 5
80+
u = solve_time_step(dt, u) # returns new solution
81+
precice_dt = precice.advance(dt)
82+
t = t + dt
83+
84+
precice.finalize() # frees data structures and closes communication channels
85+
```
86+
</div>
87+
</div>
88+

0 commit comments

Comments
 (0)