FEM: constraint tie, add example
This commit is contained in:
@@ -39,6 +39,7 @@ SET(FemExamples_SRCS
|
||||
femexamples/ccx_cantilever_std.py
|
||||
femexamples/constraint_contact_shell_shell.py
|
||||
femexamples/constraint_contact_solid_solid.py
|
||||
femexamples/constraint_tie.py
|
||||
femexamples/manager.py
|
||||
femexamples/material_multiple_twoboxes.py
|
||||
femexamples/material_nl_platewithhole.py
|
||||
@@ -53,6 +54,7 @@ SET(FemExampleMeshes_SRCS
|
||||
femexamples/meshes/mesh_boxanalysis_tetra10.py
|
||||
femexamples/meshes/mesh_boxes_2_vertikal_tetra10.py
|
||||
femexamples/meshes/mesh_canticcx_tetra10.py
|
||||
femexamples/meshes/mesh_constraint_tie_tetra10.py
|
||||
femexamples/meshes/mesh_contact_box_halfcylinder_tetra10.py
|
||||
femexamples/meshes/mesh_contact_tube_tube_tria3.py
|
||||
femexamples/meshes/mesh_rc_wall_2d_tria6.py
|
||||
|
||||
160
src/Mod/Fem/femexamples/constraint_tie.py
Normal file
160
src/Mod/Fem/femexamples/constraint_tie.py
Normal file
@@ -0,0 +1,160 @@
|
||||
# ***************************************************************************
|
||||
# * Copyright (c) 2020 Bernd Hahnebach <bernd@bimstatik.org> *
|
||||
# * *
|
||||
# * 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. *
|
||||
# * *
|
||||
# * FreeCAD 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 FreeCAD; if not, write to the Free Software *
|
||||
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
|
||||
# connstraint tie, bond tow surfaces together (solid mesh only)
|
||||
# https://forum.freecadweb.org/viewtopic.php?f=18&t=42783
|
||||
# to run the example use:
|
||||
"""
|
||||
from femexamples.constraint_tie import setup
|
||||
setup()
|
||||
|
||||
"""
|
||||
|
||||
|
||||
import FreeCAD
|
||||
import ObjectsFem
|
||||
import Fem
|
||||
import Part
|
||||
import BOPTools.SplitFeatures
|
||||
from FreeCAD import Vector
|
||||
|
||||
|
||||
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 setup(doc=None, solvertype="ccxtools"):
|
||||
# setup model
|
||||
|
||||
if doc is None:
|
||||
doc = init_doc()
|
||||
|
||||
# parts
|
||||
# cones cut
|
||||
cone_outer_sh = Part.makeCone(1100, 1235, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359)
|
||||
cone_inner_sh = Part.makeCone(1050, 1185, 1005, Vector(0, 0, 0), Vector(0, 0, 1), 359)
|
||||
cone_cut_sh = cone_outer_sh.cut(cone_inner_sh)
|
||||
cone_cut_obj = doc.addObject("Part::Feature", "Cone_Cut")
|
||||
cone_cut_obj.Shape = cone_cut_sh
|
||||
|
||||
# lines
|
||||
line_fix_sh = Part.Edge(Part.LineSegment(Vector(0, -1235, 1005), Vector(0, -1185, 1005)))
|
||||
line_fix_obj = doc.addObject("Part::Feature", "Line_Fix")
|
||||
line_fix_obj.Shape = line_fix_sh
|
||||
line_force_sh = Part.Edge(Part.LineSegment(Vector(0, 1185, 1005), Vector(0, 1235, 1005)))
|
||||
line_force_obj = doc.addObject("Part::Feature", "Line_Force")
|
||||
line_force_obj.Shape = line_force_sh
|
||||
|
||||
geom_all_obj = BOPTools.SplitFeatures.makeBooleanFragments(name='BooleanFragments')
|
||||
geom_all_obj.Objects = [cone_cut_obj, line_fix_obj, line_force_obj]
|
||||
if FreeCAD.GuiUp:
|
||||
cone_cut_obj.ViewObject.hide()
|
||||
line_fix_obj.ViewObject.hide()
|
||||
line_force_obj.ViewObject.hide()
|
||||
|
||||
doc.recompute()
|
||||
|
||||
if FreeCAD.GuiUp:
|
||||
import FreeCADGui
|
||||
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
|
||||
FreeCADGui.SendMsgToActiveView("ViewFit")
|
||||
|
||||
# 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""
|
||||
if solvertype == "calculix" or solvertype == "ccxtools":
|
||||
solver_object.AnalysisType = "static"
|
||||
solver_object.GeometricalNonlinearity = "linear"
|
||||
solver_object.ThermoMechSteadyState = False
|
||||
solver_object.MatrixSolverType = "default"
|
||||
solver_object.IterationsControlParameterTimeUse = False
|
||||
solver_object.SplitInputWriter = False
|
||||
|
||||
# material
|
||||
material_obj = analysis.addObject(
|
||||
ObjectsFem.makeMaterialSolid(doc, "MechanicalMaterial")
|
||||
)[0]
|
||||
mat = material_obj.Material
|
||||
mat["Name"] = "Calculix-Steel"
|
||||
mat["YoungsModulus"] = "210000 MPa"
|
||||
mat["PoissonRatio"] = "0.30"
|
||||
material_obj.Material = mat
|
||||
analysis.addObject(material_obj)
|
||||
|
||||
# constraint fixed
|
||||
con_fixed = analysis.addObject(
|
||||
ObjectsFem.makeConstraintFixed(doc, "ConstraintFixed")
|
||||
)[0]
|
||||
con_fixed.References = [(geom_all_obj, "Edge1")]
|
||||
|
||||
# constraint force
|
||||
con_force = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintForce(doc, name="ConstraintForce")
|
||||
)[0]
|
||||
con_force.References = [(geom_all_obj, "Edge2")]
|
||||
con_force.Force = 10000.0 # 10000 N = 10 kN
|
||||
con_force.Direction = (geom_all_obj, ["Edge2"])
|
||||
con_force.Reversed = False
|
||||
|
||||
# constraint tie
|
||||
con_tie = doc.Analysis.addObject(
|
||||
ObjectsFem.makeConstraintTie(doc, name="ConstraintTie")
|
||||
)[0]
|
||||
con_tie.References = [
|
||||
(geom_all_obj, "Face5"),
|
||||
(geom_all_obj, "Face7"),
|
||||
]
|
||||
con_tie.Tolerance = 25.0
|
||||
|
||||
# mesh
|
||||
from .meshes.mesh_constraint_tie_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(
|
||||
doc.addObject("Fem::FemMeshObject", mesh_name)
|
||||
)[0]
|
||||
femmesh_obj.FemMesh = fem_mesh
|
||||
|
||||
doc.recompute()
|
||||
return doc
|
||||
@@ -35,6 +35,7 @@ doc = run_ccx_cantilevernodeload()
|
||||
doc = run_ccx_cantileverprescribeddisplacement()
|
||||
doc = run_constraint_contact_shell_shell()
|
||||
doc = run_constraint_contact_solid_solid()
|
||||
doc = run_constraint_tie()
|
||||
doc = run_material_nl_platewithhole()
|
||||
doc = run_material_multiple_twoboxes()
|
||||
doc = run_rcwall2d()
|
||||
@@ -205,6 +206,21 @@ def run_constraint_contact_solid_solid(solver=None, base_name=None):
|
||||
return doc
|
||||
|
||||
|
||||
def run_constraint_tie(solver=None, base_name=None):
|
||||
|
||||
from .constraint_tie import setup
|
||||
doc = setup()
|
||||
|
||||
if base_name is None:
|
||||
base_name = "Constraint_Tie"
|
||||
if solver is not None:
|
||||
base_name += "_" + solver
|
||||
run_analysis(doc, base_name)
|
||||
doc.recompute()
|
||||
|
||||
return doc
|
||||
|
||||
|
||||
def run_material_multiple_twoboxes(solver=None, base_name=None):
|
||||
|
||||
from .material_multiple_twoboxes import setup
|
||||
|
||||
18522
src/Mod/Fem/femexamples/meshes/mesh_constraint_tie_tetra10.py
Normal file
18522
src/Mod/Fem/femexamples/meshes/mesh_constraint_tie_tetra10.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user