Skip to content

Commit

Permalink
Merge pull request #51 from plasmapotential/main
Browse files Browse the repository at this point in the history
Merging main into runaway electrons
  • Loading branch information
feyrer authored Aug 20, 2024
2 parents 269b5a3 + fb09daa commit 031c552
Show file tree
Hide file tree
Showing 57 changed files with 2,252 additions and 93,313 deletions.
29 changes: 23 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,43 @@ name: CI

on:
push:
branches: [ plasma3D ]
branches: [ main ]
pull_request:
branches: [ plasma3D ]
branches: [ main ]

jobs:
test:
check-final-image:
runs-on: ubuntu-latest
steps:
- name: Check if final Docker image exists on Docker Hub
id: check-final-image
run: |
if docker pull plasmapotential/heat:v4.1; then
echo "Image exists on Docker Hub."
else
echo "::error ::Final HEAT Docker image v4.1 does not exist."
exit 1
fi
test:
needs: check-final-image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Pull Docker image
run: docker pull plasmapotential/heat:v4.0
run: docker pull plasmapotential/heat:v4.1

- name: Run simple CI configuration test
run: docker run -v ${{ github.workspace }}:/root/source/HEAT plasmapotential/heat:v4.0 python3 /root/source/HEAT/tests/integrationTests/ciTest.py
run: docker run -v ${{ github.workspace }}:/root/source/HEAT plasmapotential/heat:v4.1 python3 /root/source/HEAT/tests/integrationTests/ciTest.py

- name: NSTX-U Optical HEAT Calculation
run: docker run -v ${{ github.workspace }}:/root/source/HEAT plasmapotential/heat:v4.0 /root/source/HEAT/source/runTerminalModeTestOptical
run: docker run -v ${{ github.workspace }}:/root/source/HEAT plasmapotential/heat:v4.1 /root/source/HEAT/source/runTerminalModeTestOptical

- name: NSTX-U Optical Elmer FEM HEAT Calculation
run: docker run -v ${{ github.workspace }}:/root/source/HEAT plasmapotential/heat:v4.1 /root/source/HEAT/source/runTerminalModeTestOpticalElmer


# - name: NSTX-U Gyro-orbit HEAT Calculation
# run: docker run -v ${{ github.workspace }}:/root/source/HEAT plasmapotential/heat:v4.0 /root/source/HEAT/source/runTerminalModeTestGyro
#
Expand Down
239 changes: 196 additions & 43 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,49 +1,53 @@
#Dockerfile
#Engineer: T Looby
#Date: 01/27/2022
#Date: 03/20/2024
#Description: Dockerfile for building HEAT docker image
#
#this script should only be run on dev machine
#script is not run directly, but is used when buildDocker bash
#script is run. buildDocker script calls this file using syntax
#similar to this:
# docker build -t plasmapotential/heat -f ./Dockerfile ./github/source

# This dockerfile is broken into two stages. The first stage
# clones all the source code repos and builds everything from
# source inside of a container. This is time consuming, so
# it is made into its own stage called HEATbuilder. HEATbuilder
# will also be saved on dockerhub from now on, with a version
# tag. Users can pull HEATbuilder to save time.
#
# The second stage is the final HEAT container. It only contains
# the packages required to run HEAT, and none of the files used
# to build everything from source.
#
# A user can build both stages like this (command also works to only
# build final stage if HEATbuilder is already complete):
# docker build -t plasmapotential/heat .
#
# note: cross platform build (for apple silicon)
# docker buildx build --platform linux/amd64,linux/arm64 -t plasmapotential/heat -f ./Dockerfile . --push
#
# User can also only build the first stage (HEATbuilder) like this:
# docker build --target HEATbuilder -t plasmapotential/heatbuilder .
#
# after creating an image, tag it using a command like this
# docker tag plasmapotential/heat:latest plasmapotential/heat:<tag>
#
# upload to dockerhub via a command like this
# docker push plasmapotential/heat:<tag>
#
# launch bash terminal in container interatively
# docker-compose run HEAT /bin/bash
#
#======================================================================
#1st build stage. build all necessary packages from source
#======================================================================
# start from base
FROM ubuntu:22.04
FROM ubuntu:22.04 AS HEATbuilder
SHELL ["/bin/bash", "-c"]

LABEL maintainer="[email protected]"

# environment variables
ENV SHELL /bin/bash
ENV runMode docker
ENV AppDir /root
ENV APPDIR /root
ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONPATH /usr/lib/freecad-python3/lib

#set up paths for libs
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/qt5
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/netgen
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/mafot/lib
#ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/paraview/lib #comment to prevent qt5 conflicts
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/openfoam/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/openfoam/platforms/linux64GccDPInt32Opt/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/openfoam/platforms/linux64GccDPInt32Opt/lib/sys-openmpi
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/swak4foam/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/openfoam/platforms/linux64GccDPInt32Opt/lib/dummy
#ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/open3d/lib:/root/opt/open3d/lib/python_package
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/m3dc1/lib

#set up paths for bins
ENV PATH $PATH:/root/opt/mafot/bin
ENV PATH $PATH:/root/opt/paraview/bin
ENV PATH $PATH:/root/opt/openfoam/bin
ENV PATH $PATH:/root/opt/openfoam/platforms/linux64GccDPInt32Opt/bin
ENV PATH $PATH:/root/opt/swak4foam/bin
#ENV PATH $PATH:/root/opt/open3d/bin
ENV PATH $PATH:/root/opt/m3dc1/bin

#===system-wide deps for HEAT
#update layer
RUN apt-get -yqq update

Expand All @@ -54,6 +58,97 @@ RUN apt-get -yqq install python3 && \
apt-get -yqq install python3-distutils
#RUN apt-get -yqq install mdsplus-python

#utility tools/libs layers
#RUN apt-get -yqq libnglib-6.2
RUN apt-get -yqq install coreutils libcurl4 libunwind-dev nano git gfortran iputils-ping iproute2 htop

#3D plasmas layer
RUN apt-get -yqq install libopenmpi-dev libhdf5-openmpi-dev libnetcdf-dev libnetcdff-dev libblas-dev liblapack-dev

#linking layer
RUN ln -s /usr/lib/x86_64-linux-gnu/libunwind.so /usr/lib/x86_64-linux-gnu/libunwind.so.1

#clone EFIT
#RUN git clone https://github.com/ORNL-Fusion/EFIT.git /root/source/EFIT

#clone HEAT
RUN git clone https://github.com/plasmapotential/HEAT.git /root/source/HEAT

#change to root (home) dir
WORKDIR /root

#clone and build M3DC1 fusion-io libs
RUN git clone https://github.com/nferraro/fusion-io.git /root/source/M3DC1/fusion-io
COPY buildM3DC1 /root/source/M3DC1/fusion-io/buildM3DC1
COPY make.inc.ubuntu_x86 /root/source/M3DC1/fusion-io/install/make.inc.ubuntu_x86
RUN mkdir -p /root/source/M3DC1/build && /root/source/M3DC1/fusion-io/buildM3DC1

#clone and build MAFOT
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/hdf5/openmpi
#note branch here can be changed if PR goes thru
RUN git clone -b HEATv4.1 --single-branch https://github.com/ORNL-Fusion/MAFOT.git /root/source/MAFOT
COPY buildMAFOT /root/source/MAFOT/buildMAFOT
RUN mkdir -p /root/source/MAFOT/build/bin && \
mkdir -p /root/source/MAFOT/build/lib && \
/root/source/MAFOT/buildMAFOT

#clone openfoam, third party libs
#OpenFOAM version defined by user
ARG OFversion=2306
RUN apt-get -yqq update && \
apt-get install -yqq python-is-python3 flex bison wget mercurial libscotch-dev libptscotch-dev && \
wget -P /root/source/openfoam/ https://dl.openfoam.com/source/v${OFversion}/ThirdParty-v${OFversion}.tgz && \
wget -P /root/source/openfoam/ https://dl.openfoam.com/source/v${OFversion}/OpenFOAM-v${OFversion}.tgz && \
tar -xzf /root/source/openfoam/ThirdParty-v${OFversion}.tgz -C /root/source/openfoam/ && \
tar -xzf /root/source/openfoam/OpenFOAM-v${OFversion}.tgz -C /root/source/openfoam/ && \
mkdir -p /root/source/openfoam/swak4Foam

#build openfoam
ENV WM_THIRD_PARTY_DIR /root/source/openfoam/ThirdParty-v${OFversion}
WORKDIR /root/source/openfoam/OpenFOAM-v${OFversion}
RUN mkdir -p /root/source/openfoam/OpenFOAM-v${OFversion}/applications/solvers/custom && \
cp -au /root/source/HEAT/source/heatFoam /root/source/openfoam/OpenFOAM-v${OFversion}/applications/solvers/custom/heatFoam && \
source /root/source/openfoam/OpenFOAM-v${OFversion}/etc/bashrc && \
./Allwmake -j -s -q -l && \
cd /root/source/openfoam/OpenFOAM-v${OFversion}/applications/solvers/custom/heatFoam && \
wmake

#clone and build swak4foam
WORKDIR /root/source/openfoam/
RUN source /root/source/openfoam/OpenFOAM-v${OFversion}/etc/bashrc && \
hg clone http://hg.code.sf.net/p/openfoam-extend/swak4Foam && \
cd /root/source/openfoam/swak4Foam && \
hg update develop && \
./AllwmakeAll

#clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

#======================================================================
#2nd build stage. build container without unncesary build artifacts
#to keep final image smaller
#======================================================================
#if user doesnt want to build first stage, they can pull HEATbuilder from
#dockerhub using the following command (need to comment out first stage too):
#FROM plasmapotential/HEATbuilder:<tag> as HEATbuilder

FROM ubuntu:22.04
LABEL maintainer="[email protected]"
ARG DEBIAN_FRONTEND=noninteractive
ENV runMode docker

#update layer
RUN apt-get -yqq update && apt-get -yqq upgrade

#python layer
RUN apt-get -yqq install python3 && \
apt-get -yqq install python3-pip && \
apt-get -yqq install python3-pkg-resources && \
apt-get -yqq install python3-distutils && \
apt-get -yqq install python3-paraview

#RUN apt-get -yqq install mdsplus-python

# freecad layer
#RUN apt-get -yqq install libfreecad-python3-0.20 #22.04
#RUN apt-get -yqq install libfreecad-python3-0.19 #22.10
Expand All @@ -66,30 +161,88 @@ RUN apt-get -yqq install software-properties-common && \
apt-get update && \
apt-get install -yqq freecad-python3

#utility tools/libs layers
RUN apt-get -yqq install coreutils libnglib-6.2 libcurl4 libunwind-dev nano git gfortran iputils-ping iproute2 htop
# elmer layer / OF layer
RUN apt-get -yqq update && \
apt-add-repository ppa:elmer-csc-ubuntu/elmer-csc-ppa && \
apt-get update && \
apt-get install -yqq elmerfem-csc libglu1 libscotch-dev libptscotch-dev python-is-python3

#RUN apt-get -yqq libnglib-6.2
RUN apt-get -yqq install coreutils libcurl4 libunwind-dev nano git gfortran iputils-ping iproute2 htop

#3D plasmas layer
RUN apt-get -yqq install libopenmpi-dev libhdf5-openmpi-dev libnetcdf-dev libnetcdff-dev

#linking layer
RUN ln -s /usr/lib/x86_64-linux-gnu/libunwind.so /usr/lib/x86_64-linux-gnu/libunwind.so.1

# copy context
WORKDIR /root
COPY . .
#clone EFIT
RUN git clone https://github.com/ORNL-Fusion/EFIT.git /root/source/EFIT

# fetch app specific deps
#clone HEAT (note v4.1 branch can be changed)
RUN git clone -b v4.1 --single-branch https://github.com/plasmapotential/HEAT.git /root/source/HEAT

# fetch HEAT specific python dependencies
RUN python3 -m pip install --upgrade pip && \
python3 -m pip install --ignore-installed blinker && \
python3 -m pip install -r requirements.txt

#clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
python3 -m pip install -r /root/source/HEAT/docker/requirements.txt

#make build dirs
RUN mkdir -p /root/builds/M3DC1 && \
mkdir -p /root/builds/MAFOT && \
mkdir -p /root/builds/openfoam && \
mkdir -p /root/builds/swak4foam

#copy M3DC1 fusion-io bins / libs
COPY --from=HEATbuilder /root/source/M3DC1/build/bin /root/builds/M3DC1/bin
COPY --from=HEATbuilder /root/source/M3DC1/build/lib /root/builds/M3DC1/lib
COPY --from=HEATbuilder /root/source/M3DC1/build/include /root/builds/M3DC1/include
COPY --from=HEATbuilder /root/source/M3DC1/build/modules /root/builds/M3DC1/modules

#copy MAFOT bins / libs
COPY --from=HEATbuilder /root/source/MAFOT/build/bin /root/builds/MAFOT/bin
COPY --from=HEATbuilder /root/source/MAFOT/build/lib /root/builds/MAFOT/lib

#copy openFOAM bin / libs
ENV OFversion 2306
COPY --from=HEATbuilder /root/source/openfoam/OpenFOAM-v${OFversion}/platforms /root/builds/openfoam/platforms
COPY --from=HEATbuilder /root/source/openfoam/OpenFOAM-v${OFversion}/build /root/builds/openfoam/build
COPY --from=HEATbuilder /root/source/openfoam/OpenFOAM-v${OFversion}/bin /root/builds/openfoam/bin
COPY --from=HEATbuilder /root/source/openfoam/OpenFOAM-v${OFversion}/etc /root/builds/openfoam/etc

#copy swak4foam bins / libs
COPY --from=HEATbuilder /root/OpenFOAM/user-v2306/platforms/linux64GccDPInt32Opt/bin /root/builds/swak4Foam/bin
COPY --from=HEATbuilder /root/OpenFOAM/user-v2306/platforms/linux64GccDPInt32Opt/lib /root/builds/swak4Foam/lib

#paths for libs
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/qt5
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/lib/x86_64-linux-gnu/netgen
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/builds/MAFOT/lib
#ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/opt/paraview/lib #comment to prevent qt5 conflicts
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/builds/openfoam/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/builds/openfoam/platforms/linux64GccDPInt32Opt/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/builds/openfoam/platforms/linux64GccDPInt32Opt/lib/sys-openmpi
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/builds/openfoam/platforms/linux64GccDPInt32Opt/lib/dummy
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/builds/swak4Foam/lib
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/root/builds/M3DC1/lib
ENV PYTHONPATH $PYTHONPATH:/root/builds/M3DC1/lib

#set up paths for bins
ENV PATH $PATH:/root/builds/MAFOT/bin
#ENV PATH $PATH:/root/builds/paraview/bin
ENV PATH $PATH:/root/builds/openfoam/bin
ENV PATH $PATH:/root/builds/openfoam/platforms/linux64GccDPInt32Opt/bin
ENV PATH $PATH:/root/builds/swak4foam/bin
ENV PATH $PATH:/root/builds/M3DC1/bin
ENV PYTHONPATH $PYTHONPATH:/usr/lib/freecad-python3/lib

# expose port
EXPOSE 8050

WORKDIR /root

#clean up
RUN apt-get clean && rm -rf /var/lib/apt/lists/*

# start app
CMD [ "python3", "./source/HEAT/source/launchHEAT.py", "--a", "0.0.0.0", "--p", "8050", "--m", "g" ]
1 change: 1 addition & 0 deletions docker/buildDocker
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
#THIS FILE IS NO LONGER USED. LEGACY LEFT FOR REFERENCE UNTIL v5.0
#Engineer: T Looby
#Date: 12/27/2023
#Description: prepares docker context, then creates docker container
Expand Down
12 changes: 12 additions & 0 deletions docker/buildM3DC1
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
#builds M3DC1 Fusion-io libs inside the container
echo "Building M3DC1 fusion-io..."
#sets up environment and builds fusion-io libs
export FIO_ROOT=/root/source/M3DC1/fusion-io
export FIO_ARCH="ubuntu_x86"
export FIO_INSTALL_DIR=/root/source/M3DC1/build
export PYTHON=python3

cd /root/source/M3DC1/fusion-io
make
make install
15 changes: 15 additions & 0 deletions docker/buildMAFOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash
#builds MAFOT inside the container
echo "Building Blitz..."
cd ./source/MAFOT/blitz++
tar -xvzf blitz-0.9_cstdlibPatched.tar.gz
cd blitz-0.9
./configure
make lib
make install
cd /root/source/MAFOT
rm make.inc
ln -s install/make.inc.HEAT make.inc
ls /
echo "Building MAFOT..."
make heat
Loading

0 comments on commit 031c552

Please sign in to comment.