Debian Codegraph @

src/Mod/Fem/femexamples/ccx_cantilever_ele_tetra4.py

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