-1

I'm using the FEniCS package to do some FEM. I'm trying to push a DirichletBC instance into a vector of type const BoundaryCondition*. Currently I've got

std::vector<const BoundaryCondition*> bcs;
DirichletBC bcl(V0, c, left);
bcs.push_back(&bcl)

Even though this is done in an example I've seen, I get the error

no matching function for call to
std::vector<const dolfin::BoundaryCondition*>::push_back(dolfin::DirichletBC&)

Having a look through the dolfin library files I see a SWIG typemap .i file that seems to allow this kind of behaviour, do I use this, or have I missed something?

LogicStuff
  • 19,397
  • 6
  • 54
  • 74
oxidising
  • 171
  • 2
  • 16
  • why would you want to put the pointer to a local stack variable in your vector? how about `DirichletBC* bcl=new DirichletBC(V0, c, left); bcs.push_back(bcl)`? – m.s. Apr 23 '15 at 14:18
  • Are you sure that `DirichletBC` inherits publicly from `BoundaryCondition`? It seems that the compiler is not able to find a conversion from `DirichletBC` to `BoundaryCondition` – Bérenger Apr 23 '15 at 15:05

1 Answers1

0

I don't know why it took me so long to just try making the vector of type DirichletBC* instead. Now I have

std::vector<const DirichletBC*> bcs; DirichletBC bcl(V0, c, left); bcs.push_back(&bcl)

and it works fine.

oxidising
  • 171
  • 2
  • 16