Exemplo n.º 1
0
def host(commun):
    """Define the host processor"""

    # Initialise the grid
    grid = Grid()

    # Build a 5*5 grid
    i = 6
    n = 2**i + 1

    # Specify the boundary conditions and the rhs
    true_soln = sin_soln
    rhs = sin_rhs

    # Find the number of processors
    p = commun.get_no_workers()

    # Specify the boundary conditions and the rhs

    # Create a square FEM grid of size n*n
    build_square_grid_matrix(n, grid, true_soln)

    # Calculate and store the A matrix and rhs vector
    build_equation_linear_2D(grid, Poisson_tri_integrate, rhs)

    # Subdivide the grids
    sub_grids = subdivide_grid(p, grid)

    #    for cell in sub_grids:
    #        plot_fem_grid(sub_grids[cell][0])

    # Send each subgrid to the specified worker processor
    for i in range(p):
        commun.send_grid(i, sub_grids[i][0])
Exemplo n.º 2
0
def generate_XGmatrix():

    build_equation_linear_2D(grid, TPS_tri_intergrateX, zero)

    Nl = []
    for node in (not_slave_node(grid)):
        #print(i)
        Nl.append([node, node.get_node_id()])

    Nl = sorted(Nl, key=itemgetter(1))

    Nl = [node[0] for node in Nl]

    for node in Nl:
        node.set_value(Nl.index(node))

    XGmatrix = zeros([len(Nl), len(Nl)])

    for node in node_iterator(grid):

        # Ignore slave (or boundary) nodes
        if not node.get_slave():

            # Which row corresponds to the current node?
            i = int(node.get_value())

            for endpt1 in connect_iterator(grid, node.get_node_id()):

                # Which column corresponds to the current node?
                j = int(grid.get_value(endpt1))

                # What is the corresponding matrix value (in the FEM grid)
                stiffness = grid.get_matrix_value(node.get_node_id(),
                                                  endpt1)[0]

                # We must not include slave nodes in the matrix columns
                if not grid.get_slave(endpt1):
                    XGmatrix[i, j] = stiffness
    return XGmatrix
Exemplo n.º 3
0
build_packman_grid(true_soln, start_angle , end_angle , N_angle, N_length, grid)
#build_packman_grid(zero, start_angle, end_angle, N_angle, N_length, grid)


#Initialise the A matrix
fem_matrix = zeros([389,389])

#fem_matrix = lil_matrix((25,25))
#fem_matrix = csc_matrix((25,25))

# Initialise the load vector
load_vector = zeros([183,1])


build_equation_linear_2D(grid, Poisson_tri_integrate, rhs)





def not_slave_node(grid):
    for node in node_iterator(grid):
        if not node.get_slave():
            yield node





IntNode=[]