1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """The general classes for a node, an element and a reference frame.
23 The L{Node<mbdyn.bindings.basic_objects.Node>} class defined here
24 is an equivalent to the general C{Node} class defined in 'I{node.h}' and
25 manipulated by the C{DataManager}. The same remark applied for the
26 L{Element<mbdyn.bindings.basic_objects.Element>} class that is equivalent to
27 the C{Elem} class defined in 'I{elem.h}'. Those two classes
28 are used to defined all the other types of nodes or elements, this is
29 the MBDyn polymorphism. That's why this package follows the same organisation,
30 every node will first be converted to a
31 L{Node<mbdyn.bindings.basic_objects.Node>} or to an
32 L{Element<mbdyn.bindings.basic_objects.Element>} by L{WraptMBDyn}.
33 Then the L{Groups} class will try to access a more specific object.
34
35 However the class C{ReferenceFrame} in L{mbdyn.bindings.frames}
36 does not follow this complexity because a single definition is suffisant.
37 """
38
39
41 """A basic bindings object interfacing a C++ instance."""
42
44 """The C++ instance reference is supposed to be received
45 in the constructor
46 because this object will represent a MBDyn node, element
47 or reference frame"""
48 if c_inst != None:
49 self.c_inst = c_inst
50 self.label = c_inst.GetLabel()
51
53 """Set the C++ instance coming from MBDyn"""
54 self.c_inst = c_inst
55
57 """Return the MBDyn label"""
58 return self.label
59
60
61 -class Node(BasicObject):
62 """The top class of a node. This class is motivated by 'I{node.h}'
63 in MBDyn and 'I{node.i} in the SWIG interface."""
64
66 mess = "Node pointer with label %s in MBDyn"
67 return mess % str(self.label)
68
69
71 """The top class of an element. This class is coming from 'I{elem.h}'
72 in MBDyn and 'I{elem.i}' for the SWIG interface"""
73
75 BasicObject.__init__(self, c_inst)
76 if c_inst != None:
77 self.class_key = c_inst.get_class_key()
78
80 mess = "%(class)s pointer with label %(label)s in MBDyn"
81 return mess % {"class" : self.class_key,
82 "label" : str(self.label)}
83
84
85 BASIC_CLASS = {"NODE": Node, "ELEM": Element}
86
87
89 """A function to fill a Numpy array of size 3x1 from a C{Vec3} instance.
90 The C{Vec3} instance is described in the SWIG file 'I{libmbmath.i}'.
91 """
92 for i in range(3):
93 array[i][0] = vec3.get_value(i)
94
96 """A function to fill a Numpy array of size 3x3 from a C{Mat3x3}
97 instance. The C{Mat3x3} instance is described in the SWIG file
98 'I{libmbmath.i}'."""
99 for i in range(3):
100 for j in range(3):
101 array[i][j] = mat3x3.get_value(i, j)
102