Dear Daniel,

Thank you for a very good answer, adding the fe_values_scalar and 
cell_scalar fixed the problem.

I have a follow-up question about the solution I get out, how is the data 
organized in the solution vector? Say for example I want to loop over all 
the x components, how would I do that?

Best,
Joel

On Friday, August 12, 2016 at 5:35:07 PM UTC+2, Daniel Arndt wrote:
>
> Joel,
>
> Yes the matrix you are assembling is a vector-valued mass matrix now.
> For me your code is failing with
>
> void dealii::FEValuesBase<dim, spacedim>::get_function_gradients(const 
> InputVector&, std::vector<dealii::Tensor<1, spacedim, typename 
> InputVector::value_type> >&) const [with InputVector = 
> dealii::Vector<double>; int dim = 3; int spacedim = 3; typename 
> InputVector::value_type = double]
> The violated condition was: 
>     (fe->n_components()) == (1)
> The name and call sequence of the exception was:
>     dealii::ExcDimensionMismatch((fe->n_components()),(1))
> Additional Information: 
> Dimension 3 not equal to 1
>
> and this is not surprising. What you are doing is to extract the gradients 
> of a vector-valued finite element solution. The object that should store 
> this should therefore be a std::vector<std::vector<Tensor<1,dim>> as you 
> want to store for each quadrature point and each component a Tensor<1,dim>.
>
> What you want to do is really that in "Do not work". As you have two 
> DoFHandlers, you should also have two FEValues objects and two 
> cell_iterator corresponding to the correct DoFHandler. Then you can extract 
> the gradient of your scalar field and project it onto the ansatz space for 
> the vector-valued field. This should look like:
>
> typename DoFHandler<dim>::active_cell_iterator cell_scalar = 
> dof_handler_scalar.begin_active();
> typename DoFHandler<dim>::active_cell_iterator cell = 
> dof_handler.begin_active();
> ...
>
>  for (; cell!=endc; ++cell, ++cell_vector)
>     {
>       fe_values.reinit (cell);
>       fe_values_scalar.reinit (cell_scalar);
>       fe_values_scalar.get_function_gradients(test,fe_function_grad);
>       ...
>     }
>
> Best,
> Daniel
>

-- 
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see 
https://groups.google.com/d/forum/dealii?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to dealii+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to