Closed DanielNobbe closed 11 months ago
Perhaps you have duplicate nodes there on the interface, with no connectivity from one quadrant to another?
mesh.draw(node_numbering=True).show()
will generate quite a mess but perhaps with zooming you can see if that's the case.
Looks like there are indeed duplicate nodes on the interface, thank you for the suggestion. Do you have any ideas on how to link these duplicate nodes?
You should preferably create a proper mesh right at the start. I don't use pygmsh
and, therefore, I don't know how the code must be modified.
There is a hack to remove duplicate nodes via mesh = mesh + mesh
but this will, as a side effect, remove any tags attached to the elements or the facets of your mesh. This means that those top-left
etc. tags will vanish.
It is of course possible to add any missing tags again using MeshTri.with_subdomains
and MeshTri.with_boundaries
commands but I think it is perhaps a suboptimal solution and I'd rather try fixing the original mesh.
It is also possible to create meshes manually by combining square blocks:
mesh1 = MeshTri().refined(5)
mesh2 = MeshTri().translated((1.0, 0.0)).refined(5)
mesh = mesh1 + mesh2
mesh = mesh.with_subdomains({
'left': lambda x: x[0] < 1.,
'right': lambda x: x[0] > 1.,
})
If you are only interested in this simple geometry, it is also possible to skip all this mesh generation and tagging effort and simply hard code the following form with the heat conductivity defined inside:
@BilinearForm
def conduction(u, v, w):
hc = ((w.x[0] < 1) * (w.x[1] < 1) * 10 +
(w.x[0] > 1) * (w.x[1] > 1) * 10000 +
(w.x[0] < 1) * (w.x[1] > 1) * 5 +
(w.x[0] > 1) * (w.x[1] < 1) * 1)
return dot(hc * grad(u), grad(v))
Hi all,
I'm pretty new to using this library, and having a hard time adapting one of the examples to my use case.
I have adapted example 17 (heat transfer in a wire) to a case where there are four quadrants in a square. See an outcome from my test below. The left bottom square is heated.
I run into two problem:
basis0.get_dofs(elements=s)
, the indices returned byself.normalize_elements
do not align with the indices inself.topo.t
. The returned values fromnormalize_elements
start at index 160, and the indices in the last quadrant go 160 over the max index inself.topo.t
. I am not sure where to look for the cause of this, so any pointers would be great.get_element_dofs
call, I can work around this problem, but I am not sure what the result is. In that case, my analysis runs, but there is no heat propagated through the active boundary between the bottom-left and top-left quadrants. I'm sure I'm missing something here, since there is heat transfer through the boundary layer in the example. Any pointers would be great.Thanks in advance!
See my code below:
requirements.txt