Skip to content

Commit

Permalink
TST: 2nd set of tests to run using TPF. Still takes a while ~130s loc…
Browse files Browse the repository at this point in the history
…ally
  • Loading branch information
zhang-alvin committed Apr 15, 2020
1 parent bcfdf8b commit 3d854a5
Show file tree
Hide file tree
Showing 11 changed files with 247 additions and 233 deletions.
24 changes: 12 additions & 12 deletions 2d/caissonBreakwater/sliding/tank.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,38 +629,38 @@

# Input checks
if spaceOrder not in [1,2]:
print "INVALID: spaceOrder" + spaceOrder
print("INVALID: spaceOrder" + spaceOrder)
sys.exit()

if useRBLES not in [0.0, 1.0]:
print "INVALID: useRBLES" + useRBLES
print("INVALID: useRBLES" + useRBLES)
sys.exit()

if useMetrics not in [0.0, 1.0]:
print "INVALID: useMetrics"
print("INVALID: useMetrics")
sys.exit()

# Discretization
nd = 2
if spaceOrder == 1:
hFactor=1.0
if useHex:
basis=C0_AffineLinearOnCubeWithNodalBasis
elementQuadrature = CubeGaussQuadrature(nd,3)
elementBoundaryQuadrature = CubeGaussQuadrature(nd-1,3)
basis=C0_AffineLinearOnCubeWithNodalBasis
elementQuadrature = CubeGaussQuadrature(nd,3)
elementBoundaryQuadrature = CubeGaussQuadrature(nd-1,3)
else:
basis=C0_AffineLinearOnSimplexWithNodalBasis
elementQuadrature = SimplexGaussQuadrature(nd,3)
elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,3)
#elementBoundaryQuadrature = SimplexLobattoQuadrature(nd-1,1)
basis=C0_AffineLinearOnSimplexWithNodalBasis
elementQuadrature = SimplexGaussQuadrature(nd,3)
elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,3)
#elementBoundaryQuadrature = SimplexLobattoQuadrature(nd-1,1)
elif spaceOrder == 2:
hFactor=0.5
if useHex:
basis=C0_AffineLagrangeOnCubeWithNodalBasis
basis=C0_AffineLagrangeOnCubeWithNodalBasis
elementQuadrature = CubeGaussQuadrature(nd,4)
elementBoundaryQuadrature = CubeGaussQuadrature(nd-1,4)
else:
basis=C0_AffineQuadraticOnSimplexWithNodalBasis
basis=C0_AffineQuadraticOnSimplexWithNodalBasis
elementQuadrature = SimplexGaussQuadrature(nd,4)
elementBoundaryQuadrature = SimplexGaussQuadrature(nd-1,4)

Expand Down
4 changes: 2 additions & 2 deletions 2d/caissonBreakwater/sliding/tank_so.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
elif '_so.pyc' in name_so[-7:]:
name = name_so[:-7]
else:
raise NameError, 'Split operator module must end with "_so.py"'
raise(NameError, 'Split operator module must end with "_so.py"')

try:
case = __import__(name)
Context.setFromModule(case)
ct = Context.get()
except ImportError:
raise ImportError, str(name) + '.py not found'
raise(ImportError, str(name) + '.py not found')

from proteus import BoundaryConditions

Expand Down
9 changes: 5 additions & 4 deletions 2d/hydraulicStructures/sluice_gate/sluice_gate.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
("gauge_dx", 0.1, "Horizontal spacing of gauges/gauge columns in m"),
("point_gauge_y", 0.09, "Height of point gauge placement in m"),
# refinement
("refinement", 25, "Refinement level he = tank_dim[0]/(4*refinement-1)"),
# use for later testing ("refinement", 25, "Refinement level he = tank_dim[0]/(4*refinement-1)"),
("refinement", 5, "Refinement level he = tank_dim[0]/(4*refinement-1)"),
("cfl", 0.75, "Target cfl"),
("variable_refine_borders", None, "List of vertical borders between "
"refinement regions (include 0 and "
Expand Down Expand Up @@ -101,13 +102,13 @@
applyCorrection = True
# ----- INPUT CHECKS ----- #
if spaceOrder not in [1,2]:
raise ValueError("INVALID: spaceOrder(" + str(spaceOrder) + ")")
raise(ValueError("INVALID: spaceOrder(" + str(spaceOrder) + ")"))

if useRBLES not in [0.0, 1.0]:
raise ValueError("INVALID: useRBLES(" + str(useRBLES) + ")")
raise(ValueError("INVALID: useRBLES(" + str(useRBLES) + ")"))

if useMetrics not in [0.0, 1.0]:
raise ValueError("INVALID: useMetrics(" + str(useMetrics) + ")")
raise(ValueError("INVALID: useMetrics(" + str(useMetrics) + ")"))

# ----- DISCRETIZATION ----- #

Expand Down
4 changes: 2 additions & 2 deletions 2d/hydraulicStructures/sluice_gate/sluice_gate_so.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
elif '_so.pyc' in name_so[-7:]:
name = name_so[:-7]
else:
raise NameError, 'Split operator module must end with "_so.py"'
raise(NameError, 'Split operator module must end with "_so.py"')

try:
case = __import__(name)
Context.setFromModule(case)
ct = Context.get()
except ImportError:
raise ImportError, str(name) + '.py not found'
raise(ImportError, str(name) + '.py not found')


if ct.useOnlyVF:
Expand Down
85 changes: 44 additions & 41 deletions Tests/2nd_set/test_oscillating_cylinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import math
#import importlib
from proteus import defaults
import subprocess

from proteus.defaults import (load_physics as load_p,
load_numerics as load_n,
Expand Down Expand Up @@ -71,47 +72,49 @@ def teardown_method(self,method):


def test_run(self):
from petsc4py import PETSc
pList = []
nList = []
so = load_so('tank_so',modulepath)
for (p,n) in so.pnList:
pList.append(load_p(p,modulepath))
nList.append(load_n(n,modulepath))
if pList[-1].name == None:
pList[-1].name = p
#so = tank_so
so.name = "tank"
if so.sList == []:
for i in range(len(so.pnList)):
s = default_s
so.sList.append(s)
Profiling.logLevel=7
Profiling.verbose=True
# PETSc solver configuration
OptDB = PETSc.Options()
with open(petsc_options) as f:
all = f.read().split()
i = 0
while i < len(all):
if i < len(all)-1:
if all[i+1][0]!='-':
print "setting", all[i].strip(),all[i+1]
OptDB.setValue(all[i].strip('-'),all[i+1])
i = i+2
else:
print "setting", all[i].strip(), "True"
OptDB.setValue(all[i].strip('-'),True)
i = i+1
else:
print "setting", all[i].strip(), "True"
OptDB.setValue(all[i].strip('-'),True)
i= i+1
so.tnList=[0.0,0.001,0.011]
#so.tnList=[0.0,0.001]+[0.001 + i*0.01 for i in range(1,int(round(0.03/0.01))+1)]
ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
ns.calculateSolution('tank')

#from petsc4py import PETSc
#pList = []
#nList = []
#so = load_so('tank_so',modulepath)
#for (p,n) in so.pnList:
# pList.append(load_p(p,modulepath))
# nList.append(load_n(n,modulepath))
# if pList[-1].name == None:
# pList[-1].name = p
##so = tank_so
#so.name = "tank"
#if so.sList == []:
# for i in range(len(so.pnList)):
# s = default_s
# so.sList.append(s)
#Profiling.logLevel=7
#Profiling.verbose=True
## PETSc solver configuration
#OptDB = PETSc.Options()
#with open(petsc_options) as f:
# all = f.read().split()
# i = 0
# while i < len(all):
# if i < len(all)-1:
# if all[i+1][0]!='-':
# print("setting", all[i].strip(),all[i+1])
# OptDB.setValue(all[i].strip('-'),all[i+1])
# i = i+2
# else:
# print("setting", all[i].strip(), "True")
# OptDB.setValue(all[i].strip('-'),True)
# i = i+1
# else:
# print("setting", all[i].strip(), "True")
# OptDB.setValue(all[i].strip('-'),True)
# i= i+1
#so.tnList=[0.0,0.001,0.011]
##so.tnList=[0.0,0.001]+[0.001 + i*0.01 for i in range(1,int(round(0.03/0.01))+1)]
#ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
#ns.calculateSolution('tank')

runCommand = "parun --TwoPhaseFlow --path " +modulepath+" -C \"Tend=0.011\" oscillating_cylinder.py"
subprocess.check_call(runCommand,shell=True)

oscillating_log = NumericResults.create_log('proteus.log')

Expand Down
87 changes: 45 additions & 42 deletions Tests/2nd_set/test_quiescent_water.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@
import collections as cll
import csv
from proteus.test_utils import TestTools
import subprocess

from proteus.defaults import (load_physics as load_p,
load_numerics as load_n,
load_system as load_so)

modulepath = os.path.join(os.path.dirname(os.path.abspath(__file__)),'../../2d/benchmarks/quiescent_water_probe_benchmark')
modulepath = os.path.join(os.path.dirname(os.path.abspath(__file__)),'../../2d/benchmarks/wavesloshing')
petsc_options = os.path.join(os.path.dirname(os.path.abspath(__file__)),"../../inputTemplates/petsc.options.asm")


Expand Down Expand Up @@ -65,48 +66,50 @@ def teardown_method(self,method):


def test_run(self):
from petsc4py import PETSc
pList = []
nList = []
so = load_so('quiescent_water_test_gauges_so',modulepath)
for (p,n) in so.pnList:
pList.append(load_p(p,modulepath))
nList.append(load_n(n,modulepath))
if pList[-1].name == None:
pList[-1].name = p
#so = quiescent_water_test_gauges_so
so.name = "quiescent_water_test_gauges"
if so.sList == []:
for i in range(len(so.pnList)):
s = default_s
so.sList.append(s)
Profiling.logLevel=7
Profiling.verbose=True
# PETSc solver configuration
OptDB = PETSc.Options()
with open(petsc_options) as f:
all = f.read().split()
i=0
while i < len(all):
if i < len(all)-1:
if all[i+1][0]!='-':
print "setting ", all[i].strip(), all[i+1]
OptDB.setValue(all[i].strip('-'),all[i+1])
i=i+2
else:
print "setting ", all[i].strip(), "True"
OptDB.setValue(all[i].strip('-'),True)
i=i+1
else:
print "setting ", all[i].strip(), "True"
OptDB.setValue(all[i].strip('-'),True)
i=i+1
so.tnList=[0.0,0.001,0.011]
#so.tnList=[0.0,0.001]+[0.001 + i*0.01 for i in range(1,int(round(0.03/0.01))+1)]
ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
ns.calculateSolution('quiescent_water_test_gauges')

#from petsc4py import PETSc
#pList = []
#nList = []
#so = load_so('quiescent_water_test_gauges_so',modulepath)
#for (p,n) in so.pnList:
# pList.append(load_p(p,modulepath))
# nList.append(load_n(n,modulepath))
# if pList[-1].name == None:
# pList[-1].name = p
##so = quiescent_water_test_gauges_so
#so.name = "quiescent_water_test_gauges"
#if so.sList == []:
# for i in range(len(so.pnList)):
# s = default_s
# so.sList.append(s)
#Profiling.logLevel=7
#Profiling.verbose=True
## PETSc solver configuration
#OptDB = PETSc.Options()
#with open(petsc_options) as f:
# all = f.read().split()
# i=0
# while i < len(all):
# if i < len(all)-1:
# if all[i+1][0]!='-':
# print "setting ", all[i].strip(), all[i+1]
# OptDB.setValue(all[i].strip('-'),all[i+1])
# i=i+2
# else:
# print "setting ", all[i].strip(), "True"
# OptDB.setValue(all[i].strip('-'),True)
# i=i+1
# else:
# print "setting ", all[i].strip(), "True"
# OptDB.setValue(all[i].strip('-'),True)
# i=i+1
#so.tnList=[0.0,0.001,0.011]
##so.tnList=[0.0,0.001]+[0.001 + i*0.01 for i in range(1,int(round(0.03/0.01))+1)]
#ns = NumericalSolution.NS_base(so,pList,nList,so.sList,opts)
#ns.calculateSolution('quiescent_water_test_gauges')

runCommand = "parun --TwoPhaseFlow --path " +modulepath+" -C \"T=0.011 amplitude=0.0 he=0.01\" wavesloshing.py"
subprocess.check_call(runCommand,shell=True)

quiescent_log = NumericResults.create_log('proteus.log')

text = quiescent_log.read()
Expand Down
Loading

0 comments on commit 3d854a5

Please sign in to comment.