AssemblerBase::reset_sparsity is nowhere used

Issue #280 resolved
Jan Blechta created an issue

AssemblerBase::reset_sparsity parameter is nowhere used (in a contradiction with documentation). Actual criterion for building sparsity pattern in AssemblerBase::init_global_tensor is

 58   if (A.size(0) == 0)
 59   {
 60     Timer t0("Build sparsity");
...
133   }
134   else
135   {
136     // If tensor is not reset, check that dimensions are correct
...
146   }

Comments (9)

  1. Prof Garth Wells

    We need to keep this for a bit to avoid breaking code. It would be good if a warning could be issued when it's used. It's not a function, so it'll take something a bit cleverer to print a warning.

  2. Jan Blechta reporter

    Actually, is the criterion A.size(0) == 0 intended? Is the intention that user must initialize new tensor to assemble something with different pattern?

  3. Prof Garth Wells

    It will soon not be possible to re-initialise a matrix/vector. This was discussed previously on the mailing list. A.size(0) == 0 is true if the matrix has not been initialised.

  4. Jan Blechta reporter

    @garth-wells According to the GenericTensor interface, proper check should be A.empty() instead of A.size(0) == 0. (Use case: user (me) implements GenericMatrix and non-zero size(0) is known from construction time but tensor still needs initialization...)

    Bug report: at least PETScMatrix::empty(), EpetraMatrix::empty() and uBLASMatrix::empty() seems to not work:

    from dolfin import *
    
    mesh = UnitSquareMesh(3, 3)
    V = FunctionSpace(mesh, 'CG', 1)
    u, v = TrialFunction(V), TestFunction(V)
    a = inner(grad(u), grad(v))*dx
    L = v*dx
    
    for A in [uBLASDenseMatrix(), uBLASSparseMatrix(), PETScMatrix(), EpetraMatrix()]:
        print A.str(False), A.empty(), A.size(0)
        AssemblerBase().init_global_tensor(A, Form(a))
        print A.str(False), A.empty(), A.size(0)
    
    for b in [uBLASVector(), PETScVector(), EpetraVector()]:
        print b.str(False), b.empty(), b.size(0)
        AssemblerBase().init_global_tensor(b, Form(L))
        print b.str(False), b.empty(), b.size(0)
    
  5. Prof Garth Wells

    @blechta 'GenericTensor::empty' makes more sense in this context. Maybe you could make pull request that cleans this up?

  6. Log in to comment