Skip to content

Commit

Permalink
updated docker scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sathwikreddy56 committed Jan 7, 2025
1 parent 92e4b03 commit fe1877a
Show file tree
Hide file tree
Showing 3 changed files with 133 additions and 14 deletions.
71 changes: 57 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,31 @@
# --security-opt label=type:container_runtime_t \
# windninja:3.11.1
#



### Update environment variables for OpenMPI
## If running docker / singulairty container on mulitple cores make sure to use these environmental varibale before trying to run Windninja
# OPENMPI_VERSION=4.0.4
# export MPI_DIR=/opt/openmpi-${OPENMPI_VERSION}
# export MPI_BIN=$MPI_DIR/bin
# export MPI_LIB=$MPI_DIR/lib
# export MPI_INC=$MPI_DIR/include
# export PATH=$MPI_BIN:$PATH
# export LD_LIBRARY_PATH=$MPI_LIB:$LD_LIBRARY_PATH


# export CPL_DEBUG=NINJAFOAM
# source /opt/openfoam8/etc/bashrc
# export OMPI_ALLOW_RUN_AS_ROOT=1
# export OMPI_ALLOW_RUN_AS_ROOT_CONFIRM=1
# export FOAM_USER_LIBBIN=/usr/local/lib/


FROM ubuntu:20.04
USER root
ADD . /opt/src/windninja/
ADD ../../scripts/ /opt/src/scripts/
SHELL [ "/usr/bin/bash", "-c" ]
ENV DEBIAN_FRONTEND noninteractive
ENV WM_PROJECT_INST_DIR /opt
Expand All @@ -31,33 +53,54 @@ RUN dpkg-reconfigure debconf --frontend=noninteractive && \
pkg-config g++ libboost-program-options-dev \
libboost-date-time-dev libboost-test-dev python3-pip && \
cd /opt/src && \
sed -i -e 's/\r$//' ./windninja/scripts/build_deps_ubuntu_2004.sh && \
DEBIAN_FRONTEND=noninteractive ./windninja/scripts/build_deps_ubuntu_2004.sh && \
DEBIAN_FRONTEND=noninteractive ./windninja/scripts/build_deps_docker.sh && \
rm -rf /var/lib/apt/lists

RUN cd /opt/src/windninja && \
mkdir build && \
mkdir /data && \
cd /opt/src/windninja/build && \
cmake -D SUPRESS_WARNINGS=ON -DNINJAFOAM=ON -DBUILD_FETCH_DEM=ON .. && \
make -j4 && \

# Building the windninja with different funationalites
cmake \
# Just a flag to ignore some of the common warnings (required)
-D SUPRESS_WARNINGS=ON \
# This flag is responsible for Momentum solver (required)
-D NINJAFOAM=ON \
# This Flag is required to allow the WindNinja to download DEM Files (optional)
-D BUILD_FETCH_DEM=ON \
#This Flag is required to build the slope aspect grid (optional)
-D BUILD_SLOPE_ASPECT_GRID=ON \
# This Flag is required to build the flow seperation grid utility (optional)
-D BUILD_FLOW_SEPARATION_GRID=ON \
# User can add their specific flag from the cmake here similarly from the above example
.. && \
make -j12 && \
make install && \
ldconfig && \
cd /opt/src/windninja && \
sed -i -e 's/\r$//' scripts/build_libs.sh && \
/usr/bin/bash -c scripts/build_libs.sh
cd /opt/src/windninja


RUN mkdir -p $FOAM_RUN/../applications && \
cp -r /opt/src/windninja/src/ninjafoam/* $FOAM_RUN/../applications && \
cd $FOAM_RUN/../applications/8 && \
# This segment is responsible for
RUN source /opt/openfoam8/etc/bashrc &&\
mkdir -p $FOAM_RUN/../applications && \
cp -r /opt/src/windninja/src/ninjafoam/8/* $FOAM_RUN/../applications && \
cd $FOAM_RUN/../applications/ && \
sed -i "s|export WM_PROJECT_INST_DIR=|export WM_PROJECT_INST_DIR=/opt|g" /opt/openfoam8/etc/bashrc && \
sed -i "s|export WM_PROJECT_DIR=\$WM_PROJECT_INST_DIR/openfoam8|export WM_PROJECT_DIR=/opt/openfoam8|g" /opt/openfoam8/etc/bashrc && \
. /opt/openfoam8/etc/bashrc && \
wmake libso && \
cd utility/applyInit && \
wmake
# pip3 install numpy

CMD /usr/bin/bash -c /usr/local/bin/WindNinja
wmake &&\


cp $FOAM_RUN/../platforms/linux64GccDPInt32Opt/lib/libWindNinja.so /opt/openfoam8/platforms/linux64GccDPInt32Opt/lib/ &&\
cp $FOAM_RUN/../platforms/linux64GccDPInt32Opt/bin/applyInit /opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/ &&\
chmod 644 /opt/openfoam8/platforms/linux64GccDPInt32Opt/lib/libWindNinja.so &&\
chmod 755 /opt/openfoam8/platforms/linux64GccDPInt32Opt/bin/applyInit


RUN pip3 install numpy

VOLUME /data
WORKDIR /data
74 changes: 74 additions & 0 deletions scripts/build_deps_docker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash
PREFIX=/usr/local
POPPLER="poppler-0.23.4"
PROJ="proj-6.3.2"
GDAL="gdal-3.2.1"

#Dependencies
sudo -E apt-get install -y pkg-config libfontconfig1-dev libcurl4-gnutls-dev libnetcdf-dev \
libboost-program-options-dev libboost-date-time-dev libgeos-dev \
libboost-test-dev libsqlite3-dev sqlite3


### Install OpenMPI
OPENMPI_VERSION=4.0.4
wget https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-${OPENMPI_VERSION}.tar.gz
tar -xzf openmpi-${OPENMPI_VERSION}.tar.gz
rm -f openmpi-${OPENMPI_VERSION}.tar.gz
cd openmpi-${OPENMPI_VERSION}
./configure --prefix=/opt/openmpi-${OPENMPI_VERSION}
make -j 12 all install
cd ..
rm -rf openmpi-${OPENMPI_VERSION}

### Update environment variables for OpenMPI
export MPI_DIR=/opt/openmpi-${OPENMPI_VERSION}
export MPI_BIN=$MPI_DIR/bin
export MPI_LIB=$MPI_DIR/lib
export MPI_INC=$MPI_DIR/include
export PATH=$MPI_BIN:$PATH
export LD_LIBRARY_PATH=$MPI_LIB:$LD_LIBRARY_PATH

#Get and build poppler for PDF support in GDAL
wget https://poppler.freedesktop.org/$POPPLER.tar.xz
tar -xvf $POPPLER.tar.xz
cd $POPPLER/
./configure --prefix=$PREFIX --enable-xpdf-headers
make -j 12
sudo make install
cd ..

#Get and build proj
wget https://download.osgeo.org/proj/$PROJ.tar.gz
tar xvfz $PROJ.tar.gz
cd $PROJ
./configure --prefix=$PREFIX
make clean
make -j 12
sudo make install
cd ..

#Get and build GDAL with poppler support
wget https://download.osgeo.org/gdal/${GDAL:5}/$GDAL.tar.gz
tar -xvf $GDAL.tar.gz
cd $GDAL/
./configure --prefix=$PREFIX --with-poppler=$PREFIX
make -j 8
sudo make install
cd ..

#Add qt4 libs from ppa
#See here for more info:
#https://ubuntuhandbook.org/index.php/2020/07/install-qt4-ubuntu-20-04/
sudo add-apt-repository ppa:rock-core/qt4
sudo apt-get update
sudo -E apt-get install -y libqt4-dev libqtwebkit-dev

#Use OpenFOAM 8
#add the dl.openfoam.org repo and install OpenFOAM 8
sudo sh -c "wget -O - https://dl.openfoam.org/gpg.key | apt-key add -"
sudo add-apt-repository http://dl.openfoam.org/ubuntu
sudo apt-get update
sudo -E apt-get install -y openfoam8
echo "source /opt/openfoam8/etc/bashrc" >> /etc/bash.bashrc

2 changes: 2 additions & 0 deletions src/ninja/ninjafoam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1277,6 +1277,7 @@ void NinjaFoam::MoveDynamicMesh()
const char *const papszArgv[] = { "mpiexec",
"-np",
CPLSPrintf("%d", input.numberCPUs),
"--allow-run-as-root",
"moveDynamicMesh",
"-case",
pszFoamPath,
Expand Down Expand Up @@ -1664,6 +1665,7 @@ bool NinjaFoam::SimpleFoam()
const char *const papszArgv[] = { "mpiexec",
"-np",
CPLSPrintf("%d", input.numberCPUs),
"--allow-run-as-root",
"simpleFoam",
"-case",
pszFoamPath,
Expand Down

0 comments on commit fe1877a

Please sign in to comment.