dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #08184
Re: SubFunctions Extraction
On Thu, Jun 12, 2008 at 05:41:36PM +0100, Nuno David Lopes wrote:
> Isn't the code:
> ......................
> Matrix A;
> Vector b,x;
> assemble(A,a,mesh);
> assemble(b,L,mesh);
> solver.solve(A,x,b);
> Function up(mesh,x,a); //up=(u,p) velocities and pressure
> Function u=up[0];
> Function p=up[1];
> ...........................
> supposed to work?
> this gives an error:
> ----------------------
> conversion from 'dolfin::SubFunction' to non-scalar type 'dolfin::Function'
> requested
> --------------------
>
> On the other hand I know that this works:
> Function u(up[0]);
> Function p(up[1]);
It's the "explicit" keyword in Function.h that prevents this. Without
this, C++ does some magic (like generating assignment operators and
similar). We want to prevent this to be able to control what happens
during assignment. Another reason is to prevent automatic casting
in other cases. See here for example:
http://www.sjbrown.co.uk/?article=explicit
Martin may have some more comments.
--
Anders
Attachment:
signature.asc
Description: Digital signature
References