FEM: examples, add new ccx_cantilever_selfweight exam

This commit is contained in:
Sudhanshu Dubey
2020-07-12 02:25:42 +05:30
committed by Bernd Hahnebach
parent 8ed3060812
commit ca0f9b44d4
3 changed files with 2255 additions and 0 deletions

View File

@@ -51,6 +51,7 @@ SET(FemExamples_SRCS
femexamples/constraint_contact_shell_shell.py
femexamples/constraint_contact_solid_solid.py
femexamples/constraint_section_print.py
femexamples/constraint_selfweight_cantilever.py
femexamples/constraint_tie.py
femexamples/examplesgui.py
femexamples/manager.py
@@ -77,6 +78,7 @@ SET(FemExampleMeshes_SRCS
femexamples/meshes/mesh_multibodybeam_tria6.py
femexamples/meshes/mesh_rc_wall_2d_tria6.py
femexamples/meshes/mesh_section_print_tetra10.py
femexamples/meshes/mesh_selfweight_cantilever_tetra10.py
femexamples/meshes/mesh_platewithhole_tetra10.py
femexamples/meshes/mesh_thermomech_bimetall_tetra10.py
femexamples/meshes/mesh_thermomech_flow1d_seg3.py

View File

@@ -0,0 +1,146 @@
# ***************************************************************************
# * Copyright (c) 2020 Sudhanshu Dubey <sudhanshu.thethunder@gmail.com> *
# * *
# * This file is part of the FreeCAD CAx development system. *
# * *
# * 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 *
# * *
# ***************************************************************************
# to run the example use:
"""
from femexamples.constraint_selfweight_cantilever import setup
setup()
"""
import FreeCAD
import Fem
import ObjectsFem
mesh_name = "Mesh" # needs to be Mesh to work with unit tests
def init_doc(doc=None):
if doc is None:
doc = FreeCAD.newDocument()
return doc
def get_information():
info = {"name": "Constraint Self Weight Cantilever",
"meshtype": "solid",
"meshelement": "Tet10",
"constraints": ["fixed", "self weight"],
"solvers": ["calculix", "elmer"],
"material": "solid",
"equation": "mechanical"
}
return info
def setup(doc=None, solvertype="ccxtools"):
# setup self weight cantilever base model
if doc is None:
doc = init_doc()
# geometry object
# name is important because the other method in this module use obj name
geom_obj = doc.addObject("Part::Box", "Box")
geom_obj.Height = geom_obj.Width = 1000
geom_obj.Length = 32000
doc.recompute()
if FreeCAD.GuiUp:
geom_obj.ViewObject.Document.activeView().viewAxonometric()
geom_obj.ViewObject.Document.activeView().fitAll()
# analysis
analysis = ObjectsFem.makeAnalysis(doc, "Analysis")
# solver
if solvertype == "calculix":
solver_object = analysis.addObject(
ObjectsFem.makeSolverCalculix(doc, "SolverCalculiX")
)[0]
elif solvertype == "ccxtools":
solver_object = analysis.addObject(
ObjectsFem.makeSolverCalculixCcxTools(doc, "CalculiXccxTools")
)[0]
solver_object.WorkingDir = u""
elif solvertype == "elmer":
solver_object = analysis.addObject(
ObjectsFem.makeSolverElmer(doc, "SolverElmer")
)[0]
ObjectsFem.makeEquationElasticity(doc, solver_object)
else:
FreeCAD.Console.PrintWarning(
"Not known or not supported solver type: {}. "
"No solver object was created.\n".format(solvertype)
)
if solvertype == "calculix" or solvertype == "ccxtools":
solver_object.SplitInputWriter = False
solver_object.AnalysisType = "static"
solver_object.GeometricalNonlinearity = "linear"
solver_object.ThermoMechSteadyState = False
solver_object.MatrixSolverType = "default"
solver_object.IterationsControlParameterTimeUse = False
# material
material_object = analysis.addObject(
ObjectsFem.makeMaterialSolid(doc, "FemMaterial")
)[0]
mat = material_object.Material
mat["Name"] = "CalculiX-Steel"
mat["YoungsModulus"] = "210000 MPa"
mat["PoissonRatio"] = "0.30"
mat["Density"] = "7900 kg/m^3"
material_object.Material = mat
# fixed_constraint
fixed_constraint = analysis.addObject(
ObjectsFem.makeConstraintFixed(doc, name="ConstraintFixed")
)[0]
fixed_constraint.References = [(geom_obj, "Face1")]
# selfweight_constraint
selfweight = doc.Analysis.addObject(
ObjectsFem.makeConstraintSelfWeight(doc)
)[0]
selfweight.Gravity_z = -1.00
# mesh
from .meshes.mesh_selfweight_cantilever_tetra10 import create_nodes, create_elements
fem_mesh = Fem.FemMesh()
control = create_nodes(fem_mesh)
if not control:
FreeCAD.Console.PrintError("Error on creating nodes.\n")
control = create_elements(fem_mesh)
if not control:
FreeCAD.Console.PrintError("Error on creating elements.\n")
femmesh_obj = analysis.addObject(
ObjectsFem.makeMeshGmsh(doc, mesh_name)
)[0]
femmesh_obj.FemMesh = fem_mesh
femmesh_obj.Part = geom_obj
femmesh_obj.SecondOrderLinear = False
doc.recompute()
return doc

File diff suppressed because it is too large Load Diff