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


Python Mesh.from_region方法代码示例

本文整理汇总了Python中mesh.Mesh.from_region方法的典型用法代码示例。如果您正苦于以下问题:Python Mesh.from_region方法的具体用法?Python Mesh.from_region怎么用?Python Mesh.from_region使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mesh.Mesh的用法示例。


在下文中一共展示了Mesh.from_region方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: save_state

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import from_region [as 别名]
    def save_state(
        self, filename, state=None, out=None, fill_value=None, post_process_hook=None, file_per_var=False, **kwargs
    ):
        extend = not file_per_var
        if (out is None) and (state is not None):
            out = self.state_to_output(state, fill_value=fill_value, extend=extend)
            if post_process_hook is not None:
                out = post_process_hook(out, self, state, extend=extend)

        float_format = get_default_attr(self.conf.options, "float_format", None)

        if file_per_var:
            import os.path as op

            meshes = {}
            for var in self.variables.iter_state():
                rname = var.field.region.name
                if meshes.has_key(rname):
                    mesh = meshes[rname]
                else:
                    mesh = Mesh.from_region(var.field.region, self.domain.mesh, localize=True)
                    meshes[rname] = mesh
                vout = {}
                for key, val in out.iteritems():
                    if val.var_name == var.name:
                        vout[key] = val
                base, suffix = op.splitext(filename)
                mesh.write(base + "_" + var.name + suffix, io="auto", out=vout, float_format=float_format, **kwargs)
        else:
            self.domain.mesh.write(filename, io="auto", out=out, float_format=float_format, **kwargs)
开发者ID:certik,项目名称:sfepy,代码行数:32,代码来源:problemDef.py

示例2: save_regions

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import from_region [as 别名]
    def save_regions(self, filename_trunk, region_names=None):
        """Save regions as meshes."""

        if region_names is None:
            region_names = self.domain.regions.get_names()

        output("saving regions...")
        for name in region_names:
            region = self.domain.regions[name]
            output(name)
            aux = Mesh.from_region(region, self.domain.mesh, self.domain.ed, self.domain.fa)
            aux.write("%s_%s.mesh" % (filename_trunk, region.name), io="auto")
        output("...done")
开发者ID:certik,项目名称:sfepy,代码行数:15,代码来源:problemDef.py

示例3: save_regions

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import from_region [as 别名]
    def save_regions( self, filename_trunk, region_names = None ):
        """Save regions as meshes."""

        if region_names is None:
            region_names = self.domain.regions.get_names()

        output( 'saving regions...' )
        for name in region_names:
            region = self.domain.regions[name]
            output( name )
            aux = Mesh.from_region(region, self.domain.mesh)
            aux.write( '%s_%s.mesh' % (filename_trunk, region.name),
                       io = 'auto' )
        output( '...done' )
开发者ID:mikegraham,项目名称:sfepy,代码行数:16,代码来源:problemDef.py

示例4: save_state

# 需要导入模块: from mesh import Mesh [as 别名]
# 或者: from mesh.Mesh import from_region [as 别名]
    def save_state(self, filename, state=None, out=None,
                   fill_value=None, post_process_hook=None,
                   linearization=None, file_per_var=False, **kwargs):
        """
        Parameters
        ----------
        file_per_var : bool or None
            If True, data of each variable are stored in a separate
            file. If None, it is set to the application option value.
        linearization : Struct or None
            The linearization configuration for higher order
            approximations. If its kind is 'adaptive', `file_per_var` is
            assumed True.
        """
        linearization = get_default(linearization, self.linearization)
        if linearization.kind != 'adaptive':
            file_per_var = get_default(file_per_var, self.file_per_var)

        else:
            file_per_var = True

        extend = not file_per_var
        if (out is None) and (state is not None):
            out = state.create_output_dict(fill_value=fill_value,
                                           extend=extend,
                                           linearization=linearization)

            if post_process_hook is not None:
                out = post_process_hook(out, self, state, extend=extend)

        if linearization.kind == 'adaptive':
            for key, val in out.iteritems():
                mesh = val.get('mesh', self.domain.mesh)
                aux = io.edit_filename(filename, suffix='_' + val.var_name)
                mesh.write(aux, io='auto', out={key : val},
                           float_format=self.float_format, **kwargs)
                if hasattr(val, 'levels'):
                    output('max. refinement per group:', val.levels)

        elif file_per_var:
            meshes = {}

            if self.equations is None:
                varnames = {}
                for key, val in out.iteritems():
                    varnames[val.var_name] = 1
                varnames = varnames.keys()
                outvars = self.create_variables(varnames)
                itervars = outvars.__iter__
            else:
                itervars = self.equations.variables.iter_state

            for var in itervars():
                rname = var.field.region.name
                if meshes.has_key( rname ):
                    mesh = meshes[rname]
                else:
                    mesh = Mesh.from_region(var.field.region, self.domain.mesh,
                                            localize=True,
                                            is_surface=var.is_surface)
                    meshes[rname] = mesh

                vout = {}
                for key, val in out.iteritems():
                    try:
                        if val.var_name == var.name:
                            vout[key] = val

                    except AttributeError:
                        msg = 'missing var_name attribute in output!'
                        raise ValueError(msg)

                aux = io.edit_filename(filename, suffix='_' + var.name)
                mesh.write(aux, io='auto', out=vout,
                           float_format=self.float_format, **kwargs)
        else:
            self.domain.mesh.write(filename, io='auto', out=out,
                                   float_format=self.float_format, **kwargs)
开发者ID:mikegraham,项目名称:sfepy,代码行数:80,代码来源:problemDef.py


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