def elem_dep_data_h8(na, nb, nt): fens, fes = h8_block(a, b, t, na, nb, nt) femm = FEMMDeforLinear(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=2)) bfes = mesh_boundary(femm.fes) fesel = fe_select(fens, bfes, box=[a, a, 0, b, 0, t], inflate=htol) tsfes = bfes.subset(fesel) sfemm = FEMMDeforLinear(fes=tsfes, integration_rule=GaussRule(dim=2, order=2)) return fens, femm, sfemm
def elem_dep_data_h20r(na, nb, nts): print(na, nb, nts) # fens, fes = t4_block(a, b, t, na, nb, nt, orientation='a') fens, fes = h8_composite_plate(a, b, ts, na, nb, nts) fens, fes = h8_to_h20(fens, fes) bfes = mesh_boundary(fes) t = sum(ts) fesel = fe_select(fens, bfes, box=[0, a, 0, b, t, t], inflate=htol) tsfes = bfes.subset(fesel) femms = [] for layer in range(len(nts)): aangle = angles[layer] / 180. * math.pi mcsys = CSys(matrix=rotmat(numpy.array([0.0, 0.0, aangle]))) el = fe_select(fens, fes, bylabel=True, label=layer) femms.append( FEMMDeforLinear(material=m, material_csys=mcsys, fes=fes.subset(el), integration_rule=GaussRule(dim=3, order=2))) sfemm = FEMMDeforLinear(fes=tsfes, integration_rule=GaussRule(dim=2, order=2)) return fens, femms, sfemm
def test_Gauss(self): from numpy.testing import assert_array_almost_equal from spyfe.integ_rules import GaussRule ir = GaussRule(dim=3, order=2) assert_array_almost_equal( ir.param_coords, numpy.array([[-0.57735027, -0.57735027, -0.57735027], [-0.57735027, -0.57735027, 0.57735027], [-0.57735027, 0.57735027, -0.57735027], [-0.57735027, 0.57735027, 0.57735027], [0.57735027, -0.57735027, -0.57735027], [0.57735027, -0.57735027, 0.57735027], [0.57735027, 0.57735027, -0.57735027], [0.57735027, 0.57735027, 0.57735027]]))
def __init__(self, material=None, fes=None, integration_rule=None, material_csys=CSys(), assoc_geom=None): """Constructor. :param material: Material object. :param fes: Finite element set object. :param integration_rule: Integration rule object. """ integration_rule = GaussRule( dim=3, order=2) if integration_rule is None else integration_rule super().__init__(fes=fes, material=material, integration_rule=integration_rule, material_csys=material_csys, assoc_geom=assoc_geom)
na, nb, nh = 6,6,4 m = MatDeforTriaxLinearIso(rho=rho, e=E, nu=nu) start = time.time() fens, fes = h8_block(a, b, h, na, nb, nh) 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])
fes.gradbfunpar(numpy.array([0, 0, 0])) geom = NodalField(fens=fens) vtkexport("Poisson_fe_H20_mesh", fes, geom) print('Mesh generation', time.time() - start) bfes = mesh_boundary(fes) cn = connected_nodes(bfes) temp = NodalField(nfens=fens.count(), dim=1) for j in cn: temp.set_ebc([j], val=boundaryf(fens.xyz[j, 0], fens.xyz[j, 1], fens.xyz[j, 2])) temp.apply_ebc() femm = FEMMHeatDiff(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=3)) S = femm.connection_matrix(geom) perm = reverse_cuthill_mckee(S, symmetric_mode=True) temp.numberdofs(node_perm=perm) # temp.numberdofs() 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()
geom = NodalField(fens=fens) u = NodalField(nfens=fens.count(), dim=3) cn = fenode_select(fens, box=numpy.array([0, W, 0, 0, 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([W, W, 0, L, 0, H]), inflate=htol) for j in cn: u.set_ebc([j], comp=0, val=0.0) u.apply_ebc() u.numberdofs() print('Number of degrees of freedom', u.nfreedofs) femm = FEMMDeforLinear(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=2)) start = time.time() bfes = mesh_boundary(fes) fesel = fe_select(fens, bfes, box=[0, W, L, L, 0, H], inflate=htol) fi = ForceIntensity(magn=lambda x, J: numpy.array([0, 0, magn])) tsfes = bfes.subset(fesel) sfemm = FEMMDeforLinear(fes=tsfes, integration_rule=GaussRule(dim=2, order=2)) F = sfemm.distrib_loads(geom, u, fi, 2) start = time.time() K = femm.stiffness(geom, u) print('Matrix assembly', time.time() - start) start = time.time() U, info = minres(K, F) print(info) u.scatter_sysvec(U)
direction=lambda x: numpy.array([0.0, +1.0]), tolerance=0.99) topright = numpy.concatenate((top, right)) print('Mesh generation', time.time() - start) model_data = {} model_data['fens'] = fens model_data['regions'] \ = [{'femm': FEMMHeatDiff(material=m, fes=fes, integration_rule=TriRule(npts=1))} ] model_data['boundary_conditions'] \ = {'essential': [{'node_list': connected_nodes(bfes.subset(bottom)), 'temperature': lambda x: 100.0 }], 'surface_transfer': [{'femm': FEMMHeatDiffSurface(fes=bfes.subset(topright), integration_rule=GaussRule(dim=1, order=1), surface_transfer_coeff=lambda x: 750.0), 'ambient_temperature': lambda x: 0.0 }] } # Call the solver steady_state(model_data) print(model_data['timings']) nodeA = fenode_select(fens, box=bounding_box([Width, Heightb]), inflate=Width / 1e6) print('Temperature at nodeA (', nodeA, ')=', model_data['temp'].values[nodeA]) # Visualize the temperature plot_temperature(model_data)
N = 30 xs = numpy.linspace(0.0, 1.0, N + 1) ys = numpy.linspace(0.0, 1.0, N + 1) fens, fes = q4_blockx(xs, ys) 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() femm = FEMMHeatDiff(material=m, fes=fes, integration_rule=GaussRule(dim=2, order=2)) # S = femm.connection_matrix(geom) # perm = reverse_cuthill_mckee(S,symmetric_mode=True) # temp.numberdofs(node_perm=perm) temp.numberdofs() 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()
m = MatDeforTriaxLinearIso(e=E, nu=nu, alpha=alpha) start = time.time() fens, feslist = abaqus_importer.import_mesh('LE11_H8.inp') # Account for the instance rotation fens = rotate_mesh(fens, math.pi*90./180*numpy.array([1.0, 0.0, 0.0]), numpy.array([0.0, 0.0, 0.0])) for fes in feslist: print(fes.count()) fes = feslist[0] print('Mesh import', time.time() - start) geom = NodalField(fens=fens) u = NodalField(nfens=fens.count(), dim=3) u.apply_ebc() femm = FEMMDeforLinearH8MSGSO(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=2)) 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) bfes = mesh_boundary(fes) htol = 1.0/1000 feselzm = fe_select(fens, bfes, plane=([1.293431,-535.757E-03,0.],[0.,0.,-1.]), inflate=htol) feselzp = fe_select(fens, bfes, plane=([653.275E-03,-270.595E-03,1.79],[0.,0.,+1.]), inflate=htol) 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()
m = MatHeatDiff(thermal_conductivity=k * numpy.identity(3)) start = time.time() N = 4 xs = numpy.linspace(0.0, 1.0, N + 1) ys = numpy.linspace(0.0, 1.0, N + 1) zs = numpy.linspace(0.0, 1.0, N + 1) fens, fes = h8_blockx(xs, ys, zs) 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 j in cn: temp.set_ebc([j], val=boundaryf(fens.xyz[j, 0], fens.xyz[j, 1], fens.xyz[j, 2])) temp.apply_ebc() femm = FEMMHeatDiff(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=2)) S = femm.connection_matrix(geom) perm = reverse_cuthill_mckee(S, symmetric_mode=True) temp.numberdofs(node_perm=perm) # temp.numberdofs() 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()
fens, feslist = abaqus_importer.import_mesh('LE11_H20.inp') # Account for the instance rotation fens = rotate_mesh(fens, math.pi * 90. / 180 * numpy.array([1.0, 0.0, 0.0]), numpy.array([0.0, 0.0, 0.0])) for fes in feslist: print(fes.count()) fes = feslist[0] print('Mesh import', time.time() - start) geom = NodalField(fens=fens) u = NodalField(nfens=fens.count(), dim=3) u.apply_ebc() femm = FEMMDeforLinear(material=m, fes=fes, integration_rule=GaussRule(dim=3, order=4)) 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) bfes = mesh_boundary(fes) htol = 1.0 / 1000 feselzm = fe_select(fens, bfes, plane=([1.293431, -535.757E-03, 0.], [0., 0., -1.]), inflate=htol) feselzp = fe_select(fens, bfes, plane=([653.275E-03, -270.595E-03, 1.79], [0., 0., +1.]),