Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
matvec=lambda v:self.precondWrapper(u, v),
dtype='float64')
Pw = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.precondWrapper(w, v),
dtype='float64')
# solution parameters
max_iter = 100
res_tol = 1.e-7
i = 1
converged = False
# reset precond count for cost tracking
self.precondCount = 0
while i < max_iter:
# solve linearized system
dU, infoU = KrylovSolver(dRudu, -Ru, M=Pu)
dW, infoW = KrylovSolver(dRwdw, -Rw, M=Pw)
# update guess
u += dU
w += dW
# update residual
R = self.getResidual(design, numpy.hstack((u, w)))
[Ru, Rw] = numpy.hsplit(R, 2)
# print iteration information
if self.cout:
print "iter = %i : L2 norm of residual = %e" % \
(i, numpy.linalg.norm(R))
if infoU != 0:
print "MDO_IDF.nonlinearSolve() >> GMRES for U failed!"
break
elif infoW != 0:
print "MDO_IDF.nonlinearSolve() >> GMRES for W failed!"
dtype='float64')
Pw = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.precondWrapper(w, v),
dtype='float64')
# solution parameters
max_iter = 100
res_tol = 1.e-7
i = 1
converged = False
# reset precond count for cost tracking
self.precondCount = 0
while i < max_iter:
# solve linearized system
dU, infoU = KrylovSolver(dRudu, -Ru, M=Pu)
dW, infoW = KrylovSolver(dRwdw, -Rw, M=Pw)
# update guess
u += dU
w += dW
# update residual
R = self.getResidual(design, numpy.hstack((u, w)))
[Ru, Rw] = numpy.hsplit(R, 2)
# print iteration information
if self.cout:
print "iter = %i : L2 norm of residual = %e" % \
(i, numpy.linalg.norm(R))
if infoU != 0:
print "MDO_IDF.nonlinearSolve() >> GMRES for U failed!"
break
elif infoW != 0:
print "MDO_IDF.nonlinearSolve() >> GMRES for W failed!"
break
# mat-vec products for the ILU-based preconditioners
PTu = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.transPrecondWrapper(u, v),
dtype='float64')
PTw = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.transPrecondWrapper(w, v),
dtype='float64')
# calculate tolerances
abs_tol = 1.e-7
rel_tol = abs_tol/numpy.linalg.norm(rhs)
# calculate the solution and store them at the specified index
self.precondCount = 0
solU, infoU = KrylovSolver(dRuduT, rhsU, tol=rel_tol, M=PTu)
solW, infoW = KrylovSolver(dRwdwT, rhsW, tol=rel_tol, M=PTw)
result.data = numpy.hstack((solU, solW))
# evaluate FGMRES output for U discipline
convergedU = False
if infoU == 0:
convergedU = True
elif infoU > 0:
print "solve_linearsys() >> FGMRES for U: Failed @ %i iter" % infoU
else:
print "solve_linearsys() >> FGMRES for U: Breakdown!"
# evaluate FGMRES output for W discipline
convergedW = False
if infoW == 0:
convergedW = True
elif infoW > 0:
print "solve_linearsys() >> FGMRES for W: Failed @ %i iter" % infoW
else:
# mat-vec products for the ILU-based preconditioners
Pu = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.precondWrapper(u, v),
dtype='float64')
Pw = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.precondWrapper(w, v),
dtype='float64')
# calculate tolerances
abs_tol = 1.e-7
rel_tol = abs_tol/numpy.linalg.norm(rhs)
# calculate the solution and store them at the specified index
self.precondCount = 0
solU, infoU = KrylovSolver(dRudu, rhsU, tol=rel_tol, M=Pu)
solW, infoW = KrylovSolver(dRwdw, rhsW, tol=rel_tol, M=Pw)
result.data = numpy.hstack((solU, solW))
# evaluate FGMRES output for U discipline
convergedU = False
if infoU == 0:
convergedU = True
elif infoU > 0:
print "solve_linearsys() >> FGMRES for U: Failed @ %i iter" % infoU
else:
print "solve_linearsys() >> FGMRES for U: Breakdown!"
# evaluate FGMRES output for W discipline
convergedW = False
if infoW == 0:
convergedW = True
elif infoW > 0:
print "solve_linearsys() >> FGMRES for W: Failed @ %i iter" % infoW
else:
dtype='float64')
# mat-vec products for the ILU-based preconditioners
Pu = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.precondWrapper(u, v),
dtype='float64')
Pw = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.precondWrapper(w, v),
dtype='float64')
# calculate tolerances
abs_tol = 1.e-7
rel_tol = abs_tol/numpy.linalg.norm(rhs)
# calculate the solution and store them at the specified index
self.precondCount = 0
solU, infoU = KrylovSolver(dRudu, rhsU, tol=rel_tol, M=Pu)
solW, infoW = KrylovSolver(dRwdw, rhsW, tol=rel_tol, M=Pw)
result.data = numpy.hstack((solU, solW))
# evaluate FGMRES output for U discipline
convergedU = False
if infoU == 0:
convergedU = True
elif infoU > 0:
print "solve_linearsys() >> FGMRES for U: Failed @ %i iter" % infoU
else:
print "solve_linearsys() >> FGMRES for U: Breakdown!"
# evaluate FGMRES output for W discipline
convergedW = False
if infoW == 0:
convergedW = True
elif infoW > 0:
print "solve_linearsys() >> FGMRES for W: Failed @ %i iter" % infoW
dtype='float64')
# mat-vec products for the ILU-based preconditioners
PTu = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.transPrecondWrapper(u, v),
dtype='float64')
PTw = LinearOperator(
(self.solver.nState, self.solver.nState),
matvec=lambda v:self.transPrecondWrapper(w, v),
dtype='float64')
# calculate tolerances
abs_tol = 1.e-7
rel_tol = abs_tol/numpy.linalg.norm(rhs)
# calculate the solution and store them at the specified index
self.precondCount = 0
solU, infoU = KrylovSolver(dRuduT, rhsU, tol=rel_tol, M=PTu)
solW, infoW = KrylovSolver(dRwdwT, rhsW, tol=rel_tol, M=PTw)
result.data = numpy.hstack((solU, solW))
# evaluate FGMRES output for U discipline
convergedU = False
if infoU == 0:
convergedU = True
elif infoU > 0:
print "solve_linearsys() >> FGMRES for U: Failed @ %i iter" % infoU
else:
print "solve_linearsys() >> FGMRES for U: Breakdown!"
# evaluate FGMRES output for W discipline
convergedW = False
if infoW == 0:
convergedW = True
elif infoW > 0:
print "solve_linearsys() >> FGMRES for W: Failed @ %i iter" % infoW