1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """The elements for the beam group. Until now, until
23 a L{Beam3} has been implemented and is described by a L{BeamSection}.
24 The L{mbdyn.law} module is also in used to set the constitutive law.
25 """
26 from mbdyn.references import NONE_REF
27 from mbdyn.common import MANAGER, get_mbdyn_name
28 from mbdyn.general import NULL
29
30 from mbdyn.elements_base import ElementWithNode
31
32 BEAM_CLASS = {}
33
34
36 """A section of a beam, used by the L{Beam3} class
37 """
38
40 self.indice = indice
41 self.beam = beam_obj
42 self.ref = NONE_REF
43 self.law = None
44 self.mbdyn_law = None
45
46 self.name = {"omatrix": "omatrix_section%i" % indice,
47 "law" : "law_section%i" % indice,
48 "law_value" : "law_value_section%i" % indice}
49
50 self.beam.arg_names += [self.name["omatrix"],
51 self.name["law"],
52 self.name["law_value"]]
53
59 """Set the referential from which coordinates are given"""
60 self.ref = ref
61
63 """Set the constitutive law on the section beam"""
64 if law == "same":
65 self._set_law(self.beam.section1.law, com)
66 else:
67 self._set_law(law, com)
68
70 """Set the constitutive law. Tow possibilities in the input:
71 - an indice needs to be given if the law is written as a block
72 definition in the MBDyn input file
73 - an keyword type and a value need to be given
74 if the constitutive law is defined from scratch for the beam
75 """
76 if law.written_in_a_block:
77 MANAGER.add_argument(self.beam, self.name["law"], law, com)
78 self.beam.arg_names.remove(self.name["law_value"])
79 else:
80 MANAGER.add_argument(self.beam, self.name["law"], law, com,
81 law.mbdyn_type)
82 mbdyn_name = get_mbdyn_name(self.name["law_value"])
83 setattr(self.beam, mbdyn_name, law.mbdyn_stiffness_matrix)
84
86 """Set the reference to the law by a label"""
87 if self.law.written_in_a_block:
88 self.mbdyn_law = self.law.mbdyn_label
89
90
91 -class Beam3(ElementWithNode):
92 """The beam made of 3 nodes.
93 """
94
96 ElementWithNode.__init__(self, name)
97 self.mbdyn_type = "beam"
98 self.class_key = "Beam3"
99 self.group_key = "BEAM"
100 self.arg_names += ["node1", "offset1",
101 "node2", "offset2",
102 "node3", "offset3"]
103 self.section1 = BeamSection(1, self)
104 self.section2 = BeamSection(2, self)
105 self.control_data_with_values = [("beams", "+1 # %s" % name)]
106
107 self.node1 = None
108 self.node2 = None
109 self.node3 = None
110 self.mbdyn_node1 = None
111 self.mbdyn_node2 = None
112 self.mbdyn_node3 = None
113
114 self.set_offset1(NULL)
115 self.set_offset2(NULL)
116 self.set_offset3(NULL)
117
119 """Attach the first node of the beam"""
120 self.node1 = node
121
123 """Set the offset for the first node of the beam"""
124 MANAGER.add_vector(self, "offset1", args, kargs)
125
127 """Attach the second node of the beam"""
128 self.node2 = node
129
131 """Set the offset for the second node of the beam"""
132 MANAGER.add_vector(self, "offset2", args, kargs)
133
135 """Attach the third node of the beam"""
136 self.node3 = node
137
139 """Set the offset for the third node of the beam"""
140 MANAGER.add_vector(self, "offset3", args, kargs)
141
143 """Does no make sense for a 3 nodes beam"""
144 print "Use 'set_node1', 'set_node2' and 'set_node3' instead."
145
147 """Set the node from the index given,
148 the first node has the index 0."""
149 getattr(self, "set_node%i" % (idx + 1))(node)
150
152 """Set the indices for the 3 nodes"""
153 self.mbdyn_node1 = self.node1.mbdyn_label
154 self.mbdyn_node2 = self.node2.mbdyn_label
155 self.mbdyn_node3 = self.node3.mbdyn_label
156
157
158 BEAM_CLASS["Beam3"] = Beam3
159