← Back to team overview

dolfin team mailing list archive

Shallow copy of Function

 

Hello!

To fix:

[child().child() fails for Function and FunctionSpaces in Python]
https://bugs.launchpad.net/bugs/1130354

we need to add a way of shallow copy a Function. For now we have used:

Function(boost::shared_ptr<const FunctionSpace> V,
         boost::shared_ptr<GenericVector> x);

Which create a new Function with a shared FunctionSpace and
GenericVector. The problem is that there is no way of bringing
Hierarchical data to the new Function as it is not passed through the
constructor.

We would need something like:

Function(boost::shared_ptr<const Function> u);

which is interpreted as a shallow copy.

We could then map this to:

  Function._shallow_copy()

and

  Function(const Function& u);

to

  Function._deep_copy()

in the Python interface. Then we add:

  Function.

  def copy(self, deepcopy=True):
     if deepcopy:
        return self._deep_copy()
     else:
        return self._shallow_copy()

Any objections to adding:

  Function(boost::shared_ptr<const Function> u);

as a shallow copy constructor?

If so we could maybe remove:

   Function(boost::shared_ptr<const FunctionSpace> V,
            boost::shared_ptr<GenericVector> x);

as I think we added it so we could create a shallow copy in the Python
interface.

Johan


Follow ups