本文整理汇总了Python中pymor.tools.mpi.call函数的典型用法代码示例。如果您正苦于以下问题:Python call函数的具体用法?Python call怎么用?Python call使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了call函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, obj_id, mpi_range, mpi_source, with_apply2=False, pickle_local_spaces=True,
space_type=MPIVectorSpace):
assert mpi_source or mpi_range
self.obj_id = obj_id
self.mpi_source = mpi_source
self.mpi_range = mpi_range
self.op = op = mpi.get_object(obj_id)
self.with_apply2 = with_apply2
self.pickle_local_spaces = pickle_local_spaces
self.space_type = space_type
self.linear = op.linear
self.name = op.name
self.build_parameter_type(op)
if mpi_source:
local_spaces = mpi.call(_MPIOperator_get_local_spaces, obj_id, True, pickle_local_spaces)
if all(ls == local_spaces[0] for ls in local_spaces):
local_spaces = (local_spaces[0],)
self.source = space_type(local_spaces)
else:
self.source = op.source
if mpi_range:
local_spaces = mpi.call(_MPIOperator_get_local_spaces, obj_id, False, pickle_local_spaces)
if all(ls == local_spaces[0] for ls in local_spaces):
local_spaces = (local_spaces[0],)
self.range = space_type(local_spaces)
else:
self.range = op.range
开发者ID:pymor,项目名称:pymor,代码行数:27,代码来源:mpi.py
示例2: mpi_wrap_operator
def mpi_wrap_operator(obj_id, functional=False, vector=False, with_apply2=False,
pickle_subtypes=True, array_type=MPIVectorArray):
"""Wrap MPI distributed local |Operators| to a global |Operator| on rank 0.
Given MPI distributed local |Operators| referred to by the
`~pymor.tools.mpi.ObjectId` `obj_id`, return a new |Operator|
which manages these distributed operators from rank 0. This
is done by instantiating :class:`MPIOperator`. Additionally, the
structure of the wrapped operators is preserved. E.g. |LincombOperators|
will be wrapped as a |LincombOperator| of :class:`MPIOperators`.
Parameters
----------
See :class:`MPIOperator`.
Returns
-------
The wrapped |Operator|.
"""
op = mpi.get_object(obj_id)
if isinstance(op, LincombOperator):
obj_ids = mpi.call(_mpi_wrap_operator_LincombOperator_manage_operators, obj_id)
return LincombOperator([mpi_wrap_operator(o, functional, vector, with_apply2, pickle_subtypes, array_type)
for o in obj_ids], op.coefficients, name=op.name)
elif isinstance(op, VectorArrayOperator):
array_obj_id, subtypes = mpi.call(_mpi_wrap_operator_VectorArrayOperator_manage_array, obj_id, pickle_subtypes)
if all(subtype == subtypes[0] for subtype in subtypes):
subtypes = (subtypes[0],)
return VectorArrayOperator(array_type(type(op._array), subtypes, array_obj_id),
transposed=op.transposed, name=op.name)
else:
return MPIOperator(obj_id, functional, vector, with_apply2, pickle_subtypes, array_type)
开发者ID:nsrishankar,项目名称:pymor,代码行数:32,代码来源:mpi.py
示例3: __init__
def __init__(self, obj_id, functional=False, vector=False, with_apply2=False,
pickle_subtypes=True, array_type=MPIVectorArray):
assert not (functional and vector)
self.obj_id = obj_id
self.op = op = mpi.get_object(obj_id)
self.functional = functional
self.vector = vector
self.with_apply2 = with_apply2
self.pickle_subtypes = pickle_subtypes
self.array_type = array_type
self.linear = op.linear
self.name = op.name
self.build_parameter_type(inherits=(op,))
if vector:
self.source = NumpyVectorSpace(1)
assert self.source == op.source
else:
subtypes = mpi.call(_MPIOperator_get_source_subtypes, obj_id, pickle_subtypes)
if all(subtype == subtypes[0] for subtype in subtypes):
subtypes = (subtypes[0],)
self.source = VectorSpace(array_type, (op.source.type, subtypes))
if functional:
self.range = NumpyVectorSpace(1)
assert self.range == op.range
else:
subtypes = mpi.call(_MPIOperator_get_range_subtypes, obj_id, pickle_subtypes)
if all(subtype == subtypes[0] for subtype in subtypes):
subtypes = (subtypes[0],)
self.range = VectorSpace(array_type, (op.range.type, subtypes))
开发者ID:nsrishankar,项目名称:pymor,代码行数:29,代码来源:mpi.py
示例4: apply_adjoint
def apply_adjoint(self, U, ind=None, mu=None, source_product=None, range_product=None):
assert U in self.range
mu = self.parse_parameter(mu)
U = U if self.functional else U.obj_id
source_product = source_product and source_product.obj_id
range_product = range_product and range_product.obj_id
if self.vector:
return mpi.call(
mpi.method_call,
self.obj_id,
"apply_adjoint",
U,
ind=ind,
mu=mu,
source_product=source_product,
range_product=range_product,
)
else:
space = self.source
return space.type(
space.subtype[0],
space.subtype[1],
mpi.call(
mpi.method_call_manage,
self.obj_id,
"apply_adjoint",
U,
ind=ind,
mu=mu,
source_product=source_product,
range_product=range_product,
),
)
开发者ID:JuliaBru,项目名称:pymor,代码行数:33,代码来源:mpi.py
示例5: mpi_wrap_operator
def mpi_wrap_operator(obj_id, mpi_range, mpi_source, with_apply2=False, pickle_local_spaces=True,
space_type=MPIVectorSpace):
"""Wrap MPI distributed local |Operators| to a global |Operator| on rank 0.
Given MPI distributed local |Operators| referred to by the
:class:`~pymor.tools.mpi.ObjectId` `obj_id`, return a new |Operator|
which manages these distributed operators from rank 0. This
is done by instantiating :class:`MPIOperator`. Additionally, the
structure of the wrapped operators is preserved. E.g. |LincombOperators|
will be wrapped as a |LincombOperator| of :class:`MPIOperators <MPIOperator>`.
Parameters
----------
See :class:`MPIOperator`.
Returns
-------
The wrapped |Operator|.
"""
op = mpi.get_object(obj_id)
if isinstance(op, LincombOperator):
obj_ids = mpi.call(_mpi_wrap_operator_LincombOperator_manage_operators, obj_id)
return LincombOperator([mpi_wrap_operator(o, mpi_range, mpi_source, with_apply2, pickle_local_spaces,
space_type)
for o in obj_ids], op.coefficients, name=op.name)
elif isinstance(op, VectorArrayOperator):
array_obj_id, local_spaces = mpi.call(_mpi_wrap_operator_VectorArrayOperator_manage_array,
obj_id, pickle_local_spaces)
if all(ls == local_spaces[0] for ls in local_spaces):
local_spaces = (local_spaces[0],)
return VectorArrayOperator(space_type(local_spaces).make_array(array_obj_id),
adjoint=op.adjoint, name=op.name)
else:
return MPIOperator(obj_id, mpi_range, mpi_source, with_apply2, pickle_local_spaces, space_type)
开发者ID:pymor,项目名称:pymor,代码行数:34,代码来源:mpi.py
示例6: apply
def apply(self, U, mu=None):
assert U in self.source
mu = self.parse_parameter(mu)
U = U.obj_id if self.mpi_source else U
if self.mpi_range:
return self.range.make_array(mpi.call(mpi.method_call_manage, self.obj_id, 'apply', U, mu=mu))
else:
return mpi.call(mpi.method_call, self.obj_id, 'apply', U, mu=mu)
开发者ID:pymor,项目名称:pymor,代码行数:8,代码来源:mpi.py
示例7: apply_adjoint
def apply_adjoint(self, V, mu=None):
assert V in self.range
mu = self.parse_parameter(mu)
V = V.obj_id if self.mpi_range else V
if self.mpi_source:
return self.source.make_array(
mpi.call(mpi.method_call_manage, self.obj_id, 'apply_adjoint', V, mu=mu)
)
else:
return mpi.call(mpi.method_call, self.obj_id, 'apply_adjoint', V, mu=mu)
开发者ID:pymor,项目名称:pymor,代码行数:10,代码来源:mpi.py
示例8: apply_transpose
def apply_transpose(self, V, mu=None):
assert V in self.range
mu = self.parse_parameter(mu)
V = V if self.range.id is None else V.obj_id
if self.source.id is None:
return mpi.call(mpi.method_call, self.obj_id, 'apply_transpose', V, mu=mu)
else:
return self.source.make_array(
mpi.call(mpi.method_call_manage, self.obj_id, 'apply_transpose', V, mu=mu)
)
开发者ID:renemilk,项目名称:pyMor,代码行数:10,代码来源:mpi.py
示例9: apply
def apply(self, U, ind=None, mu=None):
assert U in self.source
mu = self.parse_parameter(mu)
U = U if self.vector else U.obj_id
if self.functional:
return mpi.call(mpi.method_call, self.obj_id, 'apply', U, ind=ind, mu=mu)
else:
space = self.range
return space.type(space.subtype[0], space.subtype[1],
mpi.call(mpi.method_call_manage, self.obj_id, 'apply', U, ind=ind, mu=mu))
开发者ID:nsrishankar,项目名称:pymor,代码行数:10,代码来源:mpi.py
示例10: assemble_lincomb
def assemble_lincomb(self, operators, coefficients, solver_options=None, name=None):
if not all(isinstance(op, MPIOperator) for op in operators):
return None
assert solver_options is None
operators = [op.obj_id for op in operators]
obj_id = mpi.call(_MPIOperator_assemble_lincomb, operators, coefficients, name=name)
op = mpi.get_object(obj_id)
if op is None:
mpi.call(mpi.remove_object, obj_id)
return None
else:
return self.with_(obj_id=obj_id)
开发者ID:nsrishankar,项目名称:pymor,代码行数:12,代码来源:mpi.py
示例11: apply_inverse
def apply_inverse(self, V, mu=None, least_squares=False):
if self.source.id is None or self.range.id is None:
raise NotImplementedError
assert V in self.range
mu = self.parse_parameter(mu)
return self.source.make_array(mpi.call(mpi.method_call_manage, self.obj_id, 'apply_inverse',
V.obj_id, mu=mu, least_squares=least_squares))
开发者ID:renemilk,项目名称:pyMor,代码行数:7,代码来源:mpi.py
示例12: apply_inverse_adjoint
def apply_inverse_adjoint(self, U, mu=None, least_squares=False):
if not self.mpi_source or not self.mpi_range:
raise NotImplementedError
assert U in self.source
mu = self.parse_parameter(mu)
return self.source.make_array(mpi.call(mpi.method_call_manage, self.obj_id, 'apply_inverse_adjoint',
U.obj_id, mu=mu, least_squares=least_squares))
开发者ID:pymor,项目名称:pymor,代码行数:7,代码来源:mpi.py
示例13: mpi_wrap_discretization
def mpi_wrap_discretization(obj_id, use_with=False, with_apply2=False, array_type=MPIVectorArray):
"""Wrap MPI distributed local |Discretizations| to a global |Discretization| on rank 0.
Given MPI distributed local |Discretizations| referred to by the
`~pymor.tools.mpi.ObjectId` `obj_id`, return a new |Discretization|
which manages these distributed discretizations from rank 0. This
is done by first wrapping all |Operators| of the |Discretization| using
:func:`~pymor.operators.mpi.mpi_wrap_operator`.
When `use_with` is `False`, an :class:`MPIDiscretization` is instatiated
with the wrapped operators. A call to
:meth:`~pymor.discretizations.interfaces.DiscretizationInterface.solve`
will then use an MPI parallel call to the
:meth:`~pymor.discretizations.interfaces.DiscretizationInterface.solve`
methods of the wrapped local |Discretizations| to obtain the solution.
This is usually what you want when the actual solve is performed by
an implementation in the external solver.
When `use_with` is `True`, :meth:`~pymor.core.interfaces.ImmutableInterface.with_`
is called on the local |Discretization| on rank 0, to obtain a new
|Discretization| with the wrapped MPI |Operators|. This is mainly useful
when the local discretizations are generic |Discretizations| as in
:mod:`pymor.discretizations.basic` and
:meth:`~pymor.discretizations.interfaces.DiscretizationInterface.solve`
is implemented directly in pyMOR via operations on the contained
|Operators|.
Parameters
----------
obj_id
:class:`~pymor.tools.mpi.ObjectId` of the local |Discretization|
on each rank.
use_with
See above.
with_apply2
See :class:`~pymor.operators.mpi.MPIOperator`.
array_type
See :class:`~pymor.operators.mpi.MPIOperator`.
"""
operators, functionals, vectors, products = \
mpi.call(_mpi_wrap_discretization_manage_operators, obj_id)
operators = {k: mpi_wrap_operator(v, with_apply2=with_apply2, array_type=array_type) if v else None
for k, v in operators.iteritems()}
functionals = {k: mpi_wrap_operator(v, functional=True, with_apply2=with_apply2, array_type=array_type) if v else None
for k, v in functionals.iteritems()}
vectors = {k: mpi_wrap_operator(v, vector=True, with_apply2=with_apply2, array_type=array_type) if v else None
for k, v in vectors.iteritems()}
products = {k: mpi_wrap_operator(v, with_apply2=with_apply2, array_type=array_type) if v else None
for k, v in products.iteritems()} if products else None
if use_with:
d = mpi.get_object(obj_id)
visualizer = MPIVisualizer(obj_id)
return d.with_(operators=operators, functionals=functionals, vector_operators=vectors, products=products,
visualizer=visualizer, cache_region=None)
else:
return MPIDiscretization(obj_id, operators, functionals, vectors, products, array_type=array_type)
开发者ID:lucas-ca,项目名称:pymor,代码行数:59,代码来源:mpi.py
示例14: _map
def _map(self, function, chunks, **kwargs):
payload = mpi.get_object(self._payload)
payload[0] = chunks
try:
result = mpi.call(mpi.function_call, _worker_map_function, self._payload, function, **kwargs)
finally:
payload[0] = None
return result
开发者ID:renemilk,项目名称:pyMor,代码行数:8,代码来源:mpi.py
示例15: _apply_only
def _apply_only(self, function, worker, *args, **kwargs):
payload = mpi.get_object(self._payload)
payload[0] = (function, args, kwargs)
try:
result = mpi.call(mpi.function_call, _single_worker_call_function, self._payload, worker)
finally:
payload[0] = None
return result
开发者ID:renemilk,项目名称:pyMor,代码行数:8,代码来源:mpi.py
示例16: as_vector
def as_vector(self, mu=None):
mu = self.parse_parameter(mu)
if self.functional:
space = self.source
return space.type(space.subtype[0], space.subtype[1],
mpi.call(mpi.method_call_manage, self.obj_id, 'as_vector', mu=mu))
else:
raise NotImplementedError
开发者ID:nsrishankar,项目名称:pymor,代码行数:8,代码来源:mpi.py
示例17: random_list_array
def random_list_array(dims, length, seed):
if isinstance(dims, Number):
dims = (dims,)
return ListVectorArray([MPIVectorAutoComm(NumpyVector, tuple(dims),
mpi.call(_random_vector, dims, seed + i))
for i in range(length)],
copy=False,
subtype=(MPIVectorAutoComm, (NumpyVector, tuple(dims))))
开发者ID:JuliaBru,项目名称:pymor,代码行数:8,代码来源:mpi.py
示例18: apply_inverse
def apply_inverse(self, V, ind=None, mu=None, least_squares=False):
if self.vector or self.functional:
raise NotImplementedError
assert V in self.range
mu = self.parse_parameter(mu)
space = self.source
return space.type(space.subtype[0], space.subtype[1],
mpi.call(mpi.method_call_manage, self.obj_id, 'apply_inverse',
V.obj_id, ind=ind, mu=mu, least_squares=least_squares))
开发者ID:nsrishankar,项目名称:pymor,代码行数:9,代码来源:mpi.py
示例19: pairwise_apply2
def pairwise_apply2(self, V, U, U_ind=None, V_ind=None, mu=None):
if not self.with_apply2:
return super().pairwise_apply2(V, U, U_ind=U_ind, V_ind=V_ind, mu=mu)
assert V in self.range
assert U in self.source
mu = self.parse_parameter(mu)
U = U if self.vector else U.obj_id
V = V if self.functional else V.obj_id
return mpi.call(mpi.method_call, self.obj_id, "pairwise_apply2", V, U, U_ind=U_ind, V_ind=V_ind, mu=mu)
开发者ID:JuliaBru,项目名称:pymor,代码行数:9,代码来源:mpi.py
示例20: apply2
def apply2(self, V, U, mu=None):
if not self.with_apply2:
return super().apply2(V, U, mu=mu)
assert V in self.range
assert U in self.source
mu = self.parse_parameter(mu)
U = U if self.source.id is None else U.obj_id
V = V if self.range.id is None else V.obj_id
return mpi.call(mpi.method_call, self.obj_id, 'apply2', V, U, mu=mu)
开发者ID:renemilk,项目名称:pyMor,代码行数:9,代码来源:mpi.py
注:本文中的pymor.tools.mpi.call函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论