On 04/21/10 09:51, Dominique wrote:
On Apr 21, 8:14 am, Robert Cimrmancimr...@ntc.zcu.cz wrote:
On 04/21/10 00:43, Dominique wrote:
On Apr 20, 2:43 pm, Robert Cimrmancimr...@ntc.zcu.cz wrote: Yes, although it seems I'm having more success with eval_term_op as follows:
def get_jacobian_blocks(problem, state=None): """ Return the blocks of the Jacobian matrix as a dictionary of sparse matrices in SciPy CSR format. Input arguments are as returned by
get_problem()
. """ from sfepy.fem.evaluate import eval_term_op if state is None: state = problem.create_state_vector() blocks = {} for key in problem.conf.equations.keys(): equation = problem.conf.equations[key] blocks[key] = eval_term_op(state, equation, problem, dw_mode='matrix', tangent_matrix=None) return blocksThe difficulty is that all blocks have the size of the full Jacobian. I guess I could extract the actual blocks that I need using the dimensions given by problem.variables.di but I suspect there's a better way...
Yes, your way is ok. It could be made easier though - there could be a helper function directly in sfepy.
Maybe an example of input for assemble_by_blocks() would help too:
variables = { 'u' : ('unknown field', 'displacement_Y2', 0), 'v' : ('test field', 'displacement_Y2', 'u'), 'phi' : ('unknown field', 'potential_Y2', 0), 'psi' : ('test field', 'potential_Y2', 'phi'),
}
equations = { 'K,v,u' : """dw_lin_elastic.i1.Y2( inclusion.C, v, u )""",
'B,psi,u' : """dw_piezo_coupling.i1.Y2( inclusion.B, u, psi )""", 'D,psi,phi' : """dw_diffusion.i1.Y2( inclusion.D, psi, phi )""", 'M,v,u' : """dw_mass_vector.i1.Y2( inclusion.density, v, u )""",
}
... mtx = assemble_by_blocks(conf.equations, problem, ebcs = conf.ebcs, epbcs = conf.epbcs)
Ah that's it! I did find out that the variables must appear in the equation name, but I was setting my equations as actual equations (i.e., """something = something""") and that wasn't working properly for some reason.
Is there a convention in SfePy as to how the equations are to be interpreted when only their components are listed (as in your example above), i.e., does SfePy assume that the first bit is a left-hand side, the second bit is a right-hand side, and so on? Or is that left to the programmer?
The key should be a string with three items separated by commas: <block name>, <test variable name>, <unknown variable name>
Each weak formulation term has exactly one test variable argument, but can take several unknowns, for example (nonexistent term...)
equation = { 'A,v,u' : 'dw_a_term.i.Omega( mat, v, u, p ) 'B,v,p' : 'dw_a_term.i.Omega( mat, v, u, p ) }
would build two blocks: A = d/du dw_a_term, B = d/dp dw_a_term.
mtx is then a dict with 'K', ..., 'M' keys. Of course, the corresponding fields, materials, integrals, regions etc. have to be defined properly.
cheers, r.
-- You received this message because you are subscribed to the Google Groups "sfepy-devel" group. To post to this group, send email to sfepy...@googlegroups.com. To unsubscribe from this group, send email to sfepy-devel...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/sfepy-devel?hl=en.