Skip to content

Commit

Permalink
Add python time stepper
Browse files Browse the repository at this point in the history
  • Loading branch information
uvilla committed Jul 27, 2023
1 parent 0d85a52 commit 3291e2e
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
36 changes: 36 additions & 0 deletions src/tps-time-loop.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3
import sys
import os

from mpi4py import MPI

# set path to C++ TPS library
path = os.path.abspath(os.path.dirname(sys.argv[0]))
sys.path.append(path + "/.libs")
import libtps as tps

comm = MPI.COMM_WORLD
# TPS solver
tps = tps.Tps(comm)

tps.parseCommandLineArgs(sys.argv)
tps.parseInput()
tps.chooseDevices()
tps.chooseSolver()
tps.initialize()


it = 0
max_iters = tps.getRequiredInput("flow/maxIters")
print("Max Iters: ", max_iters)
tps.solveBegin()

while it < max_iters:
tps.solveStep()
it = it+1
print("it, ", it)

tps.solveEnd()


sys.exit (tps.getStatus())
1 change: 1 addition & 0 deletions src/tps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
tps.parseInput()
tps.chooseDevices()
tps.chooseSolver()
tps.initialize()
tps.solve()

sys.exit (tps.getStatus())
6 changes: 4 additions & 2 deletions test/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ EXTRA_DIST = tap-driver.sh test_tps_splitcomm.py soln_differ inputs meshes
inflow_outflow.test mms.ternary_2d.test mms.ternary_2d_wall.test \
mms.ternary_2d_inout.test cuda-memcheck.test mms.general_wall.test \
independent_coupling.test interp_em.test mms.euler_2d.test mms.cns_2d.test \
gradient.test coupled-3d.test coupled-3d.splitcomm.test tabulated.test lte_mixture.test distance_fcn.test \
gradient.test coupled-3d.test coupled-3d.splitcomm.test coupled-3d.py-loop.test \
tabulated.test lte_mixture.test distance_fcn.test \
sgsSmag.test sgsSigma.test plate.test pipe.mix.test

TESTS = vpath.sh
Expand Down Expand Up @@ -91,7 +92,8 @@ TESTS += cyl3d.test \

if PYTHON_ENABLED
TESTS += cyl3d.python.test \
cyl3d.python.splitcomm.test
cyl3d.python.splitcomm.test \
coupled-3d.py-loop.test
endif

endif
Expand Down
21 changes: 21 additions & 0 deletions test/coupled-3d.py-loop.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!./bats
# -*- mode: sh -*-

TEST="coupling/cycle-avg-joule-coupling-py-loop"
RUNFILE="inputs/coupled-3d.ini"
EXE="../src/tps-time-loop.py"

setup() {
SOLN_FILE=restart_output-coupled-3d.sol.h5
REF_FILE=ref_solns/coupled-3d.sol.h5
}

@test "[$TEST] verify tps runs in cylce-avg-joule-coupling mode (3D)" {
test -s $RUNFILE
mpirun -np 2 $EXE --runFile $RUNFILE

test -s $SOLN_FILE
test -s $REF_FILE

./soln_differ -r $SOLN_FILE $REF_FILE
}
2 changes: 1 addition & 1 deletion test/vpath.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [ ! -d ref_solns ];then
fi

# necessary binaries
binaries="bats die.sh soln_differ ../src/tps.py ../test/test_tps_splitcomm.py"
binaries="bats die.sh soln_differ ../src/tps.py ../src/tps-time-loop.py ../test/test_tps_splitcomm.py"
for binary in $binaries; do
if [ ! -x $binary ];then
if [ -x $testDir/$binary ];then
Expand Down

0 comments on commit 3291e2e

Please sign in to comment.