[firedrake] More questions

Lawrence Mitchell lawrence.mitchell at imperial.ac.uk
Fri Jul 24 11:29:29 BST 2015


> On 24 Jul 2015, at 11:06, Justin Chang <jychang48 at gmail.com> wrote:
> 
> Hi everyone,
> 
> I have some (what I think are) pretty simple questions that I would like answered:
> 
> 1) How do you print out the global size of the matrix?

So PyOP2 (and hence firedrake) don't expose global sizes of objects.  However, you can ask PETSc:

A = assemble(a)

print A.M.handle.getSizes()

This returns the same as MatGetSizes.

You can get the /local/ sizes with:

A.M.nrows, A.M.ncols

We should probably just expose the global sizes as well.


> 2) When FFC/pyop2 is compiling the forms, it says "Skipping optimizations, add -O to optimize", how can I tell my program to add this optimization?

I believe that many of these optimisations conflict with those that the COFFEE kernel compiler subsequently applies, so I /think/ that you can't add this optimisation right now.  Maybe Fabio can comment more clearly on this point.


> 3) Is there a way to simply output the number of KSP iterations? I am guessing it involves getIterationNumber() but I am still kind of new to petsc4py, so how would I invoke this call in the context of firedrake?


Do you want to access this number programmatically, or print to a screen?

If the latter, you can run with 'ksp_converged_reason': True in your solver_parameters dict and PETSc will print the converged reason (along with the number of iterations).

If programmatically:

solver = XXXVariationalSolver(...)

solver.solve()

print solver.snes.ksp.getIterationNumber()

If you're using preassembled operators and a LinearSolver:

solver = LinearSolver(...)

solver.solve(...)

print solver.ksp.getIterationNumber()

Again, we should expose this programmatically in the public interface.

Lawrence
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://mailman.ic.ac.uk/pipermail/firedrake/attachments/20150724/10e76dc0/attachment.sig>


More information about the firedrake mailing list