本文整理汇总了Python中sfepy.discrete.Variables.set_data方法的典型用法代码示例。如果您正苦于以下问题:Python Variables.set_data方法的具体用法?Python Variables.set_data怎么用?Python Variables.set_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.discrete.Variables
的用法示例。
在下文中一共展示了Variables.set_data方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Equations
# 需要导入模块: from sfepy.discrete import Variables [as 别名]
# 或者: from sfepy.discrete.Variables import set_data [as 别名]
class Equations(Container):
@staticmethod
def from_conf(conf, variables, regions, materials, integrals,
user=None, verbose=True):
objs = OneTypeList(Equation)
conf = copy(conf)
ii = 0
for name, desc in conf.iteritems():
if verbose:
output('equation "%s":' % name)
output(desc)
eq = Equation.from_desc(name, desc, variables, regions,
materials, integrals, user=user)
objs.append(eq)
ii += 1
obj = Equations(objs)
return obj
def __init__(self, equations):
Container.__init__(self, equations)
self.variables = Variables(self.collect_variables())
self.materials = Materials(self.collect_materials())
self.domain = self.get_domain()
self.active_bcs = set()
self.collect_conn_info()
def create_subequations(self, var_names, known_var_names=None):
"""
Create sub-equations containing only terms with the given virtual
variables.
Parameters
----------
var_names : list
The list of names of virtual variables.
known_var_names : list
The list of names of (already) known state variables.
Returns
-------
subequations : Equations instance
The sub-equations.
"""
from sfepy.discrete import FieldVariable
known_var_names = get_default(known_var_names, [])
objs = []
for iv, var_name in enumerate(var_names):
terms = [term.copy(name=term.name)
for eq in self for term in eq.terms
if term.get_virtual_name() == var_name]
# Make parameter variables from known state variables in terms
# arguments.
for known_name in known_var_names:
for term in terms:
if known_name in term.arg_names:
ii = term.arg_names.index(known_name)
state = self.variables[known_name]
par = FieldVariable(known_name, 'parameter',
state.field,
primary_var_name='(set-to-None)')
term.args[ii] = par
term._kwargs[known_name] = par
par.set_data(state())
new_terms = Terms(terms)
objs.append(Equation('eq_%d' % iv, new_terms))
subequations = Equations(objs)
return subequations
def get_domain(self):
domain = None
for eq in self:
for term in eq.terms:
if term.has_region:
domain = term.region.domain
return domain
def collect_materials(self):
"""
Collect materials present in the terms of all equations.
"""
materials = []
for eq in self:
#.........这里部分代码省略.........