def load_balance(self):

        parameter_list = Teuchos.ParameterList()
        parameter_sublist = parameter_list.sublist("ZOLTAN")
        parameter_sublist.set("DEBUG_LEVEL", "0")
        partitioner = Isorropia.Epetra.Partitioner(self.A, parameter_list)
        redistributor = Isorropia.Epetra.Redistributor(partitioner)
        self.A = redistributor.redistribute(self.A)
        self.x = redistributor.redistribute(self.x)
        self.b = redistributor.redistribute(self.b)
        return
Ejemplo n.º 2
0
def HYMLS_Bratu_problem(nx=8, interactive=False):

    try:
        from fvm import HYMLSInterface
        from PyTrilinos import Epetra
        from PyTrilinos import Teuchos
    except ImportError:
        pytest.skip("HYMLS not found")

    dim = 1
    dof = 1
    ny = 1
    nz = 1

    parameters = Teuchos.ParameterList()
    parameters.set('Bratu parameter', 0)
    parameters.set('Bordered Solver', True)
    parameters.set('Problem Type', 'Bratu problem')

    comm = Epetra.PyComm()
    interface = HYMLSInterface.Interface(comm, parameters, nx, ny, nz, dim,
                                         dof)
    m = interface.map

    continuation = Continuation(interface, parameters)

    x0 = HYMLSInterface.Vector(m)
    x0.PutScalar(0.0)
    x0 = continuation.newton(x0)

    target = 3
    ds = 0.1
    maxit = int(3.6 / ds * 2)

    (x, paras, u) = continuation.continuation(x0, 'Bratu parameter', target,
                                              ds, maxit)

    assert x.Norm2() > 0

    if not interactive:
        return

    x = gather(x)
    if comm.MyPID() == 0:
        print(x)

        # x = plot_utils.create_state_mtx(x, nx, ny, nz, dof)
        # plot_utils.plot_state(x[:, :, 0, 0], x[:, :, 0, 1], nx, ny)
    plt.plot(paras, u)
    plt.title('nx = ' + repr(nx))
    plt.xlabel('Bratu parameter C')
    plt.ylabel('Infinity Norm of u(x)')
    plt.show()
Ejemplo n.º 3
0
def test_HYMLS_2D_stretched(nx=8, interactive=False):
    try:
        from fvm import HYMLSInterface
        from PyTrilinos import Epetra
        from PyTrilinos import Teuchos
    except ImportError:
        pytest.skip("HYMLS not found")

    dim = 3
    dof = 4
    ny = nx
    nz = 1

    parameters = Teuchos.ParameterList()
    parameters.set('Reynolds Number', 0)
    parameters.set('Bordered Solver', True)
    parameters.set('Grid Stretching', True)
    parameters.set('Verbose', True)

    comm = Epetra.PyComm()
    interface = HYMLSInterface.Interface(comm, parameters, nx, ny, nz, dim,
                                         dof)
    m = interface.map

    continuation = Continuation(interface, parameters)

    x0 = HYMLSInterface.Vector(m)
    x0.PutScalar(0.0)
    x0 = continuation.newton(x0)

    start = 0
    target = 2000
    ds = 100
    x = continuation.continuation(x0, 'Reynolds Number', start, target, ds)[0]

    assert x.Norm2() > 0

    if not interactive:
        return

    x = gather(x)
    if comm.MyPID() == 0:
        print(x)

        xpos = utils.create_stretched_coordinate_vector(0, 1, nx, 1.5)
        ypos = utils.create_stretched_coordinate_vector(0, 1, ny, 1.5)

        x = plot_utils.create_velocity_magnitude_mtx(x, nx, ny, nz, dof)
        plot_utils.plot_velocity_magnitude(x[:, :, 0, 0],
                                           x[:, :, 0, 1],
                                           x=xpos,
                                           y=ypos)
Ejemplo n.º 4
0
    def load_balance(self):

        # creating partitioner and redistributing with RCB method
        param_list = Teuchos.ParameterList()
        param_list.set("Partition Method", "Default")
        partitioner = Isorropia.Epetra.Partitioner(self.A, param_list)
        redistributor = Isorropia.Epetra.Redistributor(partitioner)
        self.A = redistributor.redistribute(self.A)
        self.x = redistributor.redistribute(self.x)
        self.b = redistributor.redistribute(self.b)

        #print(self.A)
        #print(A_balanced)

        # now that its balanced, imp/exp to load balance the other data -> 'x' and 'b'?
        #print(self.A_balanced)

        return
Ejemplo n.º 5
0
def interface(nx):
    from fvm import HYMLSInterface
    from PyTrilinos import Epetra
    from PyTrilinos import Teuchos

    dim = 2
    dof = 3
    ny = nx
    nz = 1

    parameters = Teuchos.ParameterList()
    parameters.set('Reynolds Number', 0)
    parameters.set('Bordered Solver', True)

    comm = Epetra.PyComm()
    interface = HYMLSInterface.Interface(comm, parameters, nx, ny, nz, dim, dof)

    return interface
Ejemplo n.º 6
0
    def __load_balance(self):
        """Load balancing function."""
        # Load balance
        if self.rank == 0:
            print("Load balancing neighborhood graph...\n")
        # Create Teuchos parameter list to pass parameters to ZOLTAN for load
        # balancing
        parameter_list = Teuchos.ParameterList()
        parameter_list.set("Partitioning Method", "RCP")
        if not self.verbose:
            parameter_sublist = parameter_list.sublist("ZOLTAN")
            parameter_sublist.set("DEBUG_LEVEL", "0")
        # Create a partitioner to load balance the graph
        partitioner = Isorropia.Epetra.Partitioner(self.neighborhood_graph,
                                                   parameter_list)
        # And a redistributer
        redistributer = Isorropia.Epetra.Redistributor(partitioner)

        # Redistribute graph and store the map
        self.balanced_neighborhood_graph = redistributer.redistribute(
            self.neighborhood_graph)
        self.balanced_map = self.balanced_neighborhood_graph.Map()

        return
Ejemplo n.º 7
0
    unbalanced_map = Epetra.Map(global_number_of_nodes, len(nodes), 0, comm)

    #Create and populate distributed Epetra vector to the hold the unbalanced
    #data.
    my_nodes = Epetra.MultiVector(unbalanced_map, 2)
    my_nodes[:] = nodes.T
    #Create and populate an Epetra mulitvector to store the families data
    max_family_length = comm.MaxAll(max_family_length)
    my_families = Epetra.MultiVector(unbalanced_map, max_family_length)
    my_families[:] = families.T

    #Load balance
    if rank == 0: print "Load balancing...\n"
    #Create Teuchos parameter list to pass parameter to ZOLTAN for load
    #balancing
    parameter_list = Teuchos.ParameterList()
    parameter_list.set("Partitioning Method","RCB")
    if not VERBOSE:
        parameter_sublist = parameter_list.sublist("ZOLTAN")
        parameter_sublist.set("DEBUG_LEVEL", "0")
    #Create a partitioner to load balance the grid
    partitioner = Isorropia.Epetra.Partitioner(my_nodes, parameter_list)
    #And a redistributer
    redistributer = Isorropia.Epetra.Redistributor(partitioner)
    #Redistribute nodes
    my_nodes_balanced = redistributer.redistribute(my_nodes)
    #The new load balanced map
    balanced_map = my_nodes_balanced.Map()
    #Create importer and exporters to move data between banlanced and 
    #unbalanced maps
    importer = Epetra.Import(balanced_map, unbalanced_map)
Ejemplo n.º 8
0
    #     "smoother: sweeps"                          : 3,
    #     "smoother: damping factor"              : 1.0,
    #     "smoother: pre or post"                     : "both",
    #     "smoother: type"                               : "Hiptmair",
    #     "subsmoother: type"                         : "Chebyshev",
    #     "subsmoother: Chebyshev alpha"    : 27.0,
    #     "subsmoother: node sweeps"           : 4,
    #     "subsmoother: edge sweeps"           : 4,
    #     "PDE equations" : 1,
    #     "coarse: type"                                   : "Amesos-MUMPS",
    #     "coarse: max size"                           : 25,
    #     "print unused" : 0

    # }

    MLList = Teuchos.ParameterList()
    ML.SetDefaults("maxwell", MLList)

    # MList.setParameters()
    MLList.set("default values", "maxwell")
    MLList.set("max levels", 10)
    MLList.set("prec type", "MGV")
    MLList.set("increasing or decreasing", "decreasing")
    MLList.set("aggregation: type", "Uncoupled-MIS")
    MLList.set("aggregation: damping factor", 4.0 / 3.0)
    # MLList.set("eigen-analysis: type", "cg")
    # MLList.set("eigen-analysis: iterations", 10)
    MLList.set("smoother: sweeps", 5)
    MLList.set("smoother: damping factor", 1.0)
    MLList.set("smoother: pre or post", "both")
    MLList.set("smoother: type", "Hiptmair")