Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add navtabs + Python to step-by-step description #211

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions css/customstyles-precice.css
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,14 @@ ul.devlist>li {
}
}

/* style navtabs */
.post-content ol li, .post-content ul li {
margin: 0px;
}
div.tab-content {
padding: 0px;
background-color: white;
}
div.tab-content div.tab-pane pre {
margin-top: 0px;
}
53 changes: 52 additions & 1 deletion css/printstyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ a[href^="http:"]::after, a[href^="https:"]::after, a[href^="ftp:"]::after {
a[href] {
color: #0A76BB !important;
}
a[href*="mailto"]::after, a[data-toggle="tooltip"]::after, a[href].noCrossRef::after {
a[href*="mailto"]::after, a[data-toggle="tooltip"]::after, a[href].noCrossRef::after, a[data-toggle="tab"]::after {
content: "";
}

Expand Down Expand Up @@ -219,4 +219,55 @@ pre > code {
h1[id], h2[id], h3[id], h4[id], h5[id], h6[id], dt[id] {
padding-top: 1.5em;
margin-top: -1em;
}

/* prepare nav tabs for printing */
.nav > li.active > a, /* tab headers */
.nav > li > a {
color: black;
background-color: white;
border: 1px solid #ccc;
border-radius: 4px 4px 0 0;
}
.tab-content > .tab-pane {
display: block !important; /* display non-active panes */
position: relative;
}
div.tab-content div.tab-pane pre {
margin-top: 1em;
}
/* create counters to link tab headers to tab contents */
.post-content ul.nav.nav-tabs {
counter-reset: tab_number; /* creates a new instance of counter with name tab_number */
}
.post-content .nav.nav-tabs li::after {
counter-increment: tab_number; /* increment counter */
content: counter(tab_number); /* display value in small bubble */
position: absolute;
top: -1em;
left: -1em;
padding: 2px 5px;
background-color: white;
color: black;
font-size: 0.65em;
border-radius: 50%;
border: 1px solid #ccc;
box-shadow: 1px 1px 1px grey;
}
div.tab-content {
counter-reset: pane_number;
}
div.tab-pane::after {
counter-increment: pane_number;
content: counter(pane_number);
position: absolute;
top: -1em;
left: -1em;
padding: 2px 5px;
background-color: white;
color: black;
font-size: 0.65em;
border-radius: 50%;
border: 1px solid #ccc;
box-shadow: 1px 1px 1px gray;
}
33 changes: 33 additions & 0 deletions pages/docs/couple-your-code/couple-your-code-steering-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ What do they do?

So, let's extend the code of our fluid solver:


<ul id="apiTabs" class="nav nav-tabs">
<li class="active"><a href="#cpp" data-toggle="tab">C++</a></li>
<li><a href="#python" data-toggle="tab">Python</a></li>
</ul>
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="cpp" markdown="1">
```cpp
#include "precice/SolverInterface.hpp"

Expand All @@ -45,3 +52,29 @@ while (not simulationDone()){ // time loop
precice.finalize(); // frees data structures and closes communication channels
turnOffSolver();
```
</div>
<div role="tabpanel" class="tab-pane" id="python" markdown="1">
```python
import precice

turn_on_solver() # e.g. setup and partition mesh

precice = precice.Interface(
"FluidSolver", "precice-config.xml", rank, size
)
precice_dt = precice.initialize()

u = initialize_solution()

while t < t_end: # time loop
dt = compute_adaptive_dt()
dt = min(precice_dt, dt) # more about this in Step 5
u = solve_time_step(dt, u) # returns new solution
precice_dt = precice.advance(dt)
t = t + dt

precice.finalize() # frees data structures and closes communication channels
```
</div>
</div>