diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index be8ec8a1..425ae77a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,7 @@ jobs: os: ['ubuntu-latest'] defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} working-directory: ${{github.workspace}} steps: - uses: actions/checkout@v4 @@ -67,7 +67,7 @@ jobs: os: ['ubuntu-latest', 'macos-latest'] defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} working-directory: ${{github.workspace}} steps: @@ -106,7 +106,7 @@ jobs: os: ['ubuntu-latest', 'macos-latest'] defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} working-directory: ${{github.workspace}} steps: @@ -119,7 +119,7 @@ jobs: cache: true cache-write: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} - - name: Formatting and sorting import + - name: Test run: | pixi run test @@ -133,7 +133,7 @@ jobs: os: ['ubuntu-latest'] defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} working-directory: ${{github.workspace}} steps: - uses: actions/checkout@v4 @@ -172,7 +172,7 @@ jobs: os: ['ubuntu-22.04'] defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} working-directory: ${{github.workspace}} steps: - uses: actions/checkout@v4 @@ -205,58 +205,47 @@ jobs: cd OFsolvers/OF9/birdmultiphaseEulerFoam export WM_COMPILE_OPTION=Debug ./Allwmake - cd ../../../ - name: Run deckwer17 PBE run: | cd experimental_cases/OF9/deckwer17 bash run.sh - cd ../../../ - name: Run deckwer17 constantD run: | cd experimental_cases/OF9/deckwer17 cp constant/phaseProperties_constantd constant/phaseProperties bash run.sh - cd ../../../ - name: Run deckwer19 PBE run: | cd experimental_cases/OF9/deckwer19 bash run.sh - cd ../../../ - name: Run side sparger tutorial run: | cd tutorial_cases/OF9/side_sparger bash run.sh - cd ../../../ - name: Run bubble column tutorial run: | cd tutorial_cases/OF9/bubble_column_20L bash run.sh - cd ../../../ - name: Run stirred-tank tutorial run: | cd tutorial_cases/OF9/stirred_tank bash run.sh - cd ../../../ - name: Run reactive loop reactor tutorial run: | cd tutorial_cases/OF9/loop_reactor_reacting bash run.sh - cd ../../../ - name: Run mixing loop reactor tutorial run: | cd tutorial_cases/OF9/loop_reactor_mixing bash run.sh - cd ../../../ - name: Run airlift reactor tutorial run: | cd tutorial_cases/OF9/airlift_40m bash run.sh - cd ../../../ - name: Run flat panel reactor tutorial run: | cd tutorial_cases/OF9/FlatPanel_250L_ASU bash run.sh - cd ../../../ Regression-Test-OF13: name: Regression-Test-OF13 (${{ matrix.python-version }}, ${{ matrix.os }}) @@ -268,7 +257,7 @@ jobs: os: ['ubuntu-22.04'] defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} working-directory: ${{github.workspace}} steps: - uses: actions/checkout@v4 @@ -301,25 +290,21 @@ jobs: cd OFsolvers/OF13/birdmultiphaseEuler export WM_COMPILE_OPTION=Debug ./Allwmake - cd ../../../ - name: Run bubble column run: | cd tutorial_cases/OF13/bubble_column ./Allrun --test - cd ../../../ - name: STR MRF run: | cd tutorial_cases/OF13/STR_MRF ./Allrun --test - cd ../../../ - name: STR rotating mesh run: | cd tutorial_cases/OF13/STR_rotatingMesh ./Allrun --test - cd ../../../ - Regression-Test-OF-pixi: - name: Regression-Test-OF-pixi (${{ matrix.os }}) + Regression-Test-OF9-pixi: + name: Regression-Test-OF9-pixi (${{ matrix.os }}) runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -327,7 +312,7 @@ jobs: os: ['ubuntu-22.04'] defaults: run: - shell: bash -l {0} + shell: bash -leo pipefail {0} working-directory: ${{github.workspace}} steps: - uses: actions/checkout@v4 @@ -345,10 +330,8 @@ jobs: cd OFsolvers/OF9/birdmultiphaseEulerFoam export WM_COMPILE_OPTION=Debug ./Allwmake - cd ../../../ - name: Run bubble column tutorial run: | cd tutorial_cases/OF9/bubble_column_20L bash run_pixi.sh - cd ../../../ diff --git a/bird/meshing/stirred_tank_mesh.py b/bird/meshing/stirred_tank_mesh.py index 91c5a960..9b755dbd 100644 --- a/bird/meshing/stirred_tank_mesh.py +++ b/bird/meshing/stirred_tank_mesh.py @@ -11,7 +11,7 @@ def get_reactor_geom(yamlfile): def write_ofoam_preamble(outfile, react): outfile.write( - r"/*--------------------------------*- C++ -*----------------------------------*\\\n" + "/*--------------------------------*- C++ -*----------------------------------*\\\n" ) outfile.write( "| ========= | |\n" @@ -29,7 +29,7 @@ def write_ofoam_preamble(outfile, react): "| \\/ M anipulation | |\n" ) outfile.write( - r"\*---------------------------------------------------------------------------*/\n" + "/*---------------------------------------------------------------------------*/\n" ) outfile.write("FoamFile\n") outfile.write("{\n") @@ -39,18 +39,18 @@ def write_ofoam_preamble(outfile, react): outfile.write("\tobject blockMeshDict;\n") outfile.write("}\n\n") outfile.write( - r"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n\n" + "// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n\n" ) outfile.write("convertToMeters 1.0;\n\n") outfile.write( - r"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n\n" + "// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n\n" ) def write_vertices(outfile, react): outfile.write( "\n" - + r"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //" + + "// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //" + "\n" ) outfile.write("vertices\n(\n") @@ -166,7 +166,7 @@ def write_edges(outfile, react): reacthts = react.reacthts outfile.write( - r"\n// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n" + "\n// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n" ) outfile.write("edges\n(\n") @@ -204,7 +204,7 @@ def write_edges(outfile, react): def write_blocks(outfile, react): outfile.write( - r"\n// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n" + "\n// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //\n" ) outfile.write("blocks\n(\n") @@ -326,7 +326,7 @@ def write_patches(outfile, react): outfile.write( "\n" - + r"// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //" + + "// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //" + "\n" ) outfile.write("patches\n(\n") diff --git a/experimental_cases/OF9/deckwer17/run.sh b/experimental_cases/OF9/deckwer17/run.sh index 2386dc85..9c064c1d 100755 --- a/experimental_cases/OF9/deckwer17/run.sh +++ b/experimental_cases/OF9/deckwer17/run.sh @@ -7,20 +7,21 @@ else ./Allclean fi -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR - +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR if ! type "python" &> /dev/null; then echo " could not be found" echo "Skipping Mesh generation" else # Generate blockmeshDict - python ../../applications/write_block_cyl_mesh.py -i ../../bird/meshing/block_cyl_mesh_templates/coflowing/input.json -t ../../bird/meshing/block_cyl_mesh_templates/coflowing/topology.json -o system + python ../../../applications/write_block_cyl_mesh.py -i ../../../bird/meshing/block_cyl_mesh_templates/coflowing/input.json -t ../../../bird/meshing/block_cyl_mesh_templates/coflowing/topology.json -o system # Generate species thermo properties - python ../../applications/write_species_thermo_prop.py -cf . + python ../../../applications/write_species_thermo_prop.py -cf . fi diff --git a/experimental_cases/OF9/deckwer19/run.sh b/experimental_cases/OF9/deckwer19/run.sh index d93e02c2..ba0884c3 100755 --- a/experimental_cases/OF9/deckwer19/run.sh +++ b/experimental_cases/OF9/deckwer19/run.sh @@ -1,7 +1,10 @@ #!/bin/bash -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR + +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR if ! type "blockMesh" &> /dev/null; then echo " could not be found" @@ -16,10 +19,10 @@ if ! type "python" &> /dev/null; then echo "Skipping Mesh generation" else # Generate blockmeshDict - python ../../applications/write_block_cyl_mesh.py -i ../../bird/meshing/block_cyl_mesh_templates/coflowing/input.json -t ../../bird/meshing/block_cyl_mesh_templates/coflowing/topology.json -o system + python ../../../applications/write_block_cyl_mesh.py -i ../../../bird/meshing/block_cyl_mesh_templates/coflowing/input.json -t ../../../bird/meshing/block_cyl_mesh_templates/coflowing/topology.json -o system # Generate species thermo properties - python ../../applications/write_species_thermo_prop.py -cf . + python ../../../applications/write_species_thermo_prop.py -cf . fi diff --git a/tutorial_cases/OF9/FlatPanel_250L_ASU/presteps.sh b/tutorial_cases/OF9/FlatPanel_250L_ASU/presteps.sh index d1a0cf4c..d1cd43df 100644 --- a/tutorial_cases/OF9/FlatPanel_250L_ASU/presteps.sh +++ b/tutorial_cases/OF9/FlatPanel_250L_ASU/presteps.sh @@ -1,7 +1,9 @@ #!/bin/bash -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR cp -r 0.orig 0 m4 ./system/panel.m4 > ./system/blockMeshDict diff --git a/tutorial_cases/OF9/airlift_40m/presteps.sh b/tutorial_cases/OF9/airlift_40m/presteps.sh index 9e615bf8..48cbc50d 100644 --- a/tutorial_cases/OF9/airlift_40m/presteps.sh +++ b/tutorial_cases/OF9/airlift_40m/presteps.sh @@ -1,7 +1,9 @@ #!/bin/bash -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR m4 system/conc_cylinder_mesh.m4 > system/blockMeshDict rm -rf 0 diff --git a/tutorial_cases/OF9/bubble_column_20L/run.sh b/tutorial_cases/OF9/bubble_column_20L/run.sh index e9583c21..fc94b4b2 100755 --- a/tutorial_cases/OF9/bubble_column_20L/run.sh +++ b/tutorial_cases/OF9/bubble_column_20L/run.sh @@ -3,20 +3,22 @@ # Clean case ./Allclean -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR echo PRESTEP 1 # Generate blockmeshDict -python ../../applications/write_block_cyl_mesh.py -i system/mesh.json -t system/topology.json -o system +python ../../../applications/write_block_cyl_mesh.py -i system/mesh.json -t system/topology.json -o system # Generate boundary stl -python ../../applications/write_stl_patch.py -i system/inlets_outlets.json +python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json # Generate species thermo properties -python ../../applications/write_species_thermo_prop.py -cf . +python ../../../applications/write_species_thermo_prop.py -cf . echo PRESTEP 2 @@ -27,7 +29,8 @@ transformPoints "scale=(0.001 0.001 0.001)" # Inlet BC surfaceToPatch -tol 1e-3 inlets.stl -export newmeshdir=$(foamListTimes -latestTime) +newmeshdir=$(foamListTimes -latestTime) +export newmeshdir rm -rf constant/polyMesh/ cp -r $newmeshdir/polyMesh ./constant rm -rf $newmeshdir diff --git a/tutorial_cases/OF9/bubble_column_20L/run_pixi.sh b/tutorial_cases/OF9/bubble_column_20L/run_pixi.sh index 7794f5cb..377d1d04 100755 --- a/tutorial_cases/OF9/bubble_column_20L/run_pixi.sh +++ b/tutorial_cases/OF9/bubble_column_20L/run_pixi.sh @@ -10,13 +10,13 @@ trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR echo PRESTEP 1 # Generate blockmeshDict -pixi run python ../../applications/write_block_cyl_mesh.py -i system/mesh.json -t system/topology.json -o system +pixi run python ../../../applications/write_block_cyl_mesh.py -i system/mesh.json -t system/topology.json -o system # Generate boundary stl -pixi run python ../../applications/write_stl_patch.py -i system/inlets_outlets.json +pixi run python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json # Generate species thermo properties -pixi run python ../../applications/write_species_thermo_prop.py -cf . +pixi run python ../../../applications/write_species_thermo_prop.py -cf . echo PRESTEP 2 diff --git a/tutorial_cases/OF9/loop_reactor_mixing/run.sh b/tutorial_cases/OF9/loop_reactor_mixing/run.sh index 25251599..51543c76 100644 --- a/tutorial_cases/OF9/loop_reactor_mixing/run.sh +++ b/tutorial_cases/OF9/loop_reactor_mixing/run.sh @@ -5,23 +5,25 @@ #source /projects/gas2fuels/ofoam_cray_mpich/OpenFOAM-dev/etc/bashrc ./Allclean -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR echo PRESTEP 1 # Generate blockmeshDict -python ../../applications/write_block_rect_mesh.py -i system/mesh.json -o system +python ../../../applications/write_block_rect_mesh.py -i system/mesh.json -o system # Generate boundary stl -python ../../applications/write_stl_patch.py -i system/inlets_outlets.json +python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json # Generate mixers -python ../../applications/write_dynMix_fvModels.py -fs -i system/mixers.json -o constant +python ../../../applications/write_dynMix_fvModels.py -fs -i system/mixers.json -o constant # Generate species thermo properties -python ../../applications/write_species_thermo_prop.py -cf . +python ../../../applications/write_species_thermo_prop.py -cf . echo PRESTEP 2 # Mesh gen @@ -29,7 +31,8 @@ blockMesh -dict system/blockMeshDict # Inlet BC surfaceToPatch -tol 1e-3 inlets.stl -export newmeshdir=$(foamListTimes -latestTime) +newmeshdir=$(foamListTimes -latestTime) +export newmeshdir rm -rf constant/polyMesh/ cp -r $newmeshdir/polyMesh ./constant rm -rf $newmeshdir @@ -39,7 +42,8 @@ cat /tmp/boundary > constant/polyMesh/boundary # Outlet BC surfaceToPatch -tol 1e-3 outlets.stl -export newmeshdir=$(foamListTimes -latestTime) +newmeshdir=$(foamListTimes -latestTime) +export newmeshdir rm -rf constant/polyMesh/ cp -r $newmeshdir/polyMesh ./constant rm -rf $newmeshdir diff --git a/tutorial_cases/OF9/loop_reactor_reacting/run.sh b/tutorial_cases/OF9/loop_reactor_reacting/run.sh index c2edc9ab..f09790fc 100644 --- a/tutorial_cases/OF9/loop_reactor_reacting/run.sh +++ b/tutorial_cases/OF9/loop_reactor_reacting/run.sh @@ -3,26 +3,29 @@ # Clean case ./Allclean -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR # Generate blockmeshDict -python ../../applications/write_block_rect_mesh.py -i system/mesh.json -o system +python ../../../applications/write_block_rect_mesh.py -i system/mesh.json -o system # Generate boundary stl -python ../../applications/write_stl_patch.py -i system/inlets_outlets.json +python ../../../applications/write_stl_patch.py -i system/inlets_outlets.json # Generate species thermo properties -python ../../applications/write_species_thermo_prop.py -cf . +python ../../../applications/write_species_thermo_prop.py -cf . # Mesh gen blockMesh -dict system/blockMeshDict # Inlet BC surfaceToPatch -tol 1e-3 inlets.stl -export newmeshdir=$(foamListTimes -latestTime) +newmeshdir=$(foamListTimes -latestTime) +export newmeshdir rm -rf constant/polyMesh/ cp -r $newmeshdir/polyMesh ./constant rm -rf $newmeshdir @@ -32,7 +35,8 @@ cat /tmp/boundary > constant/polyMesh/boundary # Outlet BC surfaceToPatch -tol 1e-3 outlets.stl -export newmeshdir=$(foamListTimes -latestTime) +newmeshdir=$(foamListTimes -latestTime) +export newmeshdir rm -rf constant/polyMesh/ cp -r $newmeshdir/polyMesh ./constant rm -rf $newmeshdir diff --git a/tutorial_cases/OF9/side_sparger/run.sh b/tutorial_cases/OF9/side_sparger/run.sh index 6e0cc5a6..5e24c8d7 100755 --- a/tutorial_cases/OF9/side_sparger/run.sh +++ b/tutorial_cases/OF9/side_sparger/run.sh @@ -7,9 +7,11 @@ else ./Allclean fi -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR if ! type "python" &> /dev/null; then @@ -18,10 +20,10 @@ if ! type "python" &> /dev/null; then else BIRD_DIR=`python -c "import bird; print(bird.BIRD_DIR)"` # Generate blockmeshDict - python ../../applications/write_block_cyl_mesh.py -i ../../bird/meshing/block_cyl_mesh_templates/sideSparger/input.json -t ../../bird/meshing/block_cyl_mesh_templates/sideSparger/topology.json -o system + python ../../../applications/write_block_cyl_mesh.py -i ../../../bird/meshing/block_cyl_mesh_templates/sideSparger/input.json -t ../../../bird/meshing/block_cyl_mesh_templates/sideSparger/topology.json -o system # Generate species thermo properties - python ../../applications/write_species_thermo_prop.py -cf . + python ../../../applications/write_species_thermo_prop.py -cf . fi diff --git a/tutorial_cases/OF9/stirred_tank/run.sh b/tutorial_cases/OF9/stirred_tank/run.sh index 454a3bd1..78c85b06 100644 --- a/tutorial_cases/OF9/stirred_tank/run.sh +++ b/tutorial_cases/OF9/stirred_tank/run.sh @@ -7,9 +7,11 @@ else ./Allclean fi -set -e # Exit on any error -# Define what to do on error -trap 'echo "ERROR: Something failed! Running cleanup..."; ./Allclean' ERR +set -Eeuo pipefail # -E: trap also fires inside functions/subshells +trap 'exit_code=$? + echo "ERROR: Something failed! Running cleanup..." + ./Allclean || true + exit $exit_code' ERR if ! type "python" &> /dev/null; then @@ -17,10 +19,10 @@ if ! type "python" &> /dev/null; then echo "Skipping Mesh generation" else # Generate blockmeshDict - python ../../applications/write_stirred_tank_mesh.py -i ../../bird/meshing/stirred_tank_mesh_templates/base_tank/tank_par.yaml -o system/blockMeshDict + python -W error::SyntaxWarning ../../../applications/write_stirred_tank_mesh.py -i ../../../bird/meshing/stirred_tank_mesh_templates/base_tank/tank_par.yaml -o system/blockMeshDict # Generate species thermo properties - # python ../../applications/write_species_thermo_prop.py -cf . + # python ../../../applications/write_species_thermo_prop.py -cf . fi