In [1]:
from dolfin import *
import petsc4py, sys
petsc4py.init(sys.argv)
from petsc4py import PETSc
import matplotlib.pylab as plt
import PETScIO as IO
import numpy as np
import scipy.sparse as sparse
import CheckPetsc4py as CP
import scipy.sparse.linalg as sparselin
import scipy as sp
import time

In [2]:
nn = 4
mesh = RectangleMesh(0, 0, 1, 1, nn, nn,'left')

order  = 1
parameters['reorder_dofs_serial'] = False
V = FunctionSpace(mesh, "N1curl", order)
Q = FunctionSpace(mesh, "CG", order)
W = MixedFunctionSpace([V,Q])


DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.

In [3]:
parameters['linear_algebra_backend'] = 'uBLAS'

In [4]:
b0 = Expression(("x[1]*x[1]*(x[1]-1)","x[0]*x[0]*(x[0]-1)"))
print V.dim(), Q.dim()


56 25

In [5]:
def boundary(x, on_boundary):
    return on_boundary
bcb = DirichletBC(V,b0, boundary)
bc = [bcb]

In [6]:
(v) = TrialFunction(V)
(u) = TestFunction(V)
(uMix,pMix) = TrialFunctions(W)
(vMix,qMix) = TestFunctions(W)
CurlCurl = Expression(("-6*x[1]+2","-6*x[0]+2"))+b0
f = CurlCurl

In [7]:
a = inner(curl(v),curl(u))*dx
m = inner(u,v)*dx
b = inner(vMix,grad(pMix))*dx

In [8]:
A = assemble(a)
M = assemble(m)
Ms = M.sparray()
A = A.sparray()


DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.

In [9]:
B = assemble(b)
B = B.sparray()[W.dim()-V.dim():,W.dim()-Q.dim():]


DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:UFL:No integrals left after transformation, returning empty form.
Calling FFC just-in-time (JIT) compiler, this may take some time.
Level 25:FFC:Calling FFC just-in-time (JIT) compiler, this may take some time.
INFO:FFC:Compiling form ffc_form_44a9aca1f1fa466ab68a22a5214141386cc89b9b

INFO:FFC:Compiler stage 1: Analyzing form(s)
INFO:FFC:-----------------------------------
INFO:FFC:  
INFO:FFC:  Name:                   ''
  Cell:                   <triangle cell in 2D>
  Topological dimension:  2
  Geometric dimension:    2
  Rank:                   2
  Number of coefficients: 0
  Arguments:              '[v_{-2}, v_{-1}]'
  Coefficients:           '[]'
  Argument names:         '[v0, v1]'
  Coefficient names:      '[]'
  Unique elements:        'Mixed<N1curl1(?), CG1(?)>'
  Unique sub elements:    'Mixed<N1curl1(?), CG1(?)>, N1curl1(?), CG1(?)'
  Domains:                (Domain(Cell('triangle', 2), 'triangle_multiverse', 2, 2),
                          )
  Top level domains:      (Domain(Cell('triangle', 2), 'triangle_multiverse', 2, 2),
                          )
  
INFO:FFC:  Extracting monomial form representation from UFL form
INFO:FFC:  Transforming monomial form to reference element
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Estimated cost of tensor representation: 2
INFO:FFC:  representation:    auto --> tensor
DEBUG:FFC:  Selecting quadrature degree based on total polynomial degree of integrand: 1
INFO:FFC:  quadrature_degree: auto --> 1
INFO:FFC:  quadrature_rule:   auto --> default
INFO:FFC:  
INFO:FFC:Compiler stage 1 finished in 0.017025 seconds.

INFO:FFC:Compiler stage 2: Computing intermediate representation
INFO:FFC:-------------------------------------------------------
INFO:FFC:  Computing representation of 3 elements
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
INFO:FFC:  Computing representation of 3 dofmaps
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
INFO:FFC:  Computing representation of integrals
INFO:FFC:  Computing tensor representation
INFO:FFC:  Extracting monomial form representation from UFL form
INFO:FFC:  Transforming monomial form to reference element
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  Reusing element from cache
INFO:FFC:  Precomputing integrals on reference element
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  144 entries computed in 0.00157 seconds
DEBUG:FFC:  Shape of reference tensor: (6, 6, 2, 2)
DEBUG:FFC:  Primary multi index:   rank = 2 dims = [6, 6] indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]
DEBUG:FFC:  Secondary multi index: rank = 2 dims = [2, 2] indices = [[0, 0], [0, 1], [1, 0], [1, 1]]
DEBUG:FFC:  Internal multi index:  rank = 0 dims = [] indices = [[]]
DEBUG:FFC:  Secondary multi index: rank = 2 dims = [2, 2] indices = [[0, 0], [0, 1], [1, 0], [1, 1]]
DEBUG:FFC:  External multi index:  rank = 0 dims = [] indices = [[]]
INFO:FFC:  Precomputing integrals on reference element
DEBUG:FFC:  Reusing element from cache
DEBUG:FFC:  144 entries computed in 0.000956 seconds
DEBUG:FFC:  Shape of reference tensor: (6, 6, 2, 2)
DEBUG:FFC:  Primary multi index:   rank = 2 dims = [6, 6] indices = [[0, 0], [0, 1], [0, 2], [0, 3], [0, 4], [0, 5], [1, 0], [1, 1], [1, 2], [1, 3], [1, 4], [1, 5], [2, 0], [2, 1], [2, 2], [2, 3], [2, 4], [2, 5], [3, 0], [3, 1], [3, 2], [3, 3], [3, 4], [3, 5], [4, 0], [4, 1], [4, 2], [4, 3], [4, 4], [4, 5], [5, 0], [5, 1], [5, 2], [5, 3], [5, 4], [5, 5]]
DEBUG:FFC:  Secondary multi index: rank = 2 dims = [2, 2] indices = [[0, 0], [0, 1], [1, 0], [1, 1]]
DEBUG:FFC:  Internal multi index:  rank = 0 dims = [] indices = [[]]
DEBUG:FFC:  Secondary multi index: rank = 2 dims = [2, 2] indices = [[0, 0], [0, 1], [1, 0], [1, 1]]
DEBUG:FFC:  External multi index:  rank = 0 dims = [] indices = [[]]
INFO:FFC:  Computing representation of forms
INFO:FFC:  
INFO:FFC:Compiler stage 2 finished in 0.0253351 seconds.

INFO:FFC:Compiler stage 3: Optimizing intermediate representation
INFO:FFC:--------------------------------------------------------
INFO:FFC:  Skipping optimizations, add -O to optimize
INFO:FFC:  
INFO:FFC:Compiler stage 3 finished in 0.00101995 seconds.

INFO:FFC:Compiler stage 4: Generating code
INFO:FFC:---------------------------------
INFO:FFC:  Generating code for 3 element(s)
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
DEBUG:FFC:  Removing unused variable: tmp2
DEBUG:FFC:  Removing unused variable: tmp1
DEBUG:FFC:  Removing unused variable: tmp7
DEBUG:FFC:  Removing unused variable: tmp6
DEBUG:FFC:  Removing unused variable: tmp5
DEBUG:FFC:  Removing unused variable: tt
DEBUG:FFC:  Removing unused variable: ss
DEBUG:FFC:  Removing unused variable: rr
INFO:FFC:  Generating code for 3 dofmap(s)
INFO:FFC:  Generating code for integrals
INFO:FFC:  Generating code for forms
INFO:FFC:  
INFO:FFC:Compiler stage 4 finished in 0.148101 seconds.

INFO:FFC:Compiler stage 4.1 finished in 4.05312e-06 seconds.

INFO:FFC:Compiler stage 5: Formatting code
INFO:FFC:---------------------------------
INFO:FFC:  Output written to ./ffc_form_44a9aca1f1fa466ab68a22a5214141386cc89b9b.h.
INFO:FFC:  
INFO:FFC:Compiler stage 5 finished in 0.013392 seconds.

INFO:FFC:FFC finished in 0.206498 seconds.
DEBUG:FFC:Compiling and linking Python extension module, this may take some time.

In [10]:
ksp = PETSc.KSP().create()
parameters['linear_algebra_backend'] = 'PETSc'
M = assemble(m)
M = CP.Assemble(M)
ksp.setOperators(M)
x = M.getVecLeft()
ksp.setFromOptions()
ksp.setType(ksp.Type.CG)
ksp.setTolerances(1e-6)
ksp.pc.setType(ksp.pc.Type.BJACOBI)


DEBUG:FFC:Reusing form from cache.

In [11]:
OptDB = PETSc.Options()
# OptDB["pc_factor_mat_ordering_type"] = "rcm"
# OptDB["pc_factor_mat_solver_package"] = "cholmod"
ksp.setFromOptions()
C = sparse.csr_matrix((V.dim(),Q.dim()))
IO.matToSparse


Out[11]:
<function PETScIO.matToSparse>

In [12]:
C = sparse.csr_matrix((V.dim(),Q.dim()))
(v) = TrialFunction(V)
(u) = TestFunction(V)
tic()
for i in range(0,Q.dim()):
    uOut = Function(V)
    uu = Function(Q)
    x = M.getVecRight()
    zero = np.zeros((Q.dim(),1))[:,0]
    zero[i] = 1
    uu.vector()[:] = zero
    L = assemble(inner(u, grad(uu))*dx)
    rhs = IO.arrayToVec(L.array())
    ksp.solve(rhs,x)
#     x = project(grad(uu),V)
    P = x.array
    uOut.vector()[:] = P
    low_values_indices = np.abs(P) < 1e-3
    P[low_values_indices] = 0  
    P=np.around(P)
    pn = P.nonzero()[0]
    for j in range(0,len(pn)):
        C[pn[j],i] = P[pn[j]]
    del uu
print toc()


DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
/usr/local/lib/python2.7/dist-packages/scipy/sparse/compressed.py:728: SparseEfficiencyWarning: Changing the sparsity structure of a csr_matrix is expensive. lil_matrix is more efficient.
  SparseEfficiencyWarning)
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
DEBUG:UFL:No integrals left after transformation, returning empty form.
DEBUG:FFC:Reusing form from cache.
0.145342826843

In [14]:
C.shape


Out[14]:
(56, 25)

In [57]:
rhs = PETSc.Vec().create()
rhs.createWithArray(B[:,0].toarray())
V.thisown


Out[57]:
True

In [23]:
print C > 1e-6


  (111, 24)	True

In [49]:
import scipy.sparse.linalg

In [51]:
ksp.


Out[51]:
90.68455705845307

In [88]:
print np.min(np.abs(B.toarray()))
print np.max(np.abs(B.toarray()))


0.0
0.666666666667

In [90]:
m = 32

In [91]:
str(m)


Out[91]:
'32'

In [105]:
name = '../../GradMatrices/UnitSquareLeft_m='+str(nn)+'.mat'
mat = scipy.io.loadmat(name)
CC = mat['C']

In [101]:
C = mat['C']

In [110]:
CC


Out[110]:
<112x25 sparse matrix of type '<type 'numpy.float64'>'
	with 224 stored elements in Compressed Sparse Column format>

In [29]:
low_values_indices = x < 1e-4  # Where values are low
x[low_values_indices] = 0  # All

In [111]:
from PyTrilinos import ML

In [116]:
ML.


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-116-b4b91676e1f3> in <module>()
----> 1 ML.SetDefaultsMaxwell()

/home/mwathen/Work/FEniCS/lib/python2.7/site-packages/PyTrilinos/ML.pyc in SetDefaultsMaxwell(*args)
   1383         bool Overwrite=True) -> int
   1384     """
-> 1385   return _ML.SetDefaultsMaxwell(*args)
   1386 
   1387 def SetDefaultsSA(*args):

TypeError: SetDefaultsMaxwell() takes at least 3 arguments (0 given)