コード例 #1
0
def structure_m_apply_bc(KS11, KS22, MST11, MST22):
    bc_id = np.where(sy_n < delta_x/10)
    if ph.mesh_prefix == 'annulus_':
        KS22 = la_utils.set_diag(KS22,bc_id)
        MST22 = la_utils.clear_rows(MST22,bc_id)

    bc_id = np.where(sx_n < delta_x/10)
    if ph.mesh_prefix == 'annulus_':
        KS11 = la_utils.set_diag(KS11,bc_id)
        MST11 = la_utils.clear_rows(MST11,bc_id)

    return KS11, KS22, MST11, MST22
コード例 #2
0
def apply_mat_bc(D11, D22):
    #lower boundary
    bc_id = np.where(y_u < dx/10)
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #upper boundary
    bc_id = np.where(y_u > 1-dx/10)
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #left boundary
    bc_id = np.where(x_u < dx/10)
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #right boundary
    bc_id = np.where(x_u > 1-dx/10)
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    return D11, D22
コード例 #3
0
def fluid_m_apply_bc(A11, A22, A12 = None, A21 = None):
    if A12 == None:
        A12 = sparse.csr_matrix(A11.shape)
    if A21 == None:
        A21 = sparse.csr_matrix(A11.shape)
    #lower boundary
    bc_id = np.where(y_u < delta_x/10)
    if ph.mesh_prefix == 'cavity_' or ph.mesh_prefix == 'channel_' or ph.mesh_prefix == 'swingbar_':
        A11 = la_utils.set_diag(A11,bc_id)
        A12 = la_utils.clear_rows(A12, bc_id)
    A22 = la_utils.set_diag(A22,bc_id)
    A21 = la_utils.clear_rows(A21, bc_id)

    #upper boundary
    bc_id = np.where(y_u > 1-delta_x/10)
    A11 = la_utils.set_diag(A11,bc_id)
    A22 = la_utils.set_diag(A22,bc_id)
    A12 = la_utils.clear_rows(A12,bc_id)
    A21 = la_utils.clear_rows(A21,bc_id)

    #right boundary
    bc_id = np.where(x_u > 1-delta_x/10)
    if ph.mesh_prefix == 'annulus_' or ph.mesh_prefix == 'cavity_' or ph.mesh_prefix == 'swingbar_':
        A11 = la_utils.set_diag(A11,bc_id)
        A22 = la_utils.set_diag(A22,bc_id)
        A12 = la_utils.clear_rows(A12,bc_id)
        A21 = la_utils.clear_rows(A21,bc_id)

    #left boundary
    bc_id = np.where(x_u < delta_x/10)
    A11 = la_utils.set_diag(A11,bc_id)
    A12 = la_utils.clear_rows(A12,bc_id)
    if ph.mesh_prefix == 'cavity_' or ph.mesh_prefix == 'channel_' or ph.mesh_prefix == 'swingbar_':
        A22 = la_utils.set_diag(A22,bc_id)
        A21 = la_utils.clear_rows(A21,bc_id)
    return A11, A22, A12, A21
コード例 #4
0
err_BDF1 = np.zeros((5))
err_BDF2 = np.zeros((5))
err_Theta = np.zeros((5))
for t_ind in range(0, 5):
    dt = 2**(-t_ind)

    u_0 = analytical(0)
    u_1 = analytical(dt)

    M_BDF1 = M + dt*K
    M_BDF2 = 1.5*M + dt*K
    M_Theta = M + dt*Theta*K

    bc_id = np.where(y > 1-dx/10)
    M_BDF1 = la_utils.set_diag(M_BDF1,bc_id)
    M_BDF2 = la_utils.set_diag(M_BDF2,bc_id)
    M_Theta = la_utils.set_diag(M_Theta,bc_id)

    bc_id = np.where(y < dx/10)
    M_BDF1 = la_utils.set_diag(M_BDF1,bc_id)
    M_BDF2 = la_utils.set_diag(M_BDF2,bc_id)
    M_Theta = la_utils.set_diag(M_Theta,bc_id)

    bc_id = np.where(x > 1-dx/10)
    M_BDF1 = la_utils.set_diag(M_BDF1,bc_id)
    M_BDF2 = la_utils.set_diag(M_BDF2,bc_id)
    M_Theta = la_utils.set_diag(M_Theta,bc_id)

    bc_id = np.where(x < dx/10)
    M_BDF1 = la_utils.set_diag(M_BDF1,bc_id)
コード例 #5
0
ファイル: heat_test.py プロジェクト: sebwolf-de/fsi_tools
(topo_p, x_p, y_p, topo_u, x_u, y_u, c2f) = \
    lin_tri_mesh.load_t3_iso_t6_file('../mesh_collection/step.msh', '../mesh_collection/step_refined.msh')
viewers.tri_plot(x_u, y_u, topo_u)
viewers.tri_plot(x_p, y_p, topo_p)

### matrix assembly
mass = assemble.u_v_p1(topo, x, y)
stiffness = assemble.gradu_gradv_p1(topo, x, y)
BDF1 = 1 / dt * mass + kappa * stiffness

### initial condition
u_n = np.zeros(x.shape)

### boundary conditions
bc_id = np.where(x < dx / 10)
BDF1 = la_utils.set_diag(BDF1, bc_id)
bc_id = np.where(y < dx / 10)
BDF1 = la_utils.set_diag(BDF1, bc_id)
bc_id = np.where(x > 1 - dx / 10)
BDF1 = la_utils.set_diag(BDF1, bc_id)
bc_id = np.where(y > 1 - dx / 10)
BDF1 = la_utils.set_diag(BDF1, bc_id)

f = np.zeros(u_n.shape)

### VTK setup
z = np.zeros(x.shape)
n_triangles = topo.shape[0]
offset = (np.ones(n_triangles) * 3).cumsum().astype(int)
topo = topo.reshape((n_triangles * 3))
ctype = np.ones(n_triangles) * VtkTriangle.tid
コード例 #6
0
ファイル: ns_master.py プロジェクト: sebwolf-de/fsi_tools
def apply_bc_mat(D11, D22):
    #upper boundary
    bc_id = np.where(y_u > y_top - delta_x / 10)
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #lower boundary
    bc_id = np.where(y_u < y_bottom + delta_x / 10)
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #right boundary
    bc_id = np.where(x_u > x_right - delta_x / 10)
    # D11 = la_utils.set_diag(D11, bc_id)
    # D22 = la_utils.set_diag(D22, bc_id)

    #left boundary
    bc_id = np.where(x_u < x_left + delta_x / 10)
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #hole upper boundary
    bc_id = np.where(
        np.all(np.array([
            y_u > hole_y_top - delta_x / 10, y_u < hole_y_top + delta_x / 10,
            x_u > hole_x_left - delta_x / 10, x_u < hole_x_right + delta_x / 10
        ]),
               axis=0))
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #hole lower boundary
    bc_id = np.where(
        np.all(np.array([
            y_u > hole_y_bottom - delta_x / 10,
            y_u < hole_y_bottom + delta_x / 10,
            x_u > hole_x_left - delta_x / 10, x_u < hole_x_right + delta_x / 10
        ]),
               axis=0))
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #hole right boundary
    bc_id = np.where(
        np.all(np.array([
            y_u > hole_y_bottom - delta_x / 10,
            y_u < hole_y_top + delta_x / 10, x_u > hole_x_right - delta_x / 10,
            x_u < hole_x_right + delta_x / 10
        ]),
               axis=0))
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    #hole left boundary
    bc_id = np.where(
        np.all(np.array([
            y_u > hole_y_bottom - delta_x / 10,
            y_u < hole_y_top + delta_x / 10, x_u > hole_x_left - delta_x / 10,
            x_u < hole_x_left + delta_x / 10
        ]),
               axis=0))
    D11 = la_utils.set_diag(D11, bc_id)
    D22 = la_utils.set_diag(D22, bc_id)

    return D11, D22
コード例 #7
0
ファイル: poisson_test.py プロジェクト: sebwolf-de/fsi_tools

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

f = M.dot(f)

f[bc_id_unten] = 0
f[bc_id_oben] = 0
f[bc_id_links] = 0
f[bc_id_rechts] = 0

es = lambda x,y: np.reshape(c*(1-x)**2*x**2 * (1-y)**2*y**2, (x.shape[0]))
コード例 #8
0
ファイル: stokes_test.py プロジェクト: sebwolf-de/fsi_tools
    x_l = x_p[row]
    y_l = y_p[row]
    eval_p = np.zeros((0, 2))
    (phi_dx, phi_dy, phi, omega) = shp.tri_p1(x_l, y_l, eval_p)
    mean_p[0, row] += omega * np.array([1. / 3., 1. / 3., 1. / 3.])

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

m_BDF1 = 1 / ph.dt * M11 + K11
m_Theta = 1 / ph.dt * M11 + 0.5 * K11
m_BDF2 = 1.5 / ph.dt * M11 + K11

#left bnd
bc_id = np.where(x_u < delta_x / 10)
m_BDF1 = la_utils.set_diag(m_BDF1, bc_id)
m_BDF2 = la_utils.set_diag(m_BDF2, bc_id)
m_Theta = la_utils.set_diag(m_Theta, bc_id)
BT1 = la_utils.clear_rows(BT1, bc_id)
BT2 = la_utils.clear_rows(BT2, bc_id)

#right bnd
bc_id = np.where(x_u > 1 - delta_x / 10)
m_BDF1 = la_utils.set_diag(m_BDF1, bc_id)
m_BDF2 = la_utils.set_diag(m_BDF2, bc_id)
m_Theta = la_utils.set_diag(m_Theta, bc_id)
BT1 = la_utils.clear_rows(BT1, bc_id)
BT2 = la_utils.clear_rows(BT2, bc_id)

#lower bnd
bc_id = np.where(y_u < delta_x / 10)