Different get_function_gradients

36 views
Skip to first unread message

Michael Lee

unread,
Jun 24, 2021, 12:20:12 PM6/24/21
to deal.II User Group

After reading the documentation on Handling vector valued problems (The deal.II Library: Handling vector valued problems (dealii.org)), I have the following question.

What are the differences between the three functions?

(1) FEValuesBase::get_function_gradients 

(2) FEValuesViews::Scalar::get_function_gradients 

(3) FEValuesViews::Vector::get_function_gradients 


Does the (1) do all the work that the last two do? I.e., (1) gives the whole chunk of gradient, and the last two extract the scalar and vector parts from the chunk, respectively.


Jean-Paul Pelteret

unread,
Jun 24, 2021, 4:13:31 PM6/24/21
to dea...@googlegroups.com
Hi Michael,

Does the (1) do all the work that the last two do? I.e., (1) gives the whole chunk of gradient, and the last two extract the scalar and vector parts from the chunk, respectively.

They are very closely related. (1) has no knowledge on the nature of the field(s) for which the gradient is being computed, so it just returns the gradient of all individual components of the solution field at once, and it's up to you to interpret that however you need. For (2) and (3), one is interpreting the solution field (or a subset of its components) to have a certain nature, and so more context can be given to the gradients that are returned. In particular, the gradient of a scalar field is a rank-1 tensor, and the gradient of a vector field would be a rank-2 tensor. So the return types are in fact different, but essentially encode the some/all information that is given by (1). 

Does that make sense?

The great thing about using the FEValuesExtractors/FEValuesViews concept is that you are able to achieve a near 1-1 match of the written and programmed weak form, which makes implementing things a lot easier. So in most of the more recent tutorials we use them, and I’d say that more often than not we’d advocate their use.

Best,
Jean-Paul

--
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+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/89ec12a9-9553-4ee2-9bf0-8900517587c3n%40googlegroups.com.

Michael Li

unread,
Jun 24, 2021, 6:02:06 PM6/24/21
to dea...@googlegroups.com

Hi Jean-Paul,

Thank you so much for your explanation. That totally makes sense. These different functions exist for implementing  different weak forms easily. Though I can get everything using (1), but I would prefer using the others when I try to extract components of the gradient.

 

Best,

Michael

Reply all
Reply to author
Forward
0 new messages