Hi guys

I've generated an array comprising material D matrix or stiffness tensor values. It looks like this - where each block represents the material value for a cell or element (yes, they're all the same but will change in subsequent time steps).


[[[ 1604.9382716    864.19753086     0.        ]
  [  864.19753086  1604.9382716      0.        ]
  [    0.             0.           370.37037037]]

 [[ 1604.9382716    864.19753086     0.        ]
  [  864.19753086  1604.9382716      0.        ]
  [    0.             0.           370.37037037]]

 [[ 1604.9382716    864.19753086     0.        ]
  [  864.19753086  1604.9382716      0.        ]
  [    0.             0.           370.37037037]]

 ...,
 [[ 1604.9382716    864.19753086     0.        ]
  [  864.19753086  1604.9382716      0.        ]
  [    0.             0.           370.37037037]]

 [[ 1604.9382716    864.19753086     0.        ]
  [  864.19753086  1604.9382716      0.        ]
  [    0.             0.           370.37037037]]

 [[ 1604.9382716    864.19753086     0.        ]
  [  864.19753086  1604.9382716      0.        ]
  [    0.             0.           370.37037037]]]


I'd like to append this array to the vtk file generated by SfePy which contains displacements, stress and strains, etc.
I was using the following to generate the array:

    Dlist=[]
    for i in range(NELS):
        Dlist.append(pb.conf.materials.values()[i].values['D'])
    Dmatrix=array(Dlist)
    print "~~~~~~~~~~~~~~~~~~~~~~~~~~~"
    print Dmatrix
    Dstate=pb.create_state()
    Dstate.set_full(Dmatrix)
    outD=Dstate.create_output_dict()
    out['D_matrix']=Struct(name='output_data',mode='cell',data=outD,dofs=None)


but get the following *numpy* error:

Traceback (most recent call last):
  File "/home/grassy/sfepy/simple.py", line 120, in <module>
    main()
  File "/home/grassy/sfepy/simple.py", line 117, in main
    app()
  File "/home/grassy/sfepy/sfepy/applications/application.py", line 29, in call_basic
    return self.call( **kwargs )
  File "/home/grassy/sfepy/sfepy/applications/simple_app.py", line 112, in call
    post_process_hook_final=self.post_process_hook_final)
  File "/home/grassy/sfepy/sfepy/solvers/generic.py", line 216, in solve_direct
    nls_status=nls_status)
  File "/home/grassy/sfepy/sfepy/solvers/generic.py", line 148, in solve_evolutionary_op
    ts=ts)
  File "/home/grassy/sfepy/sfepy/fem/problemDef.py", line 535, in save_state
    out = post_process_hook( out, self, state, extend = extend )
  File "its.py", line 102, in strain_rate
    outD=Dstate.create_output_dict()
  File "/home/grassy/sfepy/sfepy/fem/state.py", line 188, in create_output_dict
    var_info, extend)
  File "/home/grassy/sfepy/sfepy/fem/variables.py", line 587, in state_to_output
    fill_value=fill_value))
  File "/home/grassy/sfepy/sfepy/fem/variables.py", line 1468, in create_output
    (self.n_dof / self.n_components, self.n_components))
  File "/usr/lib/python2.7/site-packages/numpy/core/fromnumeric.py", line 170, in reshape
    return reshape(newshape, order=order)
ValueError: total size of new array must be unchanged

Can I use existing SfePy methods to write this array to the vtk or should I rather write my own?



--
Andre