Hi Ahmad,

the Tensor<1,dim> is not a double. It is a tensor. So if you want do assign it. You have to create a Tensor<1,dim> and then you can fill it with data. The same is true for the gradient. In more than one dimension it is not a scalar any more. Does that help?

Best, Bärbel

--
Bärbel Janssen
Institut für Angewandte Mathematik
Universität Heidelberg

Im Neuenheimer Feld 293, Raum 213
Telefon: +49 6221 54-5449


On Mon, 14 Mar 2011, Ahmad Al Nabulsi wrote:

Hi all,
in order to make a test problem, i took a smooth function u=exp(x^2+y^2) as an 
exact solution, and I defined the gradient in y direction grad=2yexp(x^2+y^2).
I implement them as in step 7 with some modification but unfortunatelly it gave 
me the following error
"
conversion from ‘double’ to non-scalar type ‘dealii::Tensor<1, 2>’ requested
in line
  Tensor<1,dim> return_value=2*p(1)*exp(p(0)*p(0)+p(1)*p(1));
"

this is the connected part from the code

template <int dim>
class Solution : public Function<dim>
       
{
  public:
    Solution () : Function<dim>() {}
   
    virtual double value (const Point<dim>   &p,
              const unsigned int  component = 0) const;
   
    virtual Tensor<1,dim> gradient (const Point<dim>   &p,
                    const unsigned int  component = 0) const;
};
template <int dim>
double Solution<dim>::value (const Point<dim>   &p,
                 const unsigned int) const
{
  double return_value = exp(p(0)*p(0)+p(1)*p(1));
 
 
  return return_value;
}
template <int dim>
Tensor<1,dim> Solution<dim>::gradient (const Point<dim>   &p,
                       const unsigned int) const
{
  Tensor<1,dim> return_value=2*p(1)*exp(p(0)*p(0)+p(1)*p(1));

 
 
  return return_value;
}

please help me to fix the problem.

best regards,
Ahmad



_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii

Reply via email to