Ejemplo n.º 1
0
fens, fes = h8_to_h20(fens, fes)
print('Mesh generation', time.time() - start)
geom = NodalField(fens=fens)
u = NodalField(nfens=fens.count(), dim=3)
cn = fenode_select(fens, box=numpy.array([0, 0, 0, b, 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)
u.apply_ebc()
femmk = FEMMDeforLinear(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=2))
femmk.associate_geometry(geom)
u.numberdofs()
print('Number of degrees of freedom', u.nfreedofs)
start = time.time()
K = femmk.stiffness(geom, u)
K = (K.T + K)/2.0
print('Stiffness assembly', time.time() - start)
start = time.time()
femmm = FEMMDeforLinear(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=3))
M = femmm.lumped_mass(geom, u)
M = (M.T + M)/2.
# for i in range(M.shape[0]):
#     for j in range(M.shape[1]):
#         if i==j:
#             print(i,j,M[i,j])
print('Mass assembly', time.time() - start)

start = time.time()

v = numpy.random.rand(u.nfreedofs, 6)
Ejemplo n.º 2
0
feseltp = fe_select(fens,
                    bfes,
                    plane=([1.2, 0., 0.], [0., +1., 0.]),
                    inflate=htol)
feseltm = fe_select(fens,
                    bfes,
                    plane=([707.107E-03, -707.107E-03, 1.79], [-1., -1., 0.]),
                    inflate=htol)
tsfes = bfes.subset(numpy.hstack((feselzm, feselzp, feseltp, feseltm)))

start = time.time()
sfemm = FEMMDeforLinearSurfaceSpring(
    fes=tsfes,
    integration_rule=GaussRule(dim=2, order=4),
    surface_normal_spring_coefficient=(1. / ((abs(sigma_z_A_ref) / 1e12) / E)))
K = femm.stiffness(geom, u) + sfemm.stiffness_normal(geom, u)
print('Matrix assembly', time.time() - start)

start = time.time()
dT = NodalField(nfens=fens.count(), dim=1)
dT.fun_set_values(fens.xyz, lambda x: math.sqrt(x[0]**2 + x[1]**2) + x[2])
print(numpy.max(dT.values))
print(numpy.min(dT.values))
F = femm.thermal_strain_loads(geom, u, dT)
print('Load vector assembly', time.time() - start)

start = time.time()
# U, info = lgmres(K, F)
# print(info)
lu = splu(K)
del K