Skip to content

Commit 1ec4f7b

Browse files
committed
added hook, fixed pep8 testing
1 parent a9db7d2 commit 1ec4f7b

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from __future__ import division
2+
from pySDC.core.Hooks import hooks
3+
4+
5+
class error_output(hooks):
6+
"""
7+
Hook class to add output of error
8+
"""
9+
10+
def post_iteration(self, step, level_number):
11+
"""
12+
Default routine called after each iteration
13+
Args:
14+
step: the current step
15+
level_number: the current level number
16+
"""
17+
18+
super(error_output, self).post_iteration(step, level_number)
19+
20+
# some abbreviations
21+
L = step.levels[level_number]
22+
P = L.prob
23+
24+
L.sweep.compute_end_point()
25+
26+
uex = P.u_exact(step.time + step.dt)
27+
err = abs(uex - L.uend)
28+
29+
print('--- Current error (vs. exact solution) at iteration %2i and time %4.2f: %6.4e' %
30+
(step.status.iter, step.time, err))

pySDC/playgrounds/PinT_Workshop_2017/play_with_me.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def main():
6363
Tend = 4.0
6464

6565
# instantiate controller
66-
controller = allinclusive_multigrid_nonMPI(num_procs=16, controller_params=controller_params,
66+
controller = allinclusive_multigrid_nonMPI(num_procs=1, controller_params=controller_params,
6767
description=description)
6868

6969
# get initial values on finest level
@@ -73,6 +73,8 @@ def main():
7373
# call main function to get things done...
7474
uend, stats = controller.run(u0=uinit, t0=t0, Tend=Tend)
7575

76+
# The following is used only for statistics and output, the main show is over now..
77+
7678
# compute exact solution and compare
7779
uex = P.u_exact(Tend)
7880
err = abs(uex - uend)

pySDC/tests/test_pep8.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import nose.tools
55
import pep8
66

7-
BASE_PATH = os.path.abspath(os.path.join(__file__, '..', '..'))
7+
BASE_PATH = os.path.abspath(os.path.join(__file__, '..', '..', '..'))
88

99

1010
def check_files(dir):
@@ -23,5 +23,5 @@ def check_files(dir):
2323

2424

2525
def test_pep8():
26-
for dir in ['core', 'implementations', 'helpers', 'tutorial', '../projects', '../playgrounds']:
26+
for dir in ['pySDC/core', 'pySDC/implementations', 'pySDC/helpers', 'pySDC/tutorial', 'pySDC/projects', 'pySDC/playgrounds']:
2727
yield check_files, dir

0 commit comments

Comments
 (0)