Switch from std::vector<> to Array<> in the public interface

Registered by Anders Logg

We use Array<> in place of std::vector<> in some cases, but in other cases we use std::vector<>. The reasons for using Array<> is that class has been designed to allow easy (and memory safe) wrapping to Python.

The Array class should be used more extensively.

Blueprint information

Status:
Complete
Approver:
None
Priority:
Undefined
Drafter:
None
Direction:
Needs approval
Assignee:
None
Definition:
Superseded
Series goal:
None
Implementation:
Unknown
Milestone target:
None
Completed by
Garth Wells

Related branches

Sprints

Whiteboard

JH:
I am not sure about the generality of this blueprint.

The reason we added std::vector instead of pointers was to get a safe way to pass arrays of primitives back and forth between Python and C++. It did not work well with NumPy so we introduced Array. All these cases works fine now using Array. There are other occasions we use std::vector, but these might not gain too much on using Array, to the contrary we might loose functionality. For example Arrays cannot be resized, which vectors can, which is used in at least two places in the interface. The push_back functionality is also nice to have when passing Coefficients to the assembler in C++.

AL: We could consider adding that functionality to Array. I'm not saying we should, but one option is to add push_back (but name it something more sensible, i.e., append) and also add constructors that take 1, 2, 3, ..., n arguments for simple creation of a list of BCs:

  Array<DirichletBC*> bcs(&bc0, &bc1, &bc2);

AL: Also note that we had an Array class for a long time in DOLFIN before, but we removed it when we realized it was better to use STL than some home-grown array class...

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.

Subscribers

No subscribers.