Skip to content

Commit 9f36045

Browse files
Add run scripts and fix .gitignore.
1 parent fefaac8 commit 9f36045

File tree

6 files changed

+197
-0
lines changed

6 files changed

+197
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
*.log
22
Solid/VTK
3+
Fluid/*
4+
!Fluid/0
5+
!Fluid/constant
6+
!Fluid/system
7+
!Fluid/Fluid.foam
38
out
49
*.txt
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#!/bin/sh
2+
cd ${0%/*} || exit 1 # Run from this directory
3+
4+
echo "Cleaning..."
5+
6+
# Source tutorial clean functions
7+
. $WM_PROJECT_DIR/bin/tools/CleanFunctions
8+
9+
# Participant 1: Fluid
10+
Participant1="Fluid"
11+
cd ${Participant1}
12+
# Clean the case
13+
cleanCase
14+
# Create an empty .foam file for ParaView
15+
# Note: ".foam" triggers the native OpenFOAM reader of ParaView.
16+
# Change to ".OpenFOAM" to use the OpenFOAM reader provided with OpenFOAM.
17+
touch ${Participant1}.foam
18+
cd ..
19+
# Remove the log files
20+
rm -fv ${Participant1}_blockMesh.log
21+
rm -fv ${Participant1}_checkMesh.log
22+
rm -fv ${Participant1}_decomposePar.log
23+
rm -fv ${Participant1}.log
24+
rm -fv ${Participant1}_reconstructPar.log
25+
26+
# Participant 2: Solid
27+
Participant2="Solid"
28+
cd ${Participant2}
29+
# Clean the case
30+
cleanCase
31+
# Create an empty .foam file for ParaView
32+
# Note: ".foam" triggers the native OpenFOAM reader of ParaView.
33+
# Change to ".OpenFOAM" to use the OpenFOAM reader provided with OpenFOAM.
34+
touch ${Participant2}.foam
35+
cd ..
36+
# Remove the log files
37+
rm -fv ${Participant2}_blockMesh.log
38+
rm -fv ${Participant2}_checkMesh.log
39+
rm -fv ${Participant2}_decomposePar.log
40+
rm -fv ${Participant2}.log
41+
rm -fv ${Participant2}_reconstructPar.log
42+
43+
# Remove the preCICE-related log files
44+
echo "Deleting the preCICE log files..."
45+
rm -fv \
46+
precice-*.log \
47+
precice-*-events.json
48+
49+
# Output files for preCICE versions before 1.2:
50+
rm -fv \
51+
iterations-${Participant1}.txt iterations-${Participant2}.txt \
52+
convergence-${Participant1}.txt convergence-${Participant2}.txt \
53+
Events-${Participant1}.log Events-${Participant2}.log \
54+
EventTimings-${Participant1}.log EventTimings-${Participant2}.log
55+
56+
# Remove the preCICE address files
57+
rm -rfv precice-run
58+
rm -fv .*.address
59+
60+
echo "Cleaning complete!"
61+
#------------------------------------------------------------------------------
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
3+
# This script prepares and runs all the participants in one terminal,
4+
# forwarding the solvers' output to log files.
5+
# Alternatively, you may execute the scripts "runSolid" and "runFluid"
6+
# in separate terminals.
7+
8+
# The script "Allclean" cleans-up the result and log files.
9+
10+
# Participant 1: Fluid
11+
Participant1="Fluid"
12+
Solver1="buoyantPimpleFoam"
13+
14+
# Prepare
15+
echo "Preparing the ${Participant1} participant..."
16+
blockMesh -case ${Participant1} > ${Participant1}_blockMesh.log 2>&1
17+
checkMesh -case ${Participant1} > ${Participant1}_checkMesh.log 2>&1
18+
19+
# Run and get the process id
20+
echo "Starting the ${Participant1} participant..."
21+
${Solver1} -case ${Participant1} > ${Participant1}.log 2>&1 &
22+
PIDParticipant1=$!
23+
24+
# Participant 2: Solid
25+
Participant2="Solid"
26+
Solver2="laplacianFoam"
27+
28+
# Run and get the process id
29+
echo "Starting the ${Participant2} participant..."
30+
python3 Solid/heat.py > ${Participant2}.log 2>&1 &
31+
PIDParticipant2=$!
32+
33+
# Wait for all the participants to finish
34+
echo "Waiting for the participants to exit..."
35+
echo "(you may run 'tail -f ${Participant1}.log' in another terminal to check the progress)"
36+
wait ${PIDParticipant1}
37+
wait ${PIDParticipant2}
38+
if [ $? -ne 0 ] || [ "$(grep -c -E "error:" ${Participant1}.log)" -ne 0 ] || [ "$(grep -c -E "error:" ${Participant2}.log)" -ne 0 ]; then
39+
echo ""
40+
echo "Something went wrong... See the log files for more."
41+
else
42+
echo ""
43+
echo "The simulation completed!"
44+
echo "You may now open '${Participant1}/${Participant1}.foam' and '${Participant2}/${Participant2}.foam' in ParaView."
45+
# Note: ".foam" triggers the native OpenFOAM reader of ParaView.
46+
# Change to ".OpenFOAM" to use the OpenFOAM reader provided with OpenFOAM.
47+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
# Fluid participant
4+
5+
# Run this script in one terminal and the "runSolid" script in another terminal.
6+
# These scripts present how the two participants would be started manually.
7+
# Alternatively, you may execute the "Allrun" script in one terminal.
8+
9+
# The script "Allclean" cleans-up the result and log files.
10+
11+
# Prepare
12+
blockMesh -case Fluid
13+
14+
# Run
15+
buoyantPimpleFoam -case Fluid
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# Solid participant
4+
5+
# Run this script in one terminal and the "runFluid" script in another terminal.
6+
# These scripts present how the two participants would be started manually.
7+
# Alternatively, you may execute the "Allrun" script in one terminal.
8+
9+
# The script "Allclean" cleans-up the result and log files.
10+
11+
python3 Solid/heat.py

0 commit comments

Comments
 (0)