FEM: move the new python FemResult object to FemMechanicalResult object derived from C++ FemResult object
This commit is contained in:
parent
aa49586766
commit
12f53b6098
|
@ -84,6 +84,7 @@ SET(FemScripts_SRCS
|
|||
_FemBeamSection.py
|
||||
_FemConstraintSelfWeight.py
|
||||
_FemMaterialMechanicalNonlinear.py
|
||||
_FemMechanicalResult.py
|
||||
_FemMeshGmsh.py
|
||||
_FemMeshGroup.py
|
||||
_FemMeshRegion.py
|
||||
|
@ -102,6 +103,7 @@ SET(FemScripts_SRCS
|
|||
_ViewProviderFemBeamSection.py
|
||||
_ViewProviderFemConstraintSelfWeight.py
|
||||
_ViewProviderFemMaterialMechanicalNonlinear.py
|
||||
_ViewProviderFemMechanicalResult.py
|
||||
_ViewProviderFemMeshGmsh.py
|
||||
_ViewProviderFemMeshGroup.py
|
||||
_ViewProviderFemMeshRegion.py
|
||||
|
@ -109,7 +111,6 @@ SET(FemScripts_SRCS
|
|||
_ViewProviderFemSolverCalculix.py
|
||||
_ViewProviderFemSolverZ88.py
|
||||
_ViewProviderFemMaterial.py
|
||||
_ViewProviderFemResult.py
|
||||
ccxDatReader.py
|
||||
ccxFrdReader.py
|
||||
convert2TetGen.py
|
||||
|
@ -128,6 +129,7 @@ SET(FemScripts_SRCS
|
|||
FemInputWriterCcx.py
|
||||
FemInputWriterZ88.py
|
||||
FemMaterialMechanicalNonlinear.py
|
||||
FemMechanicalResult.py
|
||||
FemMesh2Mesh.py
|
||||
FemMeshGmsh.py
|
||||
FemMeshGroup.py
|
||||
|
@ -140,7 +142,6 @@ SET(FemScripts_SRCS
|
|||
FemToolsCcx.py
|
||||
FemToolsZ88.py
|
||||
FemMaterial.py
|
||||
FemResult.py
|
||||
FemSelectionObserver.py
|
||||
TestFem.py
|
||||
TaskPanelFemBeamSection.ui
|
||||
|
|
|
@ -36,6 +36,9 @@ INSTALL(
|
|||
_CommandRunSolver.py
|
||||
_CommandControlSolver.py
|
||||
|
||||
FemMechanicalResult.py
|
||||
_FemMechanicalResult.py
|
||||
_ViewProviderFemMechanicalResult.py
|
||||
_CommandShowResult.py
|
||||
_TaskPanelShowResult.py
|
||||
TaskPanelShowResult.ui
|
||||
|
@ -126,8 +129,6 @@ INSTALL(
|
|||
|
||||
# additional imports and exports
|
||||
importVTKResults.py
|
||||
FemResult.py
|
||||
_ViewProviderFemResult.py
|
||||
|
||||
DESTINATION
|
||||
Mod/Fem
|
||||
|
|
43
src/Mod/Fem/FemMechanicalResult.py
Normal file
43
src/Mod/Fem/FemMechanicalResult.py
Normal file
|
@ -0,0 +1,43 @@
|
|||
#***************************************************************************
|
||||
#* *
|
||||
#* Copyright (c) 2016 - Qingfeng Xia <qingfeng.xia()eng.ox.ac.uk> *
|
||||
#* *
|
||||
#* 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__ = "module to make a mechanical FEM result object"
|
||||
__author__ = "Qingfeng Xia, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
## \addtogroup FEM
|
||||
# \brief FreeCAD module to make mechanical result object in FEM workbench
|
||||
# @{
|
||||
|
||||
import FreeCAD
|
||||
import _FemMechanicalResult
|
||||
|
||||
|
||||
def makeFemMechanicalResult(result_obj_name):
|
||||
obj = FreeCAD.ActiveDocument.addObject('Fem::FemResultObjectPython', result_obj_name)
|
||||
_FemMechanicalResult._FemMechanicalResult(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
from _ViewProviderFemMechanicalResult import _ViewProviderFemMechanicalResult
|
||||
_ViewProviderFemMechanicalResult(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
# @}
|
|
@ -20,59 +20,61 @@
|
|||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
__title__ = "DocumentOject Class to hold Fem result"
|
||||
__author__ = "Qingfeng Xia"
|
||||
__title__ = "DocumentOject Class to hold mechanical FEM results"
|
||||
__author__ = "Qingfeng Xia, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
import FreeCAD
|
||||
import Fem
|
||||
## @package FemMechanicalResult
|
||||
# \ingroup FEM
|
||||
# \brief FreeCAD DocumentObject class to hold mechanical results in FEM workbench
|
||||
|
||||
def makeFemResult(result_obj_name):
|
||||
obj= FreeCAD.ActiveDocument.addObject('Fem::FemResultObjectPython', result_obj_name)
|
||||
# detect domain later, CFD or Mechanical later
|
||||
_MechanicalResult(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
from _ViewProviderFemResult import _ViewProviderFemResult
|
||||
_ViewProviderFemResult(obj.ViewObject)
|
||||
return obj
|
||||
|
||||
class _MechanicalResult(object):
|
||||
class _FemMechanicalResult():
|
||||
"""The Fem::_FemMechanicalResult's Proxy python type, add result specific properties
|
||||
"""
|
||||
def __init__(self, obj):
|
||||
self.Type = "MechanicalResult"
|
||||
self.Type = "FemMechanicalResult"
|
||||
self.Object = obj # keep a ref to the DocObj for nonGui usage
|
||||
obj.Proxy = self # link between App::DocumentObject to this object
|
||||
|
||||
# `Time, Stats` should have been defined in base cpp class
|
||||
obj.addProperty("App::PropertyVectorList", "DisplacementVectors", "Fem",
|
||||
"List of displacement vectors", True) # does not show up in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyVectorList", "StressVectors", "Fem",
|
||||
"List of stress vectors", True) # does not show up in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyVectorList", "StrainVectors", "Fem",
|
||||
"List of strain vectors", True) # does not show up in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyFloatList", "DisplacementLengths", "Fem",
|
||||
"List of displacement lengths", True) # readonly in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyFloatList", "StressValues", "Fem",
|
||||
"", True)
|
||||
obj.addProperty("App::PropertyFloatList", "PrincipalMax", "Fem",
|
||||
"", True)
|
||||
obj.addProperty("App::PropertyFloatList", "PrincipalMed", "Fem",
|
||||
"", True)
|
||||
obj.addProperty("App::PropertyFloatList", "PrincipalMin", "Fem",
|
||||
"", True)
|
||||
obj.addProperty("App::PropertyFloatList", "MaxShear", "Fem",
|
||||
"List of Maximum Shear stress values", True)
|
||||
obj.addProperty("App::PropertyFloatList", "UserDefined", "Fem",
|
||||
"User Defined Results", True)
|
||||
# temperature field is needed in the thermal stress analysis
|
||||
obj.addProperty("App::PropertyFloatList", "Temperature", "Fem",
|
||||
"Temperature field", True)
|
||||
# for frequency analysis
|
||||
obj.addProperty("App::PropertyInteger", "Eigenmode", "Fem",
|
||||
"", True)
|
||||
obj.addProperty("App::PropertyFloat", "EigenmodeFrequency", "Fem",
|
||||
"User Defined Results", True)
|
||||
obj.addProperty("App::PropertyString", "ResultType", "Base", "Type of the result", 1) # the 1 set the property to ReadOnly
|
||||
obj.ResultType = str(self.Type)
|
||||
|
||||
############ standard FeutureT methods ##########
|
||||
# `Time, Stats` should have been defined in base cpp class
|
||||
|
||||
# does not show up in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyVectorList", "DisplacementVectors", "Fem", "List of displacement vectors", True)
|
||||
|
||||
# does not show up in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyVectorList", "StressVectors", "Fem", "List of stress vectors", True)
|
||||
|
||||
# does not show up in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyVectorList", "StrainVectors", "Fem", "List of strain vectors", True)
|
||||
|
||||
# readonly in propertyEditor of combiView
|
||||
obj.addProperty("App::PropertyFloatList", "DisplacementLengths", "Fem", "List of displacement lengths", True)
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "StressValues", "Fem", "", True)
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "PrincipalMax", "Fem", "", True)
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "PrincipalMed", "Fem", "", True)
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "PrincipalMin", "Fem", "", True)
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "MaxShear", "Fem", "List of Maximum Shear stress values", True)
|
||||
|
||||
obj.addProperty("App::PropertyFloatList", "UserDefined", "Fem", "User Defined Results", True)
|
||||
|
||||
# temperature field is needed in the thermal stress analysis
|
||||
obj.addProperty("App::PropertyFloatList", "Temperature", "Fem", "Temperature field", True)
|
||||
|
||||
# for frequency analysis
|
||||
obj.addProperty("App::PropertyInteger", "Eigenmode", "Fem", "", True)
|
||||
|
||||
obj.addProperty("App::PropertyFloat", "EigenmodeFrequency", "Fem", "User Defined Results", True)
|
||||
|
||||
# standard FeutureT methods
|
||||
def execute(self, obj):
|
||||
""""this method is executed on object creation and whenever the document is recomputed"
|
||||
update Part or Mesh should NOT lead to recompution of the analysis automatically, time consuming
|
|
@ -20,15 +20,19 @@
|
|||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
__title__ = "ViewProvider for Fem ResultObjectPython"
|
||||
__author__ = "Qingfeng Xia"
|
||||
__title__ = "ViewProvider for FEM mechanical ResultObjectPython"
|
||||
__author__ = "Qingfeng Xia, Bernd Hahnebach"
|
||||
__url__ = "http://www.freecadweb.org"
|
||||
|
||||
## @package _ViewProviderFemMechanicalResult
|
||||
# \ingroup FEM
|
||||
# \brief FreeCAD ViewProvider for mechanical ResultObjectPython in FEM workbench
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import FemGui
|
||||
|
||||
class _ViewProviderFemResult:
|
||||
|
||||
class _ViewProviderFemMechanicalResult:
|
||||
"""A View Provider for the FemResultObject Python dervied FemResult class
|
||||
"""
|
||||
|
||||
|
@ -48,7 +52,7 @@ class _ViewProviderFemResult:
|
|||
|
||||
def onChanged(self, vobj, prop):
|
||||
return
|
||||
|
||||
|
||||
def doubleClicked(self, vobj):
|
||||
if FreeCADGui.activeWorkbench().name() != 'FemWorkbench':
|
||||
FreeCADGui.activateWorkbench("FemWorkbench")
|
||||
|
@ -58,11 +62,11 @@ class _ViewProviderFemResult:
|
|||
else:
|
||||
FreeCAD.Console.PrintError('Active Task Dialog found! Please close this one first!\n')
|
||||
return True
|
||||
|
||||
|
||||
def setEdit(self, vobj, mode):
|
||||
#if FemGui.getActiveAnalysis():
|
||||
from _TaskPanelShowResult import _TaskPanelShowResult
|
||||
taskd = _TaskPanelShowResult()
|
||||
import _TaskPanelShowResult
|
||||
taskd = _TaskPanelShowResult._TaskPanelShowResult(self.Object)
|
||||
taskd.obj = vobj.Object
|
||||
FreeCADGui.Control.showDialog(taskd)
|
||||
return True
|
|
@ -443,9 +443,8 @@ def importFrd(filename, analysis=None, result_name_prefix=None):
|
|||
results_name = result_name_prefix + 'time_' + str(step_time) + '_results'
|
||||
else:
|
||||
results_name = result_name_prefix + 'results'
|
||||
import FemResult
|
||||
results = FemResult.makeFemResult(results_name)
|
||||
#results = FreeCAD.ActiveDocument.addObject('Fem::FemResultObject', results_name)
|
||||
import FemMechanicalResult
|
||||
results = FemMechanicalResult.makeFemMechanicalResult(results_name)
|
||||
for m in analysis_object.Member:
|
||||
if m.isDerivedFrom("Fem::FemMeshObject"):
|
||||
results.Mesh = m
|
||||
|
|
|
@ -67,8 +67,8 @@ def importVTK(filename, analysis=None, result_name_prefix=None):
|
|||
|
||||
# if properties can be added in FemVTKTools importCfdResult(), this file can be used for CFD workbench
|
||||
results_name = result_name_prefix + 'results'
|
||||
from FemResult import makeFemResult
|
||||
result_obj = makeFemResult(results_name)
|
||||
from FemMechanicalResult import makeFemMechanicalResult
|
||||
result_obj = makeFemMechanicalResult(results_name)
|
||||
# result_obj = FreeCAD.ActiveDocument.addObject('Fem::FemResultObject', results_name)
|
||||
Fem.readResult(filename, result_obj.Name) # readResult always creates a new femmesh named ResultMesh
|
||||
analysis_object.Member = analysis_object.Member + [result_obj]
|
||||
|
|
|
@ -71,8 +71,8 @@ def import_z88_disp(filename, analysis=None, result_name_prefix=None):
|
|||
|
||||
for result_set in m['Results']:
|
||||
results_name = result_name_prefix + 'results'
|
||||
import FemResult
|
||||
results = FemResult.makeFemResult(results_name)
|
||||
import FemMechanicalResult
|
||||
results = FemMechanicalResult.makeFemMechanicalResult(results_name)
|
||||
#results = FreeCAD.ActiveDocument.addObject('Fem::FemResultObject', results_name)
|
||||
for m in analysis_object.Member:
|
||||
if m.isDerivedFrom("Fem::FemMeshObject"):
|
||||
|
@ -97,7 +97,7 @@ def import_z88_disp(filename, analysis=None, result_name_prefix=None):
|
|||
|
||||
# set stats of not imported values to 0
|
||||
s_max = s_min = s_avg = 0
|
||||
p1_min = p1_avg = p1_max = p2_min = p2_avg = p2_max = p3_min = p3_avg = p3_max = 0
|
||||
p1_min = p1_avg = p1_max = p2_min = p2_avg = p2_max = p3_min = p3_avg = p3_max = 0
|
||||
ms_min = ms_avg = ms_max = 0
|
||||
# s_max = max(results.StressValues)
|
||||
# s_min = min(results.StressValues)
|
||||
|
|
Loading…
Reference in New Issue
Block a user