Development based on step-25

55 views
Skip to first unread message

Toddy Liu

unread,
Sep 15, 2021, 8:33:29 AM9/15/21
to deal.II User Group
Dear Deal.II community,

I'm getting trouble in developing new code based on step-25. In step-25, the equation to be solved is u_tt−∆u=−sin(u) and the tutorial shows me how to solve such a nonlinear problem.

Specifically, the tutorial tells me how to calculate (sin(u),φ_j)_Ω in detail. So I 'm wondering how to solve such a problem which is like u_tt−∆u=∇∙V, where V is a vector and its components(x direction and y direction in 2D) are dependent on u. So could you please give me some advice about doing this or any reference in existing dealii examples.

Thank you very much.

Wolfgang Bangerth

unread,
Sep 15, 2021, 11:45:40 PM9/15/21
to dea...@googlegroups.com
The standard point of departure is always the weak formulation of the problem.
In your case, you will have a right hand side of the following form:

(div V(u), phi_i)

for which you can decide whether you want to integrate it by parts to get

-(V(u), grad phi_i) + boundary terms

or whether you want to leave it as is. If the latter, then you have to apply
the chain rule and get something along the lines of

(V'(u) . grad u, phi_i)

which you have to deal with in much the same way as if you just had

(sin(u), phi_i)

except that you also have terms that involve derivatives of u.

Does that make sense?

Best
W.


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

Toddy Liu

unread,
Sep 16, 2021, 12:47:05 AM9/16/21
to deal.II User Group
Hello, professor Wolfgang

Thank you very much for your reply and it really helps me. You explained how to deal with the latter case (V'(u) . grad u, phi_i) and I've got the point how to solve this. Addtionally. how about the former case -(V(u), grad phi_i). Specifically, how to construct the vector V(u) and then multiply with grad phi_i or to say fe_values.shape_grad(i,q_point)?

Thank you very much!

Best,
Toddy

Wolfgang Bangerth

unread,
Sep 16, 2021, 8:33:10 PM9/16/21
to dea...@googlegroups.com
On 9/15/21 10:47 PM, Toddy Liu wrote:
>
> Thank you very much for your reply and it really helps me. You explained
> how to deal with the latter case (V'(u) . grad u, phi_i) and I've got
> the point how to solve this. Addtionally. how about the former case
> -(V(u), grad phi_i). Specifically, how to construct the vector V(u) and
> then multiply with grad phi_i or to say fe_values.shape_grad(i,q_point)?

You perform the integral via quadrature, and so all you have to know is what
V(u)(x_q) = V(u(x_q))
which you evaluate in the same way as you did
sin(u(x_q))
in step-25 with the only exception that now V(u(x_q)) is a vector
(actually, a Tensor<1,dim>) instead of a scalar quantity.

Toddy Liu

unread,
Sep 16, 2021, 9:34:24 PM9/16/21
to dea...@googlegroups.com
Hi, professor Wolfgang

Yes, I can write the components of V(u(x_q)) by known expression, for example V(u(x_q))= (2u(x_q),3u(x_q)) where 2u(x_q) is the x-direction and 3u(x_q) is y-direction. I construct a vector<Tensor> named tmp_vector and assign the values by tmp_vector[0]=2u(x_q), tmp_vector[1]=3u(x_q). Then I do the multiplication tmp_vector*fe_values.shape_grad(i,q_point). But when I ran the program, errors occurred because maybe the operation between these two terms is not permitted. So I define the V(u(x_q)) by Point<dim>(2u(x_q),3u(x_q)) and the program runs without errors.

I want to ask whether the way I define V(u(x_q)) is right and are there any better ways to do this?

Thank you very much!

Best,
Toddy

Wolfgang Bangerth <bang...@colostate.edu> 于2021年9月17日周五 上午8:33写道:
--
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/d92bb312-b4e0-251d-cce6-cd0e2e08a117%40colostate.edu.

Wolfgang Bangerth

unread,
Sep 16, 2021, 11:14:38 PM9/16/21
to dea...@googlegroups.com
On 9/16/21 7:34 PM, Toddy Liu wrote:
>
> Yes, I can write the components of V(u(x_q)) by known expression, for example
> V(u(x_q))= (2u(x_q),3u(x_q)) where 2u(x_q) is the x-direction and 3u(x_q) is
> y-direction. I construct a vector<Tensor> named tmp_vector and assign the
> values by tmp_vector[0]=2u(x_q), tmp_vector[1]=3u(x_q). Then I do the
> multiplication tmp_vector*fe_values.shape_grad(i,q_point). But when I ran the
> program, errors occurred because maybe the operation between these two terms
> is not permitted. So I define the V(u(x_q)) by Point<dim>(2u(x_q),3u(x_q)) and
> the program runs without errors.

The dot product is defined between two objects of type Tensor<1,dim>. A
Point<dim> is derived from Tensor<1,dim>, so this works. Just
vector<Tensor<1,dim>> doesn't -- it should have been Tensor<1,dim>.

Toddy Liu

unread,
Sep 17, 2021, 2:09:00 AM9/17/21
to deal.II User Group
Professor Wolfgang

Thanks for your professional explanation and patient reply.

Best,
Toddy

Reply all
Reply to author
Forward
0 new messages