Hi Martin,
You solution does work. I see entirely that this is a better way to do
things than what I was attempting, but I was thrown by the
get_function_gradients prototype:
http://www.dealii.org/7.0.0/doxygen/deal.II/classFEValuesBase.html#af20a3f962f902555afdf9ef6dd8f17ee
If the link doesn't work, it's the second prototype of
get_function_gradients in the FEValuesBase class. It wants a
std::vector<std::vector<Tensor<1,dim> > >, not a
std::vector<Tensor<2,dim> >. In fact there isn't a prototype that
expects a std::vector<Tensor<2,dim> >, so I'm not sure why it compiles!
I don't really have a question about this, I'm just raising it as an
unusual point (or perhaps I'm looking at the incorrect class).
Many thanks for your help.
John
On 19/05/11 17:51, Martin Kronbichler wrote:
Dear John,
const unsigned int n_q_points = quadrature_formula.size();
const FEValuesExtractors::Vector velocities (0);
std::vector<std::vector<Tensor<1,dim> > > velocity_grads(n_q_points);
fe_values[velocities].get_function_gradients(solution,velocity_grads);
The exact error is:
error: no matching function for call to
‘dealii::FEValuesViews::Vector<2, 2>::get_function_gradients(const
dealii::BlockVector<double>&, std::vector<std::vector<dealii::Tensor<1,
2>, std::allocator<dealii::Tensor<1, 2> > >,
std::allocator<std::vector<dealii::Tensor<1, 2>,
std::allocator<dealii::Tensor<1, 2> > > > >&) const’
With the concept of FEValuesViews, we know how many components we have
in the finite element function. For a vector-valued problem, there are
dim components (known at compile time), so we collect the result of the
gradient of a finite element function as a Tensor<2,dim> and not as
std::vector<Tensor<1,dim> > with the vector of length dim. Hence, you
should write
std::vector<Tensor<2,dim> > velocity_grads(n_q_points);
Does this work for you? The access to velocity_grads is then the same as
you would access std::vector<std::vector<Tensor<1,dim> >, i.e., you
write velocity_grads[q][d] to get the gradient of the d-th component at
quadrature point q.
Best,
Martin
_______________________________________________
dealii mailing list http://poisson.dealii.org/mailman/listinfo/dealii