Skip to content

Commit

Permalink
Merge 28ecce0 into 9426db9
Browse files Browse the repository at this point in the history
  • Loading branch information
mandli committed Nov 12, 2014
2 parents 9426db9 + 28ecce0 commit f28efeb
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
9 changes: 7 additions & 2 deletions examples/shallow_1d/sill.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy
from clawpack import riemann

def setup(use_petsc=False, outdir='./_output', solver_type='classic'):
def setup(kernel_language='Python',use_petsc=False, outdir='./_output', solver_type='classic'):

if use_petsc:
import clawpack.petclaw as pyclaw
Expand Down Expand Up @@ -56,10 +56,15 @@ def setup(use_petsc=False, outdir='./_output', solver_type='classic'):
claw.tfinal = 1.0
claw.solution = pyclaw.Solution(state, domain)
claw.solver = solver
claw.outdir = outdir
claw.setplot = setplot
claw.write_aux_init = True

if outdir is not None:
claw.outdir = outdir
else:
claw.output_format = None


return claw


Expand Down
41 changes: 41 additions & 0 deletions examples/shallow_1d/test_sill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python
# encoding: utf-8

def test_1d_sill():
"""test_1d_sill
tests against expected classic solution of shallow water equations over
a sill."""

import sill

def verify_expected(expected):
""" given an expected value, returns a verification function """
def sill_verify(claw):
from clawpack.pyclaw.util import check_diff
import numpy as np

q0 = claw.frames[0].state.get_q_global()
qfinal = claw.frames[claw.num_output_times].state.get_q_global()

if q0 != None and qfinal != None:
dx = claw.solution.domain.grid.delta[0]
test = dx * np.linalg.norm(qfinal - q0, 1)
return check_diff(expected, test, reltol=1e-4)
else:
return
return sill_verify

from clawpack.pyclaw.util import gen_variants
classic_tests = gen_variants(sill.setup, verify_expected(4.04169269142e-4),
kernel_languages=["Python"],
solver_type='classic',
outdir=None)

from itertools import chain
for test in chain(classic_tests):
yield test

if __name__=='__main__':
import nose
nose.main()

0 comments on commit f28efeb

Please sign in to comment.