-
Notifications
You must be signed in to change notification settings - Fork 0
/
dof_map.py
39 lines (32 loc) · 1.09 KB
/
dof_map.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
from node2D import Node2D
class DOF_Mapper:
"""
Maps the degrees of freedom for a given structural model.
"""
def __init__(self) -> None:
pass
def map(self, structure) -> list:
"""
Assign element degrees of freedom an equation number for assembly. A
value of 0 means the degree of freedom is inactive and will be omitted
from the analysis.
"""
# importing here allows the type hint without a
# circular dependency error
from structure import Structure
structure: Structure
num_nodes = structure.get_num_nodes
dof_map = [
[0 for i in range(num_nodes)]
for i in range(structure.dofs_per_node)
]
node: Node2D
node_index = 0
eq_no = 1
for node in structure.nodes:
for dof in range(structure.dofs_per_node):
if node.get_dof(dof): # the degree of freedom is active
dof_map[dof][node_index] = eq_no
eq_no += 1
node_index += 1
return dof_map