From 3fc59a848e1a1e879e07e6809d295750ac994c13 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Wed, 24 Jan 2018 12:30:38 -0600 Subject: [PATCH] Fix symbolic operator dumping for debugging --- examples/advection/var-velocity.py | 5 ++++- grudge/execution.py | 15 ++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/examples/advection/var-velocity.py b/examples/advection/var-velocity.py index e19d6aeb..366fd1e4 100644 --- a/examples/advection/var-velocity.py +++ b/examples/advection/var-velocity.py @@ -76,7 +76,10 @@ def main(write_output=True, order=4): u_analytic(sym.nodes(dim, sym.BTAG_ALL)), quad_tag="product", flux_type=flux_type) - bound_op = bind(discr, op.sym_operator()) + bound_op = bind( + discr, op.sym_operator(), + #debug_flags=["dump_sym_operator_stages"] + ) u = bind(discr, f(sym.nodes(dim)))(queue, t=0) diff --git a/grudge/execution.py b/grudge/execution.py index 2915ee85..04482c86 100644 --- a/grudge/execution.py +++ b/grudge/execution.py @@ -559,19 +559,20 @@ def bind(discr, sym_operator, post_bind_mapper=lambda x: x, stage = [0] - def dump_optemplate(name, sym_operator): - if "dump_optemplate_stages" in debug_flags: - from grudge.tools import open_unique_debug_file - from grudge.optemplate import pretty - open_unique_debug_file("%02d-%s" % (stage[0], name), ".txt").write( - pretty(sym_operator)) + def dump_sym_operator(name, sym_operator): + if "dump_sym_operator_stages" in debug_flags: + from pytools.debug import open_unique_debug_file + outf, name = open_unique_debug_file("%02d-%s" % (stage[0], name), ".txt") + with outf: + outf.write(sym.pretty(sym_operator)) + stage[0] += 1 sym_operator = process_sym_operator( discr, sym_operator, post_bind_mapper=post_bind_mapper, - dumper=dump_optemplate) + dumper=dump_sym_operator) from grudge.symbolic.compiler import OperatorCompiler discr_code, eval_code = OperatorCompiler(discr)(sym_operator) -- GitLab