本文整理汇总了Python中sfepy.base.base.Struct类的典型用法代码示例。如果您正苦于以下问题:Python Struct类的具体用法?Python Struct怎么用?Python Struct使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Struct类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, name, definition, domain, parse_def, kind='cell',
parent=None):
"""
Create region instance.
Parameters
----------
name : str
The region name, either given, or automatic for intermediate
regions.
definition : str
The region selector definition.
domain : Domain instance
The domain of the region.
parse_def : str
The parsed definition of the region.
kind : str
The region kind - one of 'cell', 'facet', 'face', 'edge', 'vertex',
'cell_only', ..., 'vertex_only'.
parent : str, optional
The name of the parent region.
"""
tdim = domain.shape.tdim
Struct.__init__(self,
name=name, definition=definition,
domain=domain, parse_def=parse_def,
n_v_max=domain.shape.n_nod, dim=domain.shape.dim,
tdim=tdim, kind_tdim=None,
entities=[None] * (tdim + 1),
kind=None, parent=parent, shape=None,
mirror_region=None, is_empty=False)
self.set_kind(kind)
开发者ID:,项目名称:,代码行数:32,代码来源:
示例2: __init__
def __init__(self, name, definition, domain, parse_def, kind='cell',
parent=None):
"""
Create region instance.
Parameters
----------
name : str
The region name, either given, or automatic for intermediate
regions.
definition : str
The region selector definition.
domain : Domain instance
The domain of the region.
parse_def : str
The parsed definition of the region.
Notes
-----
conns, vertex_groups are links to domain data.
"""
tdim = domain.shape.tdim
Struct.__init__(self,
name=name, definition=definition,
domain=domain, parse_def=parse_def,
n_v_max=domain.shape.n_nod, dim=domain.shape.dim,
tdim=tdim,
entities=[None] * (tdim + 1),
kind=None, parent=parent, shape=None,
mirror_region=None, ig_map=None,
ig_map_i=None)
self.set_kind(kind)
开发者ID:mfkiwl,项目名称:sfepy,代码行数:32,代码来源:region.py
示例3: read_header
def read_header(fd):
"""
Read the probe data header from file descriptor fd.
Returns
-------
header : Struct instance
The probe data header.
"""
header = Struct(name='probe_data_header')
header.probe_class = fd.readline().strip()
aux = fd.readline().strip().split(':')[1]
header.n_point = int(aux.strip().split()[0])
details = []
while 1:
line = fd.readline().strip()
if line == '-----':
break
else:
details.append(line)
header.details = '\n'.join(details)
return header
开发者ID:animator,项目名称:sfepy,代码行数:26,代码来源:probes.py
示例4: __init__
def __init__( self, conf, options, output_prefix, **kwargs ):
Struct.__init__( self,
conf = conf,
options = options,
output_prefix = output_prefix )
output.prefix = self.output_prefix
self.restore()
开发者ID:olivierverdier,项目名称:sfepy,代码行数:7,代码来源:application.py
示例5: __init__
def __init__(self, name='mesh', filename=None,
prefix_dir=None, **kwargs):
"""Create a Mesh.
Parameters
----------
name : str
Object name.
filename : str
Loads a mesh from the specified file, if not None.
prefix_dir : str
If not None, the filename is relative to that directory.
"""
Struct.__init__(self, name=name, **kwargs)
self.nodal_bcs = {}
if filename is None:
self.io = None
self.setup_done = 0
else:
io = MeshIO.any_from_filename(filename, prefix_dir=prefix_dir)
output('reading mesh (%s)...' % (io.filename))
tt = time.clock()
io.read(self)
output('...done in %.2f s' % (time.clock() - tt))
self._set_shape_info()
开发者ID:LeiDai,项目名称:sfepy,代码行数:27,代码来源:mesh.py
示例6: process_conf
def process_conf(cls, conf, kwargs):
"""
Process configuration parameters.
"""
get = make_get_conf(conf, kwargs)
if len(cls._parameters) and cls._parameters[0][0] != 'name':
options = Solver._parameters + cls._parameters
else:
options = cls._parameters
opts = Struct()
allow_extra = False
for name, _, default, required, _ in options:
if name == '*':
allow_extra = True
continue
msg = ('missing "%s" in options!' % name) if required else None
setattr(opts, name, get(name, default, msg))
if allow_extra:
all_keys = set(conf.to_dict().keys())
other = all_keys.difference(opts.to_dict().keys())
for name in other:
setattr(opts, name, get(name, None, None))
return opts
开发者ID:Gkdnz,项目名称:sfepy,代码行数:29,代码来源:solvers.py
示例7: __init__
def __init__(self, name_map, gamma=None, delta=None, tau=None, tau_red=1.0,
tau_mul=1.0, delta_mul=1.0, gamma_mul=1.0,
diameter_mode='max'):
Struct.__init__(self, name_map=name_map,
gamma=gamma, delta=delta, tau=tau,
tau_red=tau_red, tau_mul=tau_mul, delta_mul=delta_mul,
gamma_mul=gamma_mul, diameter_mode=diameter_mode)
开发者ID:snilek,项目名称:sfepy,代码行数:7,代码来源:oseen.py
示例8: __init__
def __init__(self, name, share_geometry=True, n_point=None, **kwargs):
"""
Parameters
----------
name : str
The probe name, set automatically by the subclasses.
share_geometry : bool
Set to True to indicate that all the probes will work on the same
domain. Certain data are then computed only for the first probe and
cached.
n_point : int
The (fixed) number of probe points, when positive. When non-positive,
the number of points is adaptively increased starting from -n_point,
until the neighboring point distance is less than the diameter of the
elements enclosing the points. When None, it is set to -10.
For additional parameters see the __init__() docstrings of the
subclasses.
"""
Struct.__init__(self, name=name, share_geometry=share_geometry,
**kwargs)
self.set_n_point(n_point)
self.options = Struct(close_limit=0.1, size_hint=None)
self.cache = Struct(name='probe_local_evaluate_cache')
self.is_refined = False
开发者ID:clazaro,项目名称:sfepy,代码行数:28,代码来源:probes.py
示例9: __init__
def __init__(self, name, definition, domain, parse_def):
"""
Create region instance.
Parameters
----------
name : str
The region name, either given, or automatic for intermediate
regions.
definition : str
The region selector definition.
domain : Domain instance
The domain of the region.
parse_def : str
The parsed definition of the region.
Notes
-----
conns, vertex_groups are links to domain data.
"""
Struct.__init__(self,
name=name, definition=definition,
n_v_max=domain.shape.n_nod, domain=domain,
parse_def=parse_def, all_vertices=None,
igs=[], vertices={}, edges={}, faces={},
cells={}, fis={},
can_cells=True, true_cells={}, must_update=True,
is_complete=False,
mirror_region=None, ig_map=None,
ig_map_i=None)
开发者ID:tonymcdaniel,项目名称:sfepy,代码行数:30,代码来源:region.py
示例10: main
def main():
parser = ArgumentParser(description=__doc__)
parser.add_argument('--version', action='version', version='%(prog)s')
parser.add_argument('--eps', action='store', dest='eps',
default=1e-12, help=helps['eps'])
parser.add_argument('-o', '--filename-out',
action='store', dest='filename_out',
default=None, help=helps['filename-out'])
parser.add_argument('filename')
options = parser.parse_args()
filename = options.filename
mesh = Mesh.from_file(filename)
mesh_out = extract_edges(mesh, eps=float(options.eps))
mesh_out = merge_lines(mesh_out)
filename_out = options.filename_out
if filename_out is None:
filename_out = edit_filename(filename, prefix='edge_', new_ext='.vtk')
output('Outline mesh - vertices: %d, edges: %d, output filename: %s'
% (mesh_out[0].shape[0], mesh_out[2][0].shape[0], filename_out))
# hack to write '3_2' elements - edges
io = VTKMeshIO(None)
aux_mesh = Struct()
aux_mesh._get_io_data = lambda: mesh_out
aux_mesh.n_el = mesh_out[2][0].shape[0]
io.write(filename_out, aux_mesh)
开发者ID:rc,项目名称:sfepy,代码行数:30,代码来源:extract_edges.py
示例11: __init__
def __init__(self, name, kind, domain, single_facets, n_obj, indices, facets):
Struct.__init__(
self,
name=name,
kind=kind,
domain=domain,
single_facets=single_facets,
n_obj=n_obj,
indices=indices,
facets=facets,
)
self.n_all_obj, self.n_col = facets.shape
self.n_gr = len(self.n_obj)
self.indx = {}
ii = 0
for ig, nn in enumerate(self.n_obj):
self.indx[ig] = slice(ii, ii + nn)
ii += nn
self.n_fps_vec = nm.empty(self.n_all_obj, dtype=nm.int32)
self.n_fps = {}
for ig, facet in self.single_facets.iteritems():
self.n_fps_vec[self.indx[ig]] = facet.shape[1]
self.n_fps[ig] = facet.shape[1]
开发者ID:renatocoutinho,项目名称:sfepy,代码行数:25,代码来源:facets.py
示例12: init
def init(self, young=None, poisson=None, bulk=None, lam=None,
mu=None, p_wave=None):
"""
Set exactly two of the elastic constants, and compute the
remaining. (Re)-initializes the existing instance of ElasticConstants.
"""
Struct.__init__(self, young=young, poisson=poisson, bulk=bulk, lam=lam,
mu=mu, p_wave=p_wave)
values = {}
for key, val in six.iteritems(self.__dict__):
if (key in self.names) and (val is not None):
sym = getattr(self.ec, key)
values[sym] = val
known = list(values.keys())
if len(known) != 2:
raise ValueError('exactly two elastic constants must be provided!')
known = [ii.name for ii in known]
unknown = set(self.names).difference(known)
for name in unknown:
key = tuple(sorted(known)) + (name,)
val = float(self.relations[key].n(subs=values))
setattr(self, name, val)
开发者ID:lokik,项目名称:sfepy,代码行数:26,代码来源:matcoefs.py
示例13: __init__
def __init__(self, anchor, normal, bounds):
Struct.__init__(self, anchor=nm.array(anchor, dtype=nm.float64),
bounds=nm.asarray(bounds, dtype=nm.float64))
self.normal = nm.asarray(normal, dtype=nm.float64)
norm = nm.linalg.norm
self.normal /= norm(self.normal)
e3 = [0.0, 0.0, 1.0]
dd = nm.dot(e3, self.normal)
rot_angle = nm.arccos(dd)
if nm.abs(rot_angle) < 1e-14:
mtx = nm.eye(3, dtype=nm.float64)
bounds2d = self.bounds[:, :2]
else:
rot_axis = nm.cross([0.0, 0.0, 1.0], self.normal)
mtx = la.make_axis_rotation_matrix(rot_axis, rot_angle)
mm = la.insert_strided_axis(mtx, 0, self.bounds.shape[0])
rbounds = la.dot_sequences(mm, self.bounds)
bounds2d = rbounds[:, :2]
assert_(nm.allclose(nm.dot(mtx, self.normal), e3,
rtol=0.0, atol=1e-12))
self.adotn = nm.dot(self.anchor, self.normal)
self.rot_angle = rot_angle
self.mtx = mtx
self.bounds2d = bounds2d
开发者ID:Gkdnz,项目名称:sfepy,代码行数:32,代码来源:contact_bodies.py
示例14: __init__
def __init__(self, name, dtype, shape, region,
space='H1', poly_space_base='lagrange', approx_order=1):
"""Create a Field.
Parameters
----------
name : str
Object name.
dtype : numpy.dtype
Field data type: float64 or complex128.
shape : int/tuple/str
Field shape: 1 or (1,) or 'scalar', space dimension (2, or
(2,) or 3 or (3,)) or 'vector'. The field shape determines
the shape of the FE base functions and can be different from
a FieldVariable instance shape. (TODO)
region : Region
The region where the field is defined.
space : str
The function space name.
poly_space_base : str
The name of polynomial space base.
approx_order : int/str
FE approximation order, e.g. 0, 1, 2, '1B' (1 with bubble).
Notes
-----
Assumes one cell type for the whole region!
"""
if isinstance(shape, str):
try:
shape = {'scalar' : (1,),
'vector' : (region.domain.shape.dim,)}[shape]
except KeyError:
raise ValueError('unsupported field shape! (%s)', shape)
elif isinstance(shape, int):
shape = (shape,)
Struct.__init__(self,
name = name,
dtype = dtype,
shape = shape,
region = region,
space = space,
poly_space_base = poly_space_base)
self.domain = self.region.domain
self.clear_dof_conns()
self.set_approx_order(approx_order)
self.setup_geometry()
# To refactor below...
self.create_interpolant()
self.setup_approximations()
## print self.aps
## pause()
self.setup_global_base()
self.setup_coors()
开发者ID:olivierverdier,项目名称:sfepy,代码行数:60,代码来源:fields.py
示例15: __init__
def __init__(self, name, kind='time-dependent',
function=None, values=None, flags=None, **kwargs):
"""
Parameters
----------
name : str
The name of the material.
kind : 'time-dependent' or 'stationary'
The kind of the material.
function : function
The function for setting up the material values.
values : dict
Constant material values.
flags : dict, optional
Special flags.
**kwargs : keyword arguments, optional
Constant material values passed by their names.
"""
Struct.__init__(self, name=name, kind=kind, is_constant=False)
if (function is not None) and ((values is not None) or len(kwargs)):
msg = 'material can have function or values but not both! (%s)' \
% self.name
raise ValueError(msg)
self.flags = get_default(flags, {})
if hasattr(function, '__call__'):
self.function = function
elif (values is not None) or len(kwargs): # => function is None
if isinstance(values, dict):
key0 = values.keys()[0]
assert_(isinstance(key0, str))
else:
key0 = None
if (key0 and (not key0.startswith('.'))
and isinstance(values[key0], dict)):
self.function = ConstantFunctionByRegion(values)
self.is_constant = True
else:
all_values = {}
if values is not None:
all_values.update(values)
all_values.update(kwargs)
self.function = ConstantFunction(all_values)
self.is_constant = True
else: # => both values and function are None
msg = 'material %s: neither function nor values given! (%s)' \
% self.name
raise ValueError(msg)
self.reset()
开发者ID:andy-c-huang,项目名称:sfepy,代码行数:58,代码来源:materials.py
示例16: __init__
def __init__(self, name, terms):
Struct.__init__(self, name = name)
if isinstance(terms, Term): # single Term
terms = Terms([terms])
self.terms = terms
self.terms.setup()
开发者ID:AshitaPrasad,项目名称:sfepy,代码行数:9,代码来源:equations.py
示例17: __init__
def __init__(self, data_names=None, yscales=None,
xlabels=None, ylabels=None, is_plot=True, aggregate=200,
formats=None, log_filename=None):
"""`data_names` ... tuple of names grouped by subplots:
([name1, name2, ...], [name3, name4, ...], ...)
where name<n> are strings to display in (sub)plot legends."""
try:
import matplotlib as mpl
except:
mpl = None
if (mpl is not None) and mpl.rcParams['backend'] == 'GTKAgg':
can_live_plot = True
else:
can_live_plot = False
Struct.__init__(self, data_names = {},
n_arg = 0, n_gr = 0,
data = {}, x_values = {}, n_calls = 0,
yscales = {}, xlabels = {}, ylabels = {},
plot_pipe = None, formats = {}, output = None)
if data_names is not None:
n_gr = len(data_names)
else:
n_gr = 0
data_names = []
yscales = get_default(yscales, ['linear'] * n_gr)
xlabels = get_default(xlabels, ['iteration'] * n_gr)
ylabels = get_default(ylabels, [''] * n_gr )
if formats is None:
formats = [None] * n_gr
for ig, names in enumerate(data_names):
self.add_group(names, yscales[ig], xlabels[ig], ylabels[ig],
formats[ig])
self.is_plot = get_default( is_plot, True )
self.aggregate = get_default( aggregate, 100 )
self.can_plot = (can_live_plot and (mpl is not None)
and (Process is not None))
if log_filename is not None:
self.output = Output('', filename=log_filename)
self.output('# started: %s' % time.asctime())
self.output('# groups: %d' % n_gr)
for ig, names in enumerate(data_names):
self.output('# %d' % ig)
self.output('# xlabel: "%s", ylabel: "%s", yscales: "%s"'
% (xlabels[ig], ylabels[ig], yscales[ig]))
self.output('# names: "%s"' % ', '.join(names))
if self.is_plot and (not self.can_plot):
output(_msg_no_live)
开发者ID:mikegraham,项目名称:sfepy,代码行数:57,代码来源:log.py
示例18: __init__
def __init__( self, name, problem, kwargs ):
Struct.__init__( self, name = name, problem = problem, **kwargs )
self.problem.clear_equations()
self.set_default_attr('requires', [])
self.set_default_attr('is_linear', False)
self.set_default_attr('dtype', nm.float64)
self.set_default_attr('term_mode', None)
self.set_default_attr('set_volume', 'total')
开发者ID:renatocoutinho,项目名称:sfepy,代码行数:9,代码来源:coefs_base.py
示例19: __init__
def __init__(self, name):
Struct.__init__(self, name=name)
self.n_var = 0
self.var_names = []
self.n_dof = {}
self.ptr = [0]
self.indx = {}
self.details = {}
开发者ID:ZJLi2013,项目名称:sfepy,代码行数:9,代码来源:dof_info.py
示例20: __init__
def __init__(self, filename, approx, region_selects, mat_pars, options,
evp_options, eigenmomenta_options, band_gaps_options,
coefs_save_name='coefs',
corrs_save_names=None,
incwd=None,
output_dir=None, **kwargs):
Struct.__init__(self, approx=approx, region_selects=region_selects,
mat_pars=mat_pars, options=options,
evp_options=evp_options,
eigenmomenta_options=eigenmomenta_options,
band_gaps_options=band_gaps_options,
**kwargs)
self.incwd = get_default(incwd, lambda x: x)
self.conf = Struct()
self.conf.filename_mesh = self.incwd(filename)
output_dir = get_default(output_dir, self.incwd('output'))
default = {'evp' : 'evp', 'corrs_rs' : 'corrs_rs'}
self.corrs_save_names = get_default(corrs_save_names,
default)
io = MeshIO.any_from_filename(self.conf.filename_mesh)
self.bbox, self.dim = io.read_bounding_box(ret_dim=True)
rpc_axes = nm.eye(self.dim, dtype=nm.float64) \
* (self.bbox[1] - self.bbox[0])
self.conf.options = options
self.conf.options.update({
'output_dir' : output_dir,
'volume' : {
'value' : get_lattice_volume(rpc_axes),
},
'coefs' : 'coefs',
'requirements' : 'requirements',
'coefs_filename' : coefs_save_name,
})
self.conf.mat_pars = mat_pars
self.conf.solvers = self.define_solvers()
self.conf.regions = self.define_regions()
self.conf.materials = self.define_materials()
self.conf.fields = self.define_fields()
self.conf.variables = self.define_variables()
(self.conf.ebcs, self.conf.epbcs,
self.conf.lcbcs, self.all_periodic) = self.define_bcs()
self.conf.functions = self.define_functions()
self.conf.integrals = self.define_integrals()
self.equations, self.expr_coefs = self.define_equations()
self.conf.coefs = self.define_coefs()
self.conf.requirements = self.define_requirements()
开发者ID:andy-c-huang,项目名称:sfepy,代码行数:57,代码来源:band_gaps_conf.py
注:本文中的sfepy.base.base.Struct类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论