The elasticity problem with "varf"

Dear all,

I want to simulate the propagation of elastic wave in a 2D model. By the obtained displacement of a specify point with time (i.e., the waveform), I could judge the correctness of the simulation results. I have successfully obtain the correct results using “solve or problem”. However, the results obtained based on “varf” is obvious wrong. The code in “varf. file” is written according to the examples from the homepage of prof. Hecht I have tried to debug this code, while the results still is wrong.
The two codes with “solve” and “varf” are attached to this post, respectively.
Sequential_2D_Solve.edp (2.2 KB)
Sequential_2D_varf.edp (2.3 KB)

Best wishes,
Liu

You are not using the same `fespace`, why would the results by the same?

Dear Professor,

Actually, I have debugged the code using the same fespace. The results were wrong from the code with varf. I think the wrong results may be caused by the variational formulation. However, when I use the example wit varf from Prof. Hecht. The results are also different from that of the code with solve. I realize that the results between the codes with varf and solve would be different. But the trend and value of the results from code with varf are obvious wrong, which can be seen from output file. I really do not know the reason. Please give me some advice.
There are the two codes with varf and solve using the same fespace.
Sequential_2D_varf.edp (2.3 KB)
Sequential_2D_Solve.edp (2.4 KB)
Give you my best wishes.
Liu

You are using a single variational formulation with `solve` and three `varf` in the other .edp. Why not use a single `varf`?

Dear Professor,

I have many doubts. Actually, I have already asked you about the propagation of elastic wave in a 3D model. In the codes for the three-dimensional elasticity problem, I used solve in the serial calculation code and used varf in the parallel computing code. The results from the code with varf in the parallel computing code. You suggested me to use varf in the serial calculation code at first. Then, the parallel computing code with varf could be written according to the serial calculation code. Therefore, I try to change the serial code with varf for the simple 2D elastic problem.
To be honest, the code with three varf was written according to the examples, and I don’t know how to write code with one variational formula to solve my problem. Please give me some advice.

Sincerely yours,
Liu

Take your code that works (with `solve`), and switch to a single `varf`. That’s the only viable advice I can give you.

Ok, I will do that.

Dear Professor,

I am so sorry for my frequent problems.
According to your previous advice, I have switched my code to a single varf. However, the results from the code with a single varf are still wrong.
I find that the results between the two codes with solve and single are same when the time is 1, while the results of iteration over time are wrong. Therefore, I think that the codes of the variational form are correctly written. I guess that the code about iteration may be wrong. However, the code about iteration is totally same between the codes with solve and varf. I suspect there is an intrinsic error in my code with varf, which I do not understand. Therefore, please give me some more advice.
The two codes with “solve” and “varf” are attached to this post, respectively.
Sequential_2D_Solve.edp (2.2 KB)
Sequential_2D_Varf1.edp (2.2 KB)

Best,
Liu

Careful, when you write `solve Pb(u,v) = a(u,v) - l(v)`, with `a` a bilinear form and `l` a linear form, it becomes `varf Pb(u,v) = a(u,v) + l(v)`, otherwise, you are solving `Ax = -b`. This is probably why only the first iteration is correct. Please double-check the sign in front of your linear form.

Dear Professor,

Thank you so much for your advice. I have tried to change the sign in the front of linear form according to your suggestion, while the results still are wrong that are same to that of the before. I have also tried to debug through the code. Whatever, The results are always wrong.
Could you give me some more advice?
The changed code is attached to here.
Sequential_2D_Varf1.edp (2.2 KB)
Thank you very much.

Best,
Liu

Something is not right in your `varf` code, you did not change the sign in front of any of the linear form.

Dear Professor,

According to my understanding of the problem to be solved, in the code with solve “int2d(Th1)(densityidt2u1v1)-int2d(Th1)(density2idt2u1fv1)+int2d(Th1)(densityidt2u1bv1)+
int2d(Th1)(densityidt2u2v2)-int2d(Th1)(density2idt2u2fv2)+int2d(Th1)(densityidt2u2bv2)” is the bilinear form,
and “int2d(Th1)(lambda*div(u1,u2)div(v1,v2)+2.mu( epsilon(u1,u2)'epsilon(v1,v2)))" is the linear form. According to your suggestion, I have changed the linear form to "-int2d(Th1)(-1(lambdadiv(u1,u2)div(v1,v2)+2.mu( epsilon(u1,u2)'epsilon(v1,v2))))", and the results are wrong and are same to the before. I have also tried to change the linear form to "int2d(Th1)(-1(lambdadiv(u1,u2)*div(v1,v2)+2.mu( epsilon(u1,u2)‘epsilon(v1,v2))))" or "-int2d(Th1)(lambdadiv(u1,u2)*div(v1,v2)+2.mu( epsilon(u1,u2)’*epsilon(v1,v2)))”, the obtained results are also wrong. Is my understanding of linear form wrong？

Best,
Liu

I am sorry, Professor. I have changed the code.
According to my understanding of the problem to be solved, in the code with solve, “int2d(Th1)(density* idt2 * u1 * v1) - int2d(Th1)(density * 2 * idt2 * u1f * v1)+int2d(Th1)(density * idt2* u1b * v1)+
int2d(Th1)(density * idt2 * u2 * v2)-int2d(Th1)(density * 2 * idt2 * u2f * v2)+int2d(Th1)(density * idt2 * u2b * v2)” is the bilinear form,
and “int2d(Th1)(lambda * div(u1,u2) * div(v1,v2)+2. * mu * ( epsilon(u1,u2)’ * epsilon(v1,v2)))" is the linear form. According to your suggestion, I have changed the linear form to “-int2d(Th1)(-1*(lambda * div(u1,u2) * div(v1,v2)+2. * mu * ( epsilon(u1,u2)’ * epsilon(v1,v2))))”, and the results are wrong and are same to that of before. I have also tried to change the linear form to “int2d(Th1)(-1*(lambda * div(u1,u2) * div(v1,v2)+2. * mu * ( epsilon(u1,u2)’ * epsilon(v1,v2))))” or "-int2d(Th1)(lambda * div(u1,u2) * div(v1,v2)+2. * mu * ( epsilon(u1,u2)’ * epsilon(v1,v2)))”, the obtained results are also wrong. Is my understanding of linear form wrong？

`Like this`

Your understanding of linear form is wrong, you are changing the bilinear form.

Professor, according to your advice, I changed the sign before the bilinear form, while the results are still wrong.
Sequential_2D_Varf1.edp (2.3 KB)
Just send me the latest version of your code where, with respect to the code using `solve`, you changed the sign in front of all terms in your linear form, and no sign change in front of the terms in the bilinear form.