Package mbdyn :: Package elts :: Module beam
[hide private]

Source Code for Module mbdyn.elts.beam

  1  #!/usr/bin/env python 
  2  # -*- coding: utf-8 -*- 
  3  # 
  4  # This file is part of MBDyn sim suite. 
  5  # Copyright (C) 2007 André ESPAZE, as part of a Master thesis supervised by 
  6  # Martin O.L.Hansen (DTU) and Nicolas Chauvat (Logilab) 
  7   
  8  # MBDyn sim suite is free software; you can redistribute it and/or modify 
  9  # it under the terms of the GNU General Public License as published by 
 10  # the Free Software Foundation; either version 2 of the License, or 
 11  # (at your option) any later version. 
 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 General Public License for more details. 
 17  # 
 18  # You should have received a copy of the GNU General Public License 
 19  # along with this program; if not, write to the Free Software 
 20  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 
 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   
35 -class BeamSection:
36 """A section of a beam, used by the L{Beam3} class 37 """ 38
39 - def __init__(self, indice, beam_obj):
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
54 - def set_orientation_matrix(self, *args, **kargs):
55 """Set the orientation matrix of the beam section""" 56 MANAGER.add_orientation_matrix(self.beam, self.name["omatrix"], 57 args, kargs)
58 - def set_relative_from(self, ref):
59 """Set the referential from which coordinates are given""" 60 self.ref = ref
61
62 - def set_constitutive_law(self, law, com=None):
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
69 - def _set_law(self, law, com):
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
85 - def set_indice(self):
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
95 - def __init__(self, name="beam3"):
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 # Offset are set to null by default 114 self.set_offset1(NULL) 115 self.set_offset2(NULL) 116 self.set_offset3(NULL)
117
118 - def set_node1(self, node):
119 """Attach the first node of the beam""" 120 self.node1 = node
121
122 - def set_offset1(self, *args, **kargs):
123 """Set the offset for the first node of the beam""" 124 MANAGER.add_vector(self, "offset1", args, kargs)
125
126 - def set_node2(self, node):
127 """Attach the second node of the beam""" 128 self.node2 = node
129
130 - def set_offset2(self, *args, **kargs):
131 """Set the offset for the second node of the beam""" 132 MANAGER.add_vector(self, "offset2", args, kargs)
133
134 - def set_node3(self, node):
135 """Attach the third node of the beam""" 136 self.node3 = node
137
138 - def set_offset3(self, *args, **kargs):
139 """Set the offset for the third node of the beam""" 140 MANAGER.add_vector(self, "offset3", args, kargs)
141
142 - def attach_to_node(self, node):
143 """Does no make sense for a 3 nodes beam""" 144 print "Use 'set_node1', 'set_node2' and 'set_node3' instead."
145
146 - def set_node_from(self, idx, node):
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
151 - def set_node_indice(self):
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