From 3cd7609a09a16b85b398fc24139a3dc3a40bffe2 Mon Sep 17 00:00:00 2001 From: Romain Boman <romain.boman@gmail.com> Date: Fri, 4 Mar 2022 15:32:10 +0100 Subject: [PATCH] update CUPyDO script --- build_CUPyDO.sh | 576 ++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 459 insertions(+), 117 deletions(-) diff --git a/build_CUPyDO.sh b/build_CUPyDO.sh index a7f53de..a30d5ba 100755 --- a/build_CUPyDO.sh +++ b/build_CUPyDO.sh @@ -1,94 +1,354 @@ #!/bin/bash +# build CUPyDO and all related solvers / run ctest +# +# usage: build_CUPyDO.sh -b -j 2 : build (using 2 cores) +# build_CUPyDO.sh -b -t : build and test +# build_CUPyDO.sh -b -t -q : build and test (batch mode) -function build_CUPyDO() +# profile should be sourced if in batch mode +source ~/.profile +# bash: enable more errors +set -eu + +GEOGEN_VERSION=2.0.0 +SOL2_VERSION=3.2.2 +MODALI_VERSION=v2.0 +NATIVESOLID_VERSION=romain # v1.1 +PYBEAM_VERSION=master +VLM_VERSION=v2.0 +SU2_VERSION=fix_wrap_strong +PFEM3D_VERSION=v2.0.0 +# WAVES_VERSION=v2.2.2 # AttributeError: module 'flow' has no attribute 'F0PsPhiInf' +WAVES_VERSION=v2.1.1 +PFEM_VERSION=v1.19 +METAFOR_VERSION=v3492 +CUPYDO_VERSION=lacroix + +# Gmsh +# https://gmsh.info/ + +function get_last_Gmsh() { - # clone/build CUPyDO - if [ ! -d CUPyDO ] ; then - git clone git@github.com:ulgltas/CUPyDO.git + if [ ! -d Gmsh ] ; then + echo "Gmsh: retrieving gmsh-git-Linux64-sdk.tgz" + wget -q https://gmsh.info/bin/Linux/gmsh-git-Linux64-sdk.tgz + tar -xzf gmsh-git-Linux64-sdk.tgz + mv gmsh-git-Linux64-sdk Gmsh + rm gmsh-git-Linux64-sdk.tgz + else + echo "Gmsh: found" fi +} - cd CUPyDO - git pull - git checkout pfem_compatibility_update - git pull - if [ -d build ] ; then - rm -rf build +# geoGen (for VLM) +# https://github.com/acrovato/geoGen +# full python + +function get_geoGen() +{ + if [ ! -d geoGen ] ; then + echo "geoGen: retrieving geoGen ${GEOGEN_VERSION}" + wget -q https://github.com/acrovato/geoGen/archive/refs/tags/v${GEOGEN_VERSION}.tar.gz + tar -xf v${GEOGEN_VERSION}.tar.gz + mv geoGen-${GEOGEN_VERSION} geoGen + rm v${GEOGEN_VERSION}.tar.gz + else + echo "geoGen: found" fi - mkdir build - cd build - cmake .. - make -j 6 - make install - cd ../.. } -function build_waves() +# sol2 (for PFEM3D) +# https://github.com/ThePhD/sol2 + +function build_sol2() # { - # clone/build waves - if [ ! -d waves ] ; then - git clone git@gitlab.uliege.be:am-dept/waves.git + if [ ! -d sol2 ] ; then + echo "sol2: retrieving sol2 ${SOL2_VERSION}" + + SOL2_INSTALL_PREFIX=`pwd`/sol2 + + wget -q https://github.com/ThePhD/sol2/archive/refs/tags/v${SOL2_VERSION}.tar.gz + tar -xf v${SOL2_VERSION}.tar.gz + rm v${SOL2_VERSION}.tar.gz + + echo "sol2: building" + cd sol2-${SOL2_VERSION} + if [ -d build ] ; then + rm -rf build + fi + mkdir build + cd build + cmake .. -DCMAKE_INSTALL_PREFIX=${SOL2_INSTALL_PREFIX} #>sol2.cmake.log + cmake --build . --target install -- -j ${NCORES} #>sol2.build.log + cd ../.. + rm -rf sol2-${SOL2_VERSION} + else + echo "sol2: found" fi +} + +# modali: Modal integrator for fluid-structure computations +# https://github.com/ulgltas/modali +# full python - no build - cd waves - if [ -d build ] ; then - rm -rf build +function build_modali() +{ + if [ ! -d modali ] ; then + echo "modali: cloning modali ${MODALI_VERSION}" + git -c advice.detachedHead=false \ + clone --quiet \ + --branch ${MODALI_VERSION} \ + git@github.com:ulgltas/modali.git + else + echo "modali: already cloned" fi - mkdir build - cd build - cmake -DUSE_PY3=OFF -C../CMake/disable-trilinos.cmake .. - make -j 6 - cd ../.. } -function build_PFEM() +# NativeSolid (RBM?) +# https://github.com/ulgltas/NativeSolid + +function build_NativeSolid() { - # clone/build PFEM - if [ ! -d PFEM ] ; then - git clone git@gitlab.uliege.be:am-dept/PFEM.git + if [ ! -d NativeSolid ] ; then + echo "NativeSolid: cloning NativeSolid ${NATIVESOLID_VERSION}" + git -c advice.detachedHead=false \ + clone --quiet git@github.com:ulgltas/NativeSolid.git \ + --branch ${NATIVESOLID_VERSION} + else + echo "NativeSolid: already cloned" fi - cd PFEM - git pull - git checkout reorganize_schemes_and_algos - git pull - if [ -d build ] ; then - rm -rf build + # requires lapacke/cblas + # lapacke: (sudo apt install liblapacke-dev) + # cblas/blas: (sudo apt-get install libopenblas-dev) + + if [ ! -f ./NativeSolid/bin/TestCVector ] ; then + echo "NativeSolid: building" + cd NativeSolid + if [ -d build ] ; then + rm -rf build + fi + mkdir build + cd build + cmake -DCMAKE_BUILD_TYPE=Release -Wno-dev .. #>NativeSolid.cmake.log + make -j ${NCORES} #>NativeSolid.make.log + cd ../.. + else + echo "NativeSolid: already built" fi - mkdir build - cd build - cmake .. - make -j 6 - cd ../.. } +# pyBeam: +# https://github.com/pyBeam/pyBeam +# requires meson/ninja: sudo apt install meson -function build_NativeSolid() +function build_pyBeam() { - # clone/build NativeSolid - if [ ! -d NativeSolid ] ; then - git clone git@github.com:ulgltas/NativeSolid.git + if [ ! -d pyBeam ] ; then + echo "pyBeam: cloning pyBeam" + git -c advice.detachedHead=false \ + clone --depth 1 --recursive \ + git@github.com:pyBeam/pyBeam.git \ + --branch ${PYBEAM_VERSION} + ver=$(python3 -V 2>&1 | sed 's/.* \([0-9]\).\([0-9]\).*/\1\2/') + if [ "$ver" -gt "37" ]; then + # fix meson build file for python3.8 + # see https://github.com/mesonbuild/meson/issues/5629 + sed -i "s/dependency('python3')/dependency('python3-embed')/g" \ + pyBeam/meson.build + fi + else + echo "pyBeam: already cloned" fi - cd NativeSolid - if [ -d build ] ; then - rm -rf build + if [ ! -f pyBeam/build/bin/pyBeam.py ] ; then + echo "pyBeam: building" + cd pyBeam + if [ -d build ] ; then + rm -rf build + fi + mkdir build + meson build --prefix=$PWD/build + ninja -C build install + cd .. + else + echo "pyBeam: already installed" fi - mkdir build - cd build - cmake .. - make -j 6 - cd ../.. } +# VLM +# https://github.com/ulgltas/VLM -function build_modali() +function build_VLM() { - # clone modali - if [ ! -d modali ] ; then - git clone git@github.com:ulgltas/modali.git + if [ ! -d VLM ] ; then + echo "VLM: cloning VLM ${VLM_VERSION}" + git -c advice.detachedHead=false \ + clone --quiet \ + --branch ${VLM_VERSION} \ + git@github.com:ulgltas/VLM.git + else + echo "VLM: already cloned" + fi + + if [ ! -f VLM/bin/VLM ] ; then + echo "VLM: building" + cd VLM + if [ -d build ] ; then + rm -rf build + fi + mkdir build + cd build + cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release -DPYTHON_WRAPPER=ON .. + make -j ${NCORES} + make install + cd ../.. + else + echo "VLM: already built" fi } +# SU2 +# https://github.com/ulgltas/SU2 + +function build_SU2() +{ + if [ ! -d SU2 ] ; then + echo "SU2: cloning SU2" + git clone --depth 1 git@github.com:ulgltas/SU2.git \ + --branch ${SU2_VERSION} + else + echo "SU2: srcs found" + fi + + if [ ! -f SU2/build/bin/SU2_CFD ] ; then + echo "SU2: building" + cd SU2 + export CXXFLAGS="-O3" + python3 meson.py setup build \ + -Denable-pywrapper=true \ + -Denable-cgns=false \ + -Denable-tecio=false \ + -Dwith-mpi=disabled \ + -Denable-tests=false \ + -Denable-autodiff=true \ + --prefix=$PWD/build + ./ninja -C build install + cd .. + else + echo "SU2: already installed" + fi +} + +# PFEM3D +# https://github.com/ImperatorS79/PFEM3D +# sudo apt install libcgal-dev liblua5.3-dev +# +# ctest runtime: needs slpp (lua parser for python) +# https://github.com/SirAnthony/slpp +# https://pypi.org/project/SLPP/ +# => sudo pip3 install slpp + +function build_PFEM3D() +{ + if [ ! -d PFEM3D ] ; then + echo "PFEM3D: cloning PFEM3D ${PFEM3D_VERSION}" + git -c advice.detachedHead=false \ + clone --quiet \ + --branch ${PFEM3D_VERSION} \ + git@github.com:ImperatorS79/PFEM3D.git + else + echo "PFEM3D: already cloned" + fi + + if [ ! -f PFEM3D/build/bin/pfem ] ; then + echo "PFEM3D: building" + BASE=`pwd` + export GMSH=${BASE}/Gmsh + export Sol2_DIR=${BASE}/sol2/lib/cmake/sol2/ + export PATH=${GMSH}/bin:${GMSH}/lib:${PATH} + export INCLUDE=${GMSH}/include:${INCLUDE} + export LIB=${GMSH}/lib:${LIB} + cd PFEM3D + if [ -d build ] ; then + rm -rf build + fi + mkdir build + cd build + cmake -Wno-dev -DCMAKE_BUILD_TYPE=Release \ + -DUSE_SWIG=1 -DBUILD_TESTING=1 .. + make -j ${NCORES} + cp ${BASE}/Gmsh/lib/libgmsh.so bin/ + cd ../.. + else + echo "PFEM3D: already built" + fi +} + +# Waves +# https://gitlab.uliege.be/am-dept/waves + +function build_waves() +{ + if [ ! -d waves ] ; then + echo "waves: cloning waves ${WAVES_VERSION}" + git -c advice.detachedHead=false \ + clone --quiet \ + --branch ${WAVES_VERSION} \ + git@gitlab.uliege.be:am-dept/waves.git + else + echo "waves: already cloned" + fi + + if [ ! -f waves/build/bin/libwaves.so ] ; then + echo "waves: building" + cd waves + if [ -d build ] ; then + rm -rf build + fi + mkdir build + cd build + cmake -Wno-dev -C../CMake/disable-trilinos.cmake .. + make -j ${NCORES} + cd ../.. + else + echo "waves: already built" + fi +} + +# PFEM: +# https://gitlab.uliege.be/am-dept/PFEM + +function build_PFEM() +{ + if [ ! -d PFEM ] ; then + echo "PFEM: cloning PFEM ${PFEM_VERSION}" + git -c advice.detachedHead=false \ + clone --quiet \ + --branch ${PFEM_VERSION} \ + git@gitlab.uliege.be:am-dept/PFEM.git + else + echo "PFEM: already cloned" + fi + + if [ ! -f PFEM/build/bin/libpfem.so ] ; then + echo "PFEM: building" + cd PFEM + if [ -d build ] ; then + rm -rf build + fi + mkdir build + cd build + cmake -Wno-dev .. + make -j ${NCORES} + cd ../.. + else + echo "PFEM: already built" + fi +} + +# Metafor + function build_Metafor() { if [ ! -d Metafor ] ; then @@ -98,86 +358,168 @@ function build_Metafor() # clone if [ ! -d linuxbin ] ; then + echo "Metafor/linuxbin: cloning linuxbin" git clone git@gitlab.uliege.be:am-dept/linuxbin.git - fi + else + echo "Metafor/linuxbin: already cloned" + fi + if [ ! -d oo_meta ] ; then - git clone --depth=10 git@gitlab.uliege.be:am-dept/MN2L/oo_meta.git + echo "Metafor/oo_meta: cloning oo_meta ${METAFOR_VERSION}" + git -c advice.detachedHead=false \ + clone --recursive --depth=1 \ + --branch ${METAFOR_VERSION} \ + git@gitlab.uliege.be:am-dept/MN2L/oo_meta.git + else + echo "Metafor/oo_meta: already cloned" fi # build - if [ -d oo_metaB ] ; then - rm -rf oo_metaB + if [ ! -f oo_metaB/bin/Metafor ] ; then + echo "Metafor/oo_meta: building" + if [ -d oo_metaB ] ; then + rm -rf oo_metaB + fi + mkdir oo_metaB + cd oo_metaB + cmake -Wno-dev -C ../oo_meta/CMake/ubuntu-CUPyDO.cmake ../oo_meta + make -j ${NCORES} + cd .. + else + echo "Metafor/oo_meta: already built" fi - mkdir oo_metaB - cd oo_metaB - cmake -C ../oo_meta/CMake/ubuntu-CUPyDO.cmake ../oo_meta - make -j 12 - cd ../.. + + cd .. } -function build_SU2() +function build_CUPyDO() { - # clone/build SU2 - if [ ! -d SU2.src ] ; then - mkdir SU2.src + if [ ! -d CUPyDO ] ; then + echo "CUPyDO: cloning CUPyDO ${CUPYDO_VERSION}" + git clone --branch ${CUPYDO_VERSION} \ + git@github.com:ulgltas/CUPyDO.git + else + echo "CUPyDO: already cloned" fi - cd SU2.src - if [ ! -d SU2 ] ; then - git clone git@github.com:su2code/SU2.git + if [ ! -f CUPyDO/ccupydo/_CCupydo.so ] ; then + echo "CUPyDO: building" + cd CUPyDO + if [ -d build ] ; then + rm -rf build + fi + mkdir build + cd build + cmake -Wno-dev -DWITH_MPI=OFF .. + make -j ${NCORES} + make install + cd ../.. + else + echo "CUPyDO: already built" fi - cd SU2 - git checkout tags/v6.2.0 - unset MKLROOT # <= MKL should be disabled - ./bootstrap - ./configure --prefix=`readlink -f ../../SU2` \ - CXXFLAGS="-O3" \ - --enable-PY_WRAPPER - make -j 12 - make install - cd ../.. } -function build_VLM() +function do_build() { - # clone/build VLM - if [ ! -d VLM ] ; then - git clone git@github.com:ulgltas/VLM.git + # create CUPyDO main folder + if [ ! -d CUPyDO ] ; then + mkdir CUPyDO fi - cd VLM + cd CUPyDO - if [ -d build ] ; then - rm -rf build - fi - mkdir build - cd build - cmake .. - make -j 6 + # build codes + get_last_Gmsh + get_geoGen + build_sol2 + build_modali + build_NativeSolid + build_pyBeam + build_VLM + build_SU2 + build_PFEM3D + build_waves + build_PFEM + build_Metafor + build_CUPyDO - make install # is it required? - - cd ../.. + # leave CUPyDO main folder + cd .. } +function do_tests() +{ + echo "do_tests()..." + cd CUPyDO + cd CUPyDO/build + ctest -j ${NCORES} #2>&1 > ctest_stdout.txt + # output the last lines to stdout (useful for shortening mails) + #tail -n 50 ctest_stdout.txt + cd ../../.. + echo "done." +} - -# create CUPyDO main folder -if [ ! -d CUPyDO ] ; then - mkdir CUPyDO -fi -cd CUPyDO +function usage() +{ + echo "usage: $0 -b -j 2 : build (using 2 cores)" + echo " $0 -b -t : build and test" + echo " $0 -b -t -q : build and test (batch mode)" + exit 1 +} -# build codes +function go_batch() +{ + CMD_TXT="$0 -j ${NCORES}" + if [ "$DO_BUILD" = true ] ; then + CMD_TXT="$CMD_TXT -b" + fi + if [ "$DO_TESTS" = true ] ; then + CMD_TXT="$CMD_TXT -t" + fi + echo "starting script in batch mode:" + echo " $CMD_TXT" + echo $CMD_TXT | at now -m + exit 0 +} + +NCORES=`nproc --all` +RUNBATCH=false +DO_BUILD=false +DO_TESTS=false +DISPLAY_USAGE=true -build_CUPyDO -build_waves -build_PFEM -build_Metafor -build_SU2 -build_modali -build_NativeSolid -build_VLM +# -- args +while getopts "j:hbtq" option +do + case $option in + j ) + NCORES=$OPTARG ;; + h ) + usage ;; + q ) + RUNBATCH=true ;; + b ) + DO_BUILD=true ; + DISPLAY_USAGE=false ;; + t ) + DO_TESTS=true ; + DISPLAY_USAGE=false ;; + * ) + echo "[getopts] Bad option: $option" ; exit 1 ;; + esac +done +shift $(($OPTIND - 1)) -# leave CUPyDO main folder -cd .. +if [ "$RUNBATCH" = true ] ; then + go_batch +else + if [ "$DISPLAY_USAGE" = true ] ; then + usage + fi + if [ "$DO_BUILD" = true ] ; then + do_build + fi + if [ "$DO_TESTS" = true ] ; then + do_tests + fi +fi -- GitLab