当前位置: 首页>>代码示例>>Python>>正文


Python Solver.solveFor方法代码示例

本文整理汇总了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")
开发者ID:siudej,项目名称:Eigenvalues,代码行数:61,代码来源:eigenvalues.py


注:本文中的solver.Solver.solveFor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。