How to handle mesh generation: refine and maxh

2 weeks 2 days ago #2900 by dong
I tried to find the convergence rate of the Poisson problem. I modified an example from the documentation about Poisson's equation. Please see the attached file.

First, I used the mesh.Refine() command. The convergence results was shown as expected.
while fes.ndof < 10000:
    mesh.Refine()
    Solve_Poisson()
i = 1
while i < len(output):
    order_u = log(output[i-1][1]/output[i][1])/log(2)
    
    print("%0.3f | %0.3e" %
      (order_u, output[i-1][1]))
    i =  i+1
In this case, I can't handle the mesh size as I wish.

Now, I want to handle the mesh generation. Instead of using refine built-in command, I changed the 'hmax' parameter by dividing it by 2 each time. But the convergence results didn't make any sense.
hh=0.2
for i in range(4):
    mesh = Mesh(unit_square.GenerateMesh(maxh=hh))
    hh=hh/2
    Solve_Poisson()

i = 1
while i < len(output):
    order_u = log(output[i-1][1]/output[i][1])/log(2)
    
    print("%0.3f | %0.3e" %
      (order_u, output[i-1][1]))
    i =  i+1

Did I make something wrong? Could you please tell me how to handle mesh generation so that using the hmax parameter gives the same convergence results as using the refine command?
Thank you so much.
Attachments:

Please Log in or Create an account to join the conversation.

2 weeks 2 days ago #2901 by mneunteufel
Hi dong,

if you generate new meshes instead of refining an existing one, you need to recreate all FESpaces, bilinearforms, etc.

Attached I added a "SetUp" function to your file handling this stuff.

Best,
Michael

File Attachment:

File Name: poisson_new_meshes.py
File Size:1 KB
Attachments:

Please Log in or Create an account to join the conversation.

2 weeks 2 days ago #2902 by dong
Thank you so much for your clarification. That's a great tutorial.

Please Log in or Create an account to join the conversation.

© 2019 Netgen/NGSolve