dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #26396
Re: Shallow copy of Function
On 22 February 2013 13:13, Johan Hake <hake.dev@xxxxxxxxx> wrote:
> Any comment on this?
>
> Basically we need another constructor which generates a shallow copy of
> a Function, which also has access to the original Function.
>
Would this be a non-issue if using a shared_ptr? What's the difference
between a shallow copy of a Function and a pointer to a Function?
Garth
> Johan
>
> On 02/21/2013 07:08 PM, Johan Hake wrote:
>> 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
>>
>
>
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help : https://help.launchpad.net/ListHelp
Follow ups
References