Debian Codegraph @

src/Mod/Fem/femexamples/ccx_cantilever_ele_hexa20.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 FreeCAD
26
27 import Fem
28
29 from . import manager
30 from .ccx_cantilever_faceload import setup as setup_with_faceload
31 from .manager import get_meshname
32 from .manager import init_doc
33 from .meshes import generate_mesh
34
35
36 def get_information():
37 return {
38 "name": "CCX cantilever hexa20 solid elements",
39 "meshtype": "solid",
40 "meshelement": "Hexa20",
41 "constraints": ["fixed", "force"],
42 "solvers": ["ccxtools", "z88"], # elmer disabled until mesh has groups
43 "material": "solid",
44 "equations": ["mechanical"],
45 }
46
47
48 def get_explanation(header=""):
49 return (
50 header
51 + """
52
53 To run the example from Python console use:
54 from femexamples.ccx_cantilever_ele_hexa20 import setup
55 setup()
56
57
58 See forum topic post:
59 hexa20 elements and face load
60 ...
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 cantilever faceload
77 doc = setup_with_faceload(doc, solvertype)
78 femmesh_obj = doc.getObject(get_meshname())
79
80 # delete explanation object wrongly added with setup faceload
81 if hasattr(doc, "Explanation_Report001"):
82 doc.removeObject("Explanation_Report001")
83 doc.recompute()
84
85 # load the hexa20 mesh
86 from .meshes.mesh_canticcx_hexa20 import create_nodes, create_elements
87
88 fem_mesh = generate_mesh.mesh_from_existing(create_nodes, create_elements)
89 femmesh_obj.FemMesh = fem_mesh
90
91 doc.recompute()
92 return doc