normal vector stored as a const function

4 months ago by
Hello everyone,

I have a 3-component normal vector stored as a const Function  and I pass it as an input to my Expression  to make a multiplication with a constant field b defined as const double b =((M_PI*cos(2*M_PI*x[1]))/25, 1/5, 0.0);like so:

class B : public Expression 
B (const Function &normals) : Expression(3), _normals(normals) {}; 
void eval(Array<double>& values, const Array<double>& x) const
{        const double b =((M_PI*cos(2*M_PI*x[1]))/25, 1/5, 0.0);     
for (size_t i = 0; i < _normals.size(); ++i)       {
   {       values[0] = (M_PI*cos(2*M_PI*x[1]))/25;       values[1] = 1/5 ;    values[2] = 0.0;     }   
       else if((b*_normals.vector())>0.0)          
   {      values[0] = 0.0;       values[1] = 0.0;    values[2] = 0.0;        
    }    private:   const Function &_normals;};

however I do not know how to reach the rows/columns of _normals vector function and do the multiplication with b inside Expression. I can use  _normals.vector(), but when I do _normals.vector().size() I get an error saying ‘class std::shared_ptr<const dolfin::GenericVector>’ has no member named ‘size’ which I believe generic vector has a member named size.

Anyone knows how to manage this generic vector in the expression ?

Thanks in advance

Community: FEniCS Project

1 Answer

4 months ago by
You can extract the vector object:
std::vector<double> solution_vector;
solutionVectorSize = solution_vector.size();​
Thank you, this was what I was looking for.
written 3 months ago by noname  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »