← Back to team overview

dolfin team mailing list archive

Re: Status of new Expression interface

 

New Expression interface is very clever, but I wonder if I am the only one missing lack of access to method eval(values,data) from Python. It is really useful for functions which are related to cell.index() (e.g. material properties).

I'd love to see Python version of following C++ code:

class Sigma : public Expression
{
  public:
  Sigma() : Expression(3) {}
  MeshFunction<unsigned int>* mf;
  void eval(double* values, const Data& data) const
  {
    unsigned int mi = (*mf)[data.cell().index()];
    if( mi == 1 ) values[0] = 0.33; // material 1
    if( mi == 2 ) values[0] = 0.1;  // material 2
  }
};
Sigma sigma;
sigma.mf = mesh.data().mesh_function("material indicators");


rgrds.



Anders Logg wrote:
Looks like the new Expression interface might be working now but more
tests are needed. Please help out getting all the demos over to the
new interface.

The changes to the interface are as follows:

1. V=V argument in Expression should be removed

2. mesh argument in Constant should be removed

3. Subclasses of Expression overloading eval must overload dim if not
scalar

The Poisson and elasticity demos have been moved and both work.

--
Anders


------------------------------------------------------------------------

_______________________________________________
Mailing list: https://launchpad.net/~dolfin
Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
Unsubscribe : https://launchpad.net/~dolfin
More help   : https://help.launchpad.net/ListHelp




References