Do not allow re-intialisation of GenericTensor/Vector/Matrix

Issue #213 resolved
Prof Garth Wells created an issue

Comments (8)

  1. Prof Garth Wells reporter

    Fixed in 832c1b1.

    It's not anticipated that this will break any user code, but some tweaking may be required. It will issue warnings for usage that will become an error in a future version.

  2. Jan Blechta

    @garth-wells This

    from dolfin import *
    
    mesh = UnitSquareMesh(3, 3)
    
    V = VectorFunctionSpace(mesh, 'CG', 1)
    P = FunctionSpace(mesh, 'CG', 1)
    
    W = MixedFunctionSpace([V, P])
    
    v = Function(V)
    w = Function(W)
    w0, w1 = w.split()
    
    v.assign(w0)
    

    was working in 1.3.0 and now raises

    *** Error:   Unable to initialize vector of degrees of freedom for function.
    *** Reason:  Cannot re-initialize a non-empty vector. Consider creating a new function.
    *** Where:   This error was encountered inside Function.cpp.
    

    It can be worked-around by FunctionAssigner but shouldn't it be resolved to keep old codes working? (I have a suspicion that this is trivial.)

  3. Alexandre Dufour

    Hi, I'm currently migrating some 1.2 code to 1.4 and just ran into the same issue (cannot re-initialize...). How can I use the FunctionAssigner to fix this (any 2-line example code)? I'm not well aware of the inner guts of Dolfin, hence my ignorance. Cheers

  4. Log in to comment