Esempio n. 1
0
fens, fes = h8_block(L, W, H, nL, nW, nH)
fens, fes = h8_to_h20(fens, fes)
print('Mesh import', time.time() - start)

geom = NodalField(fens=fens)
u = NodalField(nfens=fens.count(), dim=3)
cn = fenode_select(fens, box=numpy.array([0.0, 0.0, 0, W, 0, H]), inflate=htol)
for j in cn:
    u.set_ebc([j], comp=0, val=0.0)
    u.set_ebc([j], comp=1, val=0.0)
    u.set_ebc([j], comp=2, val=0.0)
cn = fenode_select(fens, box=numpy.array([L, L, 0, W, 0, H]), inflate=htol)
for j in cn:
    u.set_ebc([j], comp=0, val=0.0)

u.apply_ebc()

femm = FEMMDeforLinear(material=m,
                       fes=fes,
                       integration_rule=GaussRule(dim=3, order=3))
femm.associate_geometry(geom)
S = femm.connection_matrix(geom)
perm = reverse_cuthill_mckee(S, symmetric_mode=True)
u.numberdofs(node_perm=perm)
print('Number of degrees of freedom', u.nfreedofs)

start = time.time()
K = femm.stiffness(geom, u)
print('Matrix assembly', time.time() - start)

start = time.time()
Esempio n. 2
0
k = 1.0  # thermal conductivity
m = MatHeatDiff(thermal_conductivity=array([[k, 0.0], [0.0, k]]))
Dz = 1.0  # thickness of the slice
start = time.time()
N = 100
Length, Width, nL, nW = 1.0, 1.0, N, N
fens, fes = t3_ablock(Length, Width, nL, nW)
print('Mesh generation', time.time() - start)
bfes = mesh_boundary(fes)
cn = connected_nodes(bfes)
geom = NodalField(fens=fens)
temp = NodalField(nfens=fens.count(), dim=1)
for index in cn:
    temp.set_ebc([index],
                 val=boundaryf(fens.xyz[index, 0], fens.xyz[index, 1]))
temp.apply_ebc()
temp.numberdofs()
femm = FEMMHeatDiff(material=m, fes=fes, integration_rule=TriRule(npts=1))
start = time.time()
fi = ForceIntensity(magn=lambda x, J: Q)
F = femm.distrib_loads(geom, temp, fi, 3)
print('Heat generation load', time.time() - start)
start = time.time()
F += femm.nz_ebc_loads_conductivity(geom, temp)
print('NZ EBC load', time.time() - start)
start = time.time()
K = femm.conductivity(geom, temp)
print('Matrix assembly', time.time() - start)
start = time.time()
temp.scatter_sysvec(spsolve(K, F))
# T, info = minres(K, F)