本文整理汇总了Python中solver.Solver.solveFor方法的典型用法代码示例。如果您正苦于以下问题:Python Solver.solveFor方法的具体用法?Python Solver.solveFor怎么用?Python Solver.solveFor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类solver.Solver
的用法示例。
在下文中一共展示了Solver.solveFor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_solve_clicked
# 需要导入模块: from solver import Solver [as 别名]
# 或者: from solver.Solver import solveFor [as 别名]
def on_solve_clicked(self):
""" Solve in domain tab. """
domain = self.domains_dict[str(self.domains.currentItem().text())]
if not (self.mesh is not None and domain.dim == 'FILE'):
if not self.getMesh() and self.mesh is None:
return
dim = self.mesh.topology().dim()
initsize = self.mesh.size(dim)
trans = [self.selectedTransforms.item(i).obj
for i in xrange(self.selectedTransforms.count())]
bcs = self.getBCList()
# create solver and adjust parameters
wTop, wBottom = self.getWeights()
solver = Solver(self.mesh, bcs, trans, deg=self.femDegree.value(),
bcLast=self.useTransformed.isChecked(),
method=str(self.femType.currentText()),
wTop=wTop, wBottom=wBottom)
solver.refineTo(int(self.meshSize.text()),
self.meshLimit.currentText() == 'at most',
self.refine.currentText() == 'long edge')
if self.solveType.currentIndex() == 0:
solver.solveFor(self.solveNumber.value(), None, False)
else:
solver.solveFor(self.solveNumber.value(),
float(self.targetValue.text()), False)
# get ready for pickling
solver.removeMesh()
longcalc = LongCalculation(solver, [], pickle_solutions, "Solving")
code = longcalc.exec_()
if not code:
# worker failed
longcalc.cleanUp()
self.stats.appendPlainText("Solver failed!\n\n")
return
results = longcalc.res
eigv, eigf = results[:2]
for i in range(len(eigf)):
u = solver.newFunction()
u.vector()[:] = eigf[i]
eigf[i] = u
finalsize = solver.finalsize
sol = SolutionTab(dim)
sol.data = {'geometry': results[2]}
self.fillTabData(sol.data, trans, bcs, str(initsize), str(finalsize),
solver.extraRefine)
sol.formatData()
domain = self.domains.currentItem().text()
self.solutionTabs.addTab(sol, domain)
for i, [e, u] in enumerate(zip(eigv, eigf)):
if abs(e) < 1E-9:
e = 0.0
new = QListWidgetItem(str(i+1)+': '+str(e))
new.eigenvalue = e
new.eigenfunction = u
sol.eigList.addItem(new)
self.tabs.tabBar().setCurrentIndex(4)
self.solutionTabs.tabBar().setCurrentIndex(self.solutionTabs.count()-1)
sol.setFocus(True)
self.stats.appendPlainText("Solutions found.\n\n")