本文整理汇总了Python中sfepy.base.ioutils.get_trunk函数的典型用法代码示例。如果您正苦于以下问题:Python get_trunk函数的具体用法?Python get_trunk怎么用?Python get_trunk使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_trunk函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: setup_output_info
def setup_output_info(self, problem, options):
"""Modifies both problem and options!"""
if options.output_filename_trunk is None:
if self.conf.get('filename_mesh') is not None:
filename_mesh = self.conf.filename_mesh
if isinstance(filename_mesh, MeshIO):
ofn_trunk = filename_mesh.get_filename_trunk()
else:
ofn_trunk = io.get_trunk(filename_mesh)
elif self.conf.get('filename_domain') is not None:
ofn_trunk = io.get_trunk(self.conf.filename_domain)
else:
raise ValueError('missing filename_mesh or filename_domain!')
options.output_filename_trunk = ofn_trunk
else:
ofn_trunk = options.output_filename_trunk
if hasattr(options, 'output_format') \
and (options.output_format is not None):
output_format = options.output_format
else:
output_format = self.app_options.output_format
problem.setup_output(output_filename_trunk=ofn_trunk,
output_dir=self.app_options.output_dir,
output_format=output_format,
file_per_var=self.app_options.file_per_var,
linearization=self.app_options.linearization)
开发者ID:LeiDai,项目名称:sfepy,代码行数:34,代码来源:pde_solver_app.py
示例2: from_conf
def from_conf(conf, init_fields=True, init_variables=True, init_equations=True, init_solvers=True):
mesh = Mesh.from_file(conf.filename_mesh)
eldesc_dir = op.join(install_dir, "eldesc")
domain = Domain.from_mesh(mesh, eldesc_dir)
domain.setup_groups()
domain.fix_element_orientation()
domain.setup_neighbour_lists()
obj = ProblemDefinition(conf=conf, domain=domain, eldesc_dir=eldesc_dir)
# Default output file trunk and format.
obj.ofn_trunk = io.get_trunk(conf.filename_mesh)
obj.output_format = "vtk"
obj.set_regions(conf.regions, conf.materials, conf.funmod)
if init_fields:
obj.set_fields(conf.fields)
if init_variables:
obj.set_variables(conf.variables)
if init_equations:
obj.set_equations(conf.equations)
if init_solvers:
obj.set_solvers(conf.solvers, conf.options)
obj.ts = None
return obj
开发者ID:certik,项目名称:sfepy,代码行数:33,代码来源:problemDef.py
示例3: dump_to_vtk
def dump_to_vtk( filename, options, steps = None ):
output( 'dumping to VTK...' )
mesh = Mesh.from_file( filename )
io = HDF5MeshIO( filename )
ts = TimeStepper( *io.read_time_stepper() )
if options.output_filename_trunk:
ofn_trunk = options.output_filename_trunk
else:
ofn_trunk = get_trunk( filename )
if steps is None:
iterator = ts.iter_from( options.step0 )
else:
iterator = [(step, ts.times[step]) for step in steps]
for step, time in iterator:
output( ts.format % (step, ts.n_step - 1) )
out = io.read_data( step )
if out is None: break
mesh.write( ofn_trunk + ts.suffix % step + '.vtk',
io = 'auto', out = out )
output( '...done' )
return ts.suffix
开发者ID:certik,项目名称:sfepy,代码行数:27,代码来源:extractor.py
示例4: setup_default_output
def setup_default_output(self, conf=None, options=None):
"""
Provide default values to `ProblemDefinition.setup_output()`
from `conf.options` and `options`.
"""
conf = get_default(conf, self.conf)
if options and options.output_filename_trunk:
default_output_dir, of = op.split(options.output_filename_trunk)
default_trunk = io.get_trunk(of)
else:
default_trunk = None
default_output_dir = get_default_attr(conf.options,
'output_dir', None)
if options and options.output_format:
default_output_format = options.output_format
else:
default_output_format = get_default_attr(conf.options,
'output_format', None)
default_file_per_var = get_default_attr(conf.options,
'file_per_var', None)
default_float_format = get_default_attr(conf.options,
'float_format', None)
default_linearization = Struct(kind='strip')
self.setup_output(output_filename_trunk=default_trunk,
output_dir=default_output_dir,
file_per_var=default_file_per_var,
output_format=default_output_format,
float_format=default_float_format,
linearization=default_linearization)
开发者ID:mikegraham,项目名称:sfepy,代码行数:35,代码来源:problemDef.py
示例5: setup_output_info
def setup_output_info(self, problem, options):
"""Modifies both problem and options!"""
if options.output_filename_trunk is None:
filename_mesh = self.conf.filename_mesh
if isinstance(filename_mesh, MeshIO):
ofn_trunk = filename_mesh.get_filename_trunk()
else:
ofn_trunk = io.get_trunk(filename_mesh)
options.output_filename_trunk = ofn_trunk
else:
ofn_trunk = options.output_filename_trunk
if hasattr(options, "output_format") and (options.output_format is not None):
output_format = options.output_format
else:
output_format = self.app_options.output_format
problem.setup_output(
output_filename_trunk=ofn_trunk,
output_dir=self.app_options.output_dir,
output_format=output_format,
file_per_var=self.app_options.file_per_var,
linearization=self.app_options.linearization,
)
开发者ID:sdurve,项目名称:sfepy,代码行数:28,代码来源:pde_solver_app.py
示例6: dump_to_vtk
def dump_to_vtk(filename, output_filename_trunk=None, step0=0, steps=None,
fields=None, linearization=None):
"""Dump a multi-time-step results file into a sequence of VTK files."""
def _save_step(suffix, out, mesh):
if linearization is not None:
output('linearizing...')
out = _linearize(out, fields, linearization)
output('...done')
for key, val in out.iteritems():
lmesh = val.get('mesh', mesh)
lmesh.write(output_filename_trunk + '_' + key + suffix,
io='auto', out={key : val})
if hasattr(val, 'levels'):
output('max. refinement per group:', val.levels)
else:
mesh.write(output_filename_trunk + suffix, io='auto', out=out)
output('dumping to VTK...')
io = MeshIO.any_from_filename(filename)
mesh = Mesh.from_file(filename, io=io)
if output_filename_trunk is None:
output_filename_trunk = get_trunk(filename)
try:
ts = TimeStepper(*io.read_time_stepper())
times, nts, dts = extract_times(filename)
except ValueError:
output('no time stepping info found, assuming single step')
out = io.read_data(0)
if out is not None:
_save_step('.vtk', out, mesh)
ret = None
else:
ts.times = times
ts.n_step = times.shape[0]
if steps is None:
iterator = ts.iter_from(step0)
else:
iterator = [(step, ts.times[step]) for step in steps]
for step, time in iterator:
output(ts.format % (step, ts.n_step - 1))
out = io.read_data(step)
if out is None: break
_save_step('.' + ts.suffix % step + '.vtk', out, mesh)
ret = ts.suffix
output('...done')
return ret
开发者ID:renatocoutinho,项目名称:sfepy,代码行数:60,代码来源:time_history.py
示例7: solve_optimize
def solve_optimize(conf, options):
opts = conf.options
trunk = io.get_trunk(conf.filename_mesh)
data = {}
dpb = ProblemDefinition.from_conf(conf, init_equations=False)
equations = getattr(conf, "_".join(("equations_direct", opts.problem)))
dpb.set_equations(equations)
dpb.name = "direct"
dpb.time_update(None)
apb = dpb.copy("adjoint")
equations = getattr(conf, "_".join(("equations_adjoint", opts.problem, opts.objective_function)))
apb.set_equations(equations)
apb.time_update(None)
apb.ebcs.zero_dofs()
apb.update_equations(None, ebcs=apb.ebcs)
ls_conf = dpb.get_solver_conf(opts.ls)
dnls_conf = dpb.get_solver_conf(opts.nls_direct)
anls_conf = dpb.get_solver_conf(opts.nls_adjoint)
opt_conf = dpb.get_solver_conf(opts.optimizer)
dpb.init_solvers(ls_conf=ls_conf, nls_conf=dnls_conf)
apb.init_solvers(ls_conf=ls_conf, nls_conf=anls_conf)
shape_opt = so.ShapeOptimFlowCase.from_conf(conf, dpb, apb)
design0 = shape_opt.dsg_vars.val
shape_opt.cache = Struct(design=design0 + 100, state=None, i_mesh=-1)
opt_status = IndexedStruct()
optimizer = Solver.any_from_conf(
opt_conf, obj_fun=so.obj_fun, obj_fun_grad=so.obj_fun_grad, status=opt_status, obj_args=(shape_opt, opts)
)
##
# State problem solution for the initial design.
vec_dp0 = so.solve_problem_for_design(dpb, design0, shape_opt, opts)
dpb.save_state(trunk + "_direct_initial.vtk", vec_dp0)
##
# Optimize.
des = optimizer(design0)
print opt_status
##
# Save final state (for "optimal" design).
dpb.domain.mesh.write(trunk + "_opt.mesh", io="auto")
dpb.save_state(trunk + "_direct_current.vtk", shape_opt.cache.state)
print des
开发者ID:brbr520,项目名称:sfepy,代码行数:56,代码来源:shaper.py
示例8: solve_adjoint
def solve_adjoint(conf, options, dpb, vec_dp, data):
"""
Solve the adjoint (linear) problem.
"""
opts = conf.options
if dpb:
apb = dpb.copy('adjoint')
else:
apb = ProblemDefinition.from_conf(conf)
equations = getattr(conf, '_'.join(('equations_adjoint',
opts.problem,
opts.objective_function)))
apb.set_equations(equations)
apb.time_update(None)
apb.ebcs.zero_dofs()
apb.update_equations(None, ebcs=apb.ebcs)
var_data = dpb.equations.get_state_parts(vec_dp)
var_data = remap_dict(var_data, opts.var_map)
nls_conf = apb.get_solver_conf(opts.nls_adjoint)
vec_ap = apb.solve(nls_conf=nls_conf, var_data=var_data)
trunk = io.get_trunk(conf.filename_mesh)
apb.save_state(trunk + '_adjoint.vtk', vec_ap)
shape_opt = so.ShapeOptimFlowCase.from_conf(conf, dpb, apb)
## print shape_opt
## pause()
if options.test is not None:
##
# Test shape sensitivity.
if shape_opt.test_terms_if_test:
so.test_terms([options.test], opts.term_delta, shape_opt,
var_data, vec_ap)
shape_opt.check_sensitivity([options.test], opts.delta,
var_data, vec_ap)
##
# Compute objective function.
val = shape_opt.obj_fun(vec_dp)
print 'actual obj_fun:', val
## pause()
##
# Compute shape sensitivity.
vec_sa = shape_opt.sensitivity(var_data, vec_ap)
print 'actual sensitivity:', vec_sa
开发者ID:olivierverdier,项目名称:sfepy,代码行数:52,代码来源:shaper.py
示例9: solve_direct
def solve_direct( conf, options ):
"""
Solve the direct (nonlinear) problem.
"""
opts = conf.options
if hasattr( opts, 'problem' ):
if opts.problem == 'navier_stokes':
dpb, vec_dp, data = solve_navier_stokes( conf, options )
else:
output( 'unknown problem type (%s), using generic solver.'\
% opts.problem )
dpb, vec_dp, data = solve_generic_direct( conf, options )
else: # Generic direct problem.
dpb, vec_dp, data = solve_generic_direct( conf, options )
trunk = io.get_trunk( conf.filename_mesh )
dpb.save_state( trunk + '_direct.vtk', vec_dp )
## print dpb.materials['stabil']
## pause()
if options.dump_filename is not None:
import tables as pt
import numarray as nar
fd = pt.openFile( options.dump_filename, mode = 'w',
title = "Dump file" )
out = vec_dp.create_output_dict()
for key, val in out.iteritems():
fd.createArray( fd.root, key, nar.asarray( val.data ),
'%s data' % val.mode )
fd.close()
if options.pert_mesh_filename is not None:
coors0 = dpb.get_mesh_coors()
# !!!
# 'u' is here for displacements of le.py!
vec_u = dpb.variables.get_state_part_view( vec_dp, 'u' ).copy()
vec_u = vec_u.reshape( coors0.shape )
coors = coors0 + vec_u
dpb.set_mesh_coors( coors )
dpb.domain.mesh.write( options.pert_mesh_filename, io = 'auto' )
return dpb, vec_dp, data
开发者ID:taldcroft,项目名称:sfepy,代码行数:43,代码来源:shaper.py
示例10: setup_output_info
def setup_output_info(self, problem, options):
"""Modifies both problem and options!"""
if options.output_filename_trunk is None:
ofn_trunk = io.get_trunk(self.conf.filename_mesh)
options.output_filename_trunk = ofn_trunk
else:
ofn_trunk = options.output_filename_trunk
if hasattr(options, 'output_format') \
and (options.output_format is not None):
output_format = options.output_format
else:
output_format = self.app_options.output_format
problem.setup_output(output_filename_trunk=ofn_trunk,
output_dir=self.app_options.output_dir,
output_format=output_format,
file_per_var=self.app_options.file_per_var)
开发者ID:olivierverdier,项目名称:sfepy,代码行数:20,代码来源:simple_app.py
示例11: dump_to_vtk
def dump_to_vtk(filename, output_filename_trunk=None, step0=0, steps=None):
"""Dump a multi-time-step results file into a sequence of VTK files."""
output('dumping to VTK...')
io = MeshIO.any_from_filename(filename)
mesh = Mesh.from_file(filename, io=io)
if output_filename_trunk is None:
output_filename_trunk = get_trunk(filename)
try:
ts = TimeStepper(*io.read_time_stepper())
except:
output('no time stepping info found, assuming single step')
out = io.read_data(0)
if out is not None:
mesh.write(output_filename_trunk + '.vtk', io='auto', out=out)
ret = None
else:
if steps is None:
iterator = ts.iter_from(step0)
else:
iterator = [(step, ts.times[step]) for step in steps]
for step, time in iterator:
output(ts.format % (step, ts.n_step - 1))
out = io.read_data(step)
if out is None: break
mesh.write('.'.join((output_filename_trunk,
ts.suffix % step, 'vtk')),
io='auto', out=out)
ret = ts.suffix
output('...done')
return ret
开发者ID:olivierverdier,项目名称:sfepy,代码行数:41,代码来源:time_history.py
示例12: __init__
def __init__( self, conf, options, output_prefix, **kwargs ):
"""`kwargs` are passed to ProblemDefinition.from_conf()
Command-line options have precedence over conf.options."""
Application.__init__( self, conf, options, output_prefix )
self.setup_options()
if options.output_filename_trunk is None:
ofn_trunk = op.join( self.app_options.output_dir,
io.get_trunk( conf.filename_mesh ) )
options.output_filename_trunk = ofn_trunk
else:
ofn_trunk = options.output_filename_trunk
self.problem = ProblemDefinition.from_conf( conf, **kwargs )
self.problem.ofn_trunk = ofn_trunk
self.problem.output_dir = self.app_options.output_dir
if hasattr( options, 'output_format' ):
self.problem.output_format = options.output_format
else:
self.problem.output_format = self.app_options.output_format
开发者ID:certik,项目名称:sfepy,代码行数:22,代码来源:simple_app.py
示例13: setup_output
def setup_output(self, output_filename_trunk=None, output_dir=None,
output_format=None, float_format=None,
file_per_var=None, linearization=None):
"""
Sets output options to given values, or uses the defaults for
each argument that is None.
"""
self.output_modes = {'vtk' : 'sequence', 'h5' : 'single'}
self.ofn_trunk = get_default(output_filename_trunk,
io.get_trunk(self.domain.name))
self.set_output_dir(output_dir)
self.output_format = get_default(output_format, 'vtk')
self.float_format = get_default(float_format, None)
self.file_per_var = get_default(file_per_var, False)
self.linearization = get_default(linearization, Struct(kind='strip'))
if ((self.output_format == 'h5') and
(self.linearization.kind == 'adaptive')):
self.linearization.kind = None
开发者ID:mikegraham,项目名称:sfepy,代码行数:22,代码来源:problemDef.py
示例14: solve_direct
def solve_direct(conf, options):
"""
Solve the direct (nonlinear) problem.
"""
opts = conf.options
if hasattr(opts, "problem"):
if opts.problem == "navier_stokes":
dpb, state_dp, data = solve_navier_stokes(conf, options)
else:
output("unknown problem type (%s), using generic solver." % opts.problem)
dpb, state_dp, data = solve_generic_direct(conf, options)
else: # Generic direct problem.
dpb, state_dp, data = solve_generic_direct(conf, options)
trunk = io.get_trunk(conf.filename_mesh)
dpb.save_state(trunk + "_direct.vtk", state_dp)
if options.dump_filename is not None:
import tables as pt
import numarray as nar
fd = pt.openFile(options.dump_filename, mode="w", title="Dump file")
out = state_dp.create_output_dict()
for key, val in out.iteritems():
fd.createArray(fd.root, key, nar.asarray(val.data), "%s data" % val.mode)
fd.close()
if options.pert_mesh_filename is not None:
coors0 = dpb.get_mesh_coors()
# !!!
# 'u' is here for displacements of le.py!
vec_u = state_dp("u").copy()
vec_u = vec_u.reshape(coors0.shape)
coors = coors0 + vec_u
dpb.set_mesh_coors(coors)
dpb.domain.mesh.write(options.pert_mesh_filename, io="auto")
return dpb, state_dp, data
开发者ID:brbr520,项目名称:sfepy,代码行数:38,代码来源:shaper.py
示例15: main
def main():
parser = OptionParser(usage = usage, version = "%prog " + sfepy.__version__)
parser.add_option( "-o", "", metavar = 'filename',
action = "store", dest = "output_filename_trunk",
default = None, help = help['filename'] )
parser.add_option( "-d", "--dump",
action = "store_true", dest = "dump",
default = False, help = help['dump'] )
parser.add_option( "", "--same-dir",
action = "store_true", dest = "same_dir",
default = False, help = help['same_dir'] )
parser.add_option( "-f", "--from", type = int, metavar = 'ii',
action = "store", dest = "step_from",
default = 0, help = help['from'] )
parser.add_option( "-t", "--to", type = int, metavar = 'ii',
action = "store", dest = "step_to",
default = None, help = help['to'] )
parser.add_option( "-s", "--step", type = int, metavar = 'ii',
action = "store", dest = "step_by",
default = 1, help = help['step'] )
parser.add_option( "-e", "--extract", metavar = 'list',
action = "store", dest = "extract",
default = None, help = help['extract'] )
parser.add_option( "-a", "--average",
action = "store_true", dest = "average",
default = False, help = help['average'] )
(options, args) = parser.parse_args()
if (len( args ) == 1):
filename_in = args[0];
else:
parser.print_help(),
return
if options.dump:
trunk = get_default(options.output_filename_trunk,
get_trunk(filename_in))
if options.same_dir:
trunk = os.path.join(os.path.dirname(filename_in),
os.path.basename(trunk))
if options.step_to is None:
dump_to_vtk(filename_in,
output_filename_trunk=trunk,
step0=options.step_from)
else:
dump_to_vtk(filename_in,
output_filename_trunk=trunk,
steps=nm.arange(options.step_from,
options.step_to + 1,
options.step_by, dtype=nm.int))
if options.extract:
ths, ts = extract_time_history(filename_in, options.extract)
## print ths
if options.average:
ths = average_vertex_var_in_cells( ths )
## print ths
if options.output_filename_trunk:
save_time_history(ths, ts, options.output_filename_trunk + '.h5')
else:
print dict_to_struct(ths, flag=(1, 1, 1)).str_all()
开发者ID:olivierverdier,项目名称:sfepy,代码行数:67,代码来源:extractor.py
示例16: main
def main():
parser = ArgumentParser(description=__doc__, formatter_class=RawDescriptionHelpFormatter)
parser.add_argument("--version", action="version", version="%(prog)s " + sfepy.__version__)
parser.add_argument("--debug", action="store_true", dest="debug", default=False, help=helps["debug"])
parser.add_argument(
"-o", metavar="filename", action="store", dest="output_filename_trunk", default=None, help=helps["filename"]
)
parser.add_argument("-d", "--dump", action="store_true", dest="dump", default=False, help=helps["dump"])
parser.add_argument("--same-dir", action="store_true", dest="same_dir", default=False, help=helps["same_dir"])
parser.add_argument(
"-l",
"--linearization",
metavar="options",
action="store",
dest="linearization",
default=None,
help=helps["linearization"],
)
parser.add_argument("--times", action="store_true", dest="times", default=False, help=helps["times"])
parser.add_argument(
"-f", "--from", type=int, metavar="ii", action="store", dest="step_from", default=0, help=helps["from"]
)
parser.add_argument(
"-t", "--to", type=int, metavar="ii", action="store", dest="step_to", default=None, help=helps["to"]
)
parser.add_argument(
"-s", "--step", type=int, metavar="ii", action="store", dest="step_by", default=1, help=helps["step"]
)
parser.add_argument(
"-e", "--extract", metavar="list", action="store", dest="extract", default=None, help=helps["extract"]
)
parser.add_argument("-a", "--average", action="store_true", dest="average", default=False, help=helps["average"])
parser.add_argument("input_file", nargs="?", default=None)
parser.add_argument("results_file")
options = parser.parse_args()
if options.debug:
from sfepy.base.base import debug_on_error
debug_on_error()
filename_in = options.input_file
filename_results = options.results_file
if filename_in is None:
linearize = False
else:
linearize = True
options.dump = True
if options.times:
steps, times, nts, dts = th.extract_times(filename_results)
for ii, time in enumerate(times):
step = steps[ii]
print("%d %e %e %e" % (step, time, nts[ii], dts[ii]))
if options.dump:
trunk = get_default(options.output_filename_trunk, get_trunk(filename_results))
if options.same_dir:
trunk = os.path.join(os.path.dirname(filename_results), os.path.basename(trunk))
args = {}
if linearize:
problem = create_problem(filename_in)
linearization = Struct(kind="adaptive", min_level=0, max_level=2, eps=1e-2)
aux = problem.conf.options.get("linearization", None)
linearization.update(aux)
if options.linearization is not None:
aux = parse_linearization(options.linearization)
linearization.update(aux)
args.update({"fields": problem.fields, "linearization": linearization})
if options.step_to is None:
args.update({"step0": options.step_from})
else:
args.update({"steps": nm.arange(options.step_from, options.step_to + 1, options.step_by, dtype=nm.int)})
th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)
if options.extract:
ths, ts = th.extract_time_history(filename_results, options.extract)
if options.average:
ths = th.average_vertex_var_in_cells(ths)
if options.output_filename_trunk:
th.save_time_history(ths, ts, options.output_filename_trunk + ".h5")
else:
print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())
开发者ID:rc,项目名称:sfepy,代码行数:94,代码来源:extractor.py
示例17: main
def main():
parser = OptionParser(usage=usage, version="%prog " + sfepy.__version__)
parser.add_option('-o', '', metavar='filename',
action='store', dest='output_filename_trunk',
default=None, help=help['filename'])
parser.add_option('-d', '--dump', action='store_true', dest='dump',
default=False, help=help['dump'])
parser.add_option('', '--same-dir', action='store_true', dest='same_dir',
default=False, help=help['same_dir'])
parser.add_option('-l', '--linearization', metavar='options',
action='store', dest='linearization',
default=None, help=help['linearization'])
parser.add_option('', '--times', action='store_true', dest='times',
default=False, help=help['times'])
parser.add_option('-f', '--from', type=int, metavar='ii',
action='store', dest='step_from',
default=0, help=help['from'])
parser.add_option('-t', '--to', type=int, metavar='ii',
action='store', dest='step_to',
default=None, help=help['to'])
parser.add_option('-s', '--step', type=int, metavar='ii',
action='store', dest='step_by',
default=1, help=help['step'])
parser.add_option('-e', '--extract', metavar='list',
action='store', dest='extract',
default=None, help=help['extract'])
parser.add_option('-a', '--average', action='store_true', dest='average',
default=False, help=help['average'])
(options, args) = parser.parse_args()
nargs = len(args)
if nargs == 1:
filename_results = args[0]
linearize = False
elif nargs == 2:
filename_in, filename_results = args
linearize = True
options.dump = True
else:
parser.print_help()
return
if options.times:
steps, times, nts, dts = th.extract_times(filename_results)
for ii, time in enumerate(times):
step = steps[ii]
print('%d %e %e %e' % (step, time, nts[ii], dts[ii]))
if options.dump:
trunk = get_default(options.output_filename_trunk,
get_trunk(filename_results))
if options.same_dir:
trunk = os.path.join(os.path.dirname(filename_results),
os.path.basename(trunk))
args = {}
if linearize:
problem = create_problem(filename_in)
linearization = Struct(kind='adaptive', min_level=0,
max_level=2, eps=1e-2)
aux = problem.conf.options.get('linearization', None)
linearization.update(aux)
if options.linearization is not None:
aux = parse_linearization(options.linearization)
linearization.update(aux)
args.update({'fields' : problem.fields,
'linearization' : linearization})
if options.step_to is None:
args.update({'step0' : options.step_from})
else:
args.update({'steps' : nm.arange(options.step_from,
options.step_to + 1,
options.step_by, dtype=nm.int)})
th.dump_to_vtk(filename_results, output_filename_trunk=trunk, **args)
if options.extract:
ths, ts = th.extract_time_history(filename_results, options.extract)
if options.average:
ths = th.average_vertex_var_in_cells(ths)
if options.output_filename_trunk:
th.save_time_history(ths, ts, options.output_filename_trunk + '.h5')
else:
print(dict_to_struct(ths, flag=(1, 1, 1)).str_all())
开发者ID:Nasrollah,项目名称:sfepy,代码行数:95,代码来源:extractor.py
注:本文中的sfepy.base.ioutils.get_trunk函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论