FEM: code formating
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2019 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
|
||||
# * Copyright (c) 2021 Tobias Vaara <t@vaara.se> *
|
||||
# * Copyright (c) 2021 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * 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
|
||||
|
||||
|
||||
@@ -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 = ""
|
||||
|
||||
@@ -396,4 +396,3 @@ class _TaskPanel:
|
||||
|
||||
def select_buckling_analysis(self):
|
||||
self.select_analysis_type("buckling")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user