本文整理汇总了Python中sfepy.discrete.Problem.save_state方法的典型用法代码示例。如果您正苦于以下问题:Python Problem.save_state方法的具体用法?Python Problem.save_state怎么用?Python Problem.save_state使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfepy.discrete.Problem
的用法示例。
在下文中一共展示了Problem.save_state方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_solving
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
def test_solving(self):
from sfepy.base.base import IndexedStruct
from sfepy.discrete import (FieldVariable, Material, Problem, Function,
Equation, Equations, Integral)
from sfepy.discrete.conditions import Conditions, EssentialBC
from sfepy.terms import Term
from sfepy.solvers.ls import ScipyDirect
from sfepy.solvers.nls import Newton
from sfepy.mechanics.matcoefs import stiffness_from_lame
u = FieldVariable('u', 'unknown', self.field)
v = FieldVariable('v', 'test', self.field, primary_var_name='u')
m = Material('m', D=stiffness_from_lame(self.dim, 1.0, 1.0))
f = Material('f', val=[[0.02], [0.01]])
bc_fun = Function('fix_u_fun', fix_u_fun,
extra_args={'extra_arg' : 'hello'})
fix_u = EssentialBC('fix_u', self.gamma1, {'u.all' : bc_fun})
shift_u = EssentialBC('shift_u', self.gamma2, {'u.0' : 0.1})
integral = Integral('i', order=3)
t1 = Term.new('dw_lin_elastic(m.D, v, u)',
integral, self.omega, m=m, v=v, u=u)
t2 = Term.new('dw_volume_lvf(f.val, v)', integral, self.omega, f=f, v=v)
eq = Equation('balance', t1 + t2)
eqs = Equations([eq])
ls = ScipyDirect({})
nls_status = IndexedStruct()
nls = Newton({}, lin_solver=ls, status=nls_status)
pb = Problem('elasticity', equations=eqs)
## pb.save_regions_as_groups('regions')
pb.set_bcs(ebcs=Conditions([fix_u, shift_u]))
pb.set_solver(nls)
state = pb.solve()
name = op.join(self.options.out_dir, 'test_high_level_solving.vtk')
pb.save_state(name, state)
ok = nls_status.condition == 0
if not ok:
self.report('solver did not converge!')
_ok = state.has_ebc()
if not _ok:
self.report('EBCs violated!')
ok = ok and _ok
return ok
示例2: main
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
def main():
from sfepy import data_dir
parser = OptionParser(usage=usage, version="%prog")
parser.add_option("-s", "--show", action="store_true", dest="show", default=False, help=help["show"])
options, args = parser.parse_args()
mesh = Mesh.from_file(data_dir + "/meshes/2d/rectangle_tri.mesh")
domain = Domain("domain", mesh)
min_x, max_x = domain.get_mesh_bounding_box()[:, 0]
eps = 1e-8 * (max_x - min_x)
omega = domain.create_region("Omega", "all")
gamma1 = domain.create_region("Gamma1", "vertices in x < %.10f" % (min_x + eps), "facet")
gamma2 = domain.create_region("Gamma2", "vertices in x > %.10f" % (max_x - eps), "facet")
field = Field.from_args("fu", nm.float64, "vector", omega, approx_order=2)
u = FieldVariable("u", "unknown", field)
v = FieldVariable("v", "test", field, primary_var_name="u")
m = Material("m", lam=1.0, mu=1.0)
f = Material("f", val=[[0.02], [0.01]])
integral = Integral("i", order=3)
t1 = Term.new("dw_lin_elastic_iso(m.lam, m.mu, v, u)", integral, omega, m=m, v=v, u=u)
t2 = Term.new("dw_volume_lvf(f.val, v)", integral, omega, f=f, v=v)
eq = Equation("balance", t1 + t2)
eqs = Equations([eq])
fix_u = EssentialBC("fix_u", gamma1, {"u.all": 0.0})
bc_fun = Function("shift_u_fun", shift_u_fun, extra_args={"shift": 0.01})
shift_u = EssentialBC("shift_u", gamma2, {"u.0": bc_fun})
ls = ScipyDirect({})
nls_status = IndexedStruct()
nls = Newton({}, lin_solver=ls, status=nls_status)
pb = Problem("elasticity", equations=eqs, nls=nls, ls=ls)
pb.save_regions_as_groups("regions")
pb.time_update(ebcs=Conditions([fix_u, shift_u]))
vec = pb.solve()
print nls_status
pb.save_state("linear_elasticity.vtk", vec)
if options.show:
view = Viewer("linear_elasticity.vtk")
view(vector_mode="warp_norm", rel_scaling=2, is_scalar_bar=True, is_wireframe=True)
示例3: main
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
#.........这里部分代码省略.........
default=False, help=helps['3d'])
parser.add_argument('--order', metavar='int', type=int,
action='store', dest='order',
default=1, help=helps['order'])
options = parser.parse_args()
dim = 3 if options.is_3d else 2
dims = nm.array(eval(options.dims), dtype=nm.float64)[:dim]
shape = nm.array(eval(options.shape), dtype=nm.int32)[:dim]
centre = nm.array(eval(options.centre), dtype=nm.float64)[:dim]
output('dimensions:', dims)
output('shape: ', shape)
output('centre: ', centre)
mesh0 = gen_block_mesh(dims, shape, centre, name='block-fem',
verbose=True)
domain0 = FEDomain('d', mesh0)
bbox = domain0.get_mesh_bounding_box()
min_x, max_x = bbox[:, 0]
eps = 1e-8 * (max_x - min_x)
cnt = (shape[0] - 1) // 2
g0 = 0.5 * dims[0]
grading = nm.array([g0 / 2**ii for ii in range(cnt)]) + eps + centre[0] - g0
domain, subs = refine_towards_facet(domain0, grading, 'x <')
omega = domain.create_region('Omega', 'all')
gamma1 = domain.create_region('Gamma1',
'vertices in (x < %.10f)' % (min_x + eps),
'facet')
gamma2 = domain.create_region('Gamma2',
'vertices in (x > %.10f)' % (max_x - eps),
'facet')
field = Field.from_args('fu', nm.float64, 1, omega,
approx_order=options.order)
if subs is not None:
field.substitute_dofs(subs)
u = FieldVariable('u', 'unknown', field)
v = FieldVariable('v', 'test', field, primary_var_name='u')
integral = Integral('i', order=2*options.order)
t1 = Term.new('dw_laplace(v, u)',
integral, omega, v=v, u=u)
eq = Equation('eq', t1)
eqs = Equations([eq])
def u_fun(ts, coors, bc=None, problem=None):
"""
Define a displacement depending on the y coordinate.
"""
if coors.shape[1] == 2:
min_y, max_y = bbox[:, 1]
y = (coors[:, 1] - min_y) / (max_y - min_y)
val = (max_y - min_y) * nm.cos(3 * nm.pi * y)
else:
min_y, max_y = bbox[:, 1]
min_z, max_z = bbox[:, 2]
y = (coors[:, 1] - min_y) / (max_y - min_y)
z = (coors[:, 2] - min_z) / (max_z - min_z)
val = ((max_y - min_y) * (max_z - min_z)
* nm.cos(3 * nm.pi * y) * (1.0 + 3.0 * (z - 0.5)**2))
return val
bc_fun = Function('u_fun', u_fun)
fix1 = EssentialBC('shift_u', gamma1, {'u.0' : bc_fun})
fix2 = EssentialBC('fix2', gamma2, {'u.all' : 0.0})
ls = ScipyDirect({})
nls = Newton({}, lin_solver=ls)
pb = Problem('heat', equations=eqs, nls=nls, ls=ls)
pb.time_update(ebcs=Conditions([fix1, fix2]))
state = pb.solve()
if subs is not None:
field.restore_dofs()
filename = os.path.join(options.output_dir, 'hanging.vtk')
ensure_path(filename)
pb.save_state(filename, state)
if options.order > 1:
pb.save_state(filename, state, linearization=Struct(kind='adaptive',
min_level=0,
max_level=8,
eps=1e-3))
示例4: main
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
#.........这里部分代码省略.........
eq1 = Equation('stiffness', t1)
eq2 = Equation('mass', t2)
lhs_eqs = Equations([eq1, eq2])
pb = Problem('modal', equations=lhs_eqs)
if options.bc_kind == 'free':
pb.time_update()
n_rbm = dim * (dim + 1) / 2
elif options.bc_kind == 'cantilever':
fixed = EssentialBC('Fixed', bottom, {'u.all' : 0.0})
pb.time_update(ebcs=Conditions([fixed]))
n_rbm = 0
elif options.bc_kind == 'fixed':
fixed = EssentialBC('Fixed', bottom_top, {'u.all' : 0.0})
pb.time_update(ebcs=Conditions([fixed]))
n_rbm = 0
else:
raise ValueError('unsupported BC kind! (%s)' % options.bc_kind)
if options.ignore is not None:
n_rbm = options.ignore
pb.update_materials()
# Assemble stiffness and mass matrices.
mtx_k = eq1.evaluate(mode='weak', dw_mode='matrix', asm_obj=pb.mtx_a)
mtx_m = mtx_k.copy()
mtx_m.data[:] = 0.0
mtx_m = eq2.evaluate(mode='weak', dw_mode='matrix', asm_obj=mtx_m)
try:
eigs, svecs = eig_solver(mtx_k, mtx_m, options.n_eigs + n_rbm,
eigenvectors=True)
except sla.ArpackNoConvergence as ee:
eigs = ee.eigenvalues
svecs = ee.eigenvectors
output('only %d eigenvalues converged!' % len(eigs))
output('%d eigenvalues converged (%d ignored as rigid body modes)' %
(len(eigs), n_rbm))
eigs = eigs[n_rbm:]
svecs = svecs[:, n_rbm:]
omegas = nm.sqrt(eigs)
freqs = omegas / (2 * nm.pi)
output('number | eigenvalue | angular frequency '
'| frequency')
for ii, eig in enumerate(eigs):
output('%6d | %17.12e | %17.12e | %17.12e'
% (ii + 1, eig, omegas[ii], freqs[ii]))
# Make full eigenvectors (add DOFs fixed by boundary conditions).
variables = pb.get_variables()
vecs = nm.empty((variables.di.ptr[-1], svecs.shape[1]),
dtype=nm.float64)
for ii in range(svecs.shape[1]):
vecs[:, ii] = variables.make_full_vec(svecs[:, ii])
# Save the eigenvectors.
out = {}
state = pb.create_state()
for ii in range(eigs.shape[0]):
state.set_full(vecs[:, ii])
aux = state.create_output_dict()
strain = pb.evaluate('ev_cauchy_strain.i.Omega(u)',
integrals=Integrals([integral]),
mode='el_avg', verbose=False)
out['u%03d' % ii] = aux.popitem()[1]
out['strain%03d' % ii] = Struct(mode='cell', data=strain)
pb.save_state('eigenshapes.vtk', out=out)
pb.save_regions_as_groups('regions')
if len(eigs) and options.show:
# Show the solution. If the approximation order is greater than 1, the
# extra DOFs are simply thrown away.
from sfepy.postprocess.viewer import Viewer
from sfepy.postprocess.domain_specific import DomainSpecificPlot
scaling = 0.05 * dims.max() / nm.abs(vecs).max()
ds = {}
for ii in range(eigs.shape[0]):
pd = DomainSpecificPlot('plot_displacements',
['rel_scaling=%s' % scaling,
'color_kind="tensors"',
'color_name="strain%03d"' % ii])
ds['u%03d' % ii] = pd
view = Viewer('eigenshapes.vtk')
view(domain_specific=ds, only_names=sorted(ds.keys()),
is_scalar_bar=False, is_wireframe=True)
示例5: main
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
def main():
from sfepy import data_dir
parser = OptionParser(usage=usage, version='%prog')
parser.add_option('--young', metavar='float', type=float,
action='store', dest='young',
default=2000.0, help=helps['young'])
parser.add_option('--poisson', metavar='float', type=float,
action='store', dest='poisson',
default=0.4, help=helps['poisson'])
parser.add_option('--load', metavar='float', type=float,
action='store', dest='load',
default=-1000.0, help=helps['load'])
parser.add_option('--order', metavar='int', type=int,
action='store', dest='order',
default=1, help=helps['order'])
parser.add_option('-r', '--refine', metavar='int', type=int,
action='store', dest='refine',
default=0, help=helps['refine'])
parser.add_option('-s', '--show',
action="store_true", dest='show',
default=False, help=helps['show'])
parser.add_option('-p', '--probe',
action="store_true", dest='probe',
default=False, help=helps['probe'])
options, args = parser.parse_args()
assert_((0.0 < options.poisson < 0.5),
"Poisson's ratio must be in ]0, 0.5[!")
assert_((0 < options.order),
'displacement approximation order must be at least 1!')
output('using values:')
output(" Young's modulus:", options.young)
output(" Poisson's ratio:", options.poisson)
output(' vertical load:', options.load)
output('uniform mesh refinement level:', options.refine)
# Build the problem definition.
mesh = Mesh.from_file(data_dir + '/meshes/2d/its2D.mesh')
domain = FEDomain('domain', mesh)
if options.refine > 0:
for ii in range(options.refine):
output('refine %d...' % ii)
domain = domain.refine()
output('... %d nodes %d elements'
% (domain.shape.n_nod, domain.shape.n_el))
omega = domain.create_region('Omega', 'all')
left = domain.create_region('Left',
'vertices in x < 0.001', 'facet')
bottom = domain.create_region('Bottom',
'vertices in y < 0.001', 'facet')
top = domain.create_region('Top', 'vertex 2', 'vertex')
field = Field.from_args('fu', nm.float64, 'vector', omega,
approx_order=options.order)
u = FieldVariable('u', 'unknown', field)
v = FieldVariable('v', 'test', field, primary_var_name='u')
D = stiffness_from_youngpoisson(2, options.young, options.poisson)
asphalt = Material('Asphalt', D=D)
load = Material('Load', values={'.val' : [0.0, options.load]})
integral = Integral('i', order=2*options.order)
integral0 = Integral('i', order=0)
t1 = Term.new('dw_lin_elastic(Asphalt.D, v, u)',
integral, omega, Asphalt=asphalt, v=v, u=u)
t2 = Term.new('dw_point_load(Load.val, v)',
integral0, top, Load=load, v=v)
eq = Equation('balance', t1 - t2)
eqs = Equations([eq])
xsym = EssentialBC('XSym', bottom, {'u.1' : 0.0})
ysym = EssentialBC('YSym', left, {'u.0' : 0.0})
ls = ScipyDirect({})
nls_status = IndexedStruct()
nls = Newton({}, lin_solver=ls, status=nls_status)
pb = Problem('elasticity', equations=eqs, nls=nls, ls=ls)
pb.time_update(ebcs=Conditions([xsym, ysym]))
# Solve the problem.
state = pb.solve()
output(nls_status)
# Postprocess the solution.
out = state.create_output_dict()
out = stress_strain(out, pb, state, extend=True)
pb.save_state('its2D_interactive.vtk', out=out)
gdata = geometry_data['2_3']
nc = len(gdata.coors)
#.........这里部分代码省略.........
示例6: main
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
#.........这里部分代码省略.........
gamma5 = domain.create_region('Bottom',
'vertices in z < %.10f' % (min_z + eps),
'facet')
gamma6 = domain.create_region('Top',
'vertices in z > %.10f' % (max_z - eps),
'facet')
field = Field.from_args('fu', nm.float64, 'vector', omega, approx_order=2)
u = FieldVariable('u', 'unknown', field)
v = FieldVariable('v', 'test', field, primary_var_name='u')
mu=1.1
lam=1.0
m = Material('m', lam=lam, mu=mu)
f = Material('f', val=[[0.0], [0.0],[-1.0]])
load = Material('Load',val=[[0.0],[0.0],[-Load]])
D = stiffness_from_lame(3,lam, mu)
mat = Material('Mat', D=D)
get_mat = Function('get_mat1',get_mat1)
get_mat_f = Function('get_mat_f',get_mat1)
integral = Integral('i', order=3)
s_integral = Integral('is',order=2)
t1 = Term.new('dw_lin_elastic(Mat.D, v, u)',
integral, omega, Mat=mat, v=v, u=u)
t2 = Term.new('dw_volume_lvf(f.val, v)', integral, omega, f=f, v=v)
#t3 = Term.new('DotProductSurfaceTerm(Load.val, v)',s_integral,gamma5,Load=load,v=v)
t3 = Term.new('dw_surface_ltr( Load.val, v )',s_integral,gamma6,Load=load,v=v)
eq = Equation('balance', t1 + t2 + t3)
eqs = Equations([eq])
fix_u = EssentialBC('fix_u', gamma1, {'u.all' : 0.0})
left_bc = EssentialBC('Left', gamma1, {'u.0' : 0.0})
right_bc = EssentialBC('Right', gamma2, {'u.0' : 0.0})
back_bc = EssentialBC('Front', gamma3, {'u.1' : 0.0})
front_bc = EssentialBC('Back', gamma4, {'u.1' : 0.0})
bottom_bc = EssentialBC('Bottom', gamma5, {'u.all' : 0.0})
top_bc = EssentialBC('Top', gamma6, {'u.2' : 0.2})
bc=[left_bc,right_bc,back_bc,front_bc,bottom_bc]
#bc=[bottom_bc,top_bc]
##############################
# ##### SOLVER SECTION #####
##############################
conf = Struct(method='bcgsl', precond='jacobi', sub_precond=None,
i_max=10000, eps_a=1e-50, eps_r=1e-10, eps_d=1e4,
verbose=True)
ls = PETScKrylovSolver(conf)
file.write(str(ls.name)+' '+str(ls.conf.method)+' '+str(ls.conf.precond)+' '+str(ls.conf.eps_r)+' '+str(ls.conf.i_max)+'\n' )
nls_status = IndexedStruct()
nls = Newton({'i_max':1,'eps_a':1e-10}, lin_solver=ls, status=nls_status)
pb = Problem('elasticity', equations=eqs, nls=nls, ls=ls)
dd=pb.get_materials()['Mat']
dd.set_function(get_mat1)
#xload = pb.get_materials()['f']
#xload.set_function(get_mat_f)
pb.save_regions_as_groups('regions')
pb.time_update(ebcs=Conditions(bc))
vec = pb.solve()
print nls_status
file.write('TIME TO SOLVE\n')
file.write(str(nls.status.time_stats['solve'])+'\n')
file.write('TIME TO CREATE MATRIX\n')
file.write(str(nls.status.time_stats['matrix'])+'\n')
ev = pb.evaluate
out = vec.create_output_dict()
strain = ev('ev_cauchy_strain.3.Omega(u)', mode='el_avg')
stress = ev('ev_cauchy_stress.3.Omega(Mat.D, u)', mode='el_avg',
copy_materials=False)
out['cauchy_strain'] = Struct(name='output_data', mode='cell',
data=strain, dofs=None)
out['cauchy_stress'] = Struct(name='output_data', mode='cell',
data=stress, dofs=None)
pb.save_state('strain.vtk', out=out)
print nls_status
file.close()
示例7: main
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
def main():
from sfepy import data_dir
parser = ArgumentParser()
parser.add_argument('--version', action='version', version='%(prog)s')
parser.add_argument('-s', '--show',
action="store_true", dest='show',
default=False, help=helps['show'])
options = parser.parse_args()
mesh = Mesh.from_file(data_dir + '/meshes/2d/rectangle_tri.mesh')
domain = FEDomain('domain', mesh)
min_x, max_x = domain.get_mesh_bounding_box()[:,0]
eps = 1e-8 * (max_x - min_x)
omega = domain.create_region('Omega', 'all')
gamma1 = domain.create_region('Gamma1',
'vertices in x < %.10f' % (min_x + eps),
'facet')
gamma2 = domain.create_region('Gamma2',
'vertices in x > %.10f' % (max_x - eps),
'facet')
field = Field.from_args('fu', nm.float64, 'vector', omega,
approx_order=2)
u = FieldVariable('u', 'unknown', field)
v = FieldVariable('v', 'test', field, primary_var_name='u')
m = Material('m', D=stiffness_from_lame(dim=2, lam=1.0, mu=1.0))
f = Material('f', val=[[0.02], [0.01]])
integral = Integral('i', order=3)
t1 = Term.new('dw_lin_elastic(m.D, v, u)',
integral, omega, m=m, v=v, u=u)
t2 = Term.new('dw_volume_lvf(f.val, v)', integral, omega, f=f, v=v)
eq = Equation('balance', t1 + t2)
eqs = Equations([eq])
fix_u = EssentialBC('fix_u', gamma1, {'u.all' : 0.0})
bc_fun = Function('shift_u_fun', shift_u_fun,
extra_args={'shift' : 0.01})
shift_u = EssentialBC('shift_u', gamma2, {'u.0' : bc_fun})
ls = ScipyDirect({})
nls_status = IndexedStruct()
nls = Newton({}, lin_solver=ls, status=nls_status)
pb = Problem('elasticity', equations=eqs, nls=nls, ls=ls)
pb.save_regions_as_groups('regions')
pb.time_update(ebcs=Conditions([fix_u, shift_u]))
vec = pb.solve()
print(nls_status)
pb.save_state('linear_elasticity.vtk', vec)
if options.show:
view = Viewer('linear_elasticity.vtk')
view(vector_mode='warp_norm', rel_scaling=2,
is_scalar_bar=True, is_wireframe=True)
示例8: main
# 需要导入模块: from sfepy.discrete import Problem [as 别名]
# 或者: from sfepy.discrete.Problem import save_state [as 别名]
#.........这里部分代码省略.........
pb.time_update(ebcs=Conditions(bc))
pb.save_regions_as_groups('regions')
#ls = ScipyIterative({'method':'bicgstab','i_max':100,'eps_r':1e-10})
# A = pb.mtx_a
# M = spilu(A,fill_factor = 1)
#conf = Struct(solvers ='ScipyIterative',method='bcgsl', sub_precond=None,
# i_max=1000, eps_r=1e-8)
#pb.set_conf_solvers(conf)
vec = pb.solve()
print nls_status
file.write('TIME TO SOLVE\n')
file.write(str(nls.status.time_stats['solve'])+'\n')
file.write('TIME TO CREATE MATRIX\n')
file.write(str(nls.status.time_stats['matrix'])+'\n')
#out = post_process(out, pb, state, extend=False)
ev = pb.evaluate
out = vec.create_output_dict()
strain = ev('ev_cauchy_strain.3.Omega(u)', mode='el_avg')
stress = ev('ev_cauchy_stress.3.Omega(Mat.D, u)', mode='el_avg',
copy_materials=False)
out['cauchy_strain'] = Struct(name='output_data', mode='cell',
data=strain, dofs=None)
out['cauchy_stress'] = Struct(name='output_data', mode='cell',
data=stress, dofs=None)
# Postprocess the solution.
#out = vec.create_output_dict()
#out = stress_strain(out, pb, vec,lam,mu, extend=True)
#pb.save_state('its2D_interactive.vtk', out=out)
#print 'aqui estoy'
pb.save_state('strain.vtk', out=out)
#pb.save_state('disp.vtk', out=vec)
#print 'ahora estoy aqui'
#out = stress_strain(out, pb, vec, extend=True)
#pb.save_state('out.vtk', out=out)
print nls_status
order = 3
strain_qp = ev('ev_cauchy_strain.%d.Omega(u)' % order, mode='qp')
stress_qp = ev('ev_cauchy_stress.%d.Omega(Mat.D, u)' % order,
mode='qp', copy_materials=False)
file.close()
options_probe=False
if options_probe:
# Probe the solution.
probes, labels = gen_lines(pb)
nls_options = {'eps_a':1e-8,'i_max':1}
ls = ScipyDirect({})
ls2 = ScipyIterative({'method':'bicgstab','i_max':5000,'eps_r':1e-20})
order = 5
sfield = Field.from_args('sym_tensor', nm.float64, (3,), omega,
approx_order=order-1)
stress = FieldVariable('stress', 'parameter', sfield,
primary_var_name='(set-to-None)')
strain = FieldVariable('strain', 'parameter', sfield,
primary_var_name='(set-to-None)')
cfield = Field.from_args('component', nm.float64, 1, omega,
approx_order=order-1)
component = FieldVariable('component', 'parameter', cfield,
primary_var_name='(set-to-None)')
ev = pb.evaluate
order = 2*(order - 1) #2 * (2- 1)
print "before strain_qp"
strain_qp = ev('ev_cauchy_strain.%d.Omega(u)' % order, mode='qp')
stress_qp = ev('ev_cauchy_stress.%d.Omega(Mat.D, u)' % order,
mode='qp', copy_materials=False)
print "before projections"
print stress
project_by_component(strain, strain_qp, component, order,ls2,nls_options)
#print 'strain done'
project_by_component(stress, stress_qp, component, order,ls2,nls_options)
print "after projections"
all_results = []
for ii, probe in enumerate(probes):
fig, results = probe_results2(u, strain, stress, probe, labels[ii])
fig.savefig('test_probe_%d.png' % ii)
all_results.append(results)
for ii, results in enumerate(all_results):
output('probe %d:' % ii)
output.level += 2
for key, res in ordered_iteritems(results):
output(key + ':')
val = res[1]
output(' min: %+.2e, mean: %+.2e, max: %+.2e'
% (val.min(), val.mean(), val.max()))
output.level -= 2