1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 """The general interface of MBDyn nodes. Each node group will have a
23 general class but until now the only group implemented is
24 the structural one. This file is however a start for further
25 development. The SWIG file used for the interface is 'I{node.i}'.
26 All the classes of that module are then imported in the
27 L{mbdyn.bindings.groups} thanks to the C{NODE_CLASS}
28 dictionary."""
29 import numpy as N
30 from mbdyn.bindings.basic_objects import Node, fill_vector, fill_matrix
31
32
34 """The general node for the "ABSTRACT" group"""
35 pass
36
38 """The general node for the "STRUCTURAL" group.
39 This class is described in the C++ file 'I{strnode.h}'.
40 The concerned definition is C{StructNode}."""
41
43 Node.__init__(self, c_inst)
44
45 self.position = N.zeros((3, 1))
46 self.rotation_matrix = N.zeros((3, 3))
47 self.velocity = N.zeros((3, 1))
48 self.angular_velocity = N.zeros((3, 1))
49
51 """Get the position from the MBDyn node"""
52 vec3 = self.c_inst.GetXCurr()
53 fill_vector(self.position, vec3)
54
56 """Return a copy of the position array.
57
58 @rtype: Numpy array
59 @return: vector of size 3x1"""
60 self._get_position()
61 return self.position.copy()
62
64 """Get the rotation matrix from the MBDyn node"""
65 mat3x3 = self.c_inst.GetRCurr()
66 fill_matrix(self.rotation_matrix, mat3x3)
67
69 """Return a copy of the rotation matrix array
70 the definition of its local reference frame.
71
72 @rtype: Numpy array
73 @return: matrix of size 3x3"""
74 self._get_rotation_matrix()
75 return self.rotation_matrix.copy()
76
78 """Get the velocity from the MBDyn node."""
79 vec3 = self.c_inst.GetVCurr()
80 fill_vector(self.velocity, vec3)
81
83 """Return a copy of the velocity array.
84
85 @rtype: Numpy array
86 @return: vector of size 3x1"""
87 self._get_velocity()
88 return self.velocity.copy()
89
91 """Get the angular velocity from the MBDyn node."""
92 vec3 = self.c_inst.GetWCurr()
93 fill_vector(self.angular_velocity, vec3)
94
96 """Return a copy of the angular velocity array.
97
98 @rtype: Numpy array
99 @return: vector of size 3x1"""
100 self._get_angular_velocity()
101 return self.angular_velocity.copy()
102
104 """Return the node representation as a string"""
105 mess = "StructNode with label %s in MBDyn"
106 return mess % str(self.label)
107
108
110 """The general node for the "ELECTRIC" group"""
111 pass
112
114 """The general node for the "PARAMETER" group"""
115 pass
116
118 """The general group for the "HYDRAULIC" group"""
119 pass
120
121
122 NODE_CLASS_TABLE = [
123 ("ABSTRACT", Abstract),
124 ("STRUCTURAL", Structural),
125 ("ELECTRIC", Electric),
126 ("PARAMETER", Parameter),
127 ("HYDRAULIC", Hydraulic)
128 ]
129
130 NODE_CLASS = {}
131
132 for group_key, general_class in NODE_CLASS_TABLE:
133 NODE_CLASS[group_key] = {"general" : general_class}
134