On Mon, Nov 09, 2009 at 09:43:01AM +0100, Anders Logg wrote:
> I'm debugging the adaptive machinery and I'm seeing some strange
> behaviour.
>
> Take a look at the following simple test code:
>
>   from dolfin import *
>
>   mesh = UnitSquare(2, 2)
>   V = FunctionSpace(mesh, "CG", 1)
>
>   print
>   v = Function(V)
>
>   print
>   v.function_space()
>
>   print
>   v.function_space()
>
> I would expect that the FunctionSpace constructor is called only once.
>
> But it seems to be called three times. Once at the top as expected and
> then every time function_space() is called:
>
> Debug: creating function space [at
> dolfin/function/FunctionSpace.cpp:42 in FunctionSpace()]
> this = 0x335e190
> registering V = 0x335e190
>
> Debug: creating function [at dolfin/function/Function.cpp:49 in
> Function()]
> V = 0x335e190
> registering v = 0x33622d0 for V = 0x335e218
>
> Debug: creating function space [at
> dolfin/function/FunctionSpace.cpp:64 in FunctionSpace()]
> this = 0x336c420
> registering V = 0x336c420
>
> Debug: creating function space [at
> dolfin/function/FunctionSpace.cpp:64 in FunctionSpace()]
> this = 0x336c420
> registering V = 0x336c420
>
> Is this expected? Note that the constructor is called three times but
> the pointer (this) is the same in the two last calls.

I've taken a closer look and it is correct that the constructor should
be called three times. The last two are the copy constructor in
FunctionSpace called by FunctionSpaceFromCpp (in functionspace.py).

And the reason the last two are the same is that a FunctionSpace is
constructed, then destroyed. Then again a FunctionSpace is created and
it happens to get the same address...

--
Anders

Attachment: signature.asc
Description: Digital signature

_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@fenics.org
http://www.fenics.org/mailman/listinfo/dolfin-dev

Reply via email to