dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #23241
[Bug 772787] Re: Constant needs to overload eval(values, x)
** Changed in: dolfin
Status: Fix Committed => Fix Released
--
You received this bug notification because you are a member of DOLFIN
Team, which is subscribed to DOLFIN.
https://bugs.launchpad.net/bugs/772787
Title:
Constant needs to overload eval(values,x)
Status in DOLFIN:
Fix Released
Bug description:
The following example gives me an error. I can't figure out where the
problem is in my cpp code. Is it because I am using GenericFunction?
The eval function is overloaded! Any help would be appreciated.
Thanks,
Chaffra
56 x = numpy.zeros(10)
---> 57 tau_n.compute_vertex_values(x,mesh)
58 print x
59
RuntimeError: *** Error: Missing eval() function (must be overloaded).
______________EXAMPLE____________
from dolfin import *
import numpy
cppcode = """
class Tau_n1 : public Expression
{
public:
boost::shared_ptr<GenericFunction> vth;
boost::shared_ptr<GenericFunction> total_doping;
boost::shared_ptr<GenericFunction> nt_srh;
double nref_srh;
double sigma;
double gamma;
Tau_n1() : Expression() {}
void eval(Array<double>& values, const Array<double>& x) const
{
double _vth = (*vth)(x[0],x[1],x[2]);
double _nt_srh = (*nt_srh)(x[0],x[1],x[2]);
double _nt = std::abs( (*total_doping)(x[0],x[1],x[2]) );
if (_nt == 0){
_nt = _nt_srh;
}
else{
_nt = _nt_srh*std::pow(_nt/nref_srh,gamma);
}
values[0] = 1.0/(sigma*_nt*_vth);
}
void eval(Array<double>& values, const Array<double>& x, const ufc::cell& cell) const
{
eval(values,x);
}
};
"""
mesh = UnitInterval(11)
Q = FunctionSpace(mesh,'CG',1)
tau_n = Expression(cppcode=cppcode)
tau_n.nt_srh = Constant(1e13)
tau_n.total_doping = Function(Q)
tau_n.vth = Constant(1.0)
tau_n.nref_srh = 1e12
tau_n.sigma = 1e-6
tau_n.gamma = 1.76
x = numpy.zeros(10)
tau_n.compute_vertex_values(x,mesh)
print x
References