Debian Codegraph @

src/Mod/Fem/femexamples/ccx_cantilever_ele_tria3.py

raw symbols SCIP
1 # ***************************************************************************
2 # * Copyright (c) 2021 Bernd Hahnebach <[email protected]> *
3 # * *
4 # * This file is part of the FreeCAD CAx development system. *
5 # * *
6 # * This program is free software; you can redistribute it and/or modify *
7 # * it under the terms of the GNU Lesser General Public License (LGPL) *
8 # * as published by the Free Software Foundation; either version 2 of *
9 # * the License, or (at your option) any later version. *
10 # * for detail see the LICENCE text file. *
11 # * *
12 # * This program is distributed in the hope that it will be useful, *
13 # * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 # * GNU Library General Public License for more details. *
16 # * *
17 # * You should have received a copy of the GNU Library General Public *
18 # * License along with this program; if not, write to the Free Software *
19 # * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
20 # * USA *
21 # * *
22 # ***************************************************************************
23
24 import FreeCAD
25
26 import Fem
27
28 from . import manager
29 from .ccx_cantilever_base_face import setup_cantilever_base_face
30 from .manager import get_meshname
31 from .manager import init_doc
32 from .meshes import generate_mesh
33
34
35 def get_information():
36 return {
37 "name": "CCX cantilever tria3 face elements",
38 "meshtype": "face",
39 "meshelement": "Tria3",
40 "constraints": ["fixed", "force"],
41 "solvers": ["ccxtools", "mystran"],
42 "material": "solid",
43 "equations": ["mechanical"],
44 }
45
46
47 def get_explanation(header=""):
48 return (
49 header
50 + """
51
52 To run the example from Python console use:
53 from femexamples.ccx_cantilever_ele_tria3 import setup
54 setup()
55
56
57 See forum topic post:
58
59
60 CalculiX cantilever modeled with tria3 face elements
61
62 """
63 )
64
65
66 def setup(doc=None, solvertype="ccxtools"):
67
68 # init FreeCAD document
69 if doc is None:
70 doc = init_doc()
71
72 # explanation object
73 # just keep the following line and change text string in get_explanation method
74 manager.add_explanation_obj(doc, get_explanation(manager.get_header(get_information())))
75
76 # setup CalculiX cantilever
77 doc = setup_cantilever_base_face(doc, solvertype)
78 femmesh_obj = doc.getObject(get_meshname())
79 geom_obj = doc.getObject("CanileverPlate")
80
81 # load the tria3 mesh
82 from .meshes.mesh_canticcx_tria3 import create_nodes, create_elements
83
84 fem_mesh = generate_mesh.mesh_from_existing(create_nodes, create_elements)
85
86 # overwrite mesh with the tria3 mesh
87 femmesh_obj.FemMesh = fem_mesh
88
89 # set mesh obj parameter
90 femmesh_obj.Shape = geom_obj
91 femmesh_obj.SecondOrderLinear = False
92 femmesh_obj.ElementDimension = "2D"
93 femmesh_obj.ElementOrder = "1st"
94 femmesh_obj.CharacteristicLengthMax = "150.0 mm"
95 femmesh_obj.CharacteristicLengthMin = "150.0 mm"
96
97 doc.recompute()
98 return doc