What is the correct/practical way to make non-uniform mesh?
I was trying to generate a multi-layer cube structure that contains parts of it using different finer meshes. I found two ways to do it. (To simplify the case, I just have this structure having two layers with the same size and mesh size but part of the top layer should have finer mesh.) But it turns out that the two methods generate very different mesh. The second method seems to have some mistakes. It either generates some extra shape/mesh around the finer mesh sport or the finer mesh is not connected to the other part of the structure correctly.
The code is attached here. two_methods.zip
In the first method, it is done point by point, line by line, and surface by surface (Since two layers have the same mesh size, I did not really drtaw two layers there); while in the second method, the extrude method is used. The reason I was trying to do the second method is that I will have a much more complex structure so seems like the second method is more programmable because the first method needs to find every single point, line, and face in the order.
I need to put these two mesh into a solver to simulate the temperature map of the structure while the small part is the heat source. Below are the images of the two mesh results from method 1 and method 2 respectively:
The mesh and the temperature simulation result from method 1 looks reasonable while method 2 has a weird low-temperature spot overlapped with the heat source. It can also be seen that there is some mesh around that spot in the mesh plot. Feels like in method 2, mesh are not properly connected but I do not understand why.
Can anyone let me know what is the key difference between method 1 and method 2 and how to solve my problem?