Dear all, I was wondering how to get the vector-valued gradient of solution vector. If I have my solution f (a scalar field, from the Poisson equation for example), I would like to get u = \nabla f. I started by adding this weak form to the assemble_system, but I got stuck. This is what I got so for:
template <int dim> void Step4<dim>::assemble_system () { QGauss<dim> quadrature_formula(dof_handler.get_fe().degree+1); FEValues<dim> fe_values (fe, quadrature_formula, update_values | update_gradients | update_quadrature_points | update_JxW_values); std::vector<Tensor<1, dim>> fe_function_grad(quadrature_formula.size()); const unsigned int dofs_per_cell = fe.dofs_per_cell; const unsigned int n_q_points = quadrature_formula.size(); FullMatrix<double> cell_matrix (dofs_per_cell, dofs_per_cell); Vector<double> cell_rhs (dofs_per_cell); std::vector<types::global_dof_index> local_dof_indices (dofs_per_cell); typename DoFHandler<dim>::active_cell_iterator cell = dof_handler.begin_active(), endc = dof_handler.end(); for (; cell!=endc; ++cell) { fe_values.reinit (cell); fe_values.get_function_gradients(solution,fe_function_grad); cell_matrix = 0; cell_rhs = 0; for (unsigned int q_index=0; q_index<n_q_points; ++q_index) for (unsigned int i=0; i<dofs_per_cell; ++i) { for (unsigned int j=0; j<dofs_per_cell; ++j) cell_matrix(i,j) += ((fe_values.shape_value(i, q_index) * fe_values.shape_value (j, q_index))* fe_values.JxW (q_index)); cell_rhs(i) += ((fe_values.shape_value (i, q_index) * fe_function_grad[q_index])* fe_values.JxW (q_index)); } cell->get_dof_indices (local_dof_indices); constraints.distribute_local_to_global (cell_matrix, cell_rhs, local_dof_indices, system_matrix, system_rhs); } } But this do not compile. The error is that fe_function_grad is a Tensor, not a double. How do I fix this? How do I set up the right-hand side from get_function_gradients? Best, Joel -- 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.