├── DomainSpecificLayout.py ├── DomainSpecificLayout.pyc ├── FEM_Engine.py ├── FEM_Engine.pyc ├── FormulaForm.py ├── FormulaForm.pyc ├── MainApp.py ├── MainApp.pyc ├── MainTemp.py ├── Model ├── Assembler.py ├── Assembler.pyc ├── Boundary_Conditions.py ├── Boundary_Conditions.pyc ├── Builder.py ├── Builder.pyc ├── FiniteElement │ ├── FiniteElement.py │ ├── FiniteElement.pyc │ ├── Shape_Functions.py │ ├── Shape_Functions.pyc │ ├── __init__.py │ └── __init__.pyc ├── Mesh.py ├── Mesh.pyc ├── Solver.py ├── Solver.pyc ├── __init__.py └── __init__.pyc ├── README.md ├── TheoryFinal.pdf ├── VisualizationEngine.py ├── VisualizationEngine.pyc ├── __init__.py └── __init__.pyc /DomainSpecificLayout.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file '/home/poissonbreaker/Escritorio/FEM/UI/MainApp4.3.ui' 4 | # 5 | # Created: Sun Jul 3 13:48:13 2011 6 | # by: PyQt4 UI code generator 4.7.4 7 | # 8 | # WARNING! All changes made in this file will be lost! 9 | 10 | from PyQt4 import QtCore, QtGui 11 | from sympy import sympify 12 | from sympy.simplify import nsimplify 13 | from sympy import lambdify 14 | from sympy import Symbol 15 | from FEM_Engine import Engine as FEM_Eng 16 | 17 | class Layout(QtGui.QWidget): 18 | progress = 0 19 | parent = None 20 | engine = [] 21 | p_x = 0 22 | q_x = 0 23 | f_x = 0 24 | a = 0; b = 0 25 | Nelems = 0 26 | Boundary = [0, 0] 27 | currtab = 2 28 | #input_px = None 29 | #input_qx = None 30 | #input_fx = None 31 | #input_valX0 = None 32 | #input_valXN = None 33 | Wizard = None 34 | # viz_FE_Sol = None 35 | 36 | def __init__(self, parent = None): 37 | # initialization of Qt MainWindow widget 38 | QtGui.QWidget.__init__(self, parent) 39 | self.engine = FEM_Eng() 40 | 41 | def Change_Tab(self): 42 | 43 | if (self.currtab <= 0) : 44 | self.parent.Wizard.setCurrentIndex(2) 45 | self.currtab = 2 46 | if self.progress > 90 : 47 | self.parent.Progress_conf.setProperty("value", 100) 48 | else: 49 | self.currtab -= 1 50 | if self.progress < 90 : 51 | self.progress = self.progress + 33 52 | self.parent.Progress_conf.setProperty("value", self.progress) 53 | if self.progress > 90 : 54 | self.parent.Progress_conf.setProperty("value", 100) 55 | self.parent.Wizard.setCurrentIndex(self.currtab) 56 | 57 | 58 | def CleanAll(self): 59 | self.engine.restart() 60 | self.parent.viz_FE_Sol.canvas.restart() 61 | self.progress = 0 62 | self.parent.Progress_conf.setProperty("value", 0) 63 | 64 | def setParent(self, parent): 65 | self.parent = parent 66 | self.parent.Wizard.setCurrentIndex(2) 67 | self.parent.Progress_conf.setProperty("value", 0) 68 | 69 | def Solve(self): 70 | 71 | self.p_x = sympify(unicode(self.parent.input_px.text()),rational=False) 72 | self.q_x = sympify(unicode(self.parent.input_qx.text())) 73 | self.f_x = sympify(unicode(self.parent.input_fx.text())) 74 | 75 | leftbound = self.parent.input_valX0.text() 76 | self.Boundary[0] = leftbound.toFloat()[0] 77 | 78 | rightbound = self.parent.input_valXN.text() 79 | self.Boundary[1]=rightbound.toFloat()[0] 80 | 81 | self.a = self.parent.input_Domain_L.text().toFloat()[0] 82 | self.b = self.parent.input_Domain_R.text().toFloat()[0] 83 | self.Nelems = self.parent.NofElems_viz.text().toFloat()[0] 84 | 85 | params = {'p_x': self.p_x, 'q_x': self.q_x, 86 | 'f_x':self.f_x, 'a': self.a, 'b': self.b, 87 | 'Nelems': self.Nelems, 'Boundary':self.Boundary} 88 | 89 | self.engine.RetrieveParams(**params) 90 | self.engine.Solve() 91 | [U, MSE] = self.engine.retrieve_Solution() 92 | Grid = self.engine.retrieve_Grid() 93 | self.parent.viz_FE_Sol.canvas.set_FEM_Viz(Grid, U) 94 | 95 | t= Symbol('t') 96 | Exact_sol = sympify(unicode(self.parent.viz_MSE.text()),rational=False) #compile(str(self.parent.viz_MSE.text()),'Exact_sol.py','eval') 97 | 98 | #Exact_sol_lambda = lambdify(Exact_sol, [t])#[] 99 | Exact_u = [] 100 | itr = 0 101 | for x in Grid: 102 | Exact_u.insert(itr,Exact_sol.subs({t:x})) 103 | itr +=1 104 | itr = 0 105 | for x in Grid: 106 | MSE += (Exact_u[itr] - U[itr])**2 107 | itr+=1 108 | 109 | MSE = MSE/len(Grid) 110 | MSE = MSE.evalf() 111 | self.parent.viz_MSE.setText(str(MSE)) 112 | #self.EvaluatedFormula.setText(str(a)) 113 | 114 | -------------------------------------------------------------------------------- /DomainSpecificLayout.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/DomainSpecificLayout.pyc -------------------------------------------------------------------------------- /FEM_Engine.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 27/06/2011 3 | 4 | @author: poissonbreaker 5 | ''' 6 | from Model.Solver import FE_Solver 7 | from Model.Builder import FESpace_Builder 8 | from Model.Assembler import FEMatrix_Assembler 9 | from Model.Boundary_Conditions import BC_Dirichlet_Handler 10 | 11 | # ToolChain 12 | # ____________________________________________________________________________ 13 | # | _________ ___________ ____________ ________ | 14 | # | | | FE[] | | [A,F] | | [A*,F*] | | | 15 | # | | Builder |------->| Assembler |------>| BC_Handler |-------->| Solver | | 16 | # | |_________| |___________| |____________| |________| | 17 | # |_______^_____________________________________________________________|______| 18 | # | ENGINE | 19 | # |Parameters | [u,MSE] 20 | # | | 21 | # _______|_______ _________ _______v________ 22 | # | | / \ | | 23 | # | Configuration |================|| APP ||================| Visualization | 24 | # |_______________| \_________/ |________________| 25 | # | 26 | # | [x,u] 27 | # _______v________ 28 | # | | 29 | # | Visualization | 30 | # | Engine | 31 | # |________________| 32 | 33 | 34 | class Engine(): 35 | 36 | params = {'p_x':0,'q_x':0,'f_x':0,'a':0,'b':0, 'Nelems':0, 'Boundary':0} 37 | FE = [] 38 | A = []; A_bc = [] 39 | F = []; F_bc = [] 40 | u = []; MSE = 0 41 | 42 | FE_Builder = None 43 | FE_Assembler = None 44 | FE_BC_Handler = None 45 | FE_Solver = None 46 | 47 | def __init__(self): 48 | self.FE_Builder = FESpace_Builder() 49 | self.FE_Assembler = FEMatrix_Assembler() 50 | self.FE_BC_Dirichlet_Handler = BC_Dirichlet_Handler() 51 | self.FE_Solver = FE_Solver() 52 | 53 | def RetrieveParams(self,**AppParams): 54 | self.params['p_x'] = AppParams['p_x'] 55 | self.params['q_x'] = AppParams['q_x'] 56 | self.params['f_x'] = AppParams['f_x'] 57 | self.params['a'] = AppParams['a'] 58 | self.params['b'] = AppParams['b'] 59 | self.params['Nelems'] = AppParams['Nelems'] 60 | self.params['Boundary']= AppParams['Boundary'] 61 | 62 | def Solve(self): 63 | 64 | #________________________________________________ 65 | # Building the FE space with the given parameters 66 | self.FE_Builder.SetParams(**self.params) 67 | self.FE_Builder.BuildSpace() 68 | # Retrieve the Finite Element Space 69 | self.FE = self.FE_Builder.retrieve_FESpace() 70 | #________________________________________________ 71 | # | 72 | # | FE[] 73 | #______________________V_________________________ 74 | # Assembling the Global Stiffness Matrix and F | 75 | #________________________________________________| 76 | self.FE_Assembler.Assemble(self.FE) 77 | # Retrieve A and F. The retrieved system is in general Singular 78 | [self.A, self.F] = self.FE_Assembler.retrieve_System() 79 | #________________________________________________ 80 | # | 81 | # | [A,F] 82 | #______________________V_________________________ 83 | # Applying Dirichlet Boundary Conditions | 84 | #________________________________________________| 85 | self.FE_BC_Dirichlet_Handler.ApplyBoundaryConditions(self.A, self.F, self.params['Boundary']) 86 | 87 | # Retrieve the modified system 88 | [self.A_bc, self.F_bc] = self.FE = self.FE_BC_Dirichlet_Handler.retrieve_System() 89 | #________________________________________________ 90 | # | 91 | # | [A*,F*] 92 | #______________________V_________________________ 93 | # Finally the system of equations is solved for | 94 | #____by the solver given on it parameters _______| 95 | self.FE_Solver.solve(self.A_bc,self.F_bc,'cg') 96 | 97 | # Finally retrieve the solution for the given system 98 | [self.u, self.MSE] = self.FE_Solver.retrieve_U() 99 | #________________________________________________ 100 | # | 101 | # V 102 | 103 | def retrieve_Solution(self): 104 | return [self.u, self.MSE] 105 | 106 | def restart(self): 107 | self.FE_Assembler.restart() 108 | self.FE_Builder.restart() 109 | 110 | def retrieve_Grid(self): 111 | return self.FE_Builder.retrieve_Grid() 112 | -------------------------------------------------------------------------------- /FEM_Engine.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/FEM_Engine.pyc -------------------------------------------------------------------------------- /FormulaForm.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file '/home/poissonbreaker/Escritorio/FEM/UI/FormulaParser.ui' 4 | # 5 | # Created: Sat May 28 20:30:11 2011 6 | # by: PyQt4 UI code generator 4.7.4 7 | # 8 | # WARNING! All changes made in this file will be lost! 9 | 10 | from PyQt4 import QtCore, QtGui 11 | from VisualizationEngine import FE_Viz 12 | from sympy import * 13 | 14 | class Formula_Input_Form(QtGui.QDialog): 15 | f_x = 0 16 | p_x = 0 17 | q_x = 0 18 | def setupUi(self, Frame): 19 | Frame.setObjectName("Frame") 20 | Frame.resize(384, 204) 21 | Frame.setFrameShape(QtGui.QFrame.StyledPanel) 22 | Frame.setFrameShadow(QtGui.QFrame.Raised) 23 | self.gridLayout = QtGui.QGridLayout(Frame) 24 | self.gridLayout.setObjectName("gridLayout") 25 | self.lineEdit = QtGui.QLineEdit(Frame) 26 | self.lineEdit.setObjectName("lineEdit") 27 | self.gridLayout.addWidget(self.lineEdit, 1, 0, 1, 1) 28 | self.EvaluatedFormula = QtGui.QLineEdit(Frame) 29 | self.EvaluatedFormula.setObjectName("EvaluatedFormula") 30 | self.gridLayout.addWidget(self.EvaluatedFormula, 2, 0, 1, 1) 31 | self.Parse_formulas = QtGui.QPushButton(Frame) 32 | self.Parse_formulas.setObjectName("Parse_formulas") 33 | self.gridLayout.addWidget(self.Parse_formulas, 3, 0, 1, 1) 34 | self.mpl = FE_Viz(Frame) 35 | self.mpl.setContextMenuPolicy(QtCore.Qt.DefaultContextMenu) 36 | self.mpl.setObjectName("mpl") 37 | self.gridLayout.addWidget(self.mpl, 0, 0, 1, 1) 38 | self.actionParse = QtGui.QAction(Frame) 39 | self.actionParse.setCheckable(True) 40 | self.actionParse.setObjectName("actionParse") 41 | 42 | self.retranslateUi(Frame) 43 | QtCore.QObject.connect(self.Parse_formulas, QtCore.SIGNAL("clicked()"), self.ParseFormula) 44 | #QtCore.QMetaObject.connectSlotsByName(self) 45 | 46 | def ParseFormula(self): 47 | #formula = compile(str(self.lineEdit.text()),'formula.py','eval') 48 | self.lineEdit.setValidator(QtGui.QDoubleValidator(-999.0, 999.0, 2, self.EvaluatedFormula)) 49 | y = QtCore.QString() 50 | 51 | #print self.EvaluatedFormula.validator() 52 | import PyQt4 53 | 54 | try: 55 | y = self.lineEdit.text() 56 | except ValueError: 57 | pass 58 | QtGui.QMessageBox.warning(self,"Error de entrada", y,"Valor no numérico") 59 | y = y.toFloat()[0] 60 | 61 | x = 5.2 62 | z = x+y 63 | #formula = compile(str(self.lineEdit.text()),'formula.py','eval') 64 | # a = eval(formula) 65 | #self.EvaluatedFormula.setText(str(a)) 66 | self.EvaluatedFormula.setText(str(z)) 67 | self.mpl.canvas.setEquation() 68 | 69 | def retranslateUi(self, Frame): 70 | Frame.setWindowTitle(QtGui.QApplication.translate("Frame", "Frame", None, QtGui.QApplication.UnicodeUTF8)) 71 | self.Parse_formulas.setText(QtGui.QApplication.translate("Frame", "Parse Formula", None, QtGui.QApplication.UnicodeUTF8)) 72 | self.actionParse.setText(QtGui.QApplication.translate("Frame", "Parse", None, QtGui.QApplication.UnicodeUTF8)) 73 | 74 | if __name__ == "__main__": 75 | import sys 76 | app = QtGui.QApplication(sys.argv) 77 | Frame = QtGui.QFrame() 78 | ui = Formula_Input_Form() 79 | ui.setupUi(Frame) 80 | Frame.show() 81 | sys.exit(app.exec_()) 82 | 83 | 84 | -------------------------------------------------------------------------------- /FormulaForm.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/FormulaForm.pyc -------------------------------------------------------------------------------- /MainApp.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file '/home/poissonbreaker/Escritorio/FEM/UI/MainApp4.1.ui' 4 | # 5 | # Created: Mon Jun 27 17:58:25 2011 6 | # by: PyQt4 UI code generator 4.7.4 7 | # 8 | # WARNING! All changes made in this file will be lost! 9 | 10 | from PyQt4 import QtCore, QtGui 11 | from VisualizationEngine import MplWidget 12 | from sympy import * 13 | 14 | class Ui_MainWindow(object): 15 | p_x = 0 16 | q_x = 0 17 | f_x = 0 18 | 19 | def setupUi(self, MainWindow): 20 | MainWindow.setObjectName("MainWindow") 21 | MainWindow.resize(583, 604) 22 | self.centralwidget = QtGui.QWidget(MainWindow) 23 | self.centralwidget.setObjectName("centralwidget") 24 | self.verticalLayout_2 = QtGui.QVBoxLayout(self.centralwidget) 25 | self.verticalLayout_2.setObjectName("verticalLayout_2") 26 | self.tabWidget = QtGui.QTabWidget(self.centralwidget) 27 | self.tabWidget.setObjectName("tabWidget") 28 | self.Visuallization = QtGui.QWidget() 29 | self.Visuallization.setObjectName("Visuallization") 30 | self.Visuallization 31 | self.verticalLayout_3 = QtGui.QVBoxLayout(self.Visuallization) 32 | self.verticalLayout_3.setObjectName("verticalLayout_3") 33 | self.widget_2 = MplWidget(self.Visuallization) 34 | self.widget_2.setObjectName("widget_2") 35 | self.verticalLayout_3.addWidget(self.widget_2) 36 | self.tabWidget.addTab(self.Visuallization, "") 37 | self.Configuration = QtGui.QWidget() 38 | self.Configuration.setObjectName("Configuration") 39 | self.verticalLayout_5 = QtGui.QVBoxLayout(self.Configuration) 40 | self.verticalLayout_5.setObjectName("verticalLayout_5") 41 | self.splitter = QtGui.QSplitter(self.Configuration) 42 | self.splitter.setOrientation(QtCore.Qt.Vertical) 43 | self.splitter.setObjectName("splitter") 44 | self.widget = QtGui.QWidget(self.splitter) 45 | self.widget.setObjectName("widget") 46 | self.verticalLayout_4 = QtGui.QVBoxLayout(self.widget) 47 | self.verticalLayout_4.setObjectName("verticalLayout_4") 48 | self.horizontalLayout_2 = QtGui.QHBoxLayout() 49 | self.horizontalLayout_2.setObjectName("horizontalLayout_2") 50 | self.label_fx = QtGui.QLabel(self.widget) 51 | self.label_fx.setObjectName("label_fx") 52 | self.horizontalLayout_2.addWidget(self.label_fx) 53 | self.f_x_viz = QtGui.QLineEdit(self.widget) 54 | self.f_x_viz.setObjectName("f_x_viz") 55 | self.horizontalLayout_2.addWidget(self.f_x_viz) 56 | self.verticalLayout_4.addLayout(self.horizontalLayout_2) 57 | self.horizontalLayout = QtGui.QHBoxLayout() 58 | self.horizontalLayout.setObjectName("horizontalLayout") 59 | self.label_px = QtGui.QLabel(self.widget) 60 | self.label_px.setObjectName("label_px") 61 | self.horizontalLayout.addWidget(self.label_px) 62 | self.px_viz = QtGui.QLineEdit(self.widget) 63 | self.px_viz.setObjectName("px_viz") 64 | self.horizontalLayout.addWidget(self.px_viz) 65 | self.verticalLayout_4.addLayout(self.horizontalLayout) 66 | self.horizontalLayout_3 = QtGui.QHBoxLayout() 67 | self.horizontalLayout_3.setObjectName("horizontalLayout_3") 68 | self.label_gx = QtGui.QLabel(self.widget) 69 | self.label_gx.setObjectName("label_gx") 70 | self.horizontalLayout_3.addWidget(self.label_gx) 71 | self.gx_viz = QtGui.QLineEdit(self.widget) 72 | self.gx_viz.setObjectName("gx_viz") 73 | self.horizontalLayout_3.addWidget(self.gx_viz) 74 | self.verticalLayout_4.addLayout(self.horizontalLayout_3) 75 | self.solve = QtGui.QPushButton(self.widget) 76 | self.solve.setObjectName("solve") 77 | self.verticalLayout_4.addWidget(self.solve) 78 | self.verticalLayout_5.addWidget(self.splitter) 79 | self.tabWidget.addTab(self.Configuration, "") 80 | self.verticalLayout_2.addWidget(self.tabWidget) 81 | self.label = QtGui.QLabel(self.centralwidget) 82 | self.label.setObjectName("label") 83 | self.verticalLayout_2.addWidget(self.label) 84 | self.MSE = QtGui.QLineEdit(self.centralwidget) 85 | self.MSE.setObjectName("MSE") 86 | self.verticalLayout_2.addWidget(self.MSE) 87 | MainWindow.setCentralWidget(self.centralwidget) 88 | self.statusbar = QtGui.QStatusBar(MainWindow) 89 | self.statusbar.setObjectName("statusbar") 90 | MainWindow.setStatusBar(self.statusbar) 91 | self.actionX = QtGui.QAction(MainWindow) 92 | self.actionX.setCheckable(True) 93 | self.actionX.setObjectName("actionX") 94 | self.actionGetr = QtGui.QAction(MainWindow) 95 | self.actionGetr.setObjectName("actionGetr") 96 | self.retranslateUi(MainWindow) 97 | self.tabWidget.setCurrentIndex(0) 98 | #QtCore.QObject.connect(self.solve, QtCore.SIGNAL("clicked()"), self.Solve) 99 | #QtCore.QMetaObject.connectSlotsByName(MainWindow) 100 | 101 | def Solve(self): 102 | self.p_x = sympify(self.px_viz.text()) 103 | self.q_x = sympify(self.gx_viz.text()) 104 | self.f_x = sympify(self.f_x_viz.text()) 105 | params = {'p_x': self.p_x, 'q_x': self.q_x, 'f_x':self.f_x} 106 | 107 | def retranslateUi(self, MainWindow): 108 | MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) 109 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.Visuallization), QtGui.QApplication.translate("MainWindow", "Visualization", None, QtGui.QApplication.UnicodeUTF8)) 110 | self.label_fx.setText(QtGui.QApplication.translate("MainWindow", "f(x)=", None, QtGui.QApplication.UnicodeUTF8)) 111 | self.label_px.setText(QtGui.QApplication.translate("MainWindow", "p(x)=", None, QtGui.QApplication.UnicodeUTF8)) 112 | self.label_gx.setText(QtGui.QApplication.translate("MainWindow", "g(x)=", None, QtGui.QApplication.UnicodeUTF8)) 113 | self.solve.setText(QtGui.QApplication.translate("MainWindow", "Solve", None, QtGui.QApplication.UnicodeUTF8)) 114 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.Configuration), QtGui.QApplication.translate("MainWindow", "Configuration", None, QtGui.QApplication.UnicodeUTF8)) 115 | self.label.setText(QtGui.QApplication.translate("MainWindow", "MSE", None, QtGui.QApplication.UnicodeUTF8)) 116 | self.actionX.setText(QtGui.QApplication.translate("MainWindow", "x", None, QtGui.QApplication.UnicodeUTF8)) 117 | self.actionGetr.setText(QtGui.QApplication.translate("MainWindow", "Getr", None, QtGui.QApplication.UnicodeUTF8)) 118 | 119 | if __name__ == "__main__": 120 | import sys 121 | app = QtGui.QApplication(sys.argv) 122 | MainWindow = QtGui.QMainWindow() 123 | ui = Ui_MainWindow() 124 | ui.setupUi(MainWindow) 125 | MainWindow.show() 126 | sys.exit(app.exec_()) 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /MainApp.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/MainApp.pyc -------------------------------------------------------------------------------- /MainTemp.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | # Form implementation generated from reading ui file '/home/poissonbreaker/Escritorio/FEM/UI/MainApp4.3.ui' 4 | # 5 | # Created: Sun Jul 3 15:59:27 2011 6 | # by: PyQt4 UI code generator 4.7.4 7 | # 8 | # WARNING! All changes made in this file will be lost! 9 | 10 | from PyQt4 import QtCore, QtGui 11 | from DomainSpecificLayout import Layout 12 | class Ui_MainWindow(object): 13 | def setupUi(self, MainWindow): 14 | MainWindow.setObjectName("MainWindow") 15 | MainWindow.resize(649, 630) 16 | MainWindow.setMinimumSize(QtCore.QSize(649, 630)) 17 | MainWindow.setMaximumSize(QtCore.QSize(649, 630)) 18 | self.centralwidget = Layout(MainWindow) 19 | self.centralwidget.setObjectName("centralwidget") 20 | self.verticalLayout_2 = QtGui.QVBoxLayout(self.centralwidget) 21 | self.verticalLayout_2.setObjectName("verticalLayout_2") 22 | self.tabWidget = QtGui.QTabWidget(self.centralwidget) 23 | self.tabWidget.setObjectName("tabWidget") 24 | self.Visualization = QtGui.QWidget() 25 | self.Visualization.setObjectName("Visualization") 26 | self.verticalLayout_3 = QtGui.QVBoxLayout(self.Visualization) 27 | self.verticalLayout_3.setObjectName("verticalLayout_3") 28 | self.viz_FE_Sol = FE_Viz(self.Visualization) 29 | self.viz_FE_Sol.setObjectName("viz_FE_Sol") 30 | self.verticalLayout_3.addWidget(self.viz_FE_Sol) 31 | self.tabWidget.addTab(self.Visualization, "") 32 | self.Configuration = QtGui.QWidget() 33 | self.Configuration.setObjectName("Configuration") 34 | self.viz_ODE_eq = Eq_Viz(self.Configuration) 35 | self.viz_ODE_eq.setGeometry(QtCore.QRect(9, 9, 591, 141)) 36 | self.viz_ODE_eq.setObjectName("viz_ODE_eq") 37 | self.Wizard = QtGui.QStackedWidget(self.Configuration) 38 | self.Wizard.setGeometry(QtCore.QRect(40, 160, 551, 231)) 39 | self.Wizard.setObjectName("Wizard") 40 | self.Space_Conf = QtGui.QWidget() 41 | self.Space_Conf.setObjectName("Space_Conf") 42 | self.Button_Next_to_Final = QtGui.QCommandLinkButton(self.Space_Conf) 43 | self.Button_Next_to_Final.setGeometry(QtCore.QRect(450, 110, 71, 31)) 44 | self.Button_Next_to_Final.setObjectName("Button_Next_to_Final") 45 | self.Frame_Space_Conf = QtGui.QFrame(self.Space_Conf) 46 | self.Frame_Space_Conf.setGeometry(QtCore.QRect(160, 30, 231, 191)) 47 | self.Frame_Space_Conf.setFrameShape(QtGui.QFrame.StyledPanel) 48 | self.Frame_Space_Conf.setFrameShadow(QtGui.QFrame.Raised) 49 | self.Frame_Space_Conf.setObjectName("Frame_Space_Conf") 50 | self.verticalLayout_7 = QtGui.QVBoxLayout(self.Frame_Space_Conf) 51 | self.verticalLayout_7.setObjectName("verticalLayout_7") 52 | self.toolBox = QtGui.QToolBox(self.Frame_Space_Conf) 53 | self.toolBox.setStyleSheet("\n" 54 | "background-color: rgb(246, 246, 246);") 55 | self.toolBox.setObjectName("toolBox") 56 | self.Domain = QtGui.QWidget() 57 | self.Domain.setGeometry(QtCore.QRect(0, 0, 211, 109)) 58 | self.Domain.setObjectName("Domain") 59 | self.verticalLayout = QtGui.QVBoxLayout(self.Domain) 60 | self.verticalLayout.setObjectName("verticalLayout") 61 | self.Layout_a = QtGui.QHBoxLayout() 62 | self.Layout_a.setObjectName("Layout_a") 63 | spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 64 | self.Layout_a.addItem(spacerItem) 65 | self.label_Domain_L = QtGui.QLabel(self.Domain) 66 | self.label_Domain_L.setMinimumSize(QtCore.QSize(8, 30)) 67 | self.label_Domain_L.setMaximumSize(QtCore.QSize(8, 30)) 68 | self.label_Domain_L.setObjectName("label_Domain_L") 69 | self.Layout_a.addWidget(self.label_Domain_L) 70 | spacerItem1 = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) 71 | self.Layout_a.addItem(spacerItem1) 72 | self.input_Domain_L = QtGui.QLineEdit(self.Domain) 73 | self.input_Domain_L.setMinimumSize(QtCore.QSize(51, 27)) 74 | self.input_Domain_L.setMaximumSize(QtCore.QSize(51, 27)) 75 | self.input_Domain_L.setObjectName("input_Domain_L") 76 | self.Layout_a.addWidget(self.input_Domain_L) 77 | spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 78 | self.Layout_a.addItem(spacerItem2) 79 | self.verticalLayout.addLayout(self.Layout_a) 80 | self.Layout_b = QtGui.QHBoxLayout() 81 | self.Layout_b.setObjectName("Layout_b") 82 | spacerItem3 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 83 | self.Layout_b.addItem(spacerItem3) 84 | self.label_Domain_R = QtGui.QLabel(self.Domain) 85 | self.label_Domain_R.setMinimumSize(QtCore.QSize(9, 33)) 86 | self.label_Domain_R.setMaximumSize(QtCore.QSize(9, 33)) 87 | self.label_Domain_R.setObjectName("label_Domain_R") 88 | self.Layout_b.addWidget(self.label_Domain_R) 89 | spacerItem4 = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) 90 | self.Layout_b.addItem(spacerItem4) 91 | self.input_Domain_R = QtGui.QLineEdit(self.Domain) 92 | self.input_Domain_R.setMinimumSize(QtCore.QSize(51, 27)) 93 | self.input_Domain_R.setMaximumSize(QtCore.QSize(51, 27)) 94 | self.input_Domain_R.setObjectName("input_Domain_R") 95 | self.Layout_b.addWidget(self.input_Domain_R) 96 | spacerItem5 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 97 | self.Layout_b.addItem(spacerItem5) 98 | self.verticalLayout.addLayout(self.Layout_b) 99 | self.toolBox.addItem(self.Domain, "") 100 | self.Boundary = QtGui.QWidget() 101 | self.Boundary.setGeometry(QtCore.QRect(0, 0, 211, 109)) 102 | self.Boundary.setObjectName("Boundary") 103 | self.verticalLayout_5 = QtGui.QVBoxLayout(self.Boundary) 104 | self.verticalLayout_5.setObjectName("verticalLayout_5") 105 | self.Layout_X0 = QtGui.QHBoxLayout() 106 | self.Layout_X0.setObjectName("Layout_X0") 107 | spacerItem6 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 108 | self.Layout_X0.addItem(spacerItem6) 109 | self.label_valX0 = QtGui.QLabel(self.Boundary) 110 | self.label_valX0.setMinimumSize(QtCore.QSize(72, 32)) 111 | self.label_valX0.setMaximumSize(QtCore.QSize(72, 32)) 112 | self.label_valX0.setObjectName("label_valX0") 113 | self.Layout_X0.addWidget(self.label_valX0) 114 | spacerItem7 = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) 115 | self.Layout_X0.addItem(spacerItem7) 116 | self.input_valX0 = QtGui.QLineEdit(self.Boundary) 117 | self.input_valX0.setMinimumSize(QtCore.QSize(51, 27)) 118 | self.input_valX0.setMaximumSize(QtCore.QSize(51, 27)) 119 | self.input_valX0.setObjectName("input_valX0") 120 | self.Layout_X0.addWidget(self.input_valX0) 121 | spacerItem8 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 122 | self.Layout_X0.addItem(spacerItem8) 123 | self.verticalLayout_5.addLayout(self.Layout_X0) 124 | self.Layout_XN = QtGui.QHBoxLayout() 125 | self.Layout_XN.setObjectName("Layout_XN") 126 | spacerItem9 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 127 | self.Layout_XN.addItem(spacerItem9) 128 | self.label_valXN = QtGui.QLabel(self.Boundary) 129 | self.label_valXN.setMinimumSize(QtCore.QSize(73, 31)) 130 | self.label_valXN.setMaximumSize(QtCore.QSize(73, 31)) 131 | self.label_valXN.setObjectName("label_valXN") 132 | self.Layout_XN.addWidget(self.label_valXN) 133 | spacerItem10 = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) 134 | self.Layout_XN.addItem(spacerItem10) 135 | self.input_valXN = QtGui.QLineEdit(self.Boundary) 136 | self.input_valXN.setMinimumSize(QtCore.QSize(51, 27)) 137 | self.input_valXN.setMaximumSize(QtCore.QSize(51, 27)) 138 | self.input_valXN.setObjectName("input_valXN") 139 | self.Layout_XN.addWidget(self.input_valXN) 140 | spacerItem11 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 141 | self.Layout_XN.addItem(spacerItem11) 142 | self.verticalLayout_5.addLayout(self.Layout_XN) 143 | self.toolBox.addItem(self.Boundary, "") 144 | self.verticalLayout_7.addWidget(self.toolBox) 145 | self.Wizard.addWidget(self.Space_Conf) 146 | self.NElems_Conf = QtGui.QWidget() 147 | self.NElems_Conf.setObjectName("NElems_Conf") 148 | self.Button_to_Start = QtGui.QCommandLinkButton(self.NElems_Conf) 149 | self.Button_to_Start.setGeometry(QtCore.QRect(450, 110, 71, 31)) 150 | self.Button_to_Start.setObjectName("Button_to_Start") 151 | self.Frame_NElem_Conf = QtGui.QFrame(self.NElems_Conf) 152 | self.Frame_NElem_Conf.setGeometry(QtCore.QRect(100, 70, 311, 95)) 153 | self.Frame_NElem_Conf.setFrameShape(QtGui.QFrame.StyledPanel) 154 | self.Frame_NElem_Conf.setFrameShadow(QtGui.QFrame.Raised) 155 | self.Frame_NElem_Conf.setObjectName("Frame_NElem_Conf") 156 | self.verticalLayout_8 = QtGui.QVBoxLayout(self.Frame_NElem_Conf) 157 | self.verticalLayout_8.setObjectName("verticalLayout_8") 158 | self.Layout_NElems = QtGui.QHBoxLayout() 159 | self.Layout_NElems.setObjectName("Layout_NElems") 160 | spacerItem12 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 161 | self.Layout_NElems.addItem(spacerItem12) 162 | self.label_NofElems = QtGui.QLabel(self.Frame_NElem_Conf) 163 | self.label_NofElems.setObjectName("label_NofElems") 164 | self.Layout_NElems.addWidget(self.label_NofElems) 165 | spacerItem13 = QtGui.QSpacerItem(1, 1, QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) 166 | self.Layout_NElems.addItem(spacerItem13) 167 | self.NofElems_viz = QtGui.QLineEdit(self.Frame_NElem_Conf) 168 | self.NofElems_viz.setMinimumSize(QtCore.QSize(81, 27)) 169 | self.NofElems_viz.setMaximumSize(QtCore.QSize(81, 27)) 170 | self.NofElems_viz.setObjectName("NofElems_viz") 171 | self.Layout_NElems.addWidget(self.NofElems_viz) 172 | spacerItem14 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) 173 | self.Layout_NElems.addItem(spacerItem14) 174 | spacerItem15 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) 175 | self.Layout_NElems.addItem(spacerItem15) 176 | self.verticalLayout_8.addLayout(self.Layout_NElems) 177 | self.solve = QtGui.QPushButton(self.Frame_NElem_Conf) 178 | self.solve.setObjectName("solve") 179 | self.verticalLayout_8.addWidget(self.solve) 180 | self.Wizard.addWidget(self.NElems_Conf) 181 | self.Functions_Conf = QtGui.QWidget() 182 | self.Functions_Conf.setObjectName("Functions_Conf") 183 | self.Button_Next_to_params = QtGui.QCommandLinkButton(self.Functions_Conf) 184 | self.Button_Next_to_params.setGeometry(QtCore.QRect(450, 110, 71, 31)) 185 | self.Button_Next_to_params.setObjectName("Button_Next_to_params") 186 | self.Frame_Functions_Conf = QtGui.QFrame(self.Functions_Conf) 187 | self.Frame_Functions_Conf.setGeometry(QtCore.QRect(80, 40, 331, 171)) 188 | self.Frame_Functions_Conf.setFrameShape(QtGui.QFrame.StyledPanel) 189 | self.Frame_Functions_Conf.setFrameShadow(QtGui.QFrame.Raised) 190 | self.Frame_Functions_Conf.setObjectName("Frame_Functions_Conf") 191 | self.groupBox = QtGui.QGroupBox(self.Frame_Functions_Conf) 192 | self.groupBox.setGeometry(QtCore.QRect(10, 0, 331, 201)) 193 | self.groupBox.setObjectName("groupBox") 194 | self.splitter = QtGui.QSplitter(self.groupBox) 195 | self.splitter.setGeometry(QtCore.QRect(70, 40, 192, 101)) 196 | self.splitter.setOrientation(QtCore.Qt.Vertical) 197 | self.splitter.setObjectName("splitter") 198 | self.layoutWidget = QtGui.QWidget(self.splitter) 199 | self.layoutWidget.setObjectName("layoutWidget") 200 | self.verticalLayout_4 = QtGui.QVBoxLayout(self.layoutWidget) 201 | self.verticalLayout_4.setObjectName("verticalLayout_4") 202 | self.horizontalLayout_2 = QtGui.QHBoxLayout() 203 | self.horizontalLayout_2.setObjectName("horizontalLayout_2") 204 | self.label_fx = QtGui.QLabel(self.layoutWidget) 205 | self.label_fx.setObjectName("label_fx") 206 | self.horizontalLayout_2.addWidget(self.label_fx) 207 | self.input_fx = QtGui.QLineEdit(self.layoutWidget) 208 | self.input_fx.setObjectName("input_fx") 209 | self.horizontalLayout_2.addWidget(self.input_fx) 210 | self.verticalLayout_4.addLayout(self.horizontalLayout_2) 211 | self.horizontalLayout = QtGui.QHBoxLayout() 212 | self.horizontalLayout.setObjectName("horizontalLayout") 213 | self.label_px = QtGui.QLabel(self.layoutWidget) 214 | self.label_px.setObjectName("label_px") 215 | self.horizontalLayout.addWidget(self.label_px) 216 | self.input_px = QtGui.QLineEdit(self.layoutWidget) 217 | self.input_px.setObjectName("input_px") 218 | self.horizontalLayout.addWidget(self.input_px) 219 | self.verticalLayout_4.addLayout(self.horizontalLayout) 220 | self.horizontalLayout_3 = QtGui.QHBoxLayout() 221 | self.horizontalLayout_3.setObjectName("horizontalLayout_3") 222 | self.label_qx = QtGui.QLabel(self.layoutWidget) 223 | self.label_qx.setObjectName("label_qx") 224 | self.horizontalLayout_3.addWidget(self.label_qx) 225 | self.input_qx = QtGui.QLineEdit(self.layoutWidget) 226 | self.input_qx.setObjectName("input_qx") 227 | self.horizontalLayout_3.addWidget(self.input_qx) 228 | self.verticalLayout_4.addLayout(self.horizontalLayout_3) 229 | self.Wizard.addWidget(self.Functions_Conf) 230 | self.line = QtGui.QFrame(self.Configuration) 231 | self.line.setGeometry(QtCore.QRect(-3, 150, 631, 20)) 232 | self.line.setMinimumSize(QtCore.QSize(631, 20)) 233 | self.line.setFrameShape(QtGui.QFrame.HLine) 234 | self.line.setFrameShadow(QtGui.QFrame.Sunken) 235 | self.line.setObjectName("line") 236 | self.groupBox_3 = QtGui.QGroupBox(self.Configuration) 237 | self.groupBox_3.setGeometry(QtCore.QRect(210, 410, 191, 94)) 238 | self.groupBox_3.setAlignment(QtCore.Qt.AlignCenter) 239 | self.groupBox_3.setFlat(False) 240 | self.groupBox_3.setObjectName("groupBox_3") 241 | self.verticalLayout_6 = QtGui.QVBoxLayout(self.groupBox_3) 242 | self.verticalLayout_6.setObjectName("verticalLayout_6") 243 | self.Progress_conf = QtGui.QProgressBar(self.groupBox_3) 244 | self.Progress_conf.setProperty("value", 24) 245 | self.Progress_conf.setObjectName("Progress_conf") 246 | self.verticalLayout_6.addWidget(self.Progress_conf) 247 | self.Button_restart = QtGui.QPushButton(self.groupBox_3) 248 | self.Button_restart.setObjectName("Button_restart") 249 | self.verticalLayout_6.addWidget(self.Button_restart) 250 | self.line_2 = QtGui.QFrame(self.Configuration) 251 | self.line_2.setGeometry(QtCore.QRect(0, 390, 631, 20)) 252 | self.line_2.setMinimumSize(QtCore.QSize(631, 20)) 253 | self.line_2.setFrameShape(QtGui.QFrame.HLine) 254 | self.line_2.setFrameShadow(QtGui.QFrame.Sunken) 255 | self.line_2.setObjectName("line_2") 256 | self.tabWidget.addTab(self.Configuration, "") 257 | self.verticalLayout_2.addWidget(self.tabWidget) 258 | self.label = QtGui.QLabel(self.centralwidget) 259 | self.label.setObjectName("label") 260 | self.verticalLayout_2.addWidget(self.label) 261 | self.viz_MSE = QtGui.QLineEdit(self.centralwidget) 262 | self.viz_MSE.setObjectName("viz_MSE") 263 | self.verticalLayout_2.addWidget(self.viz_MSE) 264 | MainWindow.setCentralWidget(self.centralwidget) 265 | self.bar_Prog_Conf = QtGui.QStatusBar(MainWindow) 266 | self.bar_Prog_Conf.setObjectName("bar_Prog_Conf") 267 | MainWindow.setStatusBar(self.bar_Prog_Conf) 268 | self.actionX = QtGui.QAction(MainWindow) 269 | self.actionX.setCheckable(True) 270 | self.actionX.setObjectName("actionX") 271 | self.actionGetr = QtGui.QAction(MainWindow) 272 | self.actionGetr.setObjectName("actionGetr") 273 | 274 | self.retranslateUi(MainWindow) 275 | self.tabWidget.setCurrentIndex(1) 276 | self.Wizard.setCurrentIndex(0) 277 | self.toolBox.setCurrentIndex(1) 278 | 279 | self.centralwidget.setParent(self) 280 | 281 | QtCore.QObject.connect(self.Button_Next_to_Final, QtCore.SIGNAL("clicked()"), self.centralwidget.Change_Tab) 282 | QtCore.QObject.connect(self.Button_Next_to_params, QtCore.SIGNAL("clicked()"), self.centralwidget.Change_Tab) 283 | QtCore.QObject.connect(self.Button_to_Start, QtCore.SIGNAL("clicked()"), self.centralwidget.Change_Tab) 284 | QtCore.QObject.connect(self.solve, QtCore.SIGNAL("clicked()"), self.centralwidget.Solve) 285 | QtCore.QObject.connect(self.Button_restart, QtCore.SIGNAL("clicked()"), self.centralwidget.CleanAll) 286 | 287 | QtCore.QMetaObject.connectSlotsByName(MainWindow) 288 | 289 | def retranslateUi(self, MainWindow): 290 | MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) 291 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.Visualization), QtGui.QApplication.translate("MainWindow", "Visualization", None, QtGui.QApplication.UnicodeUTF8)) 292 | self.Button_Next_to_Final.setText(QtGui.QApplication.translate("MainWindow", "Apply", None, QtGui.QApplication.UnicodeUTF8)) 293 | self.label_Domain_L.setText(QtGui.QApplication.translate("MainWindow", "a", None, QtGui.QApplication.UnicodeUTF8)) 294 | self.label_Domain_R.setText(QtGui.QApplication.translate("MainWindow", "b", None, QtGui.QApplication.UnicodeUTF8)) 295 | self.toolBox.setItemText(self.toolBox.indexOf(self.Domain), QtGui.QApplication.translate("MainWindow", "Domain", None, QtGui.QApplication.UnicodeUTF8)) 296 | self.label_valX0.setText(QtGui.QApplication.translate("MainWindow", "\n" 297 | "\n" 300 | "

Value at x0

", None, QtGui.QApplication.UnicodeUTF8)) 301 | self.label_valXN.setText(QtGui.QApplication.translate("MainWindow", "\n" 302 | "\n" 305 | "

Value at xN

", None, QtGui.QApplication.UnicodeUTF8)) 306 | self.toolBox.setItemText(self.toolBox.indexOf(self.Boundary), QtGui.QApplication.translate("MainWindow", "Boundary", None, QtGui.QApplication.UnicodeUTF8)) 307 | self.Button_to_Start.setText(QtGui.QApplication.translate("MainWindow", "Start", None, QtGui.QApplication.UnicodeUTF8)) 308 | self.label_NofElems.setText(QtGui.QApplication.translate("MainWindow", "Number of elements", None, QtGui.QApplication.UnicodeUTF8)) 309 | self.solve.setText(QtGui.QApplication.translate("MainWindow", "Solve", None, QtGui.QApplication.UnicodeUTF8)) 310 | self.Button_Next_to_params.setText(QtGui.QApplication.translate("MainWindow", "Apply", None, QtGui.QApplication.UnicodeUTF8)) 311 | self.groupBox.setTitle(QtGui.QApplication.translate("MainWindow", "Functions ", None, QtGui.QApplication.UnicodeUTF8)) 312 | self.label_fx.setText(QtGui.QApplication.translate("MainWindow", "f(x)=", None, QtGui.QApplication.UnicodeUTF8)) 313 | self.label_px.setText(QtGui.QApplication.translate("MainWindow", "p(x)=", None, QtGui.QApplication.UnicodeUTF8)) 314 | self.label_qx.setText(QtGui.QApplication.translate("MainWindow", "q(x)=", None, QtGui.QApplication.UnicodeUTF8)) 315 | self.groupBox_3.setTitle(QtGui.QApplication.translate("MainWindow", "Configuration Process", None, QtGui.QApplication.UnicodeUTF8)) 316 | self.Button_restart.setText(QtGui.QApplication.translate("MainWindow", "Restart", None, QtGui.QApplication.UnicodeUTF8)) 317 | self.tabWidget.setTabText(self.tabWidget.indexOf(self.Configuration), QtGui.QApplication.translate("MainWindow", "Configuration", None, QtGui.QApplication.UnicodeUTF8)) 318 | self.label.setText(QtGui.QApplication.translate("MainWindow", "MSE", None, QtGui.QApplication.UnicodeUTF8)) 319 | self.actionX.setText(QtGui.QApplication.translate("MainWindow", "x", None, QtGui.QApplication.UnicodeUTF8)) 320 | self.actionGetr.setText(QtGui.QApplication.translate("MainWindow", "Getr", None, QtGui.QApplication.UnicodeUTF8)) 321 | 322 | from VisualizationEngine import Eq_Viz, FE_Viz 323 | 324 | if __name__ == "__main__": 325 | import sys 326 | app = QtGui.QApplication(sys.argv) 327 | MainWindow = QtGui.QMainWindow() 328 | ui = Ui_MainWindow() 329 | ui.setupUi(MainWindow) 330 | MainWindow.show() 331 | sys.exit(app.exec_()) 332 | -------------------------------------------------------------------------------- /Model/Assembler.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 27/06/2011 3 | 4 | @author: poissonbreaker 5 | ''' 6 | from numpy import * 7 | from scipy import linalg 8 | from scipy import sparse 9 | 10 | # This Class should be initialized with the whole FE space 11 | class FEMatrix_Assembler(): 12 | 13 | # Final Stiffness Matrix and Force Vector 14 | A = [] 15 | F = [] 16 | 17 | # Matrix Data 18 | data_A = [] 19 | rows_A = [] 20 | cols_A = [] 21 | 22 | data_F = [] 23 | rows_F = [] 24 | cols_F = [] 25 | 26 | def Assemble(self, FE): 27 | 28 | # Assembling the final A matrix 29 | 30 | for Element in FE: 31 | for i in Element.Aj['data']: 32 | self.data_A.append(i) 33 | for i in Element.Aj['rows']: 34 | for j in Element.Aj['cols']: 35 | self.rows_A.append(i) 36 | self.cols_A.append(j) 37 | 38 | # Retrieve a linked list version of the matrix for a fast modification 39 | # of the terms at the moment of applying boundary conditions. 40 | self.A = sparse.coo_matrix((self.data_A,(self.rows_A,self.cols_A)), dtype=float32).tolil() 41 | 42 | # Assembling the final F vector 43 | 44 | for Element in FE: 45 | for i in Element.Fj['data']: 46 | self.data_F.append(i) 47 | for i in Element.Fj['rows']: 48 | for j in Element.Fj['cols']: 49 | self.rows_F.append(i) 50 | self.cols_F.append(j) 51 | 52 | # Retrieve a linked list version of the matrix for a fast modification 53 | # of the terms at the moment of applying boundary conditions. 54 | self.F = sparse.coo_matrix((self.data_F,(self.rows_F,self.cols_F)),dtype=float32).tolil() 55 | 56 | def restart(self): 57 | self.A = [] 58 | self.F = [] 59 | # Matrix Data 60 | self.data_A = [] 61 | self.rows_A = [] 62 | self.cols_A = [] 63 | 64 | self.data_F = [] 65 | self.rows_F = [] 66 | self.cols_F = [] 67 | 68 | 69 | def retrieve_System(self): 70 | return [self.A, self.F] 71 | -------------------------------------------------------------------------------- /Model/Assembler.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/Assembler.pyc -------------------------------------------------------------------------------- /Model/Boundary_Conditions.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 27/06/2011 3 | 4 | @author: poissonbreaker 5 | ''' 6 | from numpy import * 7 | from scipy import linalg 8 | from scipy import sparse 9 | 10 | # The process of application of Boundary conditions is depicted 11 | # --------------------------------- 12 | # | u[1] = u_0 u[n] = u_n | 13 | # --------------------------------- 14 | # 15 | # A[1][2:n] = 0 F[1] = a11*u_0 16 | # A[n][1:n-1] = 0 F[n] = ann*u_n 17 | # _ _ _ _ _ _ 18 | # | a11 0 ....... 0 | | u1 | | a11*u_0 | 19 | # | a21 a22 ....... 0 | | u2 | | f2 | 20 | # | a31 a32 ....... 0 | | u3 | = | f3 | 21 | # | 0 : . : | | : | | : | 22 | # | : : . a(n-1)n| | : | | : | 23 | # |_ 0 0 ..... ann _| |_un_| |_ann*u_n_| 24 | # 25 | # A[2:n][1] = 0 F[2:n-1]-u_0*A[2:n][1] 26 | # A[1:n-1][n] = 0 -u_n*A[1:n-1][n] 27 | # _ _ _ _ _ _ 28 | # | a11 0 ...... 0 | | u1 | | a11*u_0 | 29 | # | 0 a22 ...... 0 | | u2 | | f2 | 30 | # | 0 a32 ...... 0 | | u3 | = | f3 | 31 | # | : . : | | : | | : | 32 | # | : . 0 | | : | | : | 33 | # |_ 0 0 0 0 ann_| |_un_| |_ann*u_n_| 34 | 35 | class BC_Dirichlet_Handler(): 36 | A = [] 37 | F = [] 38 | Applied = False 39 | 40 | def __init__(self): 41 | pass 42 | 43 | 44 | def ApplyBoundaryConditions(self, A, F, Boundary): 45 | 46 | self.Applied = True 47 | ncols = A.get_shape()[1]; nrows = A.get_shape()[0] 48 | 49 | A[0,1:ncols] = zeros((1,ncols-1)) 50 | A[nrows-1,0:ncols-1] = zeros((1,ncols-1)) 51 | 52 | A11 = A[0,0] 53 | Ann = A[nrows-1,ncols-1] 54 | 55 | F[0,0] = A11*Boundary[0] 56 | F[ncols-1,0] = Ann*Boundary[1] 57 | 58 | Bound_left = Boundary[0]*A[0:nrows,0] 59 | Bound_left[0,0] = 0 60 | Bound_right = Boundary[1]*A[0:nrows,ncols-1] 61 | Bound_right[nrows-1,0]=0 62 | 63 | F = F.tocsc() 64 | Bound_left = Bound_left.tocsc() 65 | Bound_right = Bound_right.tocsc() 66 | 67 | F = F-Bound_right-Bound_left 68 | 69 | for i in range(1,nrows): 70 | A[i,0] = 0 71 | for i in range(1,nrows-1): 72 | A[i,ncols-1] = 0 73 | 74 | self.A = A 75 | self.F = F 76 | 77 | def retrieve_System(self): 78 | if (self.Applied): 79 | return [self.A, self.F] 80 | else: 81 | return -1 82 | 83 | -------------------------------------------------------------------------------- /Model/Boundary_Conditions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/Boundary_Conditions.pyc -------------------------------------------------------------------------------- /Model/Builder.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 27/06/2011 3 | 4 | @author: poissonbreaker 5 | ''' 6 | from numpy import * 7 | from scipy.sparse import linalg 8 | from sympy import * 9 | 10 | from Mesh import Mesh 11 | from FiniteElement.FiniteElement import Finite_Element 12 | from FiniteElement.Shape_Functions import ShapeFunctionsSpace 13 | 14 | class FESpace_Builder(): 15 | 16 | # List of finite Elements to create. 17 | FE = [] 18 | 19 | # p(x), q(x) and f(x) may come from a text input in the user interface 20 | # and it must be sympified. 21 | x = Symbol('x') 22 | p_x = 0 23 | q_x = 0 24 | f_x = 0 25 | 26 | # Data for building the 1-D Mesh --> a: left_bound, b: right_bound 27 | Nelems = 3 28 | a = 1 29 | b = 5 30 | Grid = [] 31 | Boundary = [1,3] 32 | 33 | 34 | def __init__(self): 35 | self.Shape_Funct = ShapeFunctionsSpace() 36 | 37 | def SetParams(self,**params): 38 | self.p_x = params['p_x'] 39 | self.q_x = params['q_x'] 40 | self.f_x = params['f_x'] 41 | self.a = params['a'] 42 | self.b = params['b'] 43 | self.Nelems = params['Nelems'] 44 | 45 | def BuildSpace(self): 46 | # Generating the Mesh 47 | Params = {'Nelems': self.Nelems,'a': self.a,'b': self.b} 48 | mesh = Mesh(**Params) 49 | # Retreiving the mesh ends up with a tuple with the Grid and its iterator 50 | (self.Grid, Grid_itr) = mesh.get_Mesh() 51 | print self.Grid 52 | i = 0 53 | # Generate the elements over the Grid 54 | NodesPerElem = len(self.Shape_Funct.getSF_Names()) 55 | for k in Grid_itr: 56 | Segment_Props = {'k':i,'Interval':self.Grid[k:k+NodesPerElem]} 57 | self.FE.insert(i,Finite_Element(**Segment_Props)) 58 | i=i+1 59 | 60 | # Calculate functionals 61 | for Element in self.FE: 62 | for funct in self.Shape_Funct.getSF_Names(): 63 | Element.Functional(self.Shape_Funct.getFunctional(funct))(Element.interval) 64 | 65 | # For each element assign p(x), q(x) and f(x) 66 | for Element in self.FE: 67 | Element.p_x = self.p_x 68 | Element.q_x = self.q_x 69 | Element.f_x = self.f_x 70 | 71 | # Creating the local symbolic Matrices and evaluating the numerical integrals over the interval 72 | for Element in self.FE: 73 | Element.create_stiff_local_Sym() 74 | Element.create_nodal_forces_local_Sym() 75 | Element.solve_stiff_local() 76 | Element.solve_forces_local() 77 | 78 | def retrieve_FESpace(self): 79 | return self.FE 80 | 81 | def restart(self): 82 | self.FE = [] 83 | 84 | def retrieve_Grid(self): 85 | return self.Grid -------------------------------------------------------------------------------- /Model/Builder.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/Builder.pyc -------------------------------------------------------------------------------- /Model/FiniteElement/FiniteElement.py: -------------------------------------------------------------------------------- 1 | from numpy import * 2 | from scipy import linalg 3 | from scipy import integrate as integral 4 | from scipy import sparse 5 | from sympy import * 6 | import matplotlib.pyplot as plt 7 | 8 | x = Symbol('x') 9 | 10 | # The stiffness Matrix on the interval. 11 | # 12 | # x_j _ _ 13 | # / | v'_(j-1,j) | _ _ 14 | # s | | | | | 15 | # Aj = | p(x) | v'_(j-1/2,j)| | v'_(j-1/2,j) v'_(j-1,j) v'_(j,j) | dx + 16 | # / | | |_ _| 17 | # x_(j-1) |_ v'_(j,j) _| 18 | # 19 | # x_j _ _ 20 | # / | v_(j-1,j) | _ _ 21 | # | | | | | 22 | # | q(x) | v_(j-1/2,j)| | v_(j-1/2,j) v_(j-1,j) v_(j,j) | dx + 23 | # / | | |_ _| 24 | # x_(j-1) |_ v_(j,j) _| 25 | # 26 | # The stiffness matrix is stored in COO format (help matrix_COO), based on 27 | # coordinates and values, is compact and is suitable for the final assemly 28 | # since is possible to summ up repeated values of coordinates as needed 29 | # for the values of the Matrix on th right nodes of each preceding element 30 | # and the next leftmost node (i.e element meet at those points as defined 31 | # on the functionals x_(j-1) =< x =< x_j && x_j =< x =< x_j+1) ) 32 | # ^ ^ 33 | # | | 34 | # -------- 35 | # Finite Element for a 1 dimensional ODE with polimorphic use of shape functions 36 | 37 | class Finite_Element(): 38 | 39 | def __init__(self,**SegmentProps): 40 | 41 | # Interval of the actual element (K) 42 | self.interval = SegmentProps['Interval'] 43 | 44 | #Shape Functions and their derivatives () 45 | self.left_SF = 0; self.dleft_SF = 0 46 | self.right_SF = 0; self.dright_SF = 0 47 | self.middle_SF = 0; self.dmiddle_SF = 0 48 | 49 | #q(x) and p(x) 50 | self.p_x = 0 51 | self.q_x = 0 52 | self.f_x = 0 53 | 54 | # Stiffness Matrix data 55 | self.Aj = {'data':0,'rows':0, 'cols':0} 56 | self.Aj['data'] = zeros((1,9)) 57 | self.Aj['rows'] = SegmentProps['k']*array([2,2,2],dtype=float32) + array([0,1,2],dtype=float32) 58 | self.Aj['cols'] = SegmentProps['k']*array([2,2,2],dtype=float32) + array([0,1,2],dtype=float32) 59 | 60 | # Nodal Forces Vector data 61 | self.Fj = {'data':0,'rows':0, 'cols':0} 62 | self.Fj['data'] = zeros((1,3)) 63 | self.Fj['rows'] = SegmentProps['k']*array([2,2,2],dtype=float32) + array([0,1,2],dtype=float32) 64 | self.Fj['cols'] = [0] 65 | #Local symbolic Stiffness Matrix and Nodal Forces Vector 66 | self.Stiff_loc_Sym = 0 67 | self.Forces_loc_Sym = 0 68 | 69 | def Functional(self,func): 70 | def ActualSF(*args): 71 | print 'The ', func.__name__, 'shape function has been called' 72 | Piecewise_Polinomial = func(*args) 73 | if(func.__name__== 'v_j_left'): 74 | self.left_SF = Piecewise_Polinomial 75 | self.dleft_SF = Piecewise_Polinomial.diff(x) 76 | elif(func.__name__== 'v_j_right'): 77 | self.right_SF = Piecewise_Polinomial 78 | self.dright_SF = Piecewise_Polinomial.diff(x) 79 | elif(func.__name__== 'v_j_middle'): 80 | self.middle_SF = Piecewise_Polinomial 81 | self.dmiddle_SF = Piecewise_Polinomial.diff(x) 82 | return ActualSF 83 | 84 | def SetParams(self,**params): 85 | self.p_x = params['p_x'] 86 | self.q_x = params['q_x'] 87 | self.f_x = params['f_x'] 88 | 89 | def create_stiff_local_Sym(self): 90 | self.StiffLocal_deriv = self.p_x*Matrix([[self.dright_SF], [self.dmiddle_SF], [self.dleft_SF]])*Matrix([[self.dright_SF, self.dmiddle_SF, self.dleft_SF]]) 91 | self.StiffLocal_noderiv = self.q_x*Matrix([[self.right_SF], [self.middle_SF], [self.left_SF]])*Matrix([[self.right_SF, self.middle_SF, self.left_SF]]) 92 | self.Stiff_loc_Sym = self.StiffLocal_deriv + self.StiffLocal_noderiv 93 | 94 | def create_nodal_forces_local_Sym(self): 95 | self.Forces_loc_Sym = self.f_x*Matrix([[self.right_SF], [self.middle_SF], [self.left_SF]]) 96 | 97 | def solve_stiff_local(self): 98 | j = 0 99 | for eq in self.Stiff_loc_Sym: 100 | self.Aj['data'][j]=integral.quad(lambdify(x,eq),self.interval[0],self.interval[2]) 101 | self.Aj['data'][j]=self.Aj['data'][j][0] 102 | j = j+1 103 | def solve_forces_local(self): 104 | j = 0 105 | for eq in self.Forces_loc_Sym: 106 | self.Fj['data'][j]=integral.quad(lambdify(x,eq),self.interval[0],self.interval[2]) 107 | self.Fj['data'][j]=self.Fj['data'][j][0] 108 | j = j+1 109 | -------------------------------------------------------------------------------- /Model/FiniteElement/FiniteElement.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/FiniteElement/FiniteElement.pyc -------------------------------------------------------------------------------- /Model/FiniteElement/Shape_Functions.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 27/06/2011 3 | 4 | @author: poissonbreaker 5 | ''' 6 | from sympy import Symbol 7 | 8 | x = Symbol('x') 9 | class ShapeFunctionsSpace(): 10 | 11 | # Here is created a dictionary which holds the different shape functions in order to call them by name 12 | # Each functional receives as parameter the interval over which the element is placed along the grid. 13 | 14 | def __init__(self): 15 | self.Shape_Functions = {'v_(j,j)': self.v_j_left, 'v_(j-1,j)': self.v_j_right, 'v_(j-1/2,j)': self.v_j_middle} 16 | self.SF_names = self.Shape_Functions.keys() 17 | 18 | def v_j_left(self,K_j): 19 | h_j = K_j[2] - K_j[0] 20 | v_j = 1 + 3*(x - K_j[2])/h_j+2*((x - K_j[2])/h_j)**2 21 | return v_j 22 | 23 | def v_j_right(self,K_j): 24 | h_j = K_j[2] - K_j[0] 25 | v_j =1 - 3*(x - K_j[0])/h_j+2*((x - K_j[0])/h_j)**2 26 | return v_j 27 | 28 | def v_j_middle(self,K_j): 29 | h_j = K_j[2] - K_j[0] 30 | v_j = 1 - 4*((x - K_j[1])/h_j)**2 31 | return v_j 32 | 33 | def getSF_Names(self): 34 | return self.SF_names 35 | 36 | def getFunctional(self,String): 37 | return self.Shape_Functions[String] 38 | -------------------------------------------------------------------------------- /Model/FiniteElement/Shape_Functions.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/FiniteElement/Shape_Functions.pyc -------------------------------------------------------------------------------- /Model/FiniteElement/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/FiniteElement/__init__.py -------------------------------------------------------------------------------- /Model/FiniteElement/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/FiniteElement/__init__.pyc -------------------------------------------------------------------------------- /Model/Mesh.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 27/06/2011 3 | 4 | @author: poissonbreaker 5 | ''' 6 | from numpy import * 7 | from scipy import linalg 8 | from scipy import sparse 9 | 10 | # Class for creating a 1-D Mesh. 11 | class Mesh(): 12 | 13 | #Initialization of the sub-space (Grid) for which we are looking for an 14 | #approximate solution to the 1-D n-order ordinary differencial equation. 15 | #The parameter k in the inicialization is the number of element, the 16 | #currently the elements are numbered as follows: 17 | # 18 | # For N elements 19 | # a b 20 | # |--------|--------|--------|----------------|--------| 21 | # x0 x1-1/2 x1 x2-1/2 ........ xN-1/2 xN 22 | # 23 | # there exist 2N+1 nodes along the grid. X0 and XN correspond 24 | # to the values at boundaries (i.e [a,b], X0 = a, XN = b) 25 | # the iterator over the interval is used as a help function 26 | # to generate the elements over the interval each 2 nodes. 27 | 28 | def __init__(self,**params): 29 | self.Nnodes = 2*params['Nelems']+1 30 | self.grid = linspace(params['a'], params['b'], self.Nnodes, endpoint=True, retstep=False) 31 | self.iterator = arange(0,size(self.grid)-1,2) 32 | def get_Mesh(self): 33 | return (self.grid,self.iterator) 34 | -------------------------------------------------------------------------------- /Model/Mesh.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/Mesh.pyc -------------------------------------------------------------------------------- /Model/Solver.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Created on 27/06/2011 3 | 4 | @author: poissonbreaker 5 | ''' 6 | from numpy import * 7 | from scipy.sparse import linalg 8 | from sympy import * 9 | 10 | class FE_Solver(): 11 | 12 | u = [] 13 | MSE = 0 14 | 15 | def __init__(self): 16 | pass 17 | 18 | def solve(self, A, F,Solver): 19 | # "spsolve" for internal solver 20 | # "cg" for conjugate gradient 21 | A = A.tocsc() 22 | #F = F.toarray() 23 | if (Solver == "spsolve"): 24 | self.u = linalg.spsolve(A.astype(float32),F.astype(float32)) 25 | if (Solver == "cg"): 26 | self.u = linalg.cg(A.toarray(),F.toarray())[0] 27 | 28 | def retrieve_U(self): 29 | return [self.u, self.MSE] 30 | -------------------------------------------------------------------------------- /Model/Solver.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/Solver.pyc -------------------------------------------------------------------------------- /Model/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/__init__.py -------------------------------------------------------------------------------- /Model/__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/Model/__init__.pyc -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PyFEM 2 | 3 | A modular Finite Element Method framework implemented in Python. 4 | -------------------------------------------------------------------------------- /TheoryFinal.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/TheoryFinal.pdf -------------------------------------------------------------------------------- /VisualizationEngine.py: -------------------------------------------------------------------------------- 1 | import sys, os, random 2 | from PyQt4.QtCore import * 3 | from PyQt4.QtGui import * 4 | 5 | import matplotlib 6 | from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 7 | from matplotlib.backends.backend_qt4agg import NavigationToolbar2QTAgg as NavigationToolbar 8 | # Python Qt4 bindings for GUI objects 9 | from PyQt4 import QtGui 10 | # import the Qt4Agg FigureCanvas object, that binds Figure to 11 | # Qt4Agg backend. It also inherits from QWidget 12 | 13 | 14 | # Matplotlib Figure object 15 | from matplotlib.figure import Figure 16 | 17 | class MplCanvas(FigureCanvas): 18 | """Class to represent the FigureCanvas widget""" 19 | def __init__(self): 20 | # setup Matplotlib Figure and Axis 21 | self.fig = Figure() 22 | self.ax = self.fig.add_subplot(111) 23 | # initialization of the canvas 24 | FigureCanvas.__init__(self, self.fig) 25 | # we define the widget as expandable 26 | FigureCanvas.setSizePolicy(self, QtGui.QSizePolicy.Expanding, 27 | QtGui.QSizePolicy.Expanding) 28 | # notify the system of updated policy 29 | FigureCanvas.updateGeometry(self) 30 | 31 | def setEquation(self): 32 | self.fig.subplots_adjust(top=0.85) 33 | # self.ax.text(3, 8, 'boxed italics text in data coords', style='italic', 34 | # bbox={'facecolor':'red', 'alpha':0.5, 'pad':10}) 35 | self.ax.text(-0.8, 1.6, r'$\minus{\frac{d}{dx} \left[p(x)\frac{du}{dx}\right]} + q(x)u = f(x)$', fontsize=40) 36 | # self.ax.text(3, 2, unicode('unicode: Institut f\374r Festk\366rperphysik', 'latin-1')) 37 | # self.ax.text(0.95, 0.01, 'colored text in axes coords', 38 | # verticalalignment='bottom', horizontalalignment='right', 39 | # transform=self.ax.transAxes, 40 | # color='green', fontsize=15) 41 | # self.ax.plot([2], [1], 'o') 42 | # self.ax.annotate('annotate', xy=(2, 1), xytext=(3, 4), 43 | # arrowprops=dict(facecolor='black', shrink=0.05)) 44 | self.ax.axis([0,10,0,5]) 45 | self.ax.set_axis_off() 46 | self.draw() 47 | 48 | def set_FEM_Viz(self, Grid, u): 49 | self.ax.plot(Grid,u,'*') 50 | self.ax.xaxis.set_label_text('$x_j$') 51 | self.ax.yaxis.set_label_text('$u(x)$') 52 | #self.ax.x_label('$x_j$') 53 | #self.ax.title('FE solution for $u(x)$') 54 | self.ax.grid() 55 | self.draw() 56 | 57 | def restart(self): 58 | print "I have been called and I clean everything :)" 59 | self.ax.clear() 60 | self.ax.plot([0], [0], 'o') 61 | self.draw() 62 | 63 | class FE_Viz(QtGui.QWidget): 64 | """Widget defined in Qt Designer""" 65 | def __init__(self, parent = None): 66 | # initialization of Qt MainWindow widget 67 | QtGui.QWidget.__init__(self, parent) 68 | # set the canvas to the Matplotlib widget 69 | self.canvas = MplCanvas() 70 | # create a vertical box layout 71 | self.vbl = QtGui.QVBoxLayout() 72 | # add mpl widget to vertical box 73 | self.vbl.addWidget(self.canvas) 74 | # set the layout to the vertical box 75 | self.setLayout(self.vbl) 76 | 77 | 78 | class Eq_Viz(QtGui.QWidget): 79 | """Widget defined in Qt Designer""" 80 | def __init__(self, parent = None): 81 | # initialization of Qt MainWindow widget 82 | QtGui.QWidget.__init__(self, parent) 83 | # set the canvas to the Matplotlib widget 84 | self.canvas = MplCanvas() 85 | # create a vertical box layout 86 | self.vbl = QtGui.QVBoxLayout() 87 | # add mpl widget to vertical box 88 | self.vbl.addWidget(self.canvas) 89 | # set the layout to the vertical box 90 | self.setLayout(self.vbl) 91 | self.canvas.setEquation() 92 | 93 | class MplWidget(QtGui.QWidget): 94 | def __init__(self, parent = None): 95 | QtGui.QWidget.__init__(self, parent) 96 | self.canvas = MplCanvas() 97 | self.vbl = QtGui.QVBoxLayout() 98 | self.vbl.addWidget(self.canvas) 99 | self.mpl_toolbar = NavigationToolbar(self.canvas, parent) 100 | self.vbl.addWidget(self.mpl_toolbar) 101 | self.setLayout(self.vbl) 102 | def addPlot(self,plot): 103 | x,y = plot.getArrays() 104 | self.canvas.ax.plot(x,y, plot.getStyle(), label=plot.getName(),color=plot.getColor()) 105 | def draw(self): 106 | self.canvas.draw() 107 | self.canvas.ax.legend() 108 | def clearPlots(self): 109 | self.canvas.draw() -------------------------------------------------------------------------------- /VisualizationEngine.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/VisualizationEngine.pyc -------------------------------------------------------------------------------- /__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/__init__.py -------------------------------------------------------------------------------- /__init__.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jdavid1385/pyFEM/bd58d81fede0813e23cba51f03f347b68491cc24/__init__.pyc --------------------------------------------------------------------------------