FEM CalculiX 2D mechanical analyses (plane stress, plane strain and axisymmetric) (#12562)

This commit is contained in:
FEA-eng
2024-03-02 18:46:18 +01:00
committed by GitHub
parent 6c8ee59645
commit 7eae061bf1
4 changed files with 92 additions and 3 deletions

View File

@@ -381,6 +381,21 @@ def add_attributes(obj, ccx_prefs):
)
obj.BeamReducedIntegration = True
if not hasattr(obj, "ModelSpace"):
model_space_types = [
"3D",
"plane stress",
"plane strain",
"axisymmetric"
]
obj.addProperty(
"App::PropertyEnumeration",
"ModelSpace",
"Fem",
"Type of model space"
)
obj.ModelSpace = model_space_types
"""
Should there be some equation object for Calculix too?

View File

@@ -109,11 +109,14 @@ def write_femelement_geometry(f, ccxwriter):
f.write(section_geo)
elif "shellthickness_obj" in matgeoset: # shell mesh
shellth_obj = matgeoset["shellthickness_obj"]
section_def = "*SHELL SECTION, {}{}\n".format(elsetdef, material)
if ccxwriter.solver_obj.ModelSpace == "3D":
section_def = "*SHELL SECTION, {}{}\n".format(elsetdef, material)
else:
section_def = "*SOLID SECTION, {}{}\n".format(elsetdef, material)
thickness = shellth_obj.Thickness.getValueAs("mm").Value
section_geo = "{:.13G}\n".format(thickness)
f.write(section_def)
f.write(section_geo)
f.write(section_geo)
else: # solid mesh
section_def = "*SOLID SECTION, {}{}\n".format(elsetdef, material)
f.write(section_def)

View File

@@ -54,7 +54,15 @@ def write_mesh(ccxwriter):
# Use reduced integration beam elements if this option is enabled in ccx solver settings
if ccxwriter.solver_obj.BeamReducedIntegration:
meshtools.beam_reduced_integration(ccxwriter.femmesh_file)
# Use 2D elements if model space is not set to 3D
if ccxwriter.solver_obj.ModelSpace == "plane stress":
meshtools.plane_stress(ccxwriter.femmesh_file)
if ccxwriter.solver_obj.ModelSpace == "plane strain":
meshtools.plane_strain(ccxwriter.femmesh_file)
if ccxwriter.solver_obj.ModelSpace == "axisymmetric":
meshtools.axisymmetric(ccxwriter.femmesh_file)
inpfile = codecs.open(ccxwriter.file_name, "w", encoding="utf-8")
inpfile.write("{}\n".format(59 * "*"))
inpfile.write("** {}\n".format(write_name))
@@ -77,6 +85,14 @@ def write_mesh(ccxwriter):
if ccxwriter.solver_obj.BeamReducedIntegration:
meshtools.beam_reduced_integration(ccxwriter.femmesh_file)
# Use 2D elements if model space is not set to 3D
if ccxwriter.solver_obj.ModelSpace == "plane stress":
meshtools.plane_stress(ccxwriter.femmesh_file)
if ccxwriter.solver_obj.ModelSpace == "plane strain":
meshtools.plane_strain(ccxwriter.femmesh_file)
if ccxwriter.solver_obj.ModelSpace == "axisymmetric":
meshtools.axisymmetric(ccxwriter.femmesh_file)
# reopen file with "append" to add all the rest
inpfile = codecs.open(ccxwriter.femmesh_file, "a", encoding="utf-8")
inpfile.write("\n\n")