Hi Robert,

Thank you for your kind answer.
Added 'facet' to the regions did fix the error problem, but the values of the fluxes are not as expected :

flux1.sum() :  -0.817686412623

flux2.sum() :  0.904600038826


It should be -1 and 1...

flux1 has 8 "terms" and flux2 has 9 "terms"... 


Is it a problem in the mesh ? Or is it a "side effet" of to the "extend_cell_data()" issue ?

What values do you get ?


Best regards,


David.





2014-04-02 22:34 GMT+02:00 Robert Cimrman <cimr...@ntc.zcu.cz>:
Hi David,


On 04/02/2014 07:09 PM, David Libault wrote:
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...


<snip>

sfepy: reading mesh [line2, tri3, quad4, tetra4, hexa8] (essai_2D.mesh)...
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)

Two things are needed to make it work:

- set the kind of boundary regions to 'facet':

region_03 = {
    'name' : 'Gamma_Left',
    'select' : 'vertices of group 1',
    'kind' : 'facet',
}

region_4 = {
    'name' : 'Gamma_Right',
    'select' : 'vertices of group 2',
    'kind' : 'facet',
}

- get the latest git sources, as I have just fixed a bug in extend_cell_data() that occurred only for is_surface=True.

Then I can run your old script - let me know it the above works for you.

Best regards.
r.


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.




--
You received this message because you are subscribed to the Google Groups "sfepy-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sfepy-devel+unsubscribe@googlegroups.com.
To post to this group, send email to sfepy...@googlegroups.com.
Visit this group at http://groups.google.com/group/sfepy-devel.