I'm still working on the same thermal diffusion problem I referred to in the "thermal diffusion - Dirichlet vs. Neumann BCs" thread. The problem is attached file "flndrs2d.py" and *appears* to give a reasonable solution, but I still need to calculate heat flux out the top of the model. So, following Robert's suggestion i added a post_process hook that evaluates d_surface_flux:

def post_process(out, problem, state, extend=False):


Calculate gradient of the solution.


flux = problem.evaluate('d_surface_flux.2.Gamma_Top(coef.val, t)',

mode='eval', copy_materials=False, verbose=False)

print flux 

When I call this using my rather complicated materials definition in the attached file, d_surface flux fails with the following error:

  File "/Users/philcummins/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/sfepy/discrete/functions.py", line 114, in get_constants

    nqp = qps.shape[ig][1]

KeyError: 1

(after a lengthy traceback). If I change the materials definition to a very simple one:

materials = {

      'flux' : ({'val' : 0.03},),

      'coef' : ({'val' : 1.0},),


Then d_surface_flux appears to evaluate OK, but it just returns a single value of zero. (I am expecting a vector). I'm not sure what to try next, any suggestions?

Many thanks

- Phil

P.S. I have also attached a coarsened mesh file, in case anyone wants to try to run it. But you need to remove the "2km" in the name of the mesh file in flndrs2d.py if you want it to work.