Exm7
# Mesh example: Temperature distribution in a plate
Meshing 8-node-isoparametric elements (second order incomplete quads).
Shows use of surfacemarkers/elementmarkers to apply different properties
to elements in different regions.
## Problem variables
kx1 = 100
ky1 = 100
kx2 = 10
ky2 = 10
t = 1.0
# Gauss points or integration points
n = 2
ep = [t, n]
D1 = np.matrix([
[kx1, 0.],
[0., ky1]
])
D2 = np.matrix([
[kx2, 0.],
[0., ky2]
])
# markers 10 & 11 will be used to specify different regions with different
# conductivity.
Ddict = {10 : D1, 11 : D2}
## Define geometry
### Add points
### Add splines
### Add surfaces
## Generate mesh
el_type = 16
dofs_per_node = 1
mesh = cfm.GmshMesh(g, el_type, dofs_per_node)
coords, edof, dofs, bdofs, elementmarkers = mesh.create()
Info : GMSH -> Python-module
## Solve problem
### Assemble system matrix
n_dofs = np.size(dofs)
ex, ey = cfc.coordxtr(edof, coords, dofs)
K = np.zeros([n_dofs,n_dofs])
for eltopo, elx, ely, elMarker in zip(edof, ex, ey, elementmarkers):
# Calc element stiffness matrix: Conductivity matrix D is taken
# from Ddict and depends on which region (which marker) the element is in.
Ke = cfc.flw2i8e(elx, ely, ep, Ddict[elMarker])
cfc.assem(eltopo, K, Ke)
### Solving equation system
### Compute element forces
## Visualise results


cfv.figure(fig_size=(10, 10))
cfv.draw_nodal_values_shaded(a, coords, edof, title="Temperature", dofs_per_node=mesh.dofs_per_node, el_type=mesh.el_type, draw_elements=True)
cbar = cfv.colorbar(orientation="vertical")
cbar.set_label("Temperature")
cfv.text("The bend has high conductivity", (77,135))
cfv.text("This part has low conductivity", (20,-90))
Text(20, -90, 'This part has low conductivity')
