Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-25 Thread Xuefeng Li
On Fri, Jul 24, 2020 at 9:58 PM Wolfgang Bangerth 
wrote:

> On 7/23/20 12:07 PM, Xuefeng Li wrote:
> >
> > Well, the above function calculates the gradients of a finite element at
> the
> > quadrature points of a cell, not at the nodal points of a cell.
> > Such a need arises in the following situation.
> >
> > for ( x in vector_of_nodal_points )
> >v(x) = g(x, u(x), grad u(x))
>
> It's worth pointing out, however, that for the common FE_Q elements, the
> function values u(x) are continuous and so it doesn't matter how exactly
> you
> compute u(x) at node points. On the other hand, grad u(x) is in general
> discontinuous and so trying to evaluate it at node points is not actually
> possible: You will either get the values from one adjacent cell or the
> value
> from another.
>
> In other words, if you want to compute a function that depends on 'grad
> u',
> you need to think about what exactly you mean by that. In the formulation
> above, v(x) will in general be a discontinuous function, and you need to
> think
> about whether using FE_Q (a continuous finite element space) is really
> what
> you want to do.
>
> Best
>   W.
>
> Indeed, grad u would be discontinuous under normal conditions when u is
approximated by FE_Q. I remember vaguely that such an issue was discussed
in one or more of the tutorial Step examples. Thanks for your follow-up.

-- 
Stay put, practice social distancing, and be safe!

Best,

--Xuefeng Li, (504)865-3340(phone)
   Like floating clouds, the heart rests easy
   Like flowing water, the spirit stays free
  Loyola University New Orleans
   New Orleans, Louisiana (504)865-2051(fax)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAO2HPGW9tZ-U0mSuNYQcrzKGtnvg7mSoBA58svEL8DYEtfz%3DPQ%40mail.gmail.com.


Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-24 Thread Wolfgang Bangerth

On 7/23/20 12:07 PM, Xuefeng Li wrote:


Well, the above function calculates the gradients of a finite element at the 
quadrature points of a cell, not at the nodal points of a cell.

Such a need arises in the following situation.

for ( x in vector_of_nodal_points )
   v(x) = g(x, u(x), grad u(x))


It's worth pointing out, however, that for the common FE_Q elements, the 
function values u(x) are continuous and so it doesn't matter how exactly you 
compute u(x) at node points. On the other hand, grad u(x) is in general 
discontinuous and so trying to evaluate it at node points is not actually 
possible: You will either get the values from one adjacent cell or the value 
from another.


In other words, if you want to compute a function that depends on 'grad u', 
you need to think about what exactly you mean by that. In the formulation 
above, v(x) will in general be a discontinuous function, and you need to think 
about whether using FE_Q (a continuous finite element space) is really what 
you want to do.


Best
 W.

--

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

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/d2d54493-3b73-2f2f-8002-c3f9ef317177%40colostate.edu.


Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-24 Thread Xuefeng Li
On Thu, Jul 23, 2020 at 5:14 PM Daniel Arndt  wrote:

>
> You can do similarly,
>
> Quadrature q(fe.get_unit_support_points());
> FEValues fe_values (..., q, update_q_points);
> for (const auto& cell)
>   ...
>   points = fe_values.get_quadrature_points();
>   fe_values.get_function_values(values);
>   fe_values.get_function_gradients(gradients);
>   for (unsigned int i=0; i v(local_dof_indices[i]) = f(points[i],  values(i), gradients(i));
>
>
> Yes! Declaring a quadrature on support points is a great solution. Thanks
a lot!

-- 
Stay put, practice social distancing, and be safe!

Best,

--Xuefeng Li, (504)865-3340(phone)
   Like floating clouds, the heart rests easy
   Like flowing water, the spirit stays free
  Loyola University New Orleans
   New Orleans, Louisiana (504)865-2051(fax)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAO2HPGW8067gaFaYx2QjVHc719xdUVSh%3Dyg2UdhrFa4U38cn5Q%40mail.gmail.com.


Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-23 Thread Daniel Arndt
>
> We need to update function v based on solution u in the following loop.
>
> for ( x in vector_of_nodal_points )
>   v(x) = f(x, u(x))
>
> where v(x) and u(x) are the nodal point value for functions v and u,
> respectively, and f() is some function depending on function u as well as
> the location of the nodal point. So in this case, we need to access nodal
> point coordinates and nodal point values of the solution in the same loop.
>

You can just loop over all degrees of freedom and do

for (unsigned int i=0; ihttps://github.com/dealii/dealii/wiki/Frequently-Asked-Questions#how-to-get-the-mapped-position-of-support-points-of-my-element).



> Well, the above function calculates the gradients of a finite element at
> the quadrature points of a cell, not at the nodal points of a cell.
> Such a need arises in the following situation.
>
> for ( x in vector_of_nodal_points )
>   v(x) = g(x, u(x), grad u(x))
>

You can do similarly,

Quadrature q(fe.get_unit_support_points());
FEValues fe_values (..., q, update_q_points);
for (const auto& cell)
  ...
  points = fe_values.get_quadrature_points();
  fe_values.get_function_values(values);
  fe_values.get_function_gradients(gradients);
  for (unsigned int i=0; ihttp://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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAOYDWbL%2Brkbnqd0vbec33eDzSZdnVCzArZghU1fkU9uyhaXW1w%40mail.gmail.com.


Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-23 Thread Xuefeng Li
On Thu, Jul 23, 2020 at 12:43 PM Daniel Arndt 
wrote:

> However, I have two more related questions. BTW, I am a newbie in C++
>> programming. So my questions may seem absurd.
>>
>>1. Now that we have a vector holding all nodal point coordinates, and
>>another vector holding all nodal point values of the solution. How do we
>>access every nodal point coordinates, and at the same time, the associated
>>nodal point value within the same loop?
>>
>> Can you clarify in a short pseudocode example what you are trying to
> achieve?
>

We need to update function v based on solution u in the following loop.

for ( x in vector_of_nodal_points )
  v(x) = f(x, u(x))

where v(x) and u(x) are the nodal point value for functions v and u,
respectively, and f() is some function depending on function u as well as
the location of the nodal point. So in this case, we need to access nodal
point coordinates and nodal point values of the solution in the same loop.


>
>>1. In addition to nodal point values of a solution, are the partial
>>derivatives (or gradient) of the solution at each nodal point available in
>>deal.ii?
>>
>> That's basically what DataPostprocessor is doing. In general, you can
> loop over all cells and calculate the derivatives locally. Have a look at
> FEValuesBase::get_function_gradients (
> https://www.dealii.org/current/doxygen/deal.II/classFEValuesBase.html#ad1f4e0deb5d982e8172d82141c634a67
> ).
>
> Well, the above function calculates the gradients of a finite element at
the quadrature points of a cell, not at the nodal points of a cell.
Such a need arises in the following situation.

for ( x in vector_of_nodal_points )
  v(x) = g(x, u(x), grad u(x))

-- 
Stay put, practice social distancing, and be safe!

Best,

--Xuefeng Li, (504)865-3340(phone)
   Like floating clouds, the heart rests easy
   Like flowing water, the spirit stays free
  Loyola University New Orleans
   New Orleans, Louisiana (504)865-2051(fax)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAO2HPGV-p6f7Tp_C%3DcTS9tNTva9gnm3cT8-JHjkviS7bXFxJXQ%40mail.gmail.com.


Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-23 Thread Daniel Arndt
>
> However, I have two more related questions. BTW, I am a newbie in C++
> programming. So my questions may seem absurd.
>
>1. Now that we have a vector holding all nodal point coordinates, and
>another vector holding all nodal point values of the solution. How do we
>access every nodal point coordinates, and at the same time, the associated
>nodal point value within the same loop?
>
> Can you clarify in a short pseudocode example what you are trying to
achieve?

>
>1. In addition to nodal point values of a solution, are the partial
>derivatives (or gradient) of the solution at each nodal point available in
>deal.ii?
>
> That's basically what DataPostprocessor is doing. In general, you can loop
over all cells and calculate the derivatives locally. Have a look at
FEValuesBase::get_function_gradients (
https://www.dealii.org/current/doxygen/deal.II/classFEValuesBase.html#ad1f4e0deb5d982e8172d82141c634a67
).

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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAOYDWbJmMnq-3Vz%2BKEtsdnoMhOxihuJvhhFrN9Ke8QjKiam1sA%40mail.gmail.com.


Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-23 Thread Xuefeng Li
On Sun, Jul 19, 2020 at 7:36 PM Wolfgang Bangerth 
wrote:

> On 7/19/20 6:28 PM, Daniel Arndt wrote:
> >
> > The tutorial examples show only how to access values of the solution
> at
> > the quadrature points within each cell.
> >
> >
> https://github.com/dealii/dealii/wiki/Frequently-Asked-Questions#how-to-get-the-mapped-position-of-support-points-of-my-element
> > <
> https://nam01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdealii%2Fdealii%2Fwiki%2FFrequently-Asked-Questions%23how-to-get-the-mapped-position-of-support-points-of-my-element=02%7C01%7CWolfgang.Bangerth%40colostate.edu%7Cc61491e1703e46c5be0f08d82c43defe%7Cafb58802ff7a4bb1ab21367ff2ecfc8b%7C0%7C0%7C637308017305040965=TM3AYA4IqcrckUMqRTWfCJWUz3MGrUx%2FRFGvRrsg40Y%3D=0>
>
> > might also be helpful.
>
> You might also be interested in looking at the do_half_phase_step()
> function
> of step-58:
>
>
> https://dealii.org/developer/doxygen/deal.II/step_58.html#ImplementingtheStrangsplittingsteps
>
> Best
>   W.
>
>
> Thank both of you for your replies. The Step-58 function is very helpful
in showing how to access nodal point values of a solution vector object. I
assume I can access the nodal point coordinates in the similar way, where a
vector of nodal points is created using the
   DoFTools::map_dofs_to_support_points()
function.

However, I have two more related questions. BTW, I am a newbie in C++
programming. So my questions may seem absurd.

   1. Now that we have a vector holding all nodal point coordinates, and
   another vector holding all nodal point values of the solution. How do we
   access every nodal point coordinates, and at the same time, the associated
   nodal point value within the same loop?
   2. In addition to nodal point values of a solution, are the partial
   derivatives (or gradient) of the solution at each nodal point available in
   deal.ii?

Thanks again for any assistance!

-- 
Stay put, practice social distancing, and be safe!

Best,

--Xuefeng Li, (504)865-3340(phone)
   Like floating clouds, the heart rests easy
   Like flowing water, the spirit stays free
  Loyola University New Orleans
   New Orleans, Louisiana (504)865-2051(fax)

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/CAO2HPGUH18nde3KSrBkVFmeiuyChR_MKevmVMNDh%2B7xc5BO6%3DA%40mail.gmail.com.


Re: [deal.II] Accessing nodal values of a FEM solution

2020-07-19 Thread Wolfgang Bangerth

On 7/19/20 6:28 PM, Daniel Arndt wrote:


The tutorial examples show only how to access values of the solution at
the quadrature points within each cell.

https://github.com/dealii/dealii/wiki/Frequently-Asked-Questions#how-to-get-the-mapped-position-of-support-points-of-my-element 
 
might also be helpful.


You might also be interested in looking at the do_half_phase_step() function 
of step-58:


https://dealii.org/developer/doxygen/deal.II/step_58.html#ImplementingtheStrangsplittingsteps

Best
 W.


--

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

--
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/dealii/e41d69b2-bfcd-5001-7559-876226768dce%40colostate.edu.