diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 000000000..e776985e3 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -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 diff --git a/.devcontainer/README.md b/.devcontainer/README.md new file mode 100644 index 000000000..e256aed40 --- /dev/null +++ b/.devcontainer/README.md @@ -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 +``` diff --git a/.devcontainer/big/Dockerfile b/.devcontainer/big/Dockerfile new file mode 100644 index 000000000..68bd6ee66 --- /dev/null +++ b/.devcontainer/big/Dockerfile @@ -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 diff --git a/.devcontainer/big/README.md b/.devcontainer/big/README.md new file mode 100644 index 000000000..ba63b54e6 --- /dev/null +++ b/.devcontainer/big/README.md @@ -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 +``` diff --git a/.devcontainer/big/devcontainer.json b/.devcontainer/big/devcontainer.json new file mode 100644 index 000000000..50d005f1b --- /dev/null +++ b/.devcontainer/big/devcontainer.json @@ -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" + } + } + } + } +} diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 000000000..9f260fd3f --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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" + } + } + } + } +} diff --git a/README.md b/README.md index db5106c30..a79a99a82 100644 --- a/README.md +++ b/README.md @@ -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):
[![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):
[![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):
[![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):
[![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)
[![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 diff --git a/example/runr/karman.xml b/example/runr/karman.xml new file mode 100644 index 000000000..b8904eb06 --- /dev/null +++ b/example/runr/karman.xml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + + + + + + + ramp = colorRamp(c("black","red","yellow","white")) + + + 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") + + + diff --git a/src/Handlers/cbRunR.cpp b/src/Handlers/cbRunR.cpp index ae20185e8..c43f22049 100644 --- a/src/Handlers/cbRunR.cpp +++ b/src/Handlers/cbRunR.cpp @@ -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) { @@ -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(); diff --git a/src/Handlers/cbRunR.h b/src/Handlers/cbRunR.h index 26552cf68..b5cf2c67d 100644 --- a/src/Handlers/cbRunR.h +++ b/src/Handlers/cbRunR.h @@ -24,6 +24,8 @@ class RunR : public Callback { std::string source; + bool interactive; + bool echo; public: static RInside R; int Init (); diff --git a/tools/install.sh b/tools/install.sh index d84677f02..1989eb6eb 100755 --- a/tools/install.sh +++ b/tools/install.sh @@ -322,7 +322,6 @@ do else install_rpackage "$1" fi - shift ;; rdep) if $GITHUB