当前位置: 首页>>代码示例>>Python>>正文


Python Struct.get_function方法代码示例

本文整理汇总了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)
开发者ID:mikegraham,项目名称:sfepy,代码行数:69,代码来源:problemDef.py

示例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,
开发者ID:,项目名称:,代码行数:70,代码来源:


注:本文中的sfepy.base.base.Struct.get_function方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。