Skip to content

Commit

Permalink
Merge pull request #449 from llaniewski/feature/codespaces
Browse files Browse the repository at this point in the history
Adding codespaces support
  • Loading branch information
llaniewski authored Sep 4, 2023
2 parents 7216c6c + b39313a commit d8b060a
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 10 deletions.
15 changes: 15 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-debian-11

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
openssh-server \
openmpi-bin libopenmpi-dev \
r-base-dev r-recommended qpdf

COPY tools/install.sh /tmp/
RUN chmod +x /tmp/install.sh

USER vscode
WORKDIR /home/vscode

RUN /tmp/install.sh rdep
20 changes: 20 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
![TCLB Solver Header](https://raw.githubusercontent.com/CFD-GO/documents/master/assets/header.png)

TCLB Solver - Codespace (Small)
===

**Configure**
```bash
make configure
./configure --disable-cuda --with-openmp --enable-cpu-layout
```

**Compile**
```bash
make d2q9
```

**Run**
```bash
CLB/d2q9/main example/runr/karman.xml
```
20 changes: 20 additions & 0 deletions .devcontainer/big/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
FROM mcr.microsoft.com/devcontainers/cpp:1-debian-11

RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
openssh-server \
python3-pip \
libxml2 libxml2-dev \
openmpi-bin libopenmpi-dev \
r-base-dev r-recommended qpdf \
libgl1-mesa-glx

COPY tools/install.sh /tmp/
RUN chmod +x /tmp/install.sh

USER vscode
WORKDIR /home/vscode

RUN /tmp/install.sh rdep rinside reticulate --rpackage languageserver --rpackage png
RUN pip3 install vtk
ENV RETICULATE_PYTHON=/usr/bin/python3
15 changes: 15 additions & 0 deletions .devcontainer/big/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
![TCLB Solver Header](https://raw.githubusercontent.com/CFD-GO/documents/master/assets/header.png)

TCLB Solver - Codespace (Big)
===

This container is already configured with OpenMP support. You can now:

**Compile**
```bash
make d2q9
```
**Run**
```bash
CLB/d2q9/main example/runr/karman.xml
```
26 changes: 26 additions & 0 deletions .devcontainer/big/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "Big (R+VTK)",
"build": {
"dockerfile": "Dockerfile",
"context": "../.."
},
"postCreateCommand": "make configure && ./configure --disable-cuda --enable-cpu-layout --with-openmp",
"customizations": {
"codespaces": {
"openFiles": [
".devcontainer/big/README.md"
]
},
"vscode": {
"extensions": [
"REditorSupport.r",
"CFD-GO.tclb-helper"
],
"settings": {
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
}
}
}
}
}
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Small",
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"customizations": {
"codespaces": {
"openFiles": [
".devcontainer/README.md"
]
},
"vscode": {
"extensions": [
"CFD-GO.tclb-helper"
],
"settings": {
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
}
}
}
}
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ TCLB Solver [![ZENADO DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.3550331.s
TCLB is a MPI+CUDA, MPI+CPU or MPI+HIP high-performance Computational Fluid Dynamics simulation code, based on the Lattice Boltzmann Method.
It provides a clear interface for calculation of complex physics, and the implementation of new models.

- Stable release [(`master` branch)](https://github.com/CFD-GO/TCLB/tree/master):<br/>[![CPU build status](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml/badge.svg?branch=master)](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml) [![CUDA build status](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml/badge.svg?branch=master)](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml) [![codecov](https://codecov.io/gh/CFD-GO/TCLB/branch/master/graph/badge.svg)](https://codecov.io/gh/CFD-GO/TCLB) [![documentation](https://raw.githubusercontent.com/CFD-GO/documents/master/assets/documentation.svg?sanitize=true)](https://docs.tclb.io/)
**Stable release** [(`master` branch)](https://github.com/CFD-GO/TCLB/tree/master):<br/>[![CPU build status](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml/badge.svg?branch=master)](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml) [![CUDA build status](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml/badge.svg?branch=master)](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml) [![HIP build status](https://github.com/CFD-GO/TCLB/actions/workflows/hip_comp.yml/badge.svg?branch=develop)](https://github.com/CFD-GO/TCLB/actions/workflows/hip_comp.yml) [![codecov](https://codecov.io/gh/CFD-GO/TCLB/branch/master/graph/badge.svg)](https://codecov.io/gh/CFD-GO/TCLB) [![documentation](https://raw.githubusercontent.com/CFD-GO/documents/master/assets/documentation.svg?sanitize=true)](https://docs.tclb.io/)


- Current release [(`develop` branch)](https://github.com/CFD-GO/TCLB/tree/develop):<br/>[![CPU build status](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml/badge.svg?branch=develop)](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml) [![CUDA build status](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml/badge.svg?branch=develop)](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml) [![HIP build status](https://github.com/CFD-GO/TCLB/actions/workflows/hip_comp.yml/badge.svg?branch=develop)](https://github.com/CFD-GO/TCLB/actions/workflows/hip_comp.yml) [![codecov](https://codecov.io/gh/CFD-GO/TCLB/branch/develop/graph/badge.svg)](https://codecov.io/gh/CFD-GO/TCLB) [![documentation](https://raw.githubusercontent.com/CFD-GO/documents/master/assets/documentation.svg?sanitize=true)](https://develop.docs.tclb.io/)
**Current release** [(`develop` branch)](https://github.com/CFD-GO/TCLB/tree/develop):</br>[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/CFD-GO/TCLB/tree/develop?quickstart=1&devcontainer_path=.devcontainer%2Fbig%2Fdevcontainer.json)<br/>[![CPU build status](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml/badge.svg?branch=develop)](https://github.com/CFD-GO/TCLB/actions/workflows/cpu_test.yml) [![CUDA build status](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml/badge.svg?branch=develop)](https://github.com/CFD-GO/TCLB/actions/workflows/gpu_comp.yml) [![HIP build status](https://github.com/CFD-GO/TCLB/actions/workflows/hip_comp.yml/badge.svg?branch=develop)](https://github.com/CFD-GO/TCLB/actions/workflows/hip_comp.yml) [![codecov](https://codecov.io/gh/CFD-GO/TCLB/branch/develop/graph/badge.svg)](https://codecov.io/gh/CFD-GO/TCLB) [![documentation](https://raw.githubusercontent.com/CFD-GO/documents/master/assets/documentation.svg?sanitize=true)](https://develop.docs.tclb.io/)

## How to use it

Expand Down
33 changes: 33 additions & 0 deletions example/runr/karman.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?xml version="1.0"?>
<CLBConfig version="2.0" output="output/" permissive="true">
<Geometry nx="1024" ny="100">
<MRT><Box/></MRT>
<WVelocity><Box nx="1"/></WVelocity>
<EPressure><Box dx="-1"/></EPressure>
<Wall mask="ALL">
<Box ny="1"/>
<Box dy="-1"/>
<Wedge dx="120" nx="20" dy="50" ny="20" direction="LowerRight"/>
<Wedge dx="120" nx="20" dy="30" ny="20" direction="UpperRight"/>
<Wedge dx="140" nx="20" dy="50" ny="20" direction="LowerLeft"/>
<Wedge dx="140" nx="20" dy="30" ny="20" direction="UpperLeft"/>
</Wall>
</Geometry>
<Model>
<Param name="VelocityX" value="0.05"/>
<Param name="Viscosity" value="0.01"/>
</Model>
<RunR>
ramp = colorRamp(c("black","red","yellow","white"))
</RunR>
<RunR Iterations="1000" echo="no">
U = Solver$Quantities$U
u = sqrt(U[1,,,1]^2+U[2,,,1]^2)
u = t(u/max(u))
col = ramp(u)
dim(col) = c(dim(u),3)
png::writePNG(col/255, "output/view.png")
system("code output/view.png")
</RunR>
<Solve Iterations="10000"/>
</CLBConfig>
23 changes: 16 additions & 7 deletions src/Handlers/cbRunR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,15 @@ int RunR::Init() {

R.parseEval("options(prompt='[ ] R:> ');");

interactive = false;
echo = true;

pugi::xml_attribute attr;
attr = node.attribute("interactive");
if (attr) interactive = attr.as_bool();
attr = node.attribute("echo");
if (attr) echo = attr.as_bool();

source = "";
for (pugi::xml_node par = node.first_child(); par; par = par.next_sibling()) {
if (par.type() == pugi::node_element) {
Expand Down Expand Up @@ -667,17 +676,17 @@ int RunR::Init() {

int RunR::DoIt() {
try {
if (strlen(node.child_value()) != 0) {
if (source != "") {
solver->print("Running R ...");
output("----- RunR -----\n");
output("%s\n",source.c_str());
output("----------------\n");
if (echo) {
output("----- RunR -----\n");
output("%s\n",source.c_str());
output("----------------\n");
}
R.parseEval(source);
}
bool interactive = false;
interactive = node.attribute("interactive");
if (!interactive) {
NOTICE("You can run interactive R session with Ctrl+X");
if (echo) NOTICE("You can run interactive R session with Ctrl+X");
int c = kbhit();
if (c == 24) {
int a = getchar();
Expand Down
2 changes: 2 additions & 0 deletions src/Handlers/cbRunR.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

class RunR : public Callback {
std::string source;
bool interactive;
bool echo;
public:
static RInside R;
int Init ();
Expand Down
1 change: 0 additions & 1 deletion tools/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ do
else
install_rpackage "$1"
fi
shift
;;
rdep)
if $GITHUB
Expand Down

0 comments on commit d8b060a

Please sign in to comment.