From be8d2c46252d20e4bf1cd8faafd20082ed4c8fbc Mon Sep 17 00:00:00 2001 From: Bernd Hahnebach Date: Wed, 9 Jun 2021 08:01:55 +0200 Subject: [PATCH] FEM: code formating --- .../ccx_buckling_flexuralbuckling.py | 47 +++++++++---------- src/Mod/Fem/femsolver/calculix/writer.py | 30 ++++++++++-- .../Fem/femtaskpanels/task_solver_ccxtools.py | 1 - 3 files changed, 46 insertions(+), 32 deletions(-) diff --git a/src/Mod/Fem/femexamples/ccx_buckling_flexuralbuckling.py b/src/Mod/Fem/femexamples/ccx_buckling_flexuralbuckling.py index 825e2b7b1b..0546ddf3f7 100644 --- a/src/Mod/Fem/femexamples/ccx_buckling_flexuralbuckling.py +++ b/src/Mod/Fem/femexamples/ccx_buckling_flexuralbuckling.py @@ -1,7 +1,6 @@ # *************************************************************************** -# * Copyright (c) 2019 Bernd Hahnebach * -# * Copyright (c) 2020 Sudhanshu Dubey * # * Copyright (c) 2021 Tobias Vaara * +# * Copyright (c) 2021 Bernd Hahnebach * # * * # * This file is part of the FreeCAD CAx development system. * # * * @@ -44,23 +43,24 @@ import ObjectsFem mesh_name = "Mesh" # needs to be Mesh to work with unit tests # Example geometry input - -b = 1.5 # Width -h = 8 # Height -l = 1 # Length +example_b = 1.5 # Width +example_h = 8 # Height +example_l = 1 # Length def addbox( - docxx, height, width, length, + docxx, height, width, length, x, y, z, box_name): - box_obj = docxx.addObject('Part::Box', box_name) + box_obj = docxx.addObject("Part::Box", box_name) box_obj.Height = height box_obj.Width = width box_obj.Length = length box_obj.Placement = FreeCAD.Placement( - FreeCAD.Vector(x, y, z), - FreeCAD.Rotation(0, 0, 0)) + FreeCAD.Vector(x, y, z), + FreeCAD.Rotation(0, 0, 0) + ) + return box_obj def init_doc(doc=None): @@ -70,14 +70,15 @@ def init_doc(doc=None): def get_information(): - info = {"name": "Flexural Buckling Analysis", - "meshtype": "solid", - "meshelement": "Hexa8", - "constraints": ["force", "displacement"], - "solvers": ["calculix"], - "material": "solid", - "equation": "mechanical" - } + info = { + "name": "Flexural Buckling Analysis", + "meshtype": "solid", + "meshelement": "Hexa8", + "constraints": ["force", "displacement"], + "solvers": ["calculix"], + "material": "solid", + "equation": "mechanical" + } return info @@ -87,12 +88,8 @@ def setup_base(doc=None, solvertype="ccxtools"): if doc is None: doc = init_doc() - addbox(doc, h, b, l, 0, 0, 0, 'beam') - + geom_obj = addbox(doc, example_h, example_b, example_l, 0, 0, 0, "beam") doc.recompute() - - geom_obj = doc.beam - if FreeCAD.GuiUp: geom_obj.ViewObject.Document.activeView().viewAxonometric() geom_obj.ViewObject.Document.activeView().fitAll() @@ -123,12 +120,11 @@ def setup_base(doc=None, solvertype="ccxtools"): femmesh_obj.FemMesh = fem_mesh femmesh_obj.Part = doc.beam - return doc def setup(doc=None, solvertype="ccxtools"): - #setup + # setup doc = setup_base(doc, solvertype) @@ -174,4 +170,3 @@ def setup(doc=None, solvertype="ccxtools"): doc.recompute() return doc - diff --git a/src/Mod/Fem/femsolver/calculix/writer.py b/src/Mod/Fem/femsolver/calculix/writer.py index cb2fe19cb5..cdce06a55a 100644 --- a/src/Mod/Fem/femsolver/calculix/writer.py +++ b/src/Mod/Fem/femsolver/calculix/writer.py @@ -880,7 +880,11 @@ class FemInputWriterCcx(writerbase.FemInputWriter): def write_constraints_selfweight(self, f): if not self.selfweight_objects: return - if not (self.analysis_type == "static" or self.analysis_type == "thermomech" or self.analysis_type == "buckling"): + if not ( + self.analysis_type == "static" + or self.analysis_type == "thermomech" + or self.analysis_type == "buckling" + ): return # write constraint to file @@ -914,7 +918,11 @@ class FemInputWriterCcx(writerbase.FemInputWriter): def write_constraints_force(self, f, inpfile_split=None): if not self.force_objects: return - if not (self.analysis_type == "static" or self.analysis_type == "thermomech" or self.analysis_type == "buckling"): + if not ( + self.analysis_type == "static" + or self.analysis_type == "thermomech" + or self.analysis_type == "buckling" + ): return # check shape type of reference shape and get node loads @@ -963,7 +971,11 @@ class FemInputWriterCcx(writerbase.FemInputWriter): def write_constraints_pressure(self, f, inpfile_split=None): if not self.pressure_objects: return - if not (self.analysis_type == "static" or self.analysis_type == "thermomech" or self.analysis_type == "buckling"): + if not ( + self.analysis_type == "static" + or self.analysis_type == "thermomech" + or self.analysis_type == "buckling" + ): return # get the faces and face numbers @@ -1176,7 +1188,11 @@ class FemInputWriterCcx(writerbase.FemInputWriter): if self.solver_obj.IterationsThermoMechMaximum: if self.analysis_type == "thermomech": step += ", INC=" + str(self.solver_obj.IterationsThermoMechMaximum) - elif self.analysis_type == "static" or self.analysis_type == "frequency" or self.analysis_type == "buckling": + elif ( + self.analysis_type == "static" + or self.analysis_type == "frequency" + or self.analysis_type == "buckling" + ): # parameter is for thermomechanical analysis only, see ccx manual *STEP pass # write step line @@ -1230,7 +1246,11 @@ class FemInputWriterCcx(writerbase.FemInputWriter): # Set time to 1 and ignore user inputs for steady state self.solver_obj.TimeInitialStep = 1.0 self.solver_obj.TimeEnd = 1.0 - elif self.analysis_type == "static" or self.analysis_type == "frequency" or self.analysis_type == "buckling": + elif ( + self.analysis_type == "static" + or self.analysis_type == "frequency" + or self.analysis_type == "buckling" + ): pass # not supported for static and frequency! # ANALYSIS parameter line analysis_parameter = "" diff --git a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py index 583aacca99..78cf978c9d 100644 --- a/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py +++ b/src/Mod/Fem/femtaskpanels/task_solver_ccxtools.py @@ -396,4 +396,3 @@ class _TaskPanel: def select_buckling_analysis(self): self.select_analysis_type("buckling") -