1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """The base objects for the elements.
23 The classes defined in that module are abstract, they defined an element
24 with node, by the class L{ElementWithNode} and an element without node,
25 by the class L{ElementWithoutNode}. Those two classes are the bases shared
26 by all the element definitions.
27 The L{ELEM_CLASS} dictionary, gathering all the element classes, is also created
28 in that module but will be filled in the L{mbdyn.elements} module.
29 """
30 from mbdyn.references import NONE_REF
31 from mbdyn.common import BasicObject, MANAGER
32
33 ELEM_GROUP_LIST = [\
34 "ROTOR",
35 "AUTOMATICSTRUCTURAL",
36 "GRAVITY",
37 "BODY",
38 "JOINT"
39 "BEAM",
40 "PLATE",
41 "FORCE",
42 "ELECTRICBULK",
43 "ELECTRIC",
44 "HYDRAULIC",
45 "BULK",
46 "LOADABLE",
47 "DRIVEN",
48 "EXTERNAL",
49 "AIRPROPERTIES",
50 "AEROMODAL",
51 "AERODYNAMIC",
52 "GENEL",
53 "SOCKETSTREAM_OUTPUT",
54 ]
55
56 ELEM_CLASS = {}
57 for group_key in ELEM_GROUP_LIST:
58 ELEM_CLASS[group_key] = {}
59
60
62 """A common element belongs to a group and has a clas key,
63 specific to that group, that allow to retrieve its class.
64 """
65
71
73 """A function defined by the user
74 when he inherits from an object having
75 MBDyn bindings.
76 """
77 pass
78
80 """The update of the MBDyn object at each time step.
81 Used by the user when he inherits from a Python
82 object having MBDyn bindings.
83 """
84 pass
85
87 """The default property set on an element. This method
88 is only used when writing the MBDyn input file from Python"""
89 pass
90
91
93 """Common class for the objects without node."""
94
98
100 """Not of use here. Those kind of element are not attached to a node
101 (used nevertheless when looping through the objects for setting
102 the nodes label (or index) in the 'Simulation')"""
103 pass
104
106 """Set a MBDyn driver to a constant value.
107 for example::
108
109 set_value(4.)
110
111 will write: C{const, 4.} in the MBDyn input file."""
112 MANAGER.add_argument(self, "value", value, com,
113 "const, %s" % str(value))
114
116 """Directly set the MBDyn driver as string.
117 It must be the right MBDyn syntax, nothing will be done
118 by the package. The drivers are not really supported as
119 this functionality is supposed to be provided by the bindings module
120 and WraptMBDyn."""
121 MANAGER.add_argument(self, "value", arg, com)
122
123
125 """Every element attached to a node."""
126
133
135 """Keep the reference of the node"""
136 self.node = node
137
139 """Set the node label (or index) for the element once its node
140 has received a label for the MBDyn input file"""
141 self.mbdyn_node = self.node.mbdyn_label
142
144 """Set the relative reference frame. From it, the properties will be
145 entered. Once this method called, the default properties are
146 set on the object, with an update of reference frame.
147 This method is usually called just after the object creation, else
148 there is no relative reference frame written for the input file.
149
150 WARNING: If this method is used as last, the object properties
151 are not updated. This is default of the package that needs
152 to be fixed.
153
154 Example::
155
156 ref = ReferenceFrame()
157 ref.set_position(10., 0., 0.)
158
159 node1 = StructuralNode()
160 node1.set_relative_from(ref)
161 node1.set_position(5., 0., 0.)
162
163 node2 = StructuralNode()
164 node2.set_position(5., 0., 0.)
165 node2.set_relative_from(ref)
166
167 Relative to the absolute reference frame, the node 1 will be
168 placed 15m from the origin while the node 2 will be only at 5m.
169 """
170 self.ref = ref
171 self.set_default()
172