本文整理汇总了Python中level.Level.restrict方法的典型用法代码示例。如果您正苦于以下问题:Python Level.restrict方法的具体用法?Python Level.restrict怎么用?Python Level.restrict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类level.Level
的用法示例。
在下文中一共展示了Level.restrict方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_level
# 需要导入模块: from level import Level [as 别名]
# 或者: from level.Level import restrict [as 别名]
def add_level(self, feval, sdc, interpolate=None, restrict=None):
"""Add a level to the PFASST hierarchy.
:param feval: implicit/explicit function evaluator (instance
of :class:`pfasst.feval.FEval`)
:param sdc: implicit/explicit SDC sweeper (instance
of :class:`pfasst.sdc.SDC`)
:param interpolate: interpolate from coarser level to this
level (callable)
:param restrict: restrict from this level to coarser level
(callable)
Levels should be added from finest (level 0) to coarest.
The *interpolate* callable is called as::
>>> interpolate(yF, yG, fevalF=fevaF, fevalG=fevalG, **kwargs)
and should interpolate the coarse y values *yG* that
correspond to the coarse evaluator *fevalG* to the fine y
values *yF* that correspond to the fine evaluator *fevalF*.
The (flattened) result should be stored in *yF*.
The *restrict* callable is called as::
>>> restrict(yF, yG, fevalF=fevalF, fevalG=fevalG, **kwargs)
and should restrict the fine y values *yF* that correspond to
the fine evaluator *fevalF* to the coarse y values *yG* that
correspond to the coarse evaluator *fevalG*. The (flattened)
result should be stored in *yG*.
"""
level = Level()
level.feval = feval
level.sdc = sdc
level.interpolate = interpolate
level.restrict = restrict
level.level = len(self.levels)
level.mpi = self.mpi
level.state = self.state
level.hooks = {}
level.sweeps = 1
self.levels.append(level)