|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# This script prepares and runs all the participants in one terminal, in serial, |
| 4 | +# in parallel (MPI), |
| 5 | +# forwarding the solvers' output to log files. |
| 6 | +# Alternatively, you may execute the scripts "runSolid" and "runFluid" |
| 7 | +# in separate terminals. |
| 8 | + |
| 9 | +# The script "Allclean" cleans-up the result and log files. |
| 10 | + |
| 11 | +# Participant 1: Fluid |
| 12 | +Participant1="Fluid" |
| 13 | +Solver1="buoyantPimpleFoam" |
| 14 | + |
| 15 | + # Prepare |
| 16 | + echo "Preparing the ${Participant1} participant..." |
| 17 | + blockMesh -case ${Participant1} > ${Participant1}_blockMesh.log 2>&1 |
| 18 | + checkMesh -case ${Participant1} > ${Participant1}_checkMesh.log 2>&1 |
| 19 | + |
| 20 | + # Decompose the mesh |
| 21 | + decomposePar -case ${Participant1} > ${Participant1}_decomposePar.log 2>&1 |
| 22 | + |
| 23 | + # Run and get the process id |
| 24 | + echo "Starting the ${Participant1} participant..." |
| 25 | + mpirun -np 2 ${Solver1} -parallel -case ${Participant1} > ${Participant1}.log 2>&1 & |
| 26 | + PIDParticipant1=$! |
| 27 | + |
| 28 | +# Participant 2: Solid |
| 29 | +Participant2="Solid" |
| 30 | +Solver2="laplacianFoam" |
| 31 | + |
| 32 | + # Run and get the process id |
| 33 | + echo "Starting the ${Participant2} participant..." |
| 34 | + mpirun -np 2 python3 Solid/heat.py > ${Participant2}.log 2>&1 & |
| 35 | + PIDParticipant2=$! |
| 36 | + |
| 37 | +# Wait for all the participants to finish |
| 38 | +echo "Waiting for the participants to exit..." |
| 39 | +echo "(you may run 'tail -f ${Participant1}.log' in another terminal to check the progress)" |
| 40 | +wait ${PIDParticipant1} |
| 41 | +wait ${PIDParticipant2} |
| 42 | +if [ $? -ne 0 ] || [ "$(grep -c -E "error:" ${Participant1}.log)" -ne 0 ] || [ "$(grep -c -E "error:" ${Participant2}.log)" -ne 0 ]; then |
| 43 | + echo "" |
| 44 | + echo "Something went wrong... See the log files for more." |
| 45 | +else |
| 46 | + echo "" |
| 47 | + echo "The simulation completed!" |
| 48 | + |
| 49 | + # Reconstruct the cases |
| 50 | + echo "Reconstructing case ${Participant1}..." |
| 51 | + reconstructPar -case ${Participant1} > ${Participant1}_reconstructPar.log 2>&1 |
| 52 | + echo "Reconstructing case ${Participant2}..." |
| 53 | + reconstructPar -case ${Participant2} > ${Participant2}_reconstructPar.log 2>&1 |
| 54 | + |
| 55 | + echo "You may now open '${Participant1}/${Participant1}.foam' and '${Participant2}/${Participant2}.foam' in ParaView." |
| 56 | + # Note: ".foam" triggers the native OpenFOAM reader of ParaView. |
| 57 | + # Change to ".OpenFOAM" to use the OpenFOAM reader provided with OpenFOAM. |
| 58 | +fi |
0 commit comments