Missing FunctionSpace::sub in C++

Issue #606 resolved
Anders Logg (Chalmers) created an issue

Why did we never add FunctionSpace::sub() in C++ for setting BC for subspaces.

I suggest we add this for consistency with the Python interface. Objections?

Comments (10)

  1. Prof Garth Wells

    I don't know why it's missing.

    What will the return type be? I would like std::shared_ptr. If we have an option for deep vs shallow copy, it would be nice if this is an enum.

  2. Anders Logg (Chalmers) reporter

    It should just do the same thing as operator[] does now, i.e., return a shared_ptr. There's no harm in keeping the operator[] for now but it could be removed later.

  3. Prof Garth Wells

    Let's then deprecate operator[].

    We'll also be to remove dolfin.Function.sub(..) from the Python layer and just let SWIG wrap it,

  4. Jan Blechta

    We'll also be to remove dolfin.Function.sub(..) from the Python layer and just let SWIG wrap it,

    I'm not sure about this. Both dolfin.functions.function.Function and dolfin.functions.functionspace.FunctionSpace inherit from ufl.(Coefficient|FunctionSpace) and dolfin.cpp.Function[Space]. The trick is that when any method returns just its cpp variant then it is manually wrapped into Py version. I'm not saying that it is impossible. We just need to be careful.

    One aspect is to avoid copying. One-argument versions of dolfin.functions.function.Function.__init__ and dolfin.functions.functionspace.FunctionSpace.__init__ accepts cpp variant and return wrapped Py variant without copying. At the same time they should fail with anything else, thus forbidding copy construction AFAIK.

  5. Anders Logg (Chalmers) reporter

    I suggest we don't touch how things are wrapped to Python but just make an interface change in the C++ interface: add sub and deprecate (warning) operator[].

  6. Prof Garth Wells

    How about we don't do this (not as originally planned, anyway) , and move towards the FooView (see issue #531) design to clean a load of things up. I've just felt first-hand how confusing it is to get a shared_ptr to a sub-Function.

  7. Log in to comment