← Back to team overview

dolfin team mailing list archive

Re: [Question #147330]: What is the preferred way to access data stored in the Data class now that it has been removed.

 

On Tuesday March 22 2011 03:57:44 bluejerry wrote:
> Question #147330 on DOLFIN changed:
> https://answers.launchpad.net/dolfin/+question/147330
> 
>     Status: Answered => Open
> 
> bluejerry is still having a problem:
> Thanks, this helped but,
> 
> I now get an error that new_MyFunc() takes exactly 1 argument (0 given)
> 
> (I am using Python with the complex C++ snippet)
> 
> I assume this is because the mesh is not sent as a parameter.
> 
> I tried to clear the parameter requirement specified in the constructor and
> moving the mesh to be public, i.e.

Try with:

CODE = """ class MyFunc : public Expression
 {
 public:
     boost::shared_ptr<Mesh> mesh;
     MyFunc() : Expression(3), mesh(static_cast<Mesh* >(0))   {}
     void eval(Array<double>& values, const Array<double>& x, const
 ufc::cell& ufc_cell) const {
          assert(ufc_cell.local_facet >= 0);
          assert(mesh);
          Cell cell(*mesh, ufc_cell.index);
          Point n = cell.normal(ufc_cell.local_facet);
          values[0] = -n.x()*n.y()*sin(13.34256380792608*x[0]);
          values[1] = pow(n.x(), 2)*sin(13.34256380792608*x[0]) + pow(n.z(),
 2)*sin(13.34256380792608*x[0]); values[2] =
 -n.y()*n.z()*sin(13.34256380792608*x[0]);
     }
 };
"""


Johan

> and then setting mesh in the PyDolfin code i.e.
> 
> dbc_expression = Expression(CODE, element=V.ufl_element())
> dbc_expression.mesh = mesh
> bc = DirichletBC(V,dbc_expression, Boundary())
> 
> But I now get an error that:
> 
> python: /build/buildd/dolfin-0.9.10/dolfin/mesh/MeshTopology.h:50:
> dolfin::uint dolfin::MeshTopology::size(dolfin::uint) const: Assertion
> `num_entities' failed.
> 
> What is the correct way of passing the mesh? or is this the correct way
> and this is related to some other error?
> 
> Thank you.



Follow ups

References