How to create the magnitude of my solution in a new Vector?

39 views
Skip to first unread message

Abbas

unread,
Dec 12, 2022, 7:41:22 AM12/12/22
to deal.II User Group
Hello, 

This might be a simple question but I am stuck. 

I am solving a vector problem similar to step-8. I have a Vector<double> solution with u_x and u_y at each dof. I would like to have another Vector<double> magnitude which stores the magnitude \sqrt(u_x^2+u_y^2) at each dof. Now it is clear that solution has double the size of magnitude. I need to extract the values of the magnitude vector for my weak form within the assembly loop not for post-processing. 

Why do I need this? Well I don't actually want the magnitude exactly, but what I need is the maximum value of my magnitude when I iterate in time.  

 

Wolfgang Bangerth

unread,
Dec 12, 2022, 7:24:40 PM12/12/22
to dea...@googlegroups.com
On 12/12/22 05:41, Abbas wrote:
>
> I am solving a vector problem similar to step-8. I have
> aVector<double> solution with u_x and u_y at each dof. I would like to have
> another Vector<double> magnitude which stores the magnitude \sqrt(u_x^2+u_y^2)
> at each dof. Now it is clear that solution has double the size of magnitude. I
> need to extract the values of the magnitude vector for my weak form within the
> assembly loop not for post-processing.
>
> Why do I need this? Well I don't actually want the magnitude exactly, but what
> I need is the maximum value of my magnitude when I iterate in time.

That sounds very much like you want to solve a nonlinear system -- for which
step-15 shows you how to access this sort of information.

The point to note regarding step-15, though, is that it never actually creates
a vector that stores what in your case is the magnitude. That's because the
magnitude you show above is not actually a finite element field even though
u_x and u_y are: Even though the latter are bilinear functions (assuming you
are using a Q1 element), the magnitude is not a binlinear function. As a
consequence, you don't want to compute it at each node and then interpolate it
at quadrature points; rather, you want to compute it at each quadrature point
from the original solutions u_x and u_y.

Best
W.

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


Abbas

unread,
Dec 13, 2022, 2:18:27 AM12/13/22
to deal.II User Group
EXACTLY. 
However, it is not clear to me how can I store that value, so that in the next iteration I would be able to compare it with the current value at the q-point, and take the maximum between the two ,and then store that for the next iteration and so on.   

Abbas

unread,
Dec 13, 2022, 9:57:14 AM12/13/22
to deal.II User Group
I figured it out.
I need to use history variables as in step 18.  
Reply all
Reply to author
Forward
0 new messages