本文整理汇总了Python中sfepy.base.base.OneTypeList类的典型用法代码示例。如果您正苦于以下问题:Python OneTypeList类的具体用法?Python OneTypeList怎么用?Python OneTypeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OneTypeList类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: from_conf
def from_conf(conf):
objs = OneTypeList(Function)
for key, fc in conf.iteritems():
fun = Function(name=fc.name, function=fc.function, is_constant=False, extra_args={})
objs.append(fun)
obj = Functions(objs)
return obj
开发者ID:rosendo100,项目名称:sfepy,代码行数:8,代码来源:functions.py
示例2: reset_regions
def reset_regions(self):
"""
Reset the list of regions associated with the domain.
"""
self.regions = OneTypeList(Region)
self._region_stack = []
self._bnf = create_bnf(self._region_stack)
开发者ID:Gkdnz,项目名称:sfepy,代码行数:7,代码来源:domain.py
示例3: from_conf
def from_conf(conf, functions, wanted=None):
"""
Construct Materials instance from configuration.
"""
if wanted is None:
wanted = conf.keys()
objs = OneTypeList(Material)
for key, mc in conf.iteritems():
if key not in wanted: continue
mat = Material.from_conf(mc, functions)
objs.append(mat)
obj = Materials(objs)
return obj
开发者ID:andy-c-huang,项目名称:sfepy,代码行数:16,代码来源:materials.py
示例4: from_conf
def from_conf(conf):
objs = OneTypeList(Integral)
for desc in conf.itervalues():
if hasattr(desc, 'vals'):
aux = Integral(desc.name,
coors=desc.vals,
weights=desc.weights)
else:
aux = Integral(desc.name,
order=desc.order)
objs.append(aux)
obj = Integrals(objs)
return obj
开发者ID:LeiDai,项目名称:sfepy,代码行数:17,代码来源:integrals.py
示例5: from_file_hdf5
def from_file_hdf5( filename, var_names ):
"""TODO: do not read entire file, provide data on demand."""
io = HDF5MeshIO( filename )
ts = TimeStepper( *io.read_time_stepper() )
steps = nm.arange( ts.n_step, dtype = nm.int32 )
ths = io.read_variables_time_history( var_names, ts )
objs = OneTypeList( History )
for name, th in six.iteritems(ths):
hist = History( name,
steps = steps,
times = ts.times,
th = th )
objs.append( hist )
obj = Histories( objs, dt = ts.dt,
name = ' '.join( var_names ) )
return obj
开发者ID:Nasrollah,项目名称:sfepy,代码行数:19,代码来源:history.py
示例6: from_conf
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
开发者ID:Gkdnz,项目名称:sfepy,代码行数:20,代码来源:equations.py
示例7: Domain
#.........这里部分代码省略.........
for ii, kind in enumerate(kinds):
if create[ii]:
if verbose:
output('setting up domain %s...' % kind)
tt = time.clock()
obj = Facets.from_domain(self, kind)
obj.sort_and_orient()
obj.setup_unique()
obj.setup_neighbours()
# 'ed' or 'fa'
setattr(self, kind[:2], obj)
if verbose:
output('...done in %.2f s' % (time.clock() - tt))
if not is_face:
self.fa = None
def get_facets(self, force_faces=False):
"""
Return edge and face descriptions.
"""
if force_faces and not self.fa:
return self.ed, self.ed
else:
return self.ed, self.fa
def reset_regions(self):
"""Reset the list of regions associated with the domain."""
self.regions = OneTypeList(Region)
self._region_stack = []
self._bnf = create_bnf(self._region_stack)
def create_region(self, name, select, flags=None, check_parents=True,
functions=None, add_to_regions=True):
"""Region factory constructor. Append the new region to
self.regions list."""
if flags is None:
flags = {}
if check_parents:
parents = get_parents(select)
for p in parents:
if p not in [region.name for region in self.regions]:
msg = 'parent region %s of %s not found!' % (p, name)
raise ValueError(msg)
stack = self._region_stack
try:
self._bnf.parseString(select)
except ParseException:
print 'parsing failed:', select
raise
region = visit_stack(stack, region_op,
region_leaf(self, self.regions, select,
functions))
region.name = name
forbid = flags.get('forbid', None)
if forbid:
fb = re.compile('^group +\d+(\s+\d+)*$').match(forbid)
开发者ID:mikegraham,项目名称:sfepy,代码行数:67,代码来源:domain.py
示例8: Domain
class Domain(Struct):
def __init__(self, name, mesh=None, nurbs=None, bmesh=None, regions=None,
verbose=False):
Struct.__init__(self, name=name, mesh=mesh, nurbs=nurbs, bmesh=bmesh,
regions=regions, verbose=verbose)
def get_centroids(self, dim):
"""
Return the coordinates of centroids of mesh entities with dimension
`dim`.
"""
return self.cmesh.get_centroids(dim)
def has_faces(self):
return self.shape.tdim == 3
def reset_regions(self):
"""
Reset the list of regions associated with the domain.
"""
self.regions = OneTypeList(Region)
self._region_stack = []
self._bnf = create_bnf(self._region_stack)
def create_region(self, name, select, kind='cell', parent=None,
check_parents=True, functions=None, add_to_regions=True,
allow_empty=False):
"""
Region factory constructor. Append the new region to
self.regions list.
"""
if check_parents:
parents = get_parents(select)
for p in parents:
if p not in [region.name for region in self.regions]:
msg = 'parent region %s of %s not found!' % (p, name)
raise ValueError(msg)
stack = self._region_stack
try:
self._bnf.parseString(select)
except ParseException:
print 'parsing failed:', select
raise
region = visit_stack(stack, region_op,
region_leaf(self, self.regions, select, functions))
region.name = name
region.definition = select
region.set_kind(kind)
region.finalize(allow_empty=allow_empty)
region.parent = parent
region.update_shape()
if add_to_regions:
self.regions.append(region)
return region
def create_regions(self, region_defs, functions=None):
output('creating regions...')
tt = time.clock()
self.reset_regions()
##
# Sort region definitions by dependencies.
graph, name_to_sort_name = get_dependency_graph(region_defs)
sorted_regions = sort_by_dependency(graph)
##
# Define regions.
for name in sorted_regions:
sort_name = name_to_sort_name[name]
rdef = region_defs[sort_name]
region = self.create_region(name, rdef.select,
kind=rdef.get('kind', 'cell'),
parent=rdef.get('parent', None),
check_parents=False,
functions=functions)
output(' ', region.name)
output('...done in %.2f s' % (time.clock() - tt))
return self.regions
def save_regions(self, filename, region_names=None):
"""
Save regions as individual meshes.
Parameters
----------
filename : str
The output filename.
region_names : list, optional
If given, only the listed regions are saved.
"""
import os
#.........这里部分代码省略.........
开发者ID:Gkdnz,项目名称:sfepy,代码行数:101,代码来源:domain.py
示例9: Domain
#.........这里部分代码省略.........
itry = 0
while itry < 2:
flag = -nm.ones(conn.shape[0], dtype=nm.int32)
# Changes orientation if it is wrong according to swap*!
# Changes are indicated by positive flag.
orient_elements(flag, conn, coors,
ori.roots, ori.vecs,
ori.swap_from, ori.swap_to)
if nm.alltrue(flag == 0):
if itry > 0: output('...corrected')
itry = -1
break
output('warning: bad element orientation, trying to correct...')
itry += 1
if itry == 2 and flag[0] != -1:
raise RuntimeError('elements cannot be oriented! (%d, %s)'
% (ii, self.mesh.descs[ii]))
elif flag[0] == -1:
output('warning: element orienation not checked')
def has_faces(self):
return sum([group.shape.n_face
for group in self.iter_groups()]) > 0
def reset_regions(self):
"""
Reset the list of regions associated with the domain.
"""
self.regions = OneTypeList(Region)
self._region_stack = []
self._bnf = create_bnf(self._region_stack)
def create_region(self, name, select, kind='cell', parent=None,
check_parents=True, functions=None, add_to_regions=True):
"""
Region factory constructor. Append the new region to
self.regions list.
"""
if check_parents:
parents = get_parents(select)
for p in parents:
if p not in [region.name for region in self.regions]:
msg = 'parent region %s of %s not found!' % (p, name)
raise ValueError(msg)
stack = self._region_stack
try:
self._bnf.parseString(select)
except ParseException:
print 'parsing failed:', select
raise
region = visit_stack(stack, region_op,
region_leaf(self, self.regions, select, functions))
region.name = name
region.definition = select
region.set_kind(kind)
region.parent = parent
region.update_shape()
if add_to_regions:
开发者ID:ZJLi2013,项目名称:sfepy,代码行数:67,代码来源:domain.py
示例10: extract_time_history
def extract_time_history(filename, extract, verbose=True):
"""Extract time history of a variable from a multi-time-step results file.
Parameters
----------
filename : str
The name of file to extract from.
extract : str
The description of what to extract in a string of comma-separated
description items. A description item consists of: name of the variable
to extract, mode ('e' for elements, 'n' for nodes), ids of the nodes or
elements (given by the mode). Example: 'u n 10 15, p e 0' means
variable 'u' in nodes 10, 15 and variable 'p' in element 0.
verbose : bool
Verbosity control.
Returns
-------
ths : dict
The time histories in a dict with variable names as keys. If a
nodal variable is requested in elements, its value is a dict of histories
in the element nodes.
ts : TimeStepper instance
The time stepping information.
"""
output('extracting selected data...', verbose=verbose)
output('selection:', extract, verbose=verbose)
##
# Parse extractions.
pes = OneTypeList(Struct)
for chunk in extract.split(','):
aux = chunk.strip().split()
pes.append(Struct(var = aux[0],
mode = aux[1],
indx = map(int, aux[2:]),
igs = None))
##
# Verify array limits, set igs for element data, shift indx.
mesh = Mesh.from_file(filename)
n_el, n_els, offs = mesh.n_el, mesh.n_els, mesh.el_offsets
for pe in pes:
if pe.mode == 'n':
for ii in pe.indx:
if (ii < 0) or (ii >= mesh.n_nod):
raise ValueError('node index 0 <= %d < %d!'
% (ii, mesh.n_nod))
if pe.mode == 'e':
pe.igs = []
for ii, ie in enumerate(pe.indx[:]):
if (ie < 0) or (ie >= n_el):
raise ValueError('element index 0 <= %d < %d!'
% (ie, n_el))
ig = (ie < n_els).argmax()
pe.igs.append(ig)
pe.indx[ii] = ie - offs[ig]
## print pes
##
# Extract data.
# Assumes only one element group (ignores igs)!
io = MeshIO.any_from_filename(filename)
ths = {}
for pe in pes:
mode, nname = io.read_data_header(pe.var)
output(mode, nname, verbose=verbose)
if ((pe.mode == 'n' and mode == 'vertex') or
(pe.mode == 'e' and mode == 'cell')):
th = io.read_time_history(nname, pe.indx)
elif pe.mode == 'e' and mode == 'vertex':
conn = mesh.conns[0]
th = {}
for iel in pe.indx:
ips = conn[iel]
th[iel] = io.read_time_history(nname, ips)
else:
raise ValueError('cannot extract cell data %s in nodes!' % pe.var)
ths[pe.var] = th
output('...done', verbose=verbose)
ts = TimeStepper(*io.read_time_stepper())
return ths, ts
开发者ID:LeiDai,项目名称:sfepy,代码行数:91,代码来源:time_history.py
注:本文中的sfepy.base.base.OneTypeList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论