Skip to content

Commit 54ee93b

Browse files
committed
Add first working version
0 parents  commit 54ee93b

10 files changed

+209
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.vagrant

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 Gerasimos Chourdakis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Virtual Machines for preCICE, with examples preinstalled
2+
3+
[Vagrant](https://www.vagrantup.com/) files to prepare Virtual Machines for [preCICE](https://www.precice.org/), mainly for demo and teaching purposes.
4+
5+
Available platforms:
6+
- [Ubuntu 20.04](./preCICE-Ubuntu-20.04/)
7+
8+
## What does this do?
9+
10+
Vagrant pulls a "base box" and asks e.g. VirtualBox to start a virtual machine.
11+
It then installs basic tools (such as a desktop environment), a preCICE release,
12+
several solvers and adapters, as well as example and tutorial files.
13+
14+
## How to use this?
15+
16+
1. Get a Virtual Machine provider, such as [VirtualBox](https://www.virtualbox.org/)
17+
2. Get [Vagrant](https://www.vagrantup.com/)
18+
3. Change to the directory of the platform you want (e.g. `cd preCICE-Ubuntu-20.04`)
19+
4. Start with `vagrant up`
20+
5. After the provisioning finishes, restart the machine with `vagrant reload` to get a full GUI
21+
22+
### What else can I do?
23+
24+
- Suspend and resume the machine: `vagrant suspend`, `vagrant resume`
25+
- Turn off or destroy the machine: `vagrant halt`, `vagrant destroy`
26+
- Update the machine after you change the related scripts: `vagrant provision`
27+
- SSH into the machine: `vagrant ssh`
28+
- Package your already provisioned box (e.g. to reduce the starting time on another machine): `vagrant package --base "preCICE-Ubuntu-20.04" --output preCICE.box`
29+
- Change the number of cores and the allocated memory: edit `vb.cpus` and `vb.memory` in the `Vagrantfile`.
30+
- Share files between host and guest system: the guest system's `/vagrant/` directory reflects the directory of the `Vagrantfile`.

preCICE-Ubuntu-20.04/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Ubuntu 20.04 Vagrant box with preCICE and examples
2+
3+
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:
4+
- Xubuntu-core (Xfce desktop environment) and related tools
5+
- VirtualBox guest additions
6+
- Git, CMake, ccmake, VS Code
7+
- preCICE v2.1.1 from the official binaries
8+
- preCICE Python bindings
9+
- OpenFOAM v2006 and the OpenFOAM-preCICE adapter
10+
- Paraview from the official binaries
11+
12+
It then adds on the `/home/vagrant/Desktop`:
13+
- The preCICE examples (solverdummies), including a copy of the Python solverdummy.
14+
- The preCICE tutorials from the `precice/tutorials`
15+
16+
The adapter repositories remain in `/home/vagrant/`.
17+
18+
## How to use
19+
20+
After installing VirtualBox and Vagrant, start with `vagrant up`. See the [README file of this repository](../README.md) for more.
21+
22+
- User/password: `vagrant`/`vagrant`
23+
- Keyboard layout: US English (QWERTY), change in [`install-basics.sh`](./install-basics.sh)

preCICE-Ubuntu-20.04/Vagrantfile

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
Vagrant.configure("2") do |config|
5+
# The Vagrant documentation recommends the bento images instead of ubuntu (more providers, open source)
6+
config.vm.box = "bento/ubuntu-20.04"
7+
8+
# We don't want the box to automatically update every time it starts.
9+
# We can instead handle updates internally, without destroying the machine.
10+
config.vm.box_check_update = false
11+
12+
# Share an additional folder to the guest VM. The first argument is
13+
# the path on the host to the actual folder. The second argument is
14+
# the path on the guest to mount the folder. And the optional third
15+
# argument is a set of non-required options.
16+
# config.vm.synced_folder "../data", "/vagrant_data"
17+
18+
config.vm.provider "virtualbox" do |vb|
19+
# Name of the machine
20+
vb.name = "preCICE-Ubuntu-20.04"
21+
# Display the VirtualBox GUI when booting the machine
22+
vb.gui = true
23+
# Number of cores
24+
vb.cpus = 2
25+
# Customize the amount of memory on the VM:
26+
vb.memory = "2048"
27+
# Workaround to fix extremely long boot time
28+
# See https://bugs.launchpad.net/cloud-images/+bug/1874453 (#36)
29+
#vb.customize [ "modifyvm", :id, "--uartmode1", "file", File::NULL ]
30+
end
31+
32+
# Install a desktop environment and basic tools
33+
config.vm.provision "shell", path: "install-basics.sh"
34+
35+
# Install common development tools
36+
config.vm.provision "shell", path: "install-devel.sh"
37+
38+
# Install preCICE
39+
config.vm.provision "shell", path: "install-precice.sh"
40+
41+
# Install solvers, adapters, and related tools
42+
config.vm.provision "shell", path: "install-openfoam.sh"
43+
config.vm.provision "shell", path: "install-paraview.sh"
44+
end
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
# We (may) need the multiverse repository for the VBox Guest Additions
5+
sudo apt-add-repository multiverse
6+
apt-get update
7+
sudo apt-get upgrade -qy
8+
9+
# Install the Xfce desktop environment and basic applications
10+
sudo apt-get install -y xubuntu-core^
11+
sudo apt-get install -y thunar xfce4-terminal terminator bash-completion tree evince firefox firefox-locale-en
12+
13+
# Install the VirtualBox guest additions
14+
sudo apt-get install -y virtualbox-guest-dkms virtualbox-guest-utils virtualbox-guest-x11
15+
16+
# Use US-English keyboard layout
17+
L='us' && sudo sed -i 's/XKBLAYOUT=\"\w*"/XKBLAYOUT=\"'$L'\"/g' /etc/default/keyboard
18+
19+
# Set a hostname
20+
echo "precicevm" | sudo tee /etc/hostname

preCICE-Ubuntu-20.04/install-devel.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
sudo apt-get install -y git cmake cmake-curses-gui
5+
6+
sudo snap install code --classic
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
USER="vagrant"
5+
6+
# Add the signing key, add the repository, update:
7+
wget -q -O - https://dl.openfoam.com/add-debian-repo.sh | sudo bash
8+
9+
# Install OpenFOAM v2006:
10+
sudo apt-get install -y openfoam2006-default
11+
openfoam-selector --set openfoam2006 --system
12+
# todo: Somehow the openfoam-selector is not enough - the binaries are discoverable, but the libraries not. Remedy:
13+
echo "source /etc/profile.d/openfoam-selector.sh" >> /home/vagrant/.bashrc
14+
15+
# Get the OpenFOAM-preCICE adapter
16+
if [ ! -d "openfoam-adapter/" ]; then
17+
sudo -u ${USER} git clone --branch master https://github.com/precice/openfoam-adapter.git
18+
fi
19+
cd openfoam-adapter
20+
sudo -u ${USER} -s bash -c "source /usr/lib/openfoam/openfoam2006/etc/bashrc && ./Allwmake"
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
USER="vagrant"
5+
6+
curl "https://www.paraview.org/paraview-downloads/download.php?submit=Download&version=v5.8&type=binary&os=Linux&downloadFile=ParaView-5.8.1-MPI-Linux-Python3.7-64bit.tar.gz" > /home/vagrant/paraview.tar.gz
7+
cd /home/vagrant/
8+
sudo -u ${USER} tar -xzf paraview.tar.gz
9+
rm paraview.tar.gz
10+
sudo -u ${USER} ln -sf /home/vagrant/ParaView-5.8.1-MPI-Linux-Python3.7-64bit/bin/paraview /home/vagrant/Desktop/
+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/sh
2+
set -ex
3+
4+
USER="vagrant"
5+
6+
# Download the preCICE Ubuntu 20.04 package from GitHub, install it, and cleanup
7+
wget --quiet https://github.com/precice/precice/releases/download/v2.1.1/libprecice2_2.1.1_focal.deb
8+
sudo apt-get install -y ./libprecice2_2.1.1_focal.deb
9+
rm ./libprecice2_2.1.1_focal.deb
10+
11+
# Collect examples
12+
sudo -u ${USER} mkdir -p /home/vagrant/Desktop
13+
cd /home/vagrant/Desktop
14+
sudo -u ${USER} cp -r /usr/share/precice/examples/ .
15+
if [ ! -d "tutorials/" ]; then
16+
sudo -u ${USER} git clone --branch master https://github.com/precice/tutorials.git
17+
fi
18+
cd -
19+
20+
### OPTIONAL - preCICE Python bindings and Python example
21+
# Get PIP and the preCICE Python bindings
22+
sudo apt-get install -y python3-pip
23+
sudo -u ${USER} pip3 install --upgrade pip
24+
sudo -u ${USER} pip3 install --user pyprecice
25+
26+
# Get the Python solverdummy into the examples
27+
cd /home/vagrant/Desktop
28+
if [ ! -d "python-bindings/" ]; then
29+
sudo -u ${USER} git clone --branch master https://github.com/precice/python-bindings.git
30+
fi
31+
sudo -u ${USER} cp -r python-bindings/solverdummy/ examples/solverdummies/python/
32+
sudo rm -r python-bindings
33+
cd -
34+
###

0 commit comments

Comments
 (0)