dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22162
Re: [Question #147330]: What is the preferred way to access data stored in the Data class now that it has been removed.
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.
class MyFunc : public Expression
{
public:
const Mesh& mesh;
MyFunc() : Expression(3), mesh(mesh) {}
void eval(Array<double>& values, const Array<double>& x, const ufc::cell& ufc_cell) const
{
assert(ufc_cell.local_facet >= 0);
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]);
}
};
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.
--
You received this question notification because you are a member of
DOLFIN Team, which is an answer contact for DOLFIN.
Follow ups