FEM: solver calculix object, move make def into make objects FEM module

This commit is contained in:
Bernd Hahnebach 2017-02-20 17:54:01 +01:00 committed by wmayer
parent 6ffbac3e6b
commit 4f0f3aa4fa
7 changed files with 18 additions and 53 deletions

View File

@ -133,7 +133,6 @@ SET(FemScripts_SRCS
FemMeshGroup.py FemMeshGroup.py
FemMeshRegion.py FemMeshRegion.py
FemMeshTools.py FemMeshTools.py
FemSolverCalculix.py
FemSolverZ88.py FemSolverZ88.py
FemTools.py FemTools.py
FemToolsCcx.py FemToolsCcx.py

View File

@ -108,7 +108,6 @@ INSTALL(
importCcxFrdResults.py importCcxFrdResults.py
FemInputWriterCcx.py FemInputWriterCcx.py
FemToolsCcx.py FemToolsCcx.py
FemSolverCalculix.py
_FemSolverCalculix.py _FemSolverCalculix.py
_ViewProviderFemSolverCalculix.py _ViewProviderFemSolverCalculix.py
_CommandSolverCalculix.py _CommandSolverCalculix.py

View File

@ -1,43 +0,0 @@
# ***************************************************************************
# * *
# * Copyright (c) 2015 - Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
# * as published by the Free Software Foundation; either version 2 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program is distributed in the hope that it will be useful, *
# * but WITHOUT ANY WARRANTY; without even the implied warranty of *
# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
# * GNU Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
__title__ = "FemSolverCalculix"
__author__ = "Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
## \addtogroup FEM
# @{
import FreeCAD
import _FemSolverCalculix
def makeFemSolverCalculix(name="CalculiX"):
'''makeSolverCalculix(name): makes a Calculix solver object'''
obj = FreeCAD.ActiveDocument.addObject("Fem::FemSolverObjectPython", name)
_FemSolverCalculix._FemSolverCalculix(obj)
if FreeCAD.GuiUp:
import _ViewProviderFemSolverCalculix
_ViewProviderFemSolverCalculix._ViewProviderFemSolverCalculix(obj.ViewObject)
return obj
# @}

View File

@ -37,6 +37,18 @@ def makeAnalysis(name):
return obj return obj
########## solvers ##########
def makeSolverCalculix(name="CalculiX"):
'''makeSolverCalculix(name): makes a Calculix solver object'''
obj = FreeCAD.ActiveDocument.addObject("Fem::FemSolverObjectPython", name)
import _FemSolverCalculix
_FemSolverCalculix._FemSolverCalculix(obj)
if FreeCAD.GuiUp:
import _ViewProviderFemSolverCalculix
_ViewProviderFemSolverCalculix._ViewProviderFemSolverCalculix(obj.ViewObject)
return obj
########## element geometry definitions ########## ########## element geometry definitions ##########
def makeBeamSection(sectiontype='Rectangular', width=10.0, height=25.0, name="BeamSection"): def makeBeamSection(sectiontype='Rectangular', width=10.0, height=25.0, name="BeamSection"):
'''makeBeamSection([width], [height], [name]): creates an beamsection object to define a cross section''' '''makeBeamSection([width], [height], [name]): creates an beamsection object to define a cross section'''

View File

@ -28,7 +28,6 @@ import Fem
import FemToolsCcx import FemToolsCcx
import FreeCAD import FreeCAD
import ObjectsFem import ObjectsFem
import FemSolverCalculix
import FemMaterial import FemMaterial
import csv import csv
import tempfile import tempfile
@ -86,7 +85,7 @@ class FemTest(unittest.TestCase):
self.active_doc.recompute() self.active_doc.recompute()
def create_new_solver(self): def create_new_solver(self):
self.solver_object = FemSolverCalculix.makeFemSolverCalculix('CalculiX') self.solver_object = ObjectsFem.makeSolverCalculix('CalculiX')
self.solver_object.GeometricalNonlinearity = 'linear' self.solver_object.GeometricalNonlinearity = 'linear'
self.solver_object.ThermoMechSteadyState = False self.solver_object.ThermoMechSteadyState = False
self.solver_object.MatrixSolverType = 'default' self.solver_object.MatrixSolverType = 'default'
@ -308,7 +307,7 @@ class TherMechFemTest(unittest.TestCase):
self.active_doc.recompute() self.active_doc.recompute()
def create_new_solver(self): def create_new_solver(self):
self.solver_object = FemSolverCalculix.makeFemSolverCalculix('CalculiX') self.solver_object = ObjectsFem.makeSolverCalculix('CalculiX')
self.solver_object.AnalysisType = 'thermomech' self.solver_object.AnalysisType = 'thermomech'
self.solver_object.GeometricalNonlinearity = 'linear' self.solver_object.GeometricalNonlinearity = 'linear'
self.solver_object.ThermoMechSteadyState = True self.solver_object.ThermoMechSteadyState = True

View File

@ -47,10 +47,9 @@ class _CommandAnalysis(FemCommands):
FreeCAD.ActiveDocument.openTransaction("Create Analysis") FreeCAD.ActiveDocument.openTransaction("Create Analysis")
FreeCADGui.addModule("FemGui") FreeCADGui.addModule("FemGui")
FreeCADGui.addModule("ObjectsFem") FreeCADGui.addModule("ObjectsFem")
FreeCADGui.addModule("FemSolverCalculix")
FreeCADGui.doCommand("ObjectsFem.makeAnalysis('Analysis')") FreeCADGui.doCommand("ObjectsFem.makeAnalysis('Analysis')")
FreeCADGui.doCommand("FemGui.setActiveAnalysis(App.activeDocument().ActiveObject)") FreeCADGui.doCommand("FemGui.setActiveAnalysis(App.activeDocument().ActiveObject)")
FreeCADGui.doCommand("FemSolverCalculix.makeFemSolverCalculix('CalculiX')") FreeCADGui.doCommand("ObjectsFem.makeSolverCalculix('CalculiX')")
FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [App.activeDocument().ActiveObject]") FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [App.activeDocument().ActiveObject]")
sel = FreeCADGui.Selection.getSelection() sel = FreeCADGui.Selection.getSelection()
if (len(sel) == 1): if (len(sel) == 1):

View File

@ -50,13 +50,13 @@ class _CommandSolverCalculix(FemCommands):
if hasattr(m, "Proxy") and m.Proxy.Type == "FemMaterialMechanicalNonlinear": if hasattr(m, "Proxy") and m.Proxy.Type == "FemMaterialMechanicalNonlinear":
has_nonlinear_material_obj = True has_nonlinear_material_obj = True
FreeCAD.ActiveDocument.openTransaction("Create SolverCalculix") FreeCAD.ActiveDocument.openTransaction("Create SolverCalculix")
FreeCADGui.addModule("FemSolverCalculix") FreeCADGui.addModule("ObjectsFem")
if has_nonlinear_material_obj: if has_nonlinear_material_obj:
FreeCADGui.doCommand("solver = FemSolverCalculix.makeFemSolverCalculix()") FreeCADGui.doCommand("solver = ObjectsFem.makeSolverCalculix()")
FreeCADGui.doCommand("solver.MaterialNonlinearity = 'nonlinear'") FreeCADGui.doCommand("solver.MaterialNonlinearity = 'nonlinear'")
FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [solver]") FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [solver]")
else: else:
FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [FemSolverCalculix.makeFemSolverCalculix()]") FreeCADGui.doCommand("FemGui.getActiveAnalysis().Member = FemGui.getActiveAnalysis().Member + [ObjectsFem.makeSolverCalculix()]")
FreeCADGui.addCommand('Fem_SolverCalculix', _CommandSolverCalculix()) FreeCADGui.addCommand('Fem_SolverCalculix', _CommandSolverCalculix())