2008/8/23 Garth N. Wells <gnw20@xxxxxxxxx>:
Martin Sandve Alnæs wrote:
Add an instantiation of Array<DirichletBC*> to the .i files beside
ArrayFunctionPtr.
I added this.
An use cpp_DirichletBC.
I tried this is demo/pde/sym-dirichlet-bc/python/demo.py, but I get
Traceback (most recent call last):
File "demo.py", line 55, in <module>
bc = cpp_DirichletBC(u0, mesh, boundary)
NameError: name 'cpp_DirichletBC' is not defined
from dolfin.dolfin import cpp_DirichletBC
Note that cpp_DirichletBC won't hold on to python referenced objects,
so you need to keep some python references to your meshfunctions
and vectors etc. to avoid garbage collection.
As you say, this is a problem with this
"inheritance pattern".
Is there a way to 'up cast' Python objects. For example, DirichletBC is
derived from cpp_DirichletBC, so can I get a cast a DirichletBC object to a
cpp_DirichletBC object?
Garth
The DirichletBC object is already a cpp_DirichletBC object, it obviously
works fine for single objects, so the problem is in the vector typemap.
Maybe you can create an empty ArrayDirichletBC() and add one item
at a time to it?
a = ArrayDirichletBC()
for b in bcs:
a.push_back(b)