← Back to team overview

dolfin team mailing list archive

error: invalid initialization

 

I couldn't add the elasticity module to the last version of dolfin so I'm
eventually converting my whole solver from pydolfin to C++ putting
everything inside the class ElasticityUpdatedSolver. However from the
constructor:

ElasticityUpdatedSolver::ElasticityUpdatedSolver(Mesh& mesh, char* tag,
						 Function& v0,
						 real rho,
						 real E, real nu, real nuv,
						 real nuplast,
						 real k, real T, real origin, real weight)
  : mesh(mesh), f(mesh.numVertices(), tag), v0(v0), rho(rho), E(E),
    weight(weight),
    solutionfile(strcat(tag, "_solution.pvd")), file(solutionfile),
    nuplast(nuplast), deltat(k), dt(k), solver(tag),
    T(T), filecounter(0), lastsample(0),
    lmbda(E * nu / ((1 + nu) * (1 - 2 * nu))),
    mu(E / (2 * (1 + nu))), nu(nu), nuv(nuv),
    time(0.0), rtol(get("ODE discrete tolerance")),
    maxiters(get("ODE maximum iterations")), do_plasticity(false),
    yld(0.0),
    savesamplefreq(33.0),
    fcount(0),
    element1(new PlasticityUpdated::BilinearForm::TestElement),
    element2(new XvMass::LinearForm::TestElement),
    element3(new PlasticityUpdated::BilinearForm::FunctionElement_2),
    u0(x0, mesh, *element1),
    sigma0(xsigma0, mesh, *element2),
    sigma1(xsigma1, mesh, *element2),
    epsilon1(xepsilon1, mesh, *element2),
    sigmanorm(xSnorm, mesh, *element3),
    bc(mesh, 0.0, -0.0, 0.0, origin) {}

I can't rid of the following errors:

ElasticityUpdatedSolver.cpp:48: error: invalid initialization of reference
of type 'dolfin::Function&' from expression of type 'dolfin::real'
ElasticityUpdatedSolver.cpp:48: error: invalid initialization of reference
of type 'dolfin::Function&' from expression of type 'dolfin::real'
ElasticityUpdatedSolver.cpp:48: error: invalid initialization of reference
of type 'dolfin::Function&' from expression of type 'dolfin::real'
ElasticityUpdatedSolver.cpp:48: error: invalid initialization of non-const
reference of type 'dolfin::Function&' from a temporary of type
'dolfin::real'
ElasticityUpdatedSolver.cpp:48: error: invalid initialization of non-const
reference of type 'dolfin::Function&' from a temporary of type
'dolfin::real'
ElasticityUpdatedSolver.cpp:48: error: invalid initialization of reference
of type 'dolfin::Function&' from expression of type 'dolfin::real'

which all come from the lines in which I used the constructor:

Function::Function(real value);

taken from the class Function. Thanks for your help.

Alessio





Follow ups