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

Update main, v202104.1.0 #22

Merged
merged 10 commits into from
Apr 30, 2021
Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Build and package
on:
pull_request:
types: [ready_for_review]
jobs:
vagrant-up:
runs-on: macos-10.15

steps:
- uses: actions/checkout@v2

- name: Cache Vagrant boxes
uses: actions/cache@v2
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-

- name: Show Vagrant version
run: vagrant --version

- name: Run vagrant up
run: vagrant up

- name: Package Vagrant box
run: vagrant package --base "preCICE-VM" --output preCICE.box

- name: Generate Vagrant box SHA256 hash
run: shasum -a 256 preCICE.box

- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: precice-vagrant-box
path: preCICE.box
retention-days: 7

12 changes: 12 additions & 0 deletions .github/workflows/check-shell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Lint scripts
on: [push, pull_request]
jobs:
check_shell:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v2
- name: Lint shell scripts (shellcheck)
uses: ludeeus/action-shellcheck@master
with:
ignore: Vagrantfile
47 changes: 39 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Ready-to-use boxes are available on [Vagrant Cloud](https://app.vagrantup.com/pr
You can afterwards also see and manage the produced VM in VirtualBox.

A few things you may need:

- The username and password are `vagrant`/`vagrant`
- The keyboard layout is US English (QWERTY). You can change this in [`install-basics.sh`](./install-basics.sh) or through the keyboard setting shortcut on `~/Desktop`.
- Find scripts to install additional software on `~/Desktop/shared`.
Expand All @@ -40,27 +41,33 @@ A few things you may need:
## What is included?

This box is based on the [bento/ubuntu-20.04](https://github.com/chef/bento/blob/master/packer_templates/ubuntu/ubuntu-20.04-amd64.json) base box and installs:

- Xubuntu-core (Xfce desktop environment) and related tools
- VirtualBox guest additions
- Terminator (a nice split-window terminal emulator, find it in `Applications > System`)
- Git, CMake, ccmake
- Editors: nano, vim, gedit
- preCICE latest for the master branch
- preCICE config visualizer latest from the master branch
- preCICE Python bindings
- OpenFOAM v2012 and the OpenFOAM-preCICE adapter
- deal.II 9.2 from the official backports and the deal.II-preCICE adapter (you still need to copy the compiled executables wherever you need them)
- CalculiX 2.16 from source and the CalculiX-preCICE adapter
- FEniCS latest from the FEniCS PPA and the FEniCS-preCICE adapter
- preCICE config visualizer (master)
- preCICE Python bindings (PIP)
- OpenFOAM v2012 and the OpenFOAM-preCICE adapter (master)
- deal.II 9.2 from the official backports and the deal.II-preCICE adapter (master)
- CalculiX 2.16 from source and the CalculiX-preCICE adapter (master)
- FEniCS latest from the FEniCS PPA and the FEniCS-preCICE adapter (PIP)
- Nutils latest from PIP
- SU2 6.0.0 and the SU2-preCICE adapter from source
- SU2 6.0.0 and the SU2-preCICE adapter (master)
- code_aster 14.6 and the code_aster-preCICE adapter (master)
- Paraview from the official binaries
- Gnuplot

It then adds to the `/home/vagrant/`:

It then adds on the `/home/vagrant/Desktop`:
- The preCICE examples (solverdummies), including a copy of the Python solverdummy.
- The preCICE tutorials from the `precice/tutorials`

The adapter repositories remain in `/home/vagrant/`.
It also adds a few shortcuts on the Desktop (see `post-install.sh`).
At the end, it cleans up all object files and the APT cache (see `cleanup.sh`).

## Troubleshooting

Expand All @@ -77,3 +84,27 @@ Usually running again (e.g. with `vagrant up --provision`) helps.
### There is no GUI

In case you killed the session before provisioning finished, the setup of your VM might be incomplete. You might still be able to interact with the VM without the GUI. In that case, run `vagrant up --provision`.

## Testing before publishing

We now have a GitHub action that can build the Vagrant box. This workflow only runs for pull requests that are marked as "ready for review" (i.e. not "draft"), as it takes significant time to complete (~1.5h). If you already submitted a normal PR but the workflow is not triggered, convert the PR to draft and then to "ready for review" again.

The workflow uploads the resulting box as an artifact and it also prints its SHA256 checksum before that. Download the job artifact and unzip it. Then run add the box to Vagrant:

```bash
vagrant box add test-box precice-vagrant-box/preCICE.box
```

You can then start a VM by going into an empty directory and executing:

```bash
vagrant init test-box
vagrant up
```

Afterwards, you probably want to destroy everything to save storage space:

```bash
vagrant destroy
vagrant box remove test-box
```
31 changes: 18 additions & 13 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,37 @@ Vagrant.configure("2") do |config|
end

# Install a desktop environment and basic tools
config.vm.provision "shell", path: "provisioning/install-basics.sh"
config.vm.provision "shell", path: "provisioning/install-basics.sh", privileged: false

# Install common development tools
config.vm.provision "shell", path: "provisioning/install-devel.sh"
config.vm.provision "shell", path: "provisioning/install-devel.sh", privileged: false

# Install preCICE
config.vm.provision "shell", path: "provisioning/install-precice.sh"
config.vm.provision "shell", path: "provisioning/install-precice.sh", privileged: false

# Install solvers, adapters, and related tools
config.vm.provision "shell", path: "provisioning/install-config-visualizer.sh"
config.vm.provision "shell", path: "provisioning/install-openfoam.sh"
config.vm.provision "shell", path: "provisioning/install-dealii.sh"
config.vm.provision "shell", path: "provisioning/install-calculix.sh"
config.vm.provision "shell", path: "provisioning/install-fenics.sh"
config.vm.provision "shell", path: "provisioning/install-nutils.sh"
config.vm.provision "shell", path: "provisioning/install-su2.sh"
config.vm.provision "shell", path: "provisioning/install-paraview.sh"
config.vm.provision "shell", path: "provisioning/install-config-visualizer.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-openfoam.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-dealii.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-calculix.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-fenics.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-nutils.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-su2.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-code_aster.sh", privileged: false
config.vm.provision "shell", path: "provisioning/install-paraview.sh", privileged: false

# Post-installation steps
config.vm.provision "shell", path: "provisioning/post-install.sh"
config.vm.provision "file", source: "provisioning/install-vscode.sh", destination: "~/Desktop/install-vscode.sh"
config.vm.provision "shell", path: "provisioning/post-install.sh", privileged: false
config.vm.provision "file", source: "provisioning/install-vscode.sh", destination: "~/install-vscode.sh"
config.vm.provision "file", source: "provisioning/get-started.desktop", destination: "~/Desktop/get-started.desktop"
config.vm.provision "file", source: "provisioning/.alias", destination: "~/.alias"

# Pre-packaging steps
config.vm.provision "shell", path: "provisioning/cleanup.sh", privileged: false
# Add the default Vagrant insecure public key to the authorized keys
config.vm.provision "file", source: "provisioning/vagrant.pub", destination: "~/.ssh/vagrant.pub"
config.vm.provision "shell", inline: <<-SHELL
cat /home/vagrant/.ssh/vagrant.pub >> /home/vagrant/.ssh/authorized_keys
SHELL

end
12 changes: 12 additions & 0 deletions provisioning/.alias
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# preCICE config visualizer
function config-visualizer-pdf(){
cat $1 | precice-config-visualizer | dot -Tpdf > precice-config.pdf
}

function config-visualizer-svg(){
cat $1 | precice-config-visualizer | dot -Tsvg > precice-config.svg
}

function config-visualizer(){
cat $1 | precice-config-visualizer | dot -Tpng > precice-config.png
}
8 changes: 8 additions & 0 deletions provisioning/cleanup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
set -ex

# Cleanup the APT cache to save space
sudo apt-get clean

# Cleanup all object files from compilation
find "${HOME}" -type f -name '*.o' -exec rm -fv {} \;
6 changes: 6 additions & 0 deletions provisioning/get-started.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Desktop Entry]
Encoding=UTF-8
Name=Get started
Type=Link
URL=https://precice.org/installation-vm.html
Icon=text-html
16 changes: 6 additions & 10 deletions provisioning/install-basics.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# We (may) need the multiverse repository for the VBox Guest Additions
sudo apt-add-repository multiverse
apt-get update
sudo apt-get update
sudo apt-get upgrade -qy

# Install the Xfce desktop environment and basic applications
Expand All @@ -15,16 +13,14 @@ sudo apt-get install -y thunar xfce4-terminal terminator bash-completion tree ev
# Install the VirtualBox guest additions
sudo apt-get install -y virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11

# Create /home/${USER}/desktop
sudo -u ${USER} mkdir -p /home/${USER}/Desktop
chown ${USER}:${USER} /home/${USER}/Desktop
# Create Desktop
mkdir -p ~/Desktop

# Use US-English keyboard layout
L='us' && sudo sed -i 's/XKBLAYOUT=\"\w*"/XKBLAYOUT=\"'$L'\"/g' /etc/default/keyboard
# Add a shortcut to the keyboard options on the Desktop
cp /usr/share/applications/xfce-keyboard-settings.desktop /home/${USER}/Desktop/
chmod +x /home/${USER}/Desktop/xfce-keyboard-settings.desktop
chown ${USER}:${USER} /home/${USER}/Desktop/xfce-keyboard-settings.desktop
cp /usr/share/applications/xfce-keyboard-settings.desktop ~/Desktop/
chmod +x ~/Desktop/xfce-keyboard-settings.desktop

# Set a hostname
echo "precicevm" | sudo tee /etc/hostname
22 changes: 11 additions & 11 deletions provisioning/install-calculix.sh
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Install dependencies
sudo apt-get install -y libarpack2-dev libspooles-dev libyaml-cpp-dev

# Install CalculiX
cd /home/${USER}/
# Install CalculiX
wget --quiet http://www.dhondt.de/ccx_2.16.src.tar.bz2
tar xvjf ccx_2.16.src.tar.bz2
tar xvjf ccx_2.16.src.tar.bz2
rm -fv ccx_2.16.src.tar.bz2

# Get the CalculiX-preCICE adapter
if [ ! -d "calculix-adapter/" ]; then
sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/calculix-adapter.git
git clone --depth=1 --branch master https://github.com/precice/calculix-adapter.git
fi
cd calculix-adapter
git pull
sudo -u ${USER} -s bash -c "make -j 2"
(
cd calculix-adapter
git pull
make -j 2
)

# Add the CalculiX adapter to PATH
echo "export PATH=\"/home/${USER}/calculix-adapter/bin:\${PATH}\"" >> /home/${USER}/.bashrc
echo "export PATH=\"\${HOME}/calculix-adapter/bin:\${PATH}\"" >>~/.bashrc
77 changes: 77 additions & 0 deletions provisioning/install-code_aster.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#!/usr/bin/env bash
set -ex

# Install dependencies
sudo apt-get install -y bison cmake make flex g++ gcc gfortran \
grace liblapack-dev libblas-dev \
libboost-numpy-dev libboost-python-dev \
python3 python3-dev python3-numpy \
tk zlib1g-dev

# Install code_aster 14.6 - skip to save time if target dir exists
if [ ! -d "code_aster/" ]; then
wget --quiet https://www.code-aster.org/FICHIERS/aster-full-src-14.6.0-1.noarch.tar.gz
tar xvzf aster-full-src-14.6.0-1.noarch.tar.gz && rm -fv aster-full-src-14.6.0-1.noarch.tar.gz
(
cd aster-full-src-14.6.0
yes | python3 setup.py install --prefix="${HOME}/code_aster"
)
echo ". ${HOME}/code_aster/etc/codeaster/profile.sh" >>~/.bashrc
rm -rf ./aster-full-src-14.6.0/
fi

# Get the code_aster-preCICE adapter
if [ ! -d "code_aster-adapter/" ]; then
git clone --depth=1 --branch master https://github.com/precice/code_aster-adapter.git
fi
(
cd "${HOME}/code_aster/14.6/lib/aster/Execution"
ln -sf "${HOME}/code_aster-adapter/cht/adapter.py" .
)

# Optional: Update the tutorials exchange directory (needs to be absolute) and generate the export file.
(
cd "${HOME}/tutorials/flow-over-heated-plate-steady-state"

sed -i "s|exchange-directory=\"..\"|exchange-directory=\"$(pwd)\"|g" precice-config.xml

cd ./solid-codeaster
if [ ! -f "solid.export" ]; then
{
echo "P actions make_etude"
echo "P aster_root /code_aster"
echo "P consbtc oui"
echo "P debug nodebug"
echo "P display precicevm:0"
echo "P follow_output yes"
echo "P mclient precicevm"
echo "P memjob 524288"
echo "P memory_limit 512.0"
echo "P mode interactif"
echo "P ncpus 1"
echo "P nomjob linear-thermic"
echo "P origine salomemeca_asrun 1.10.0"
echo "P protocol_copyfrom asrun.plugins.server.SCPServer"
echo "P protocol_copyto asrun.plugins.server.SCPServer"
echo "P protocol_exec asrun.plugins.server.SSHServer"
echo "P rep_trav /tmp/root-23129e00f0db-interactif_4800"
echo "P serveur localhost"
echo "P soumbtc oui"
echo "P time_limit 600.0"
echo "P tpsjob 11"
echo "P uclient precicevm"
echo "P username precicevm"
echo "P version stable"
echo "A memjeveux 64.0"
echo "A tpmax 600.0"
echo "F comm ${HOME}/code_aster-adapter/cht/adapter.comm D 1"
echo "F libr $(pwd)/config.comm D 90"
echo "F libr $(pwd)/def.comm D 91"
echo "F mmed $(pwd)/solid.mmed D 20"
echo "R repe $(pwd)/REPE_OUT D 0"
echo "R repe $(pwd)/REPE_OUT R 0"
echo "F mess $(pwd)/solid.mess R 6"
echo "F resu $(pwd)/solid.resu R 8"
} >>solid.export
fi
)
14 changes: 6 additions & 8 deletions provisioning/install-config-visualizer.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
#!/bin/sh
#!/usr/bin/env bash
set -ex

USER="vagrant"

# Get the config-visualizer from GitHub
if [ ! -d "config-visualizer/" ]; then
sudo -u ${USER} git clone --depth=1 --branch master https://github.com/precice/config-visualizer.git
git clone --depth=1 --branch master https://github.com/precice/config-visualizer.git
fi
sudo -u ${USER} -s bash -c "pip3 install --user -e config-visualizer"
pip3 install --user -e config-visualizer

# Add the config-visualizer to PATH
echo "export PATH=\"/home/${USER}/config-visualizer/bin:${PATH}\"" >> /home/${USER}/.bashrc
echo "export PATH=\"\${HOME}/config-visualizer/bin:\${PATH}\"" >>~/.bashrc

# By default, there is no `python` executable, there is only `python3`,
# which causes issues to the config-visualizer
apt-get install -y python-is-python3
sudo apt-get install -y python-is-python3

# Install graphviz, which provides dot, an almost required package to make this useful
apt-get install -y graphviz
sudo apt-get install -y graphviz
Loading