I faced a problem. I am asking for your help.
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)
Thank you very much for your reply.
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
Thanks a lot for your reply.
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.
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)
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.
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.
Thank you so much for your reply.
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?
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?
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)
Please check it.
Where did I ever told you to change for the bilinear form? By changing the proper sign at the proper places, I confirm I get the same results with both code. If you don’t know the difference between bilinear and linear form, please look at the documentation.
Sorry, professor, my clerical error, I changed the sign of the linear form in the last code.
Actually, I have tried to change the sign at the possible locations, while the results are always wrong.
If you have knew where the sign should be change, could you explicitly pointed it out? This will help me better understand the difference between bilinear and linear forms, and better understand the difference in the usage between “solve” and “varf”.
Give you my best wishes.
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.