本文整理汇总了Python中sfepy.base.base.Struct.get_function方法的典型用法代码示例。如果您正苦于以下问题:Python Struct.get_function方法的具体用法?Python Struct.get_function怎么用?Python Struct.get_function使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.base.base.Struct
的用法示例。
在下文中一共展示了Struct.get_function方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProblemDefinition
# 需要导入模块: from sfepy.base.base import Struct [as 别名]
# 或者: from sfepy.base.base.Struct import get_function [as 别名]
#.........这里部分代码省略.........
self.setup_hooks(self.conf.options)
else:
self.setup_hooks()
self.mtx_a = None
self.solvers = None
self.clear_equations()
def setup_hooks(self, options=None):
"""
Setup various hooks (user-defined functions), as given in `options`.
Supported hooks:
- `matrix_hook`
- check/modify tangent matrix in each nonlinear solver
iteration
- `nls_iter_hook`
- called prior to every iteration of nonlinear solver, if the
solver supports that
- takes the ProblemDefinition instance (`self`) as the first
argument
"""
hook_names = ['nls_iter_hook', 'matrix_hook']
for hook_name in hook_names:
setattr(self, hook_name, None)
if options is not None:
hook = options.get(hook_name, None)
if hook is not None:
hook = self.conf.get_function(hook)
setattr(self, hook_name, hook)
iter_hook = self.nls_iter_hook
if iter_hook is not None:
self.nls_iter_hook = lambda *args, **kwargs: \
iter_hook(self, *args, **kwargs)
def copy(self, name=None):
"""
Make a copy of ProblemDefinition.
"""
if name is None:
name = self.name + '_copy'
obj = ProblemDefinition(name, conf=self.conf,
functions=self.functions,
domain=self.domain, fields=self.fields,
equations=self.equations,
auto_conf=False, auto_solvers=False)
obj.ebcs = self.ebcs
obj.epbcs = self.epbcs
obj.lcbcs = self.lcbcs
obj.set_solvers(self.conf.solvers, self.conf.options)
obj.setup_output(output_filename_trunk=self.ofn_trunk,
output_dir=self.output_dir,
output_format=self.output_format,
file_per_var=self.file_per_var,
linearization=self.linearization)
示例2: Problem
# 需要导入模块: from sfepy.base.base import Struct [as 别名]
# 或者: from sfepy.base.base.Struct import get_function [as 别名]
#.........这里部分代码省略.........
self.setup_hooks(self.conf.options)
else:
self.setup_hooks()
self.mtx_a = None
self.solvers = None
self.clear_equations()
def setup_hooks(self, options=None):
"""
Setup various hooks (user-defined functions), as given in `options`.
Supported hooks:
- `matrix_hook`
- check/modify tangent matrix in each nonlinear solver
iteration
- `nls_iter_hook`
- called prior to every iteration of nonlinear solver, if the
solver supports that
- takes the Problem instance (`self`) as the first
argument
"""
hook_names = ["nls_iter_hook", "matrix_hook"]
for hook_name in hook_names:
setattr(self, hook_name, None)
if options is not None:
hook = options.get(hook_name, None)
if hook is not None:
hook = self.conf.get_function(hook)
setattr(self, hook_name, hook)
iter_hook = self.nls_iter_hook
if iter_hook is not None:
self.nls_iter_hook = lambda *args, **kwargs: iter_hook(self, *args, **kwargs)
def copy(self, name=None):
"""
Make a copy of Problem.
"""
if name is None:
name = self.name + "_copy"
obj = Problem(
name,
conf=self.conf,
functions=self.functions,
domain=self.domain,
fields=self.fields,
equations=self.equations,
auto_conf=False,
auto_solvers=False,
)
obj.ebcs = self.ebcs
obj.epbcs = self.epbcs
obj.lcbcs = self.lcbcs
obj.set_solvers(self.conf.solvers, self.conf.options)
obj.setup_output(
output_filename_trunk=self.ofn_trunk,
output_dir=self.output_dir,