示例#1
0
import numpy as np
import sys
import time
import mui4py
domain = sys.argv[1]

# Configuration for the interfaces
config1d = mui4py.Config(1, mui4py.FLOAT64)
config2d = mui4py.Config(2, mui4py.FLOAT32)
config3d = mui4py.Config(3, mui4py.FLOAT64)

appcomm = mui4py.mpi_split_by_app()
rank = appcomm.Get_rank()

# Set up interfaces by type
# 1D interfaces
ifs = []
ifaces1d = mui4py.create_unifaces(domain, ifs, config1d)

# 2D interfaces
ifs = ["I1", "I2"]
ifaces2d = mui4py.create_unifaces(domain, ifs, config2d)
ifaces2d["I1"].set_data_types({
    "data1": mui4py.FLOAT64,
    "data2": mui4py.STRING
})
ifaces2d["I2"].set_data_types({"data": mui4py.INT64})

# 3D interfaces
ifs = ["I3"]
ifaces3d = mui4py.create_unifaces(domain, ifs, config3d)
示例#2
0
import sys
import mui4py
domain = sys.argv[1]

# Get intra communicator
appcomm = mui4py.mpi_split_by_app()
rank = appcomm.Get_rank()

# Configuration for the interface (dimensions, float type, int type)
dims = 2
config = mui4py.Config(dims, mui4py.FLOAT64)

# Default configuration for every object so no need to pass it as an argument 
# to any class constructor.
URI = "mpi://" + domain + "/ifs1"
uniface = mui4py.Uniface(uri=URI, config=config)
uniface.set_data_types({"data": mui4py.FLOAT,
                       "data_assign": mui4py.FLOAT})

# Spatial and temporal samplers
t_sampler_exact = mui4py.ChronoSamplerExact()
s_sampler_exact = mui4py.SamplerExact()

# Push/fetch some data
point = [1.0, 1.0]
t = 0.0

# Wait until commit has completed in 'pusher'
uniface.barrier(0)
fetch_val_assign = uniface.fetch("data_assign")
print("\nFetched spatially independent value '{}' from domain {}.".format(fetch_val_assign, domain))
示例#3
0
#
#  (-1,1) |=====|=====| (1,1)
#         | R2  | R3  |
#         |  x  |  x  |
#         |     |     |
#         |=====|=====|
#         | R0  | R1  |
#         |  x  |  x  |
#         |     |     |
# (-1,-1) |=====|=====| (1,-1)
#

appcomm = mui4py.mpi_split_by_app()

# Configuration for the interfaces
config = mui4py.Config(2, mui4py.FLOAT64)
# Default configuration for every object.
mui4py.set_default_config(config)
URI = "mpi://" + domain + "/ifs1"
uniface = mui4py.Uniface(uri=URI)
uniface.set_data_types({"data": mui4py.STRING})

# Eeach step from 1 to 3 sender uses a different span:
#     s = 1 -> Box intersecting R0 and R2
#     s = 2 -> Sphere intersecting R1 and R3
#     s = 3 -> Point intersecting R3
#     s = 4 -> Smart sending is disabled due to timeout
send_region_t1 = mui4py.geometry.Box([-1, -1], [-0.5, 1.0])
send_region_t2 = mui4py.geometry.Sphere([1.0, 0.0], 0.5)
send_region_t3 = mui4py.geometry.Point([0.5, 0.5])
rank = MPI_COMM_WORLD.Get_rank()

# Define MUI dimension
dimensionMUI = 2

# Define the name of push/fetch values
name_push = "coarseField"
name_fetch = "fineField"

# Define MUI push/fetch data types
data_types_push = {name_push: mui4py.FLOAT64}
data_types_fetch = {name_fetch: mui4py.FLOAT64}

# MUI interface creation
domain = "coarseDomain"
config2d = mui4py.Config(dimensionMUI, mui4py.FLOAT64)
iface = ["interface2D01", "interface2D02"]
MUI_Interfaces = mui4py.create_unifaces(domain, iface, config2d)
MUI_Interfaces["interface2D01"].set_data_types(data_types_fetch)
MUI_Interfaces["interface2D02"].set_data_types(data_types_push)

print("mpi4py.get_config(): ", mpi4py.get_config(), "\n")
print("mui4py.get_compiler_config(): ", mui4py.get_compiler_config(), "\n")
print("mui4py.get_compiler_version(): ", mui4py.get_compiler_version(), "\n")
print("mui4py.get_mpi_version(): ", mui4py.get_mpi_version(), "\n")

# Define the forget steps of MUI to reduce the memory
forgetSteps = int(5)

# Define the search radius of the RBF sampler
# The search radius should not set to a very large value so that to ensure a good convergence