-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSTAP.py
108 lines (83 loc) · 3.29 KB
/
STAP.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
/*****************************************************************************/
/* STAPpy : A python FEM code sharing the same input data file with STAP90 */
/* Computational Dynamics Laboratory */
/* School of Aerospace Engineering, Tsinghua University */
/* */
/* Created on Mon Jun 22, 2020 */
/* */
/* @author: [email protected], [email protected] */
/* http://www.comdyn.cn/ */
/*****************************************************************************/
Usage:
$ python STAP.py file_name
or
>>> STAP file_name
Command line arguments:
file_name: Input file name with the postfix of .dat or without postfix
"""
from Domain import Domain
from utils.Outputter import COutputter
from utils.Clock import Clock
from solver.LDLTSolver import CLDLTSolver
from sys import argv, exit
if __name__ == "__main__":
nargs = len(argv)
if nargs != 2:
print("Usage: \n\t$ python STAP.py InputFileName")
exit(1)
filename = argv[1]
found = filename.rfind('.')
# If the input file name is provided with an extension
if found != -1:
if filename[found:] == ".dat":
filename = filename[:found]
else:
print("*** Error *** Invalid file extension: {}".format(
filename[found+1:]))
exit(1)
input_filename = filename + ".dat"
output_filename = filename + ".out"
FEMData = Domain()
timer = Clock()
timer.Start()
# Read data and define the problem domain
if not FEMData.ReadData(input_filename, output_filename):
print("*** Error *** Data input failed!")
exit(1)
time_input = timer.ElapsedTime()
# Allocate global vectors and matrices, such as the Force, ColumnHeights,
# DiagonalAddress and StiffnessMatrix, and calculate the column heights
# and address of diagonal elements
FEMData.AllocateMatrices()
# Assemble the banded gloabl stiffness matrix
FEMData.AssembleStiffnessMatrix()
time_assemble = timer.ElapsedTime()
# Solve the linear equilibrium equations for displacements
Solver = CLDLTSolver(FEMData.GetStiffnessMatrix())
# Perform L*D*L(T) factorization of stiffness matrix
Solver.LDLT()
Output = COutputter()
# Loop over for all load cases
for lcase in range(FEMData.GetNLCASE()):
# Assemble righ-hand-side vector (force vector)
FEMData.AssembleForce(lcase + 1)
# Reduce right-hand-side force vector and back substitute
Solver.BackSubstitution(FEMData.GetForce())
Output.OutputNodalDisplacement(lcase)
time_solution = timer.ElapsedTime()
# Calculate and output stresses of all elements
Output.OutputElementStress()
time_stress = timer.ElapsedTime()
timer.Stop()
time_info = "\n S O L U T I O N T I M E L O G I N S E C \n\n" \
" TIME FOR INPUT PHASE = {}\n" \
" TIME FOR CALCULATION OF STIFFNESS MATRIX = {}\n" \
" TIME FOR FACTORIZATION AND LOAD CASE SOLUTIONS = {}\n" \
" T O T A L S O L U T I O N T I M E = {}\n".format(
time_input, time_assemble - time_input,
time_solution - time_assemble, time_stress
)
Output.OutputSolutionTime(time_info)