@@ -24,6 +24,13 @@ What do they do?
24
24
25
25
So, let's extend the code of our fluid solver:
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
#include "precice/SolverInterface.hpp"
29
36
@@ -45,3 +52,29 @@ while (not simulationDone()){ // time loop
45
52
precice.finalize(); // frees data structures and closes communication channels
46
53
turnOffSolver();
47
54
```
55
+ </div >
56
+ <div role =" tabpanel " class =" tab-pane " id =" python " markdown =" 1 " >
57
+ ``` python
58
+ import precice
59
+
60
+ turn_on_solver() # e.g. setup and partition mesh
61
+
62
+ precice = precice.Interface(
63
+ " FluidSolver" , " precice-config.xml" , rank, size
64
+ )
65
+ precice_dt = precice.initialize()
66
+
67
+ u = initialize_solution()
68
+
69
+ while t < t_end: # time loop
70
+ dt = compute_adaptive_dt()
71
+ dt = min (precice_dt, dt) # more about this in Step 5
72
+ u = solve_time_step(dt, u) # returns new solution
73
+ precice_dt = precice.advance(dt)
74
+ t = t + dt
75
+
76
+ precice.finalize() # frees data structures and closes communication channels
77
+ ```
78
+ </div >
79
+ </div >
80
+
0 commit comments