示例#1
0
ndofs_u = x_u.shape[0]
mass_1D = assemble.u_v_p1(topo_u, x_u, y_u)
mass_matrix_u = sparse.vstack([
    sparse.hstack([mass_1D, sparse.csr_matrix((ndofs_u, ndofs_u))]),
    sparse.hstack([sparse.csr_matrix((ndofs_u, ndofs_u)), mass_1D])
])

ie_s = np.arange(0, s_lgr.shape[0])
ndofs_s = max(ie_s) + 1
mass_1D = assemble.u_v_p1_periodic(topo_s, s_lgr, t_lgr, ie_s)
mass_matrix_s = sparse.vstack([
    sparse.hstack([mass_1D, sparse.csr_matrix((ndofs_s, ndofs_s))]),
    sparse.hstack([sparse.csr_matrix((ndofs_s, ndofs_s)), mass_1D])
])

stiffness_1D = assemble.gradu_gradv_p1(topo_u, x_u, y_u)
stiffness_matrix_u = sparse.vstack([
    sparse.hstack([stiffness_1D,
                   sparse.csr_matrix((ndofs_u, ndofs_u))]),
    sparse.hstack([sparse.csr_matrix((ndofs_u, ndofs_u)), stiffness_1D])
])

stiffness_1D = assemble.gradu_gradv_p1_ieq(topo_s, s_lgr, t_lgr, ie_s)
stiffness_matrix_s = sparse.vstack([
    sparse.hstack([stiffness_1D,
                   sparse.csr_matrix((ndofs_s, ndofs_s))]),
    sparse.hstack([sparse.csr_matrix((ndofs_s, ndofs_s)), stiffness_1D])
])

input_name = results_dir + 'reference'
f = open(input_name, "rb")
示例#2
0
l_n = sp_la.spsolve(MS.tocsc(), rhs)

(KS11, KS22, MST11, MST22) = structure_m_apply_bc(KS11, KS22, MST11, MST22)

MST = sparse.vstack([
    sparse.hstack([MST11,sparse.csr_matrix((ndofs_s,ndofs_s))]),
    sparse.hstack([sparse.csr_matrix((ndofs_s,ndofs_s)),MST22])
    ])

KS = sparse.vstack([
    sparse.hstack([KS11,sparse.csr_matrix((ndofs_s,ndofs_s))]),
    sparse.hstack([sparse.csr_matrix((ndofs_s,ndofs_s)),KS22])
    ])

MF11 = ph.rho_fluid*assemble.u_v_p1(topo_u,x_u,y_u)
KF11 = ph.nu*assemble.gradu_gradv_p1(topo_u,x_u,y_u)

MF = sparse.vstack([
    sparse.hstack([MF11,sparse.csr_matrix((ndofs_u,ndofs_u))]),
    sparse.hstack([sparse.csr_matrix((ndofs_u,ndofs_u)),MF11])
    ])

(BT1,BT2) = assemble.divu_p_p1_iso_p2_p1p0(topo_p,x_p,y_p,
           topo_u,x_u,y_u,c2f)

BT = sparse.vstack([BT1,BT2])
B = BT.transpose()

nodes_p = x_p.shape[0]
cells_p = topo_p.shape[0]
MP = sparse.vstack([
示例#3
0
    n = 10
dx = 1./n
print('dx = ' + str(dx))

T = 5
CN = 0.5
TOL = 1e-8
max_iter = 10

n_runs = 5

(topo_p,x_p,y_p,topo_u,x_u,y_u,c2f) = lin_t3.mesh_t3_iso_t6(n,n,dx,dx)
(topo_p,x_p,y_p) = lin_t3.mesh_t3_t0(n,n,dx,dx)
print('Mesh generation finished')

K = assemble.gradu_gradv_p1(topo_u,x_u,y_u)
M = assemble.u_v_p1(topo_u,x_u,y_u)
(BT1,BT2) = assemble.divu_p_p1_iso_p2_p1p0(topo_p,x_p,y_p,topo_u,x_u,y_u,c2f)
BT = sparse.vstack([BT1,BT2])
B = BT.transpose()

ndofs_u = BT1.shape[0]
ndofs_p = BT1.shape[1]
print('dofs u = ' + str(2*ndofs_u))
print('dofs p = ' + str(ndofs_p))

bc_id = np.where(y_u > 1-dx/10)
BT1 = la_utils.clear_rows(BT1,bc_id)
BT2 = la_utils.clear_rows(BT2,bc_id)

bc_id = np.where(y_u < dx/10)
示例#4
0
from shapely.geometry import LineString

sys.path.append('../../modules')
import assemble
import basis_func as basis
import la_utils
import lin_tri_mesh as lin_t3
import quadrature


n = 10
dx = 1./n

(topo,x,y) = lin_t3.mesh_t3(n,n,dx,dx)

K = assemble.gradu_gradv_p1(topo,x,y)
M = assemble.u_v_p1(topo,x,y)

bc_id_unten = np.where(y < dx/10)
bc_id_oben = np.where(y > 1-dx/10)
bc_id_links = np.where(x < dx/10)
bc_id_rechts = np.where(x > 1-dx/10)

K = la_utils.set_diag(K,bc_id_unten)
K = la_utils.set_diag(K,bc_id_oben)
K = la_utils.set_diag(K,bc_id_links)
K = la_utils.set_diag(K,bc_id_rechts)

c = 200
f = -c*(2-12*x+12*x**2)*(1-y)**2*y**2 - c*(2-12*y+12*y**2)*(1-x)**2*x**2