コード例 #1
0
ファイル: Calculations.py プロジェクト: gprzyby/FEM
def calculate_p_global(grid: Grid, univ_ele: UniversalElement,
                       boundaries_info: dict):
    nodes_count = grid.get_spec().mN
    global_p = np.zeros(shape=(nodes_count, 1))

    for i in range(grid.get_spec().mE):
        element = grid.getElement(i + 1)
        local_p = calculate_p_matrix(element, univ_ele, boundaries_info)

        indexes = [element[i].id - 1
                   for i in range(4)]  # -1 to align with matrix indexing

        for local_row_index, global_row_index in zip(range(4), indexes):
            global_p[global_row_index, 0] += local_p[local_row_index, 0]

    return global_p
コード例 #2
0
ファイル: Calculations.py プロジェクト: gprzyby/FEM
def calculate_c_global(grid: Grid, univ_elem: UniversalElement,
                       layer_info: dict):
    global_c = np.zeros(shape=(grid.get_spec().mN, grid.get_spec().mN))

    for i in range(grid.get_spec().mE):
        element = grid.getElement(i + 1)
        local_c = calculate_c_matrix(element, univ_elem, layer_info)

        indexes = [element[i].id - 1
                   for i in range(4)]  # -1 to align with matrix indexing

        for local_row_index, global_row_index in zip(range(4), indexes):
            for local_column_index, global_column_index in zip(
                    range(4), indexes):
                global_c[global_row_index,
                         global_column_index] += local_c[local_row_index,
                                                         local_column_index]

    return global_c
コード例 #3
0
ファイル: Calculations.py プロジェクト: gprzyby/FEM
def calculate_h_global(grid: Grid, univ_elem: UniversalElement,
                       layer_info: dict, boundaries_info: dict):
    # creating global matrix with mNxmN size(num_nodes_in_grid x num_nodes_in_grid)
    global_h = np.zeros(shape=(grid.get_spec().mN, grid.get_spec().mN))
    # iterating over every element in grid
    for i in range(grid.get_spec().mE):
        element = grid.getElement(i + 1)
        local_h = calculate_h_matrix(element, univ_elem, layer_info,
                                     boundaries_info)
        # list to store id of element nodes corresponding to shape function order
        indexes = [element[i].id - 1
                   for i in range(4)]  # -1 to align with matrix indexing
        # aggregating matrix
        for local_row_index, global_row_index in zip(range(4), indexes):
            for local_column_index, global_column_index in zip(
                    range(4), indexes):
                global_h[global_row_index,
                         global_column_index] += local_h[local_row_index,
                                                         local_column_index]

    return global_h