Proper use of fe_values.get_function_values to get values from a vector

29 views
Skip to first unread message

Matthew Rich

unread,
Aug 6, 2022, 9:54:41 AM8/6/22
to deal.II User Group
Hi 

I am again tinkering with my favorite tutorial step 23 and I am have a question again on how to move forward. What I am attempting to do now is redo this setup but rather than using helper functions to create the system matrix and RHS, I am trying to build the system by looping over the cells. 

My question stems from how I get the appropriate local values from vectors to use in the loops. So in step 23 you would want to get values from old_solution_u and old_solution_v. Now I looked at other tutorials and I not 100% sure they had a similar need. In looking over the documentation my guess is that I would use the overloaded get_function_values 

void FEValuesBase< dim, spacedim >::get_function_values
(
const InputVector & fe_function,
const ArrayView< const types::global_dof_index > & indices,
std::vector< typename InputVector::value_type > & values 
)

Is this correct? Also how would I deal with quadrature points in this instance in this context. Any help would be much appreciated?

Matt

Wolfgang Bangerth

unread,
Aug 7, 2022, 6:51:37 PM8/7/22
to dea...@googlegroups.com
On 8/6/22 07:54, Matthew Rich wrote:
>
> My question stems from how I get the appropriate local values from vectors to
> use in the loops. So in step 23 you would want to get values from
> old_solution_u and old_solution_v. Now I looked at other tutorials and I not
> 100% sure they had a similar need. In looking over the documentation my guess
> is that I would use the overloaded get_function_values
>
> void FEValuesBase
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dealii.org%2Fcurrent%2Fdoxygen%2Fdeal.II%2FclassFEValuesBase.html&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd90e48ca8ec64b3b34f908da77b3376d%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637953908863505093%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=bJBCJGYdxjYN%2BMzbjAEihuuFJWPRdxOrTI%2F6tWRIo0M%3D&reserved=0><
> dim, spacedim >::get_function_values
> (
> const InputVector & fe_function,
> const ArrayView
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dealii.org%2Fcurrent%2Fdoxygen%2Fdeal.II%2FclassArrayView.html&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd90e48ca8ec64b3b34f908da77b3376d%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637953908863505093%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gEJuVqsKxx9kLMJzHgV%2FUD518gvslifmMn2yURlU4vQ%3D&reserved=0><
> const types::global_dof_index
> <https://nam10.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.dealii.org%2Fcurrent%2Fdoxygen%2Fdeal.II%2Fnamespacetypes.html%23a3543786f7dc7c57385fc923a6afd5917&data=05%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cd90e48ca8ec64b3b34f908da77b3376d%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637953908863505093%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=5Hk7ddD%2FLA5%2FytpRC%2Be3zTRl3SU9rZd9zkY3UDaq3C0%3D&reserved=0> >
> & indices,
> std::vector< typename InputVector::value_type > & values
> )

Yes, this function will give you the values of the function described by the
first argument (the input vector), at the quadrature points the FEValues
object has been initialized with, and puts these values into the second
(output) argument.


> Is this correct? Also how would I deal with quadrature points in this instance
> in this context. Any help would be much appreciated?

You initialize an FEValues object with a quadrature object. Those are going to
be the points at which you get the values of the solution. (For this
operation, the weights of the quadrature points do not factor in.)

Best
W.


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

Reply all
Reply to author
Forward
0 new messages