Robert,

I have rerun the "old" electro static poisson problem again with mac OsX port of sfepy, and the flux evaluation doesn't seem to work...

sfepy: left over: ['verbose', '__builtins__', '__file__', '__name__', 'nm', '_filename', '__package__', 'post_process', '__doc__']

sfepy: reading mesh [line2, tri3, quad4, tetra4, hexa8] (essai_2D.mesh)...

sfepy: ...done in 0.00 s

sfepy: creating regions...

sfepy:   warning: region Gamma_Right of cell kind has empty group indices!

sfepy:     Gamma_Right

sfepy:     Omega

sfepy:   warning: region Gamma_Left of cell kind has empty group indices!

sfepy:     Gamma_Left

sfepy: ...done in 0.01 s

sfepy: equation "Voltage":

sfepy: dw_laplace.i1.Omega( coef.val, s, v ) = 0

sfepy: setting up dof connectivities...

sfepy: ...done in 0.00 s

sfepy: using solvers:

                ts: no ts

               nls: newton

                ls: ls

sfepy: updating variables...

sfepy: ...done

sfepy: matrix shape: (144, 144)

sfepy: assembling matrix graph...

sfepy: ...done in 0.00 s

sfepy: matrix structural nonzeros: 922 (4.45e-02% fill)

sfepy: updating materials...

sfepy:     coef

sfepy: ...done in 0.00 s

sfepy: nls: iter: 0, residual: 0.000000e+00 (rel: 0.000000e+00)

sfepy: equation "tmp":

sfepy: -ev_grad.2.Omega( v )

sfepy: updating materials...

sfepy: ...done in 0.00 s

sfepy: equation "tmp":

sfepy: d_surface_flux.2.Gamma_Left(coef.sigma, v)

sfepy: updating materials...

sfepy:     coef

Traceback (most recent call last):

  File "/opt/local/bin/simple.py-2.7", line 155, in <module>

    main()

  File "/opt/local/bin/simple.py-2.7", line 152, in main

    app()

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/applications/application.py", line 29, in call_basic

    return self.call(**kwargs)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/applications/pde_solver_app.py", line 213, in call

    nls_status=nls_status)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/solvers/ts_solvers.py", line 37, in __call__

    file_per_var=None)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/problemDef.py", line 715, in save_state

    out = post_process_hook(out, self, state, extend=extend)

  File "poisson_electrostatic.py", line 157, in post_process

    flux1 = pb.evaluate('d_surface_flux.2.Gamma_Left(coef.sigma, v)', mode='el')

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/problemDef.py", line 1179, in evaluate

    verbose=verbose, **kwargs)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/problemDef.py", line 1130, in create_evaluable

    verbose=verbose)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/equations.py", line 322, in time_update_materials

    verbose=verbose)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/materials.py", line 70, in time_update

    mat.time_update(ts, equations, mode=mode, problem=problem)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/materials.py", line 345, in time_update

    self.update_data(key, ts, equations, term, problem=problem)

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/materials.py", line 247, in update_data

    coors = qps.get_merged_values()

  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sfepy/fem/mappings.py", line 26, in get_merged_values

    qps = nm.concatenate([self.values[ig] for ig in self.igs], axis=0)

ValueError: need at least one array to concatenate


simple.py-2.7 --version returns simple.py-2.7 2013.4 on my system which should integrate the modifications you made two years ago.

Is your "testing function, that shows how to save the fluxes" still working ?

(I had to change 'nodes' to 'vertices' and 'elements' to 'cells' to have it work again)

Best regards,

David.

Le jeudi 30 août 2012 12:04:08 UTC+2, Robert Cimrman a écrit :
On 08/30/2012 11:08 AM, David Libault wrote:
> Robert,
>
> Understood. I was not using the correct "mode" for what I was expecting.
> Now the user interface looks nice.
>
> David.

Nevertheless, it should be documented (-> Issue 196).

So this is my current testing function, that shows how to save the fluxes (they
are displayed over the triangles that contain the boundary edges...):

def post_process(out, pb, state, extend=False):
     from sfepy.base.base import Struct
     from sfepy.fem import extend_cell_data

     electric_field = pb.evaluate('ev_grad.i1.Omega( v )', mode='el_avg')
     out['electric_field'] = Struct(name='Electric field', mode='cell',
                                    data=electric_field, dofs=None)

     flux1 = pb.evaluate('d_surface_flux.2.Gamma_Left(coef.sigma, v)',
                         mode='el')
     print flux1
     print flux1.sum()
     flux1 = extend_cell_data(flux1, pb.domain, 'Gamma_Left', val=0.0,
                              is_surface=True)
     out['flux1'] = Struct(name='output_data', mode='cell',
                           data=flux1, dofs=None)
     flux2 = pb.evaluate('d_surface_flux.2.Gamma_Right(coef.sigma, v)',
                         mode='el')
     print flux2
     print flux2.sum()
     flux2 = extend_cell_data(flux2, pb.domain, 'Gamma_Right', val=0.0,
                              is_surface=True)
     out['flux2'] = Struct(name='output_data', mode='cell',
                           data=flux2, dofs=None)

     print  pb.evaluate('d_surface_flux.2.Gamma_Right(coef.sigma, v)')
     return out

r.