How are both the gradient components calculated in deal?

53 views
Skip to first unread message

Abbas Ballout

unread,
May 22, 2023, 8:21:51 AM5/22/23
to deal.II User Group
Excuse this basic question but how is the gradient at a quadrature point on a face calculated in deal?
Take this code snipped for example: 

QGauss<1> face_quadrature_formula(fe.degree + 1);
FEFaceValues<2> fe_face_values(fe,
face_quadrature_formula,
update_values | update_quadrature_points |
update_normal_vectors | update_gradients |
update_JxW_values);

for (const auto &cell : dof_handler.active_cell_iterators())
for (const auto &face : cell->face_iterators())
{
fe_face_values.reinit(cell, face);
const auto &q_points = fe_face_values.get_quadrature_points();
const unsigned int n_q_points = q_points.size();

std::vector<Tensor<1, 2>> grads(n_q_points);
fe_face_values.get_function_gradients(solution, grads);

for (unsigned int q_point = 0; q_point < n_q_points; ++q_point)

{
std::cout << "At q_point\t" << q_points[q_point] << "\n";
std::cout << "Solution grads\t" << grads[q_point] << "\n";

std::cout << "\n";
}
}

How does get_function_gradients calculate both component gradient at a face?

Wolfgang Bangerth

unread,
May 22, 2023, 1:42:34 PM5/22/23
to dea...@googlegroups.com
On 5/22/23 06:21, Abbas Ballout wrote:
> How does get_function_gradients calculateboth component gradient at a face?

Abbas,
since
u_h(x) = \sum_j U_j \varphi_j(x)
you get the gradient as
\nabla u_h(x) = \sum_j U_j \nabla\varphi_j(x)
and the only other thing you need to know is that \varphi_j is defined by
mapping shape functions from the reference cell to the real cell.

But I suspect that you have a reason to ask that question. What is it really
that you are after?

Best
W.

--
------------------------------------------------------------------------
Wolfgang Bangerth email: bang...@colostate.edu
www: http://www.math.colostate.edu/~bangerth/


Abbas Ballout

unread,
May 23, 2023, 6:06:08 AM5/23/23
to deal.II User Group
Thanks for the reply. 

I was under the impression that get_function_gradients calculates the gradient based on the \sum_j U_j that are on the face. 

Wolfgang Bangerth

unread,
May 23, 2023, 9:42:49 AM5/23/23
to dea...@googlegroups.com
On 5/23/23 04:06, Abbas Ballout wrote:
>
> I was under the impression that get_function_gradients calculates the gradient
> based on the \sum_j U_j that are on the face.

No, it takes the entire sum and evaluates it at a point that happens to be on
the face. But other than where the point happens to be located, the sum is
exactly the same as if it were a point in the interior of the cell.
Reply all
Reply to author
Forward
0 new messages