-
Notifications
You must be signed in to change notification settings - Fork 0
/
remote-solve.py
58 lines (39 loc) · 1.5 KB
/
remote-solve.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
from scipy import *
import ndsolver
import os, time
def debug_output(something):
f = open("debug.log",'a')
f.write("[%s] - " % time.ctime() + something + "\n")
f.close()
def clear_debug():
open("debug.log",'w')
debug_output( "task started for %s %s" % (task_path, str(dP) ) )
debug_output( "ndsolver in locals(): " + str("ndsolver" in locals()) )
# When we use this module the following must be pushed:
# S, max_div, dP
have_necessary_varibles = ("S" in locals()
and "max_div" in locals()
and "dP" in locals())
debug_output("Have necessary varibles: " + str(have_necessary_varibles) )
if not have_necessary_varibles:
raise ValueError("The variables S, max_div, and dP must be 'pushed' to this script.")
# when we use this module the following may be pushed:
# P, u, v
debug_output( "Setting up Solver . . ." )
sol = ndsolver.Solver(S, dP, dbcallback = debug_output)
debug_output( "Solver Instanciated: " + str("sol" in locals()) )
debug_output("Starting solver")
sol.converge(stopping_div = max_div)
sol.regrid()
P = array( sol.P )
vgrids = [ array(v) for v in sol.V_GRIDS]
meta = sol.getMetaDict()
sol.nuke_all_trilinos()
del sol
meta['Solver'] = "ip-parallel"
return_vals_in_locals = ( "P" in locals() and
"vgrids" in locals() and
"meta" in locals() )
debug_output("Return vals in locals:" + str(return_vals_in_locals) )
debug_output("Finished!")
debug_output("*" * 10)