@@ -24,6 +24,13 @@ What do they do?
24
24
25
25
The following function allows us to query the maximum allowed time step size from preCICE:
26
26
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">
27
34
```cpp
28
35
double getMaxTimeStepSize();
29
36
```
@@ -53,3 +60,29 @@ while (not simulationDone()){ // time loop
53
60
precice.finalize(); // frees data structures and closes communication channels
54
61
turnOffSolver();
55
62
```
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