← Back to team overview

dolfin team mailing list archive

[Bug 453207] Re: Assigning a Function to another Function does not work.

 

compile a ufl form M.ufl with:

cell = interval
element = FiniteElement("CG", cell, 1)
q = TestFunction(element)
v = TrialFunction(element)

a = q*v*dx

compile the main program as:

#include <dolfin.h>
#include "M.h"

using namespace dolfin;

int main (int argc, char* argv[])
{  

  UnitInterval mesh(10);
  M::FunctionSpace V(mesh);

  Function orig(V);
  orig.vector() = 1.0; 

  Function copy = orig;

  Function copy2(orig);
  
  return 0;
}

-- 
Assigning a Function to another Function does not work.
https://bugs.launchpad.net/bugs/453207
You received this bug notification because you are subscribed to DOLFIN.

Status in DOLFIN: New

Bug description:
There is an error when one wants to assign a Function to a new one:

Function copy = orig;

or

Function copy(orig);

raise both an error as

/scratch-second/priesen/FEniCS/build/include/boost/smart_ptr/shared_ptr.hpp:412: 
typename boost::detail::shared_ptr_traits<T>::reference 
boost::shared_ptr< <template-parameter-1-1> >::operator*() const [with T 
= dolfin::GenericVector]: Assertion `px != 0' failed.

in 

#3  0x00007f98fc291a09 in dolfin::Function::operator= 
(this=0x7fff047d2810, v=@0x7fff047d29c0) at 
/scratch-second/priesen/FEniCS/build/include/boost/smart_ptr/shared_ptr.hpp:412
#4  0x00007f98fc291d09 in Function (this=0x7fff047d2810, 
v=@0x7fff047d29c0) at dolfin/function/Function.cpp:113

Workaround:

use

Function copy(V_orig);
copy.vector() = orig.vector();


References